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