31 import org.eclipse.ui.IPageLayout; |
31 import org.eclipse.ui.IPageLayout; |
32 import org.eclipse.ui.IWorkbenchWindow; |
32 import org.eclipse.ui.IWorkbenchWindow; |
33 import org.eclipse.ui.PartInitException; |
33 import org.eclipse.ui.PartInitException; |
34 import org.eclipse.ui.handlers.HandlerUtil; |
34 import org.eclipse.ui.handlers.HandlerUtil; |
35 import org.symbian.tools.tmw.core.TMWCore; |
35 import org.symbian.tools.tmw.core.TMWCore; |
36 import org.symbian.tools.tmw.core.projects.IMTWProject; |
36 import org.symbian.tools.tmw.core.projects.ITMWProject; |
37 import org.symbian.tools.tmw.ui.UIUtils; |
37 import org.symbian.tools.tmw.ui.UIUtils; |
38 import org.symbian.tools.tmw.ui.deployment.DeployWizard; |
38 import org.symbian.tools.tmw.ui.deployment.DeployWizard; |
39 |
39 |
40 /** |
40 /** |
41 * Our sample handler extends AbstractHandler, an IHandler base class. |
41 * Our sample handler extends AbstractHandler, an IHandler base class. |
54 * from the application context. |
54 * from the application context. |
55 */ |
55 */ |
56 public Object execute(ExecutionEvent event) throws ExecutionException { |
56 public Object execute(ExecutionEvent event) throws ExecutionException { |
57 final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); |
57 final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); |
58 |
58 |
59 final IMTWProject project = UIUtils.getProjectFromCommandContext(event); |
59 final ITMWProject project = UIUtils.getProjectFromCommandContext(event); |
60 if (project != null) { |
60 if (project != null) { |
61 window.getActivePage().saveAllEditors(true); |
61 window.getActivePage().saveAllEditors(true); |
62 if (validate(project, window)) { |
62 if (validate(project, window)) { |
63 new WizardDialog(window.getShell(), new DeployWizard(project)).open(); |
63 new WizardDialog(window.getShell(), new DeployWizard(project)).open(); |
64 } |
64 } |
65 } |
65 } |
66 |
66 |
67 return null; |
67 return null; |
68 } |
68 } |
69 |
69 |
70 private boolean validate(final IMTWProject project, final IWorkbenchWindow window) { |
70 private boolean validate(final ITMWProject project, final IWorkbenchWindow window) { |
71 final boolean[] retvalue = { false }; |
71 final boolean[] retvalue = { false }; |
72 final ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); |
72 final ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell()); |
73 try { |
73 try { |
74 dialog.run(true, true, new IRunnableWithProgress() { |
74 dialog.run(true, true, new IRunnableWithProgress() { |
75 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |
75 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { |