16 * Assumptions/Requirement/Pre-requisites: |
16 * Assumptions/Requirement/Pre-requisites: |
17 * Failures and causes: |
17 * Failures and causes: |
18 */ |
18 */ |
19 package org.symbian.tools.mtw.ui.deployment; |
19 package org.symbian.tools.mtw.ui.deployment; |
20 |
20 |
|
21 import java.lang.reflect.InvocationTargetException; |
|
22 |
21 import org.eclipse.core.runtime.CoreException; |
23 import org.eclipse.core.runtime.CoreException; |
22 import org.eclipse.core.runtime.IProgressMonitor; |
24 import org.eclipse.core.runtime.IProgressMonitor; |
23 import org.eclipse.core.runtime.IStatus; |
25 import org.eclipse.core.runtime.IStatus; |
24 import org.eclipse.core.runtime.jobs.ISchedulingRule; |
26 import org.eclipse.core.runtime.jobs.ISchedulingRule; |
25 import org.eclipse.core.runtime.jobs.Job; |
27 import org.eclipse.core.runtime.jobs.Job; |
26 import org.eclipse.core.runtime.jobs.MultiRule; |
28 import org.eclipse.core.runtime.jobs.MultiRule; |
|
29 import org.eclipse.jface.operation.IRunnableWithProgress; |
27 import org.eclipse.jface.wizard.Wizard; |
30 import org.eclipse.jface.wizard.Wizard; |
28 import org.eclipse.ui.statushandlers.StatusManager; |
31 import org.eclipse.ui.statushandlers.StatusManager; |
29 import org.symbian.tools.mtw.core.MTWCore; |
32 import org.symbian.tools.mtw.core.MTWCore; |
30 import org.symbian.tools.mtw.core.projects.IMTWProject; |
33 import org.symbian.tools.mtw.core.projects.IMTWProject; |
31 import org.symbian.tools.mtw.core.runtimes.IPackager; |
34 import org.symbian.tools.mtw.core.runtimes.IPackager; |
33 import org.symbian.tools.mtw.internal.deployment.DeploymentTargetWizardPage; |
36 import org.symbian.tools.mtw.internal.deployment.DeploymentTargetWizardPage; |
34 import org.symbian.tools.mtw.internal.deployment.DeploymentTargetWrapper; |
37 import org.symbian.tools.mtw.internal.deployment.DeploymentTargetWrapper; |
35 import org.symbian.tools.mtw.ui.MTWCoreUI; |
38 import org.symbian.tools.mtw.ui.MTWCoreUI; |
36 import org.symbian.tools.mtw.ui.ProjectMemo; |
39 import org.symbian.tools.mtw.ui.ProjectMemo; |
37 |
40 |
38 public class DeployWizard extends Wizard { |
41 public final class DeployWizard extends Wizard { |
39 private final DeployWizardContext context; |
42 private final DeployWizardContext context; |
40 private final IMTWProject project; |
43 private final IMTWProject project; |
41 |
44 |
42 public DeployWizard(IMTWProject project) { |
45 public DeployWizard(IMTWProject project) { |
43 this.project = project; |
46 this.project = project; |
51 addPage(new DeploymentTargetWizardPage(context, MTWCoreUI.getMemo(project))); |
54 addPage(new DeploymentTargetWizardPage(context, MTWCoreUI.getMemo(project))); |
52 } |
55 } |
53 |
56 |
54 @Override |
57 @Override |
55 public boolean performFinish() { |
58 public boolean performFinish() { |
56 return deploy(); |
59 final DeploymentTargetWrapper target = context.getTarget(); |
|
60 if (target.getType().isLongRunning()) { |
|
61 DeployJob job = new DeployJob(context.getProject(), target); |
|
62 job.schedule(); |
|
63 return true; |
|
64 } else { |
|
65 final IStatus[] retval = new IStatus[1]; |
|
66 try { |
|
67 getContainer().run(false, true, new IRunnableWithProgress() { |
|
68 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
|
69 retval[0] = doDeploy(target, context.getProject(), monitor); |
|
70 } |
|
71 }); |
|
72 } catch (InvocationTargetException e) { |
|
73 MTWCoreUI.log(e); |
|
74 } catch (InterruptedException e) { |
|
75 MTWCoreUI.log(e); |
|
76 } |
|
77 switch (retval[0].getSeverity()) { |
|
78 case IStatus.ERROR: |
|
79 StatusManager.getManager().handle(retval[0], StatusManager.SHOW | StatusManager.BLOCK); |
|
80 return false; |
|
81 case IStatus.WARNING: |
|
82 StatusManager.getManager().handle(retval[0], StatusManager.SHOW | StatusManager.BLOCK); |
|
83 default: |
|
84 return true; |
|
85 } |
|
86 } |
57 } |
87 } |
58 |
88 |
59 @Override |
89 @Override |
60 public boolean needsPreviousAndNextButtons() { |
90 public boolean needsPreviousAndNextButtons() { |
61 return false; |
91 return false; |
62 } |
92 } |
63 |
93 |
64 /** |
94 private IStatus doDeploy(DeploymentTargetWrapper target, IMTWProject project, IProgressMonitor monitor) { |
65 * deploys the actual widget. |
95 IStatus status; |
66 */ |
96 try { |
67 private boolean deploy() { |
97 IPackager packager = MTWCore.getDefault().getRuntimesManager().getPackager(project); |
68 DeploymentTargetWrapper target = context.getTarget(); |
98 status = target.deploy(project, packager, monitor); |
69 DeployJob job = new DeployJob(context.getProject(), target); |
99 } catch (CoreException e) { |
70 job.schedule(); |
100 status = e.getStatus(); |
71 return true; |
101 } |
|
102 ProjectMemo memo = MTWCoreUI.getMemo(project); |
|
103 memo.setDeploymentTarget(target.getProviderId(), target); |
|
104 return status; |
72 } |
105 } |
73 |
106 |
74 private final class DeployJob extends Job { |
107 private final class DeployJob extends Job { |
75 private final DeploymentTargetWrapper target; |
108 private final DeploymentTargetWrapper target; |
76 private final IMTWProject project; |
109 private final IMTWProject project; |
88 this.project = project; |
121 this.project = project; |
89 this.target = deploymentTarget; |
122 this.target = deploymentTarget; |
90 } |
123 } |
91 |
124 |
92 public IStatus run(IProgressMonitor monitor) { |
125 public IStatus run(IProgressMonitor monitor) { |
93 IStatus status; |
126 final IStatus status = doDeploy(target, project, monitor); |
94 try { |
|
95 IPackager packager = MTWCore.getDefault().getRuntimesManager().getPackager(project); |
|
96 status = target.deploy(project, packager, monitor); |
|
97 } catch (CoreException e) { |
|
98 status = e.getStatus(); |
|
99 } |
|
100 if (status.getSeverity() != IStatus.ERROR && status.getSeverity() != IStatus.WARNING) { |
127 if (status.getSeverity() != IStatus.ERROR && status.getSeverity() != IStatus.WARNING) { |
101 StatusManager.getManager().handle(status, StatusManager.SHOW); |
128 StatusManager.getManager().handle(status, StatusManager.SHOW); |
102 } |
129 } |
103 ProjectMemo memo = MTWCoreUI.getMemo(project); |
|
104 memo.setDeploymentTarget(target.getProviderId(), target); |
|
105 return status; |
130 return status; |
106 } |
131 } |
107 |
132 |
108 } |
133 } |
109 } |
134 } |