|
1 package com.nokia.cdt.internal.debug.launch.newwizard; |
|
2 |
|
3 import java.util.ArrayList; |
|
4 import java.util.List; |
|
5 |
|
6 import org.eclipse.core.commands.AbstractHandler; |
|
7 import org.eclipse.core.commands.ExecutionEvent; |
|
8 import org.eclipse.core.commands.ExecutionException; |
|
9 import org.eclipse.core.resources.IProject; |
|
10 import org.eclipse.core.resources.IResource; |
|
11 import org.eclipse.core.runtime.IAdaptable; |
|
12 import org.eclipse.core.runtime.IPath; |
|
13 import org.eclipse.debug.core.ILaunchManager; |
|
14 import org.eclipse.jface.viewers.ISelection; |
|
15 import org.eclipse.jface.viewers.IStructuredSelection; |
|
16 import org.eclipse.jface.wizard.WizardDialog; |
|
17 import org.eclipse.ui.handlers.HandlerUtil; |
|
18 |
|
19 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; |
|
20 import com.nokia.carbide.cdt.builder.EpocEngineHelper; |
|
21 import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; |
|
22 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
|
23 import com.nokia.carbide.remoteconnections.interfaces.IService; |
|
24 |
|
25 /** |
|
26 * Our sample handler extends AbstractHandler, an IHandler base class. |
|
27 * @see org.eclipse.core.commands.IHandler |
|
28 * @see org.eclipse.core.commands.AbstractHandler |
|
29 */ |
|
30 public class CommandRunLaunchWizard2 extends AbstractHandler { |
|
31 /** |
|
32 * The constructor. |
|
33 */ |
|
34 public CommandRunLaunchWizard2() { |
|
35 } |
|
36 |
|
37 /** |
|
38 * the command has been executed, so extract extract the needed information |
|
39 * from the application context. |
|
40 */ |
|
41 public Object execute(ExecutionEvent event) throws ExecutionException { |
|
42 ISelection sel = HandlerUtil.getCurrentSelection(event); |
|
43 IProject project = null; |
|
44 if (sel instanceof IStructuredSelection) { |
|
45 Object obj = ((IStructuredSelection) sel).getFirstElement(); |
|
46 if (obj instanceof IResource) |
|
47 project = ((IResource) obj).getProject(); |
|
48 else if (obj instanceof IAdaptable) { |
|
49 IResource rsrc = (IResource)((IAdaptable) obj).getAdapter(IResource.class); |
|
50 if (rsrc != null) |
|
51 project = rsrc.getProject(); |
|
52 } |
|
53 if (project == null) |
|
54 throw new ExecutionException("No project in selection"); |
|
55 |
|
56 ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager() |
|
57 .getProjectInfo(project); |
|
58 if (info == null) |
|
59 throw new ExecutionException("Not a Carbide project"); |
|
60 List<IPath> mmpFiles = EpocEngineHelper.getMMPFilesForProject(info); |
|
61 IService trkService = RemoteConnectionsActivator.getConnectionTypeProvider(). |
|
62 findServiceByID("com.nokia.carbide.trk.support.service.TRKService"); //$NON-NLS-1$ |
|
63 |
|
64 List<IPath> allExePaths = new ArrayList<IPath>(); |
|
65 List<IPath> currBuiltExePaths = new ArrayList<IPath>(); |
|
66 List<IPath> allMMPPaths = new ArrayList<IPath>(); |
|
67 List<IPath> currBuiltMMPPaths = new ArrayList<IPath>(); |
|
68 |
|
69 EpocEngineHelper.getPathToAllExecutables(info.getDefaultConfiguration(), |
|
70 allExePaths, |
|
71 currBuiltExePaths, |
|
72 allMMPPaths, |
|
73 currBuiltMMPPaths); |
|
74 |
|
75 LaunchWizard wiz = new LaunchWizard(project, |
|
76 info.getDefaultBuildConfigName(), |
|
77 mmpFiles, |
|
78 currBuiltExePaths, |
|
79 EpocEngineHelper.getHostPathForExecutable(info.getDefaultConfiguration(), mmpFiles.get(0)), |
|
80 false, false, |
|
81 ILaunchManager.DEBUG_MODE, |
|
82 trkService |
|
83 ); |
|
84 WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wiz); |
|
85 dialog.setPageSize(500, 300); |
|
86 dialog.open(); |
|
87 } |
|
88 |
|
89 return null; |
|
90 } |
|
91 } |