# HG changeset patch # User dadubrow # Date 1266263341 21600 # Node ID d1e221a2875f18df04b5baa177a3e8aa1e50cf56 # Parent ee68c935ffb742d2e66a85f35d0edc03b44a959e new launch wizard implementation diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/plugin.xml --- a/debuggercdi/com.nokia.cdt.debug.launch/plugin.xml Fri Feb 12 14:41:28 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/plugin.xml Mon Feb 15 13:49:01 2010 -0600 @@ -172,14 +172,15 @@ + + class="com.nokia.cdt.internal.debug.launch.BoardLaunchShortcut" + id="com.nokia.cdt.debug.launch.symbianCPPShortcut.board"> @@ -209,23 +210,185 @@ forcePluginActivation="true" property="com.nokia.cdt.debug.launch.isExecutable"/> + + + label="Run Symbian OS Application on board"/> + label="Debug Symbian OS Application on board"/> + description="Runs on a development board or reference hardware using a JTAG connection."/> + description="Debugs on a development board or reference hardware using a JTAG connection."/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -233,7 +396,7 @@ @@ -279,5 +442,5 @@ - + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/AbstractSymbianLaunchShortcut.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,185 @@ +package com.nokia.cdt.internal.debug.launch; + +import java.util.List; + +import org.eclipse.cdt.debug.core.executables.Executable; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.ILaunchShortcut2; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; + +import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; + +public abstract class AbstractSymbianLaunchShortcut implements ILaunchShortcut2 { + + protected abstract void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode); + + public void launch(IEditorPart editor, String mode) { + // launch an existing config if one exists + ILaunchConfiguration[] configs = getLaunchConfigurations(editor); + if (configs.length > 0) { + // just launch the first one that supports the mode + for (ILaunchConfiguration config : configs) { + try { + if (config.supportsMode(mode)) { + DebugUITools.launch(configs[0], mode); + return; + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + + IEditorInput editorInput = editor.getEditorInput(); + if (editorInput instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput)editorInput).getFile(); + if (file != null) { + launchProject(file.getProject(), null, null, mode); + } + } + } + + public void launch(ISelection selection, String mode) { + + // launch an existing config if one exists + ILaunchConfiguration[] configs = getLaunchConfigurations(selection); + if (configs.length > 0) { + // just launch the first one that supports the mode + for (ILaunchConfiguration config : configs) { + try { + if (config.supportsMode(mode)) { + DebugUITools.launch(configs[0], mode); + return; + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + + IPath defaultMMP = null; + boolean launched = false; + Executable executable = null; + + if (selection instanceof IStructuredSelection) { + Object firstElement = ((IStructuredSelection) selection).getFirstElement(); + if (firstElement != null && firstElement instanceof Executable) + { + launchProject(((Executable)firstElement).getProject(), (Executable)firstElement, defaultMMP, mode); + launched = true; + } + else + if (firstElement != null && firstElement instanceof IAdaptable) + { + IFile file = (IFile) ((IAdaptable) firstElement).getAdapter(IFile.class); + if (file != null) + { + IPath filePath = file.getLocation(); + if ("mmp".equalsIgnoreCase(filePath.getFileExtension())) + { + defaultMMP = filePath; + } + else + { + executable = new Executable(file.getLocation(), file.getProject(), file); + launchProject(file.getProject(), executable, defaultMMP, mode); + launched = true; + } + } + } + } + + if (!launched) + { + List projects = CarbideBuilderPlugin.getProjectsFromSelection(selection); + if (projects.size() > 0) { + launchProject(projects.get(0), executable, defaultMMP, mode); + } + } + } + + public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) { + IPath defaultMMP = null; + if (selection instanceof IStructuredSelection) { + Object firstElement = ((IStructuredSelection) selection).getFirstElement(); + if (firstElement != null && firstElement instanceof Executable) + { + return LaunchPlugin.getDefault().getLaunchConfigurations(((Executable)firstElement).getProject(), (Executable)firstElement, defaultMMP); + } + else + if (firstElement != null && firstElement instanceof IAdaptable) + { + IFile file = (IFile) ((IAdaptable) firstElement).getAdapter(IFile.class); + if (file != null) + { + IPath filePath = file.getLocation(); + if ("mmp".equalsIgnoreCase(filePath.getFileExtension())) + { + defaultMMP = filePath; + } + Executable executable = new Executable(file.getLocation(), file.getProject(), file); + return LaunchPlugin.getDefault().getLaunchConfigurations(file.getProject(), executable, defaultMMP); + } + } + } + + List projects = CarbideBuilderPlugin.getProjectsFromSelection(selection); + if (projects.size() > 0) { + return LaunchPlugin.getDefault().getLaunchConfigurations(projects.get(0), null, defaultMMP); + } + return null; + } + + public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editorpart) { + IEditorInput editorInput = editorpart.getEditorInput(); + if (editorInput instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput)editorInput).getFile(); + if (file != null) { + return LaunchPlugin.getDefault().getLaunchConfigurations(file.getProject(), null, null); + } + } + return null; + } + + public IResource getLaunchableResource(ISelection selection) { + if (selection instanceof IStructuredSelection) { + Object firstElement = ((IStructuredSelection) selection).getFirstElement(); + if (firstElement != null && firstElement instanceof IFile) + { + IFile file = (IFile) firstElement; + return file.getProject(); + } + if (firstElement != null && firstElement instanceof Executable) + { + return ((Executable)firstElement).getProject(); + } + } + List projects = CarbideBuilderPlugin.getProjectsFromSelection(selection); + if (projects.size() > 0) { + return projects.get(0); + } + return null; + } + + public IResource getLaunchableResource(IEditorPart editorpart) { + IEditorInput editorInput = editorpart.getEditorInput(); + if (editorInput instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput)editorInput).getFile(); + if (file != null) { + return file.getProject(); + } + } + return null; + } +} \ No newline at end of file diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/BoardLaunchShortcut.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/BoardLaunchShortcut.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.cdt.internal.debug.launch; + +import org.eclipse.cdt.debug.core.executables.Executable; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory; +import com.nokia.cdt.internal.debug.launch.wizard.AbstractLaunchWizard; +import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizard; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizardInstance; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions; + +public class BoardLaunchShortcut extends AbstractSymbianLaunchShortcut { + + @Override + protected void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) { + LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, + new ILaunchCreationWizardFactory() { + public ILaunchCreationWizard createLaunchCreationWizard(LaunchOptions launchOptions) throws Exception { + LaunchCreationWizard creationWizard = + LaunchCreationWizardInstance.getInstance().create( + launchOptions.project, + launchOptions.configurationName, + launchOptions.mmps, + launchOptions.exes, + launchOptions.defaultExecutable, + launchOptions.isEmulation, + launchOptions.emulatorOnly, + launchOptions.mode); + creationWizard.setCategoryId(AbstractLaunchWizard.BOARD_CATEGORY_ID); + return creationWizard; + } + }); + } + + +} + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/EmulatorLaunchShortcut.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/EmulatorLaunchShortcut.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.cdt.internal.debug.launch; + +import org.eclipse.cdt.debug.core.executables.Executable; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory; +import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizardInstance; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions; + +public class EmulatorLaunchShortcut extends AbstractSymbianLaunchShortcut { + + @Override + protected void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) { + LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, + new ILaunchCreationWizardFactory() { + public ILaunchCreationWizard createLaunchCreationWizard(LaunchOptions launchOptions) throws Exception { + return LaunchCreationWizardInstance.getInstance().create( + launchOptions.project, + launchOptions.configurationName, + launchOptions.mmps, + launchOptions.exes, + launchOptions.defaultExecutable, + launchOptions.isEmulation, + launchOptions.emulatorOnly, + launchOptions.mode); + } + }); + } + +} + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java Fri Feb 12 14:41:28 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/LaunchPlugin.java Mon Feb 15 13:49:01 2010 -0600 @@ -16,23 +16,51 @@ */ package com.nokia.cdt.internal.debug.launch; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.MissingResourceException; +import java.util.ResourceBundle; -import org.eclipse.cdt.core.model.*; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.executables.Executable; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.*; -import org.eclipse.debug.core.*; -import org.eclipse.debug.ui.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationListener; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchListener; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.AbstractDebugView; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.IDebugView; import org.eclipse.debug.ui.contexts.DebugContextEvent; import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.*; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.*; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IPartListener2; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.IWindowListener; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPartReference; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.progress.UIJob; import org.osgi.framework.BundleContext; @@ -46,15 +74,20 @@ import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; import com.nokia.carbide.remoteconnections.interfaces.IService; -import com.nokia.cdt.debug.cw.symbian.*; -import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizard; -import com.nokia.cdt.internal.debug.launch.wizard.LaunchCreationWizardInstance; +import com.nokia.cdt.debug.cw.symbian.SettingsData; +import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions; import com.nokia.cpp.internal.api.utils.core.Logging; /** * The main plugin class to be used in the desktop. */ public class LaunchPlugin extends AbstractUIPlugin implements ILaunchListener, ILaunchConfigurationListener, IStartup { + + public interface ILaunchCreationWizardFactory { + ILaunchCreationWizard createLaunchCreationWizard(LaunchOptions launchOptions) throws Exception; + } + //The shared instance. private static LaunchPlugin plugin; //Resource bundle. @@ -206,7 +239,8 @@ return isX86; } - private ILaunchConfiguration createConfigurationForProject(IProject project, Executable executable, IPath defaultMMP, String mode) throws CoreException { + private ILaunchConfiguration createConfigurationForProject(IProject project, Executable executable, + IPath defaultMMP, String mode, ILaunchCreationWizardFactory wizardFactory) throws CoreException { boolean openLaunchConfigDialog = false; @@ -292,15 +326,17 @@ // which exe to launch or emulator if not required, // which non-emulator launch type, // or both + LaunchOptions launchOptions = new LaunchOptions(); + launchOptions.project = project; + launchOptions.mode = mode; + launchOptions.configurationName = defaultConfigName; + launchOptions.isEmulation = isX86; + launchOptions.emulatorOnly = useEmulatorByDefault; + launchOptions.defaultExecutable = defaultExecutable; + launchOptions.exes = exePaths; + launchOptions.mmps = mmpPaths; try { - final LaunchCreationWizard wizard = - LaunchCreationWizardInstance.getInstance().create(project, defaultConfigName, mmpPaths, exePaths, defaultExecutable, isX86, useEmulatorByDefault, mode); - Display.getDefault().syncExec(new Runnable() { - public void run() { - wizard.init(PlatformUI.getWorkbench(), null); - wizard.openWizard(CUIPlugin.getActiveWorkbenchShell()); - } - }); + final ILaunchCreationWizard wizard = openLaunchCreationWizard(launchOptions, wizardFactory); config = wizard.getLaunchConfiguration(); openLaunchConfigDialog = wizard.shouldOpenLaunchConfigurationDialog(); } @@ -326,6 +362,19 @@ return null; } + private ILaunchCreationWizard openLaunchCreationWizard(LaunchOptions launchOptions, + ILaunchCreationWizardFactory wizardFactory) throws Exception { + final ILaunchCreationWizard wizard = + wizardFactory.createLaunchCreationWizard(launchOptions); + Display.getDefault().syncExec(new Runnable() { + public void run() { + wizard.init(); + wizard.openWizard(CUIPlugin.getActiveWorkbenchShell()); + } + }); + return wizard; + } + public ILaunchConfiguration[] getLaunchConfigurations(IProject project, Executable executable, IPath defaultMMP) { IPath defaultExecutable = null; @@ -368,10 +417,11 @@ return configs.toArray(new ILaunchConfiguration[configs.size()]); } - public void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) { + public void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode, + ILaunchCreationWizardFactory wizardFactory) { ILaunchConfiguration configuration = null; try { - configuration = createConfigurationForProject(project, executable, defaultMMP, mode); + configuration = createConfigurationForProject(project, executable, defaultMMP, mode, wizardFactory); } catch (CoreException e) { log(e); } @@ -540,7 +590,7 @@ }); } - + public static IService getTRKService() { return RemoteConnectionsActivator.getConnectionTypeProvider(). findServiceByID("com.nokia.carbide.trk.support.service.TRKService"); //$NON-NLS-1$ diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/PhoneLaunchShortcut.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.cdt.internal.debug.launch; + +import org.eclipse.cdt.debug.core.executables.Executable; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; + +import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider; +import com.nokia.carbide.remoteconnections.interfaces.IService; +import com.nokia.cdt.internal.debug.launch.LaunchPlugin.ILaunchCreationWizardFactory; +import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizard; +import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions; + +public class PhoneLaunchShortcut extends AbstractSymbianLaunchShortcut { + + @Override + protected void launchProject(IProject project, Executable executable, IPath defaultMMP, String mode) { + LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode, + new ILaunchCreationWizardFactory() { + public ILaunchCreationWizard createLaunchCreationWizard(LaunchOptions launchOptions) throws Exception { + IConnectionTypeProvider provider = RemoteConnectionsActivator.getConnectionTypeProvider(); + IService trkService = provider.findServiceByID("com.nokia.carbide.trk.support.service.TRKService"); //$NON-NLS-1$ + LaunchWizard launchWizard = new LaunchWizard(launchOptions, trkService); + return launchWizard; + }; + }); + } +} \ No newline at end of file diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/SymbianLaunchShortcut.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/SymbianLaunchShortcut.java Fri Feb 12 14:41:28 2010 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,204 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of the License "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.cdt.internal.debug.launch; - -import java.util.List; - -import org.eclipse.cdt.debug.core.executables.Executable; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.ILaunchShortcut2; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; - -import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; - -public class SymbianLaunchShortcut implements ILaunchShortcut2 { - - public void launch(IEditorPart editor, String mode) { - // launch an existing config if one exists - ILaunchConfiguration[] configs = getLaunchConfigurations(editor); - if (configs.length > 0) { - // just launch the first one that supports the mode - for (ILaunchConfiguration config : configs) { - try { - if (config.supportsMode(mode)) { - DebugUITools.launch(configs[0], mode); - return; - } - } catch (CoreException e) { - e.printStackTrace(); - } - } - } - - IEditorInput editorInput = editor.getEditorInput(); - if (editorInput instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput)editorInput).getFile(); - if (file != null) { - launchProject(file.getProject(), null, null, mode); - } - } - } - - public void launch(ISelection selection, String mode) { - - // launch an existing config if one exists - ILaunchConfiguration[] configs = getLaunchConfigurations(selection); - if (configs.length > 0) { - // just launch the first one that supports the mode - for (ILaunchConfiguration config : configs) { - try { - if (config.supportsMode(mode)) { - DebugUITools.launch(configs[0], mode); - return; - } - } catch (CoreException e) { - e.printStackTrace(); - } - } - } - - IPath defaultMMP = null; - boolean launched = false; - Executable executable = null; - - if (selection instanceof IStructuredSelection) { - Object firstElement = ((IStructuredSelection) selection).getFirstElement(); - if (firstElement != null && firstElement instanceof Executable) - { - launchProject(((Executable)firstElement).getProject(), (Executable)firstElement, defaultMMP, mode); - launched = true; - } - else - if (firstElement != null && firstElement instanceof IAdaptable) - { - IFile file = (IFile) ((IAdaptable) firstElement).getAdapter(IFile.class); - if (file != null) - { - IPath filePath = file.getLocation(); - if ("mmp".equalsIgnoreCase(filePath.getFileExtension())) - { - defaultMMP = filePath; - } - else - { - executable = new Executable(file.getLocation(), file.getProject(), file); - launchProject(file.getProject(), executable, defaultMMP, mode); - launched = true; - } - } - } - } - - if (!launched) - { - List projects = CarbideBuilderPlugin.getProjectsFromSelection(selection); - if (projects.size() > 0) { - launchProject(projects.get(0), executable, defaultMMP, mode); - } - } - } - - private void launchProject(final IProject project, final Executable executable, final IPath defaultMMP, final String mode) { - LaunchPlugin.getDefault().launchProject(project, executable, defaultMMP, mode); - } - - public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) { - IPath defaultMMP = null; - if (selection instanceof IStructuredSelection) { - Object firstElement = ((IStructuredSelection) selection).getFirstElement(); - if (firstElement != null && firstElement instanceof Executable) - { - return LaunchPlugin.getDefault().getLaunchConfigurations(((Executable)firstElement).getProject(), (Executable)firstElement, defaultMMP); - } - else - if (firstElement != null && firstElement instanceof IAdaptable) - { - IFile file = (IFile) ((IAdaptable) firstElement).getAdapter(IFile.class); - if (file != null) - { - IPath filePath = file.getLocation(); - if ("mmp".equalsIgnoreCase(filePath.getFileExtension())) - { - defaultMMP = filePath; - } - Executable executable = new Executable(file.getLocation(), file.getProject(), file); - return LaunchPlugin.getDefault().getLaunchConfigurations(file.getProject(), executable, defaultMMP); - } - } - } - - List projects = CarbideBuilderPlugin.getProjectsFromSelection(selection); - if (projects.size() > 0) { - return LaunchPlugin.getDefault().getLaunchConfigurations(projects.get(0), null, defaultMMP); - } - return null; - } - - public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editorpart) { - IEditorInput editorInput = editorpart.getEditorInput(); - if (editorInput instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput)editorInput).getFile(); - if (file != null) { - return LaunchPlugin.getDefault().getLaunchConfigurations(file.getProject(), null, null); - } - } - return null; - } - - public IResource getLaunchableResource(ISelection selection) { - if (selection instanceof IStructuredSelection) { - Object firstElement = ((IStructuredSelection) selection).getFirstElement(); - if (firstElement != null && firstElement instanceof IFile) - { - IFile file = (IFile) firstElement; - return file.getProject(); - } - if (firstElement != null && firstElement instanceof Executable) - { - return ((Executable)firstElement).getProject(); - } - } - List projects = CarbideBuilderPlugin.getProjectsFromSelection(selection); - if (projects.size() > 0) { - return projects.get(0); - } - return null; - } - - public IResource getLaunchableResource(IEditorPart editorpart) { - IEditorInput editorInput = editorpart.getEditorInput(); - if (editorInput instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput)editorInput).getFile(); - if (file != null) { - return file.getProject(); - } - } - return null; - } -} - diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/SymbianProjectPropertyTester.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/SymbianProjectPropertyTester.java Fri Feb 12 14:41:28 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/SymbianProjectPropertyTester.java Mon Feb 15 13:49:01 2010 -0600 @@ -16,16 +16,22 @@ */ package com.nokia.cdt.internal.debug.launch; +import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.debug.core.executables.Executable; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; +import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; +import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; +import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; /** * A property tester that determines if a file is an executable. @@ -41,7 +47,13 @@ } if ("isCarbideProject".equals(property)) { //$NON-NLS-1$ return isCarbideProject(receiver); - } + } + if ("isEmulator".equals(property)) { //$NON-NLS-1$ + return isEmulator(receiver); + } + if ("isNotEmulator".equals(property)) { //$NON-NLS-1$ + return !isEmulator(receiver); + } return true; } @@ -81,4 +93,63 @@ return (celement != null && celement instanceof IBinary); } + private boolean isEmulator(Object receiver) { + if (receiver instanceof Executable) { + return isEmulatorBinaryPath(((Executable) receiver).getPath()); + } + if (receiver instanceof IBinary) { + return isEmulatorBinaryPath(((IBinary) receiver).getPath()); + } + if (receiver instanceof IAdaptable) { + IResource res = (IResource) ((IAdaptable) receiver).getAdapter(IResource.class); + if (res != null) { + IProject project = res.getProject(); + if (project != null) { + ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); + if (cpi != null) { + ICarbideBuildConfiguration buildConfig = cpi.getDefaultConfiguration(); + // just check the platform for the default config + if (buildConfig.getPlatformString().equals(ISymbianBuildContext.EMULATOR_PLATFORM)) { + return true; + } + } + else { + return getIsEmulatorFromExecutablesProject(project); + } + } + } + } + return false; + } + + private boolean getIsEmulatorFromExecutablesProject(IProject project) { + ICProject cProject = CoreModel.getDefault().create(project); + if (cProject != null) { + try { + for (IBinary bin : cProject.getBinaryContainer().getBinaries()) { + if (bin.isExecutable()) { + IPath path = bin.getResource().getLocation(); + if (isEmulatorBinaryPath(path)) { + return true; + } + } + } + } catch (CModelException e) { + } + } + return false; + } + + private boolean isEmulatorBinaryPath(IPath binaryPath) { + if (binaryPath != null) { + for (String segment : binaryPath.segments()) { + if (segment.equalsIgnoreCase("winscw")) //$NON-NLS-1$ + return true; + } + } + + return false; + } + + } diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchSettingsDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchSettingsDialog.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; +import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; + +/** + * + */ +public abstract class AbstractLaunchSettingsDialog extends TitleAreaDialog { + + protected final static String UID = ".uid"; + + protected final LaunchWizardData data; + protected int INDENT; + private String title; + + protected abstract void validate(); + + /** + * @param parentShell + * @param data + */ + public AbstractLaunchSettingsDialog(Shell parentShell, LaunchWizardData data) { + super(parentShell); + setShellStyle(getShellStyle() | SWT.RESIZE); + this.data = data; + } + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("New Launch Configuration Wizard"); + } + + protected Composite initDialogArea(Composite parent, String title, String helpId) { + Composite composite = (Composite) super.createDialogArea(parent); + GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(composite); + + INDENT = convertWidthInCharsToPixels(4); + + setTitle(title); + + this.title = title; + + WorkbenchUtils.setHelpContextId(composite, helpId); + + return composite; + } + + protected int severityToMsgType(int severity) { + switch (severity) { + case IStatus.OK: + case IStatus.CANCEL: + default: + break; + case IStatus.INFO: + return IMessageProvider.INFORMATION; + case IStatus.ERROR: + return IMessageProvider.ERROR; + case IStatus.WARNING: + return IMessageProvider.WARNING; + } + return IMessageProvider.NONE; + } + + protected IStatus error(String msg, Object... args) { + return new Status(IStatus.ERROR, LaunchPlugin.PLUGIN_ID, + MessageFormat.format(msg, args)); + } + + protected IStatus warning(String msg, Object... args) { + return new Status(IStatus.WARNING, LaunchPlugin.PLUGIN_ID, + MessageFormat.format(msg, args)); + } + + private void setOkEnabled(boolean enabled) { + Button okButton = getButton(IDialogConstants.OK_ID); + if (okButton != null) + okButton.setEnabled(enabled); + } + + protected void updateStatus(IStatus status) { + setTitle(title); + + if (status.isOK()) { + setMessage("", IMessageProvider.NONE); + } else { + setMessage(status.getMessage(), severityToMsgType(status.getSeverity())); + } + + setOkEnabled(!status.matches(IStatus.ERROR)); + } + +} \ No newline at end of file diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchWizardSection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchWizardSection.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; + +/** + * + */ +public abstract class AbstractLaunchWizardSection implements IWizardSection { + + private static final String CHANGE_LABEL = "Change..."; + protected final LaunchWizardData data; + private String sectionName; + + protected IStatus status; + protected Label descriptionLabel; + protected Button changeButton; + protected Composite control; + private ISectionChangeListener changeListener; + + + public AbstractLaunchWizardSection(LaunchWizardData data, String sectionName) { + this.data = data; + this.sectionName = sectionName; + status = Status.OK_STATUS; + } + + abstract protected void dispose(); + + public IStatus getStatus() { + return status; + } + + /** Initialize the data for this section (before UI shown). */ + public abstract void initializeSettings(); + + /** Validate the settings and update status. */ + abstract protected void validate(); + + /** Update the UI when data changes. Called after validate(). */ + protected abstract void updateUI(); + + /** Create the UI for this section. */ + public abstract void createControl(Composite parent); + + /** Create the dialog for the Change... button. */ + protected abstract AbstractLaunchSettingsDialog createChangeSettingsDialog(Shell shell, LaunchWizardData dialogData); + /** Refresh the section after the Change... dialog has been closed. */ + protected abstract void refresh(); + + public Control getControl() { + return control; + } + + public String getSectionName() { + return sectionName; + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection#setChangeListener(com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection.ISectionChangeListener) + */ + public void setChangeListener(ISectionChangeListener listener) { + this.changeListener = listener; + } + + protected void createSection(Composite parent, int acceleratorIndex) { + Composite composite = new Composite(parent, SWT.NONE); + + GC gc = new GC(parent); + int INDENT = gc.getAdvanceWidth('m') * 4; + gc.dispose(); + + GridLayoutFactory.fillDefaults().numColumns(2).margins(6, 0).applyTo(composite); + + Label titleLabel = new Label(composite, SWT.NONE); + titleLabel.setText(sectionName); + titleLabel.setFont(JFaceResources.getBannerFont()); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(titleLabel); + + // spacing + Label spacer = new Label(composite, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(spacer); + + descriptionLabel = new Label(composite, SWT.WRAP); + GridDataFactory.fillDefaults().grab(true, true).indent(INDENT, 0).applyTo(descriptionLabel); + + String label = MessageFormat.format("{0}&{1}", //$NON-NLS-1$ + CHANGE_LABEL.substring(0, acceleratorIndex), CHANGE_LABEL.substring(acceleratorIndex)); + changeButton = new Button(composite, SWT.PUSH); + changeButton.setText(label); + Point minSize = changeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); + GridDataFactory.defaultsFor(changeButton).grab(false, false).hint(minSize.x + INDENT, SWT.DEFAULT).applyTo(changeButton); + changeButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + doChange(); + if (changeListener != null) + changeListener.changed(); + } + }); + + composite.addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent e) { + descriptionLabel.pack(); + } + }); + + this.control = composite; + + control.addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + dispose(); + } + }); + + validate(); + updateUI(); + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#doChange() + */ + protected void doChange() { + LaunchWizardData dialogData = data.copy(); + AbstractLaunchSettingsDialog dialog = createChangeSettingsDialog(getControl().getShell(), dialogData); + if (dialog.open() == Window.OK) { + data.apply(dialogData); + refresh(); + } + } + + protected static IStatus error(String msg, Object... args) { + return new Status(IStatus.ERROR, LaunchPlugin.PLUGIN_ID, + MessageFormat.format(msg, args)); + } + + protected IStatus warning(String msg, Object... args) { + return new Status(IStatus.WARNING, LaunchPlugin.PLUGIN_ID, + MessageFormat.format(msg, args)); + } +} \ No newline at end of file diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/CommandRunLaunchWizard2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/CommandRunLaunchWizard2.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,91 @@ +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; +import com.nokia.carbide.cdt.builder.EpocEngineHelper; +import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; +import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; +import com.nokia.carbide.remoteconnections.interfaces.IService; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class CommandRunLaunchWizard2 extends AbstractHandler { + /** + * The constructor. + */ + public CommandRunLaunchWizard2() { + } + + /** + * the command has been executed, so extract extract the needed information + * from the application context. + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection sel = HandlerUtil.getCurrentSelection(event); + IProject project = null; + if (sel instanceof IStructuredSelection) { + Object obj = ((IStructuredSelection) sel).getFirstElement(); + if (obj instanceof IResource) + project = ((IResource) obj).getProject(); + else if (obj instanceof IAdaptable) { + IResource rsrc = (IResource)((IAdaptable) obj).getAdapter(IResource.class); + if (rsrc != null) + project = rsrc.getProject(); + } + if (project == null) + throw new ExecutionException("No project in selection"); + + ICarbideProjectInfo info = CarbideBuilderPlugin.getBuildManager() + .getProjectInfo(project); + if (info == null) + throw new ExecutionException("Not a Carbide project"); + List mmpFiles = EpocEngineHelper.getMMPFilesForProject(info); + IService trkService = RemoteConnectionsActivator.getConnectionTypeProvider(). + findServiceByID("com.nokia.carbide.trk.support.service.TRKService"); //$NON-NLS-1$ + + List allExePaths = new ArrayList(); + List currBuiltExePaths = new ArrayList(); + List allMMPPaths = new ArrayList(); + List currBuiltMMPPaths = new ArrayList(); + + EpocEngineHelper.getPathToAllExecutables(info.getDefaultConfiguration(), + allExePaths, + currBuiltExePaths, + allMMPPaths, + currBuiltMMPPaths); + +// LaunchWizard wiz = new LaunchWizard(project, +// info.getDefaultBuildConfigName(), +// mmpFiles, +// currBuiltExePaths, +// EpocEngineHelper.getHostPathForExecutable(info.getDefaultConfiguration(), mmpFiles.get(0)), +// false, false, +// ILaunchManager.DEBUG_MODE, +// trkService +// ); +// WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wiz); +// dialog.setPageSize(500, 300); +// dialog.open(); + } + + return null; + } +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,273 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; +import com.nokia.carbide.remoteconnections.interfaces.IConnectedService; +import com.nokia.carbide.remoteconnections.interfaces.IConnection; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionType; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionTypeProvider; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener; +import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard; + +/** + * This dialog allows in-depth configuration of the connection settings. + */ +@SuppressWarnings("restriction") +public class ConnectToDeviceDialog extends AbstractLaunchSettingsDialog implements IConnectionListener { + private IConnectionsManager manager; + private IConnectionTypeProvider typeProvider; + private ComboViewer viewer; + private Button editButton; + private Label descriptionLabel; + + protected ConnectToDeviceDialog(Shell shell, LaunchWizardData data) { + super(shell, data); + manager = RemoteConnectionsActivator.getConnectionsManager(); + typeProvider = RemoteConnectionsActivator.getConnectionTypeProvider(); + } + + @Override + protected Control createDialogArea(Composite parent) { + final Composite composite = initDialogArea(parent, + "Change connection", + LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_CONNECTION); + + Composite viewerGroup = new Composite(composite, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(viewerGroup); + GridLayoutFactory.swtDefaults().numColumns(3).applyTo(viewerGroup); + + Label label = new Label(viewerGroup, SWT.NONE); + label.setText("Current connection"); + GridDataFactory.defaultsFor(label).applyTo(label); + + viewer = new ComboViewer(viewerGroup, SWT.READ_ONLY); + viewer.setLabelProvider(new LabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof IConnection) + return ((IConnection) element).getDisplayName(); + + return "No Current connection"; + } + }); + viewer.setContentProvider(new ArrayContentProvider()); + Combo combo = viewer.getCombo(); + GridDataFactory.defaultsFor(combo).grab(true, false).applyTo(combo); + viewer.getControl().setData(UID, "combo_viewer"); //$NON-NLS-1$ + viewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + if (getDialogArea() != null) + connectionSelected(getConnectionFromSelection(event.getSelection())); + } + }); + manager.addConnectionListener(this); + + editButton = new Button(viewerGroup, SWT.PUSH); + editButton.setText("Edit..."); + GridDataFactory.defaultsFor(editButton).applyTo(editButton); + editButton.setData(UID, "edit_button"); //$NON-NLS-1$ + editButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + IConnection connection = getConnectionFromSelection(viewer.getSelection()); + if (connection != null) { + SettingsWizard wizard = new SettingsWizard(connection, data.getService()); + wizard.open(composite.getShell()); + } + } + }); + + descriptionLabel = new Label(composite, SWT.WRAP); + GridDataFactory.defaultsFor(descriptionLabel).grab(false, true).applyTo(descriptionLabel); + composite.addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent e) { + descriptionLabel.pack(); + } + }); + + setViewerInput(data.getConnection()); + + return composite; + } + + protected void validate() { + IStatus status = ConnectToDeviceSection.revalidate(data); + + if (status.isOK()) { + IConnection connection = data.getConnection(); + if (connection != null) { + IConnectedService connectedService = null; + Collection services = manager.getConnectedServices(connection); + if (services != null) { + for (IConnectedService service : services) { + if (service != null && service.getService().getIdentifier().equals(data.getService().getIdentifier())) { + connectedService = service; + } + } + } + + if (connectedService == null) { + status = error(MessageFormat.format( + "The selected connection does not support {0}", + data.getService().getDisplayName())); + } + else { + com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus serviceStatus = + connectedService.getStatus(); + if (!serviceStatus.getEStatus().equals( + com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus.UP)) { + status = warning("The selected connection may not be usable for debugging:\n {0}", + serviceStatus.getLongDescription()); + } + } + } + } + updateStatus(status); + } + + /** + * Update for a change in the connection. We will attempt to connect to the + * device (once) to detect what TRK it is running. + */ + private void updateConnection(IConnection connection) { + String standardPNPMessage = ConnectToDeviceSection.getStandardPNPMessage(); + data.setConnection(connection); + if (connection != null) { + descriptionLabel.setText(standardPNPMessage); + } else { + descriptionLabel.setText("No connections are detected or defined. " + standardPNPMessage); + } + + } + + public void connectionSelected(IConnection connection) { + updateConnection(connection); + validate(); + } + + public void connectionAdded(IConnection connection) { + refreshUI(); + } + + public void connectionRemoved(IConnection connection) { + refreshUI(); + } + + public void currentConnectionSet(IConnection connection) { + refreshUI(); + } + + private Set getCompatibleConnectionTypes() { + HashSet types = new HashSet(); + Collection compatibleTypeIds = + typeProvider.getCompatibleConnectionTypeIds(data.getService()); + for (String typeId : compatibleTypeIds) { + types.add(typeProvider.getConnectionType(typeId)); + } + return types; + } + + private List getCompatibleConnections() { + Set types = getCompatibleConnectionTypes(); + + List compatibleConnections = new ArrayList(); + for (IConnection connection : manager.getConnections()) { + if (types.contains(connection.getConnectionType())) + compatibleConnections.add(connection); + } + return compatibleConnections; + } + + private void setViewerInput(IConnection connection) { + List connections = getCompatibleConnections(); + viewer.setInput(connections); + + if (connections.isEmpty()) + viewer.getCombo().setEnabled(false); + else { + viewer.getCombo().setEnabled(true); + if (connection == null) { + viewer.getCombo().select(0); + ISelection selection = viewer.getSelection(); + connection = getConnectionFromSelection(selection); + viewer.setSelection(selection); + } + else + viewer.setSelection(new StructuredSelection(connection)); + } + editButton.setEnabled(!viewer.getSelection().isEmpty()); + + // fire listener in case we selected anew or the current connection changed + connectionSelected(connection); + } + + private IConnection getConnectionFromSelection(ISelection selection) { + return (IConnection) ((IStructuredSelection) selection).getFirstElement(); + } + + private void refreshUI() { + Display.getDefault().syncExec(new Runnable() { + public void run() { + if (viewer != null && viewer.getContentProvider() != null) { + setViewerInput(getConnectionFromSelection(viewer.getSelection())); + } + } + }); + } + + @Override + public boolean close() { + manager.addConnectionListener(this); + return super.close(); + } +} + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; +import com.nokia.carbide.remoteconnections.interfaces.IConnection; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager; +import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener; + +/** + * Present the "Connect to device" section with a short description. + */ +public class ConnectToDeviceSection extends AbstractLaunchWizardSection implements IConnectionListener { + + private static final String NO_CURRENT_CONNECTION_MSG = "No current connection is defined or detected."; + private final UnifiedLaunchOptionsPage launchOptionsPage; + private final IConnectionsManager manager; + + /** + * @param unifiedLaunchOptionsPage + * + */ + public ConnectToDeviceSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) { + super(data, "Connect to device"); + this.launchOptionsPage = launchOptionsPage; + manager = RemoteConnectionsActivator.getConnectionsManager(); + } + + public void createControl(Composite parent) { + createSection(parent, 0); + manager.addConnectionListener(this); + } + + @Override + protected void dispose() { + manager.removeConnectionListener(this); + } + + public void initializeSettings() { + data.setConnection(manager.getCurrentConnection()); + } + + @Override + protected void validate() { + status = revalidate(data); + } + + /** Get the simple status for the connection state */ + static IStatus revalidate(LaunchWizardData data) { + IStatus status = Status.OK_STATUS; + + if (data.getConnection() == null) { + status = error(NO_CURRENT_CONNECTION_MSG); + } + + return status; + } + + static String getStandardPNPMessage() { + return "You may plug in a device over USB or activate it over WLAN, or create a new connection now for your device."; + } + + @Override + protected void updateUI() { + if (control == null || control.isDisposed()) + return; + + String msg; + if (data.getConnection() != null) + msg = MessageFormat.format("The current connection is now ''{0}''.", data.getConnectionName()); + else + msg = MessageFormat.format("{0} {1}", NO_CURRENT_CONNECTION_MSG, getStandardPNPMessage()); + + descriptionLabel.setText(msg); + launchOptionsPage.changed(); + } + + @Override + protected AbstractLaunchSettingsDialog createChangeSettingsDialog(Shell shell, LaunchWizardData dialogData) { + return new ConnectToDeviceDialog(shell, dialogData); + } + + protected void refresh() { + Display.getDefault().syncExec(new Runnable() { + public void run() { + validate(); + updateUI(); + } + }); + } + + private void doConnectionsChanged() { + data.setConnection(manager.getCurrentConnection()); + refresh(); + } + + public void connectionAdded(IConnection connection) { + doConnectionsChanged(); + } + + public void connectionRemoved(IConnection connection) { + doConnectionsChanged(); + } + + public void currentConnectionSet(IConnection connection) { + doConnectionsChanged(); + } + + @Override + protected void doChange() { + super.doChange(); + IConnection connection = data.getConnection(); + if (connection != null && !connection.equals(manager.getCurrentConnection())) + manager.setCurrentConnection(connection); + } +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessDialog.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,598 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.io.File; +import java.text.MessageFormat; +import java.util.List; + +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.PreferencesUtil; + +import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; +import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; +import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; +import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; +import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; +import com.nokia.cpp.internal.api.utils.core.PathUtils; +import com.nokia.cpp.internal.api.utils.ui.BrowseDialogUtils; + +/** + * This dialog allows in-depth configuration of the debug/run process options. + */ +public class DebugRunProcessDialog extends AbstractLaunchSettingsDialog implements ICProjectDescriptionListener { + private ComboViewer projectExecutableViewer; + private Text remoteProgramEntry; + private Button projectExecutableRadioButton; + private Button remoteExecutableRadioButton; + private Button attachToProcessRadioButton; + + private Label packageInfoLabel; + private Button installPackageCheckbox; + private Combo sisFile; + private Text sisEdit; + private Button sisBrowse; + private Composite installPackageUI; + + protected DebugRunProcessDialog(Shell shell, LaunchWizardData data) { + super(shell, data); + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = initDialogArea(parent, + MessageFormat.format("Change {0} Process", data.getModeLabel()), + data.isDebug() ? LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_DEBUG_PROCESS : + LaunchWizardHelpIds.WIZARD_DIALOG_CHANGE_RUN_PROCESS); + + + createProcessSelector(composite); + + Label sep = new Label(composite, SWT.NONE); + GridDataFactory.fillDefaults().applyTo(sep); + + createPackageConfiguration(composite); + + initUI(); + + validate(); + + return composite; + } + + + private void createProcessSelector(Composite composite) { + Label label; + + label = new Label(composite, SWT.WRAP); + label.setText(MessageFormat.format("{0} method:", data.getModeLabel())); + label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + + GridDataFactory.fillDefaults().grab(true, false).applyTo(composite); + + Composite radioGroup = new Composite(composite, SWT.NONE); + GridDataFactory.fillDefaults().grab(true, false).applyTo(radioGroup); + GridLayoutFactory.fillDefaults().extendedMargins(INDENT, 0, 0, 0).numColumns(2).applyTo(radioGroup); + + createProjectExecutableRadioButton(radioGroup); + createRemoteExecutableRadioButton(radioGroup); + + label = new Label(radioGroup, SWT.SEPARATOR | SWT.HORIZONTAL); + GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(label); + + createAttachToProcessRadioButton(radioGroup); + + String msg; + if (data.isDebug()) + msg = "Configure how to debug the program. The initial settings reflect the debug capabilities of the selected device and the SIS builder settings."; + else + msg = "Configure how to run the program."; + setMessage(msg); + + switch (data.getExeSelection()) { + case USE_PROJECT_EXECUTABLE: + projectExecutableRadioButton.setSelection(true); + break; + case USE_REMOTE_EXECUTABLE: + remoteExecutableRadioButton.setSelection(true); + break; + case ATTACH_TO_PROCESS: + attachToProcessRadioButton.setSelection(true); + break; + } + } + + private void createPackageConfiguration(Composite composite) { + Label label; + + label = new Label(composite, SWT.WRAP); + label.setText(MessageFormat.format("Deploy method:", data.getModeLabel())); + label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); + + GridDataFactory.fillDefaults().grab(true, true).applyTo(composite); + + packageInfoLabel = new Label(composite, SWT.WRAP); + GridDataFactory.fillDefaults().grab(true, false).applyTo(packageInfoLabel); + composite.addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent e) { + packageInfoLabel.pack(); + } + }); + + installPackageCheckbox = new Button(composite, SWT.CHECK); + GridDataFactory.fillDefaults().applyTo(installPackageCheckbox); + + installPackageCheckbox.setText("Install package before launch"); + installPackageUI = new Composite(composite, SWT.NONE); + GridDataFactory.fillDefaults().indent(INDENT, 0).applyTo(installPackageUI); + + createSISContents(installPackageUI); + + + installPackageCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + data.setInstallPackage(installPackageCheckbox.getSelection()); + updatePackageUI(); + } + }); + + + if (data.isInstallPackage()) { + installPackageCheckbox.setSelection(true); + updatePackageUI(); + } + + updateSisFile(); + updatePackageUI(); + } + + protected void createSISContents(Composite composite) { + GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(2).applyTo(composite); + + final IProject project = data.getProject(); + ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); + if (cpi != null) { + final Label sisLabel = new Label(composite, SWT.NONE); + sisLabel.setText("SIS File to Install:"); + GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(1, 1).applyTo(sisLabel); + sisLabel.setToolTipText("Specify which SIS file to install on the phone prior to launching"); + sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); + + sisFile = new Combo(composite, SWT.READ_ONLY); + GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(sisLabel); + sisFile.setToolTipText("Specify which SIS file to install on the phone prior to launching"); + sisFile.add("None"); //$NON-NLS-1$ + sisFile.setData(UID, "DebugRunProcessDialog.sisFile"); + + sisFile.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateSisFile(); + } + }); + + ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); + for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { + IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); + sisFile.add(sisPath.toOSString()); + } + + // select the first sis file if any, otherwise select none + if (sisFile.getItemCount() > 1) { + sisFile.select(1); + } else { + sisFile.select(0); + } + + // listen for events so we can detect if they click on the link below and add new sis info. + CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED); + + composite.addDisposeListener(new DisposeListener() { + + public void widgetDisposed(DisposeEvent e) { + CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(DebugRunProcessDialog.this); + } + }); + + Link link = new Link(composite, SWT.NONE); + link.setText("" + "Modify SIS builder settings for build configuration" + "..."); + GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false).applyTo(link); + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + PreferencesUtil.createPropertyDialogOn(getShell(), project, "com.nokia.carbide.cdt.internal.builder.ui.CarbideBuildConfigurationsPage", null, null).open(); + } + }); + link.setData(UID, "DebugRunProcessDialog.link"); + } else { + // not a Carbide project, just an executable. show a browse/edit combo + // to let them select a sis file if they want to. + final Label sisLabel = new Label(composite, SWT.NONE); + sisLabel.setText("SIS File to Install:"); //$NON-NLS-1$ + GridDataFactory.swtDefaults().span(2, 1).applyTo(sisLabel); + sisLabel.setToolTipText("Specify which SIS file to install on the phone prior to launching"); + sisLabel.setData(UID, "DebugRunProcessDialog.sisLabel"); + + sisEdit = new Text(composite, SWT.BORDER); + GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(sisEdit); + sisEdit.setToolTipText("Specify which SIS file to install on the phone prior to launching"); + sisEdit.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + updateSisFile(); + validate(); + } + }); + sisEdit.setData(UID, "DebugRunProcessDialog.sisEdit"); + + sisBrowse = new Button(composite, SWT.NONE); + sisBrowse.setText("Browse..."); + sisBrowse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); + sisBrowse.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent evt) { + FileDialog dialog = new FileDialog(getShell(), SWT.NONE); + + dialog.setText("Select installation file"); + dialog.setFilterExtensions(new String[] {"*.sis*", "*.*"}); + dialog.setFilterNames(new String[] {"Installation Files", "All Files"}); + + BrowseDialogUtils.initializeFrom(dialog, sisEdit); + + String result = dialog.open(); + if (result != null && new File(result).exists()) { + sisEdit.setText(result); + updateSisFile(); + validate(); + } + } + }); + sisBrowse.setData(UID, "DebugRunProcessDialog.sisBrowse"); + } + } + + + /** + * + */ + protected void updateSisFile() { + String sisPath; + if (sisFile != null) { + sisPath = sisFile.getSelectionIndex() == 0 ? null : sisFile.getText(); //$NON-NLS-1$ + data.setSisPath(sisPath); + } else if (sisEdit != null) { + sisPath = sisEdit.getText(); + data.setSisPath(sisPath); + } + } + + + private void updatePackageUI() { + installPackageUI.setEnabled(data.isInstallPackage()); + for (Control kid : installPackageUI.getChildren()) + kid.setEnabled(data.isInstallPackage()); + } + + + public void handleEvent(CProjectDescriptionEvent event) { + Shell shell = getShell(); + if (shell == null || shell.isDisposed()) { + return; + } + + IProject project = event.getProject() ; + + if (project != data.getProject()) { + return; + } + + if (sisFile != null) { + ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(project); + if (cpi != null) { + sisFile.removeAll(); + + sisFile.add("None"); + + ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); + for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { + IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); + sisFile.add(sisPath.toOSString()); + } + + // select the first sis file if any, otherwise select none + if (sisFile.getItemCount() > 1) { + sisFile.select(1); + } else { + sisFile.select(0); + } + } + } + } + + protected void initUI() { + List exes = data.getExes(); + projectExecutableViewer.setInput(exes); + IPath exeSelectionPath = data.getExeSelectionPath(); + if (exeSelectionPath.equals(Path.EMPTY) && !exes.isEmpty()) + exeSelectionPath = exes.get(0); + projectExecutableViewer.setSelection(new StructuredSelection(exeSelectionPath)); + IPath remotePath = createSuggestedRemotePath(exeSelectionPath); + remoteProgramEntry.setText(PathUtils.convertPathToWindows(remotePath)); + + if (data.getExeSelection() == EExeSelection.USE_PROJECT_EXECUTABLE && exeSelectionPath != null) { + projectExecutableRadioButton.forceFocus(); + } + + if (data.getExeSelection() == EExeSelection.USE_REMOTE_EXECUTABLE && exeSelectionPath != null) { + remoteExecutableRadioButton.forceFocus(); + } + + if (data.getExeSelection() == EExeSelection.ATTACH_TO_PROCESS) { + attachToProcessRadioButton.forceFocus(); + } + + handleProjectExecutableRadioSelected(); + handleRemoteExecutableRadioSelected(); + handleAttachToProcessRadioSelected(); + } + + + private IPath createSuggestedRemotePath(IPath exeSelectionPath) { + String filename = exeSelectionPath.lastSegment(); + return PathUtils.createPath("C:/sys/bin").append(filename); + } + + /** + * Allow selecting an executable detected to be built by the program. + * @param radioGroup + */ + private void createProjectExecutableRadioButton(Composite radioGroup) { + projectExecutableRadioButton = new Button(radioGroup, SWT.RADIO); + GridDataFactory.fillDefaults().grab(false, false).applyTo(projectExecutableRadioButton); + projectExecutableRadioButton.setText("Launch project &executable:"); + projectExecutableRadioButton.setData(UID, "radio_project_executable"); + + projectExecutableViewer = new ComboViewer(radioGroup, SWT.READ_ONLY); + GridDataFactory.fillDefaults().grab(true, false).applyTo(projectExecutableViewer.getControl()); + projectExecutableViewer.getControl().setData(UID, "combo_project_executable"); + + projectExecutableViewer.setContentProvider(new ArrayContentProvider()); + projectExecutableViewer.setLabelProvider(new LabelProvider() { + @Override + public String getText(Object element) { + if (element instanceof IPath) + return ((IPath) element).lastSegment(); + return super.getText(element); + } + }); + + projectExecutableRadioButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleProjectExecutableRadioSelected(); + } + + }); + + projectExecutableViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + public void selectionChanged(SelectionChangedEvent event) { + Object sel = ((IStructuredSelection) event.getSelection()).getFirstElement(); + if (sel instanceof IPath) { + data.setExeSelectionPath((IPath) sel); + + // track the default remote program from the executable, for easy editing + if (remoteProgramEntry != null) { + IPath exeSelectionPath = createSuggestedRemotePath(data.getExeSelectionPath()); + remoteProgramEntry.setText(PathUtils.convertPathToWindows(exeSelectionPath)); + } + + validate(); + } + } + }); + } + + private void handleProjectExecutableRadioSelected() { + if (projectExecutableRadioButton.getSelection()) { + projectExecutableViewer.getControl().setEnabled(true); + data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); + IPath selectedPath = (IPath) ((IStructuredSelection) projectExecutableViewer.getSelection()).getFirstElement(); + if (selectedPath != null) { + String symbianPath = PathUtils.convertPathToWindows(selectedPath); + data.setExeSelectionPath(new Path(symbianPath)); + } + validate(); + } else { + projectExecutableViewer.getControl().setEnabled(false); + // another button becomes active and sets the new launch process + } + } + + /** + * Allow user to enter an executable path. + * @param radioGroup + */ + private void createRemoteExecutableRadioButton(Composite radioGroup) { + remoteExecutableRadioButton = new Button(radioGroup, SWT.RADIO); + GridDataFactory.fillDefaults().grab(false, false).applyTo(remoteExecutableRadioButton); + remoteExecutableRadioButton.setText("Launch &remote program:"); + + remoteExecutableRadioButton.setData(UID, "radio_remote_program"); + + remoteProgramEntry = new Text(radioGroup, SWT.BORDER); + GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramEntry); + + remoteProgramEntry.setData(UID, "text_remote_program"); + + remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleRemoteExecutableRadioSelected(); + } + + }); + + remoteProgramEntry.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + data.setExeSelectionPath(new Path(remoteProgramEntry.getText().trim())); + validate(); + } + }); + } + + private void handleRemoteExecutableRadioSelected() { + if (remoteExecutableRadioButton.getSelection()) { + remoteProgramEntry.setEnabled(true); + data.setExeSelection(EExeSelection.USE_REMOTE_EXECUTABLE); + String symbianPath = PathUtils.convertPathToWindows(remoteProgramEntry.getText()); + data.setExeSelectionPath(new Path(symbianPath)); + validate(); + } else { + remoteProgramEntry.setEnabled(false); + // another button becomes active and sets the new launch process + } + } + + /** + * Allow user to attach to a process. + * @param radioGroup + */ + private void createAttachToProcessRadioButton(Composite radioGroup) { + attachToProcessRadioButton = new Button(radioGroup, SWT.RADIO); + GridDataFactory.fillDefaults().grab(false, false).applyTo(attachToProcessRadioButton); + attachToProcessRadioButton.setText("&Attach to process:"); + + attachToProcessRadioButton.setData(UID, "radio_attach_to_process"); + + Label label = new Label(radioGroup, SWT.WRAP); + GridDataFactory.fillDefaults().grab(false, false).align(SWT.LEFT, SWT.CENTER).applyTo(label); + + label.setText("(selected at launch time)"); + + attachToProcessRadioButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleAttachToProcessRadioSelected(); + } + + }); + + } + + private void handleAttachToProcessRadioSelected() { + if (attachToProcessRadioButton.getSelection()) { + data.setExeSelection(EExeSelection.ATTACH_TO_PROCESS); + data.setExeSelectionPath(null); + validate(); + } else { + // another button becomes active and sets the new launch process + } + } + + @Override + protected void validate() { + IStatus status = Status.OK_STATUS; + + // check launch method + IPath exePath = data.getExeSelectionPath(); + switch (data.getExeSelection()) { + case USE_PROJECT_EXECUTABLE: + if (exePath.isEmpty()) { + status = error("The project builds no executables."); + } + break; + case USE_REMOTE_EXECUTABLE: + if (exePath.isEmpty()) { + status = error("Enter a non-empty executable path."); + } else { + String exePathString = exePath.toString(); + char drive = exePathString.charAt(0); + char colon = exePathString.length() < 2 ? 0x0 : exePathString.charAt(1); + char root = exePathString.length() < 3 ? 0x0 : exePathString.charAt(2); + char lastChar = exePathString.charAt(exePathString.length() - 1); + if (!Character.isLetter(drive) || colon != ':' || (root != '\\' && root != '/') || + lastChar == '\\' || lastChar == '/' || lastChar == ':') { + status = error("The executable path must be absolute."); + } else if (exePath.getFileExtension() == null) { + status = warning("The executable path should end in a filename."); + } + } + break; + case ATTACH_TO_PROCESS: + break; + } + + // check SIS selection + if (data.isInstallPackage()) { + if (sisEdit != null) { + String text = sisEdit.getText().trim(); + if (text.length() > 0) { + // empty is allowed, but if they specify something, make sure + // it exists + File file = new File(text); + if (!file.exists()) { + status = error("The SIS file ''{0}'' does not exist.", text); + } + } + } + } + + updateStatus(status); + } +} + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Status; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; +import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; +import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; +import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; +import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; +import com.nokia.cpp.internal.api.utils.core.PathUtils; + +/** + * + */ +public class DebugRunProcessSection extends AbstractLaunchWizardSection { + + public DebugRunProcessSection(LaunchWizardData data) { + super(data, MessageFormat.format("{0} process", data.getModeLabel())); + } + + @Override + public void createControl(Composite parent) { + createSection(parent, 1); + } + + @Override + protected void dispose() { + + } + + @Override + public void initializeSettings() { + data.setExeSelection(EExeSelection.USE_PROJECT_EXECUTABLE); + if (data.getExes().size() > 0) + data.setExeSelectionPath(data.getExes().get(0)); + else if (data.getDefaultExecutable() != null) + data.setExeSelectionPath(data.getDefaultExecutable()); + ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager().getProjectInfo(data.getProject()); + if (cpi != null) { + data.setInstallPackage(!data.isSysTRKConnection()); + ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); + for (ISISBuilderInfo info : config.getSISBuilderInfoList()) { + IPath sisPath = info.getSigningType() == ISISBuilderInfo.DONT_SIGN ? info.getUnsignedSISFullPath() : info.getSignedSISFullPath(); + data.setSisPath(sisPath.toOSString()); + } + } + } + + @Override + protected AbstractLaunchSettingsDialog createChangeSettingsDialog( + Shell shell, LaunchWizardData dialogData) { + return new DebugRunProcessDialog(shell, dialogData); + } + + @Override + protected void refresh() { + updateUI(); + } + + @Override + protected void validate() { + + status = Status.OK_STATUS; + + switch (data.getExeSelection()) { + case USE_PROJECT_EXECUTABLE: + if (data.getExeSelectionPath() == null) + status = error("This project does not build any executables.", + data.getModeLabel().toLowerCase()); + break; + case USE_REMOTE_EXECUTABLE: + if (data.getExeSelectionPath() == null) + status = error("No remote executable is selected.", + data.getModeLabel().toLowerCase()); + break; + case ATTACH_TO_PROCESS: + break; + } + + if (data.isInstallPackage() && (data.getSisPath() == null || data.getSisPath().length() == 0)) + status = error("Carbide must install a package to debug this project."); + } + + @Override + protected void updateUI() { + + validate(); + + if (status.isOK()) { + String mainFormat = "Carbide will {0} and {1}."; + String copyOrInstallMsg = ""; + String runOrLaunchMsg = ""; + + switch (data.getExeSelection()) { + case USE_PROJECT_EXECUTABLE: + runOrLaunchMsg = "launch '" + data.getExeSelectionPath().lastSegment() + "'"; + break; + case USE_REMOTE_EXECUTABLE: + runOrLaunchMsg = "launch '" + PathUtils.convertPathToWindows(data.getExeSelectionPath()) + "'"; + break; + case ATTACH_TO_PROCESS: + runOrLaunchMsg = "attach to a process selected at launch time"; + break; + } + + copyOrInstallMsg = getCopyOrInstallMsg(); + + String runOrDebugProcessMessage = MessageFormat.format(mainFormat, copyOrInstallMsg, runOrLaunchMsg); + descriptionLabel.setText(runOrDebugProcessMessage); + } else { + descriptionLabel.setText(status.getMessage() + "\n\n" + + MessageFormat.format("Click the 'Change...' button to select another {0} method.", + data.getModeLabel().toLowerCase())); + } + } + + private String getCopyOrInstallMsg() { + if (data.isSysTRKConnection() || !data.isInstallPackage()) + return "copy files to the device"; + else + return MessageFormat.format("install \"{0}\"", data.getSisPath()); + } + +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/IWizardSection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/IWizardSection.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * + */ +public interface IWizardSection { + + public interface ISectionChangeListener { + void changed(); + } + + /** Initialize settings once per wizard (before UI is shown) */ + void initializeSettings(); + + void createControl(Composite parent); + + Control getControl(); + + /** Get the current status (never null). This serves as the validation status as well + * as being displayed in the wizard validation area. */ + IStatus getStatus(); + + /** + * @return + */ + String getSectionName(); + + /** + * Set the listener notified when the Change button is clicked. + */ + void setChangeListener(ISectionChangeListener listener); +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizard.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizard.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,207 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IPageChangedListener; +import org.eclipse.jface.dialogs.PageChangedEvent; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.wizard.IWizardContainer; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.carbide.remoteconnections.interfaces.IService; +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; +import com.nokia.cdt.internal.debug.launch.wizard.ILaunchCreationWizard; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions; + +/** + * New launch wizard for Carbide 3.0. + * + * See https://xdabug001.ext.nokia.com/bugzilla/show_bug.cgi?id=10419 + */ +public class LaunchWizard extends Wizard implements ILaunchCreationWizard { + + private LaunchWizardData launchData; + private UnifiedLaunchOptionsPage mainPage; + private Button advancedButton; + private boolean advancedEdit; + private IPageChangedListener pageChangedListener; + private boolean hasFinished; + + public LaunchWizard(LaunchOptions launchOptions, IService trkService) { + launchData = new LaunchWizardData(launchOptions, trkService); + mainPage = new UnifiedLaunchOptionsPage(launchData); + mainPage.initializeSettings(); + setWindowTitle("New Launch Configuration Wizard"); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#addPages() + */ + @Override + public void addPages() { + addPage(mainPage); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#setContainer(org.eclipse.jface.wizard.IWizardContainer) + */ + @Override + public void setContainer(final IWizardContainer wizardContainer) { + super.setContainer(wizardContainer); + + // Thanks, JFace, for making it so hard to know when the UI is ready + if (wizardContainer instanceof WizardDialog && advancedButton == null) { + pageChangedListener = new IPageChangedListener() { + + public void pageChanged(PageChangedEvent event) { + addAdvancedButton(); + ((WizardDialog)getContainer()).removePageChangedListener(pageChangedListener); + } + }; + ((WizardDialog)wizardContainer).addPageChangedListener(pageChangedListener); + } + } + + protected void addAdvancedButton() { + if (advancedButton == null) { + Composite parent = (Composite) ((Dialog) getContainer()).buttonBar; + if (parent != null) { + + advancedButton = new Button(parent, SWT.CHECK); + GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(advancedButton); + ((GridLayout) parent.getLayout()).numColumns++; + advancedButton.moveBelow(parent.getChildren()[0]); + + advancedButton.setText("Edit advanced settings before launch"); + advancedButton.setToolTipText(MessageFormat.format( + "Before finishing the wizard, edit settings in the ''{0} Configurations'' dialog.", + launchData.getModeLabel())); + advancedButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + updateDebugEditButton(); + } + }); + } + + // Thanks, JFace, for deleting validation messages on the first display + mainPage.validatePage(); + } + } + + @Override + public boolean canFinish() { + if (advancedEdit) + return true; + return super.canFinish(); + } + + protected void updateDebugEditButton() { + Button finishButton = findFinishButton(); + if (finishButton != null) { + advancedEdit = advancedButton.getSelection(); + if (advancedEdit) { + finishButton.setText("Edit"); + finishButton.setToolTipText("Click to accept settings and edit advanced settings."); + getContainer().updateButtons(); + } else { + finishButton.setText(launchData.getModeLabel()); + finishButton.setToolTipText("Click to accept settings and launch the program."); + getContainer().updateButtons(); + } + } + } + + /** + * Thanks, SWT and JFace, for making this so difficult + * @return the Finish button + */ + private Button findFinishButton() { + if (getContainer() instanceof Dialog) { + return findFinishButton((Composite) ((Dialog) getContainer()).buttonBar); + } + return null; + } + + /** + * @param buttonBar + * @return + */ + private Button findFinishButton(Composite parent) { + for (Control kid : parent.getChildren()) { + if (kid instanceof Button) { + if (kid.getData() instanceof Integer && (Integer) kid.getData() == IDialogConstants.FINISH_ID) { + return (Button) kid; + } + } + else if (kid instanceof Composite) { + Button button = findFinishButton((Composite) kid); + if (button != null) + return button; + } + } + return null; + } + + @Override + public boolean performFinish() { + hasFinished = true; + return true; + } + + public boolean shouldOpenLaunchConfigurationDialog() { + return hasFinished && advancedEdit; + } + + public ILaunchConfigurationWorkingCopy getLaunchConfiguration() { + if (!hasFinished) + return null; + + ILaunchConfigurationWorkingCopy config = null; + try { + config = launchData.createConfiguration(); + } catch (CoreException e) { + LaunchPlugin.log(e); + } + + return config; + } + + public void init() { + } + + public int openWizard(Shell shell) { + WizardDialog dialog = new WizardDialog(shell, this); + return dialog.open(); + } +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,404 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.osgi.service.prefs.Preferences; + +import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper; +import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; +import com.nokia.carbide.remoteconnections.interfaces.IConnectedService; +import com.nokia.carbide.remoteconnections.interfaces.IConnection; +import com.nokia.carbide.remoteconnections.interfaces.IService; +import com.nokia.carbide.remoteconnections.internal.api.IConnectedService2; +import com.nokia.carbide.remoteconnections.internal.registry.Registry; +import com.nokia.cdt.debug.cw.symbian.SettingsData; +import com.nokia.cdt.internal.debug.launch.wizard.LaunchOptions; +import com.nokia.cpp.internal.api.utils.core.TextUtils; + +import cwdbg.PreferenceConstants; + +/** + * Data manipulated by the launch wizard and its dialogs. + */ +@SuppressWarnings("restriction") +public class LaunchWizardData extends LaunchOptions { + public interface IPathValidator { + /** + * @param path IPath + * @return Error string or null if is valid + */ + String isValidPath(IPath path); + } + + private final IService service; + + // overall target + public static class LaunchType { + private final String launchId; + + public LaunchType(String launchId) { + this.launchId = launchId; + } + + public boolean isApplicable(LaunchWizardData data) { + return true; + } + + public String getLaunchId() { + return launchId; + } + }; + + public final static LaunchType APP_TRK = new LaunchType(null); + public final static LaunchType SYS_TRK = new LaunchType(null); + public final static LaunchType ATTACH_TO_PROCESS_LAUNCH = new LaunchType(null); + public final static LaunchType PLATSIM_RUN_MODE = new LaunchType(null); + public final static LaunchType PLATSIM_STOP_MODE = new LaunchType(null); + + // settings made in Debug/Run Process section + enum EExeSelection { + USE_PROJECT_EXECUTABLE, + USE_REMOTE_EXECUTABLE, + ATTACH_TO_PROCESS, + }; + + private EExeSelection exeSelection; + private IPath exeSelectionPath = Path.EMPTY; + private EBuildBeforeLaunchOption buildBeforeLaunch; + private boolean installPackage; + private String sisPath; + private IConnection connection; + + // settings made in the Other Settings section + enum EBuildBeforeLaunchOption { + ALWAYS, + NEVER, + USE_WORKSPACE_SETTING, + } + + public LaunchWizardData(LaunchOptions launchOptions, IService trkService) { + this.mmps = launchOptions.mmps; + this.exes = launchOptions.exes; + this.defaultExecutable = launchOptions.defaultExecutable; + this.project = launchOptions.project; + this.configurationName = launchOptions.configurationName; + this.isEmulation = launchOptions.isEmulation; + this.emulatorOnly = launchOptions.emulatorOnly; + this.mode = launchOptions.mode; + this.service = trkService; + } + + /** + * @return the service + */ + public IService getService() { + return service; + } + + /** + * @return + */ + public boolean isDebug() { + return mode.equals(ILaunchManager.DEBUG_MODE); + } + + public String getModeLabel() { + if (mode.equals(ILaunchManager.RUN_MODE)) + return "Run"; + else if (mode.equals(ILaunchManager.DEBUG_MODE)) + return "Debug"; + else + return TextUtils.titleCase(mode); + + } + + /** + * Validate the detected and/or configured data + * @return IStatus, never null + */ + public IStatus validate() { + return Status.OK_STATUS; + } + + /** + * @return + * @return + */ + public List getExes() { + return exes; + } + + /** + * @return the defaultExecutable + */ + public IPath getDefaultExecutable() { + return defaultExecutable; + } + + /** + * Set the executable selection mode + * @param selection + */ + public void setExeSelection(EExeSelection selection) { + this.exeSelection = selection; + } + /** + * Set the path for the exe + * @param path or null + */ + public void setExeSelectionPath(IPath path) { + this.exeSelectionPath = path != null ? path : Path.EMPTY; + } + + /** + * @return + */ + public EExeSelection getExeSelection() { + return exeSelection; + } + + public IPath getExeSelectionPath() { + return exeSelectionPath; + } + + public String getConnectionName() { + IConnection connection = getConnection(); + if (connection == null) + return null; + return connection.getDisplayName(); + } + + public void setBuildBeforeLaunchOption( + EBuildBeforeLaunchOption setting) { + this.buildBeforeLaunch = setting; + } + + public EBuildBeforeLaunchOption getBuildBeforeLaunch() { + return buildBeforeLaunch; + } + + /** Get current workspace setting */ + public boolean isWorkspaceBuildBeforeLaunch() { + // here's how to get the prefs from a plugin's #getPreferenceStore() without violating access + String prefId = IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH; + int idx = prefId.lastIndexOf('.'); + String plugin = prefId.substring(0, idx); + Preferences node = Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE).node(plugin); + return node.getBoolean(prefId, true); + } + + /** Get actual launch-time setting */ + public boolean isCurrentBuildBeforeLaunch() { + if (buildBeforeLaunch != EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING) + return buildBeforeLaunch == EBuildBeforeLaunchOption.ALWAYS; + return isWorkspaceBuildBeforeLaunch(); + } + + /** + * @param selection + */ + public void setInstallPackage(boolean selection) { + this.installPackage = selection; + } + + /** + * @return the installPackage + */ + public boolean isInstallPackage() { + return installPackage; + } + + /** + * @return + */ + public IProject getProject() { + return project; + } + + /** + * @param sisPath + */ + public void setSisPath(String sisPath) { + this.sisPath = sisPath; + } + + /** + * @return + */ + public String getSisPath() { + return sisPath; + } + + /** + * Copy the data, for use by a transient dialog. + * @return new copy of data + */ + public LaunchWizardData copy() { + LaunchOptions launchOptions = new LaunchOptions(); + launchOptions.mmps = mmps; + launchOptions.exes = exes; + launchOptions.defaultExecutable = defaultExecutable; + launchOptions.project = project; + launchOptions.configurationName = configurationName; + launchOptions.isEmulation = isEmulation; + launchOptions.emulatorOnly = emulatorOnly; + launchOptions.mode = mode; + LaunchWizardData d = new LaunchWizardData(launchOptions, service); + d.exeSelection = exeSelection; + d.exeSelectionPath = exeSelectionPath; + d.buildBeforeLaunch = buildBeforeLaunch; + d.installPackage = installPackage; + d.sisPath = sisPath; + d.connection = connection; + return d; + } + + /** + * Apply the given data to the receiver (when a transient dialog is accepted) + * @param dialogData + */ + public void apply(LaunchWizardData dialogData) { + exeSelection = dialogData.exeSelection; + exeSelectionPath = dialogData.exeSelectionPath; + buildBeforeLaunch = dialogData.buildBeforeLaunch; + installPackage = dialogData.installPackage; + sisPath = dialogData.sisPath; + connection = dialogData.connection; + } + + /** + * @return + */ + public boolean requiresInstallPackage() { + return !isSysTRKConnection() || installPackage; + } + + public void setConnection(IConnection connection) { + this.connection = connection; + } + + public IConnection getConnection() { + return connection; + } + + public ILaunchConfigurationWorkingCopy createConfiguration() throws CoreException { + String launchTypeId = getApplicableLaunchTypeId(); + ILaunchConfigurationType launchType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(launchTypeId); + ILaunchConfigurationWorkingCopy config = launchType.newInstance(null, configurationName); + initializeConfigSettings(launchTypeId, config); + + return config; + } + + private void initializeConfigSettings(String launchTypeId, ILaunchConfigurationWorkingCopy config) { + IPath exePath = getExePath(); + IPath mmpPath = getMmpPath(exePath); + if (launchTypeId.equals(SettingsData.APP_TRK_LAUNCH_TYPE_ID)) { + SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath); + } + else if (launchTypeId.equals(SettingsData.SYS_TRK_LAUNCH_TYPE_ID)) { + SettingsData.setDefaults(config, SettingsData.LaunchConfig_SysTRK, project, mmpPath, exePath); + } + else if (launchTypeId.equals(SettingsData.ATTACH_LAUNCH_TYPE_ID)) { + SettingsData.setDefaults(config, SettingsData.LaunchConfig_AppTRK, project, mmpPath, exePath); + } + addBuildOptions(config); + // always set the current connection id + config.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, Registry.CURRENT_CONNECTION_ID); + if (installPackage) + config.setAttribute(PreferenceConstants.J_PN_SisFileHostPath, sisPath); + } + + private IPath getMmpPath(IPath exePath) { + if (!mmps.isEmpty()) { + for (int i = 0; i < exes.size(); i++) { + IPath exe = exes.get(i); + if (exe.lastSegment().equals(exePath.lastSegment())) + return mmps.get(i); + } + } + return null; + } + + private IPath getExePath() { + if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS)) + return exes.get(0); + return exeSelectionPath; + } + + private IConnectedService getConnectedService() { + if (connection != null) { + Collection connectedServices = + RemoteConnectionsActivator.getConnectionsManager().getConnectedServices(connection); + for (IConnectedService connectedService : connectedServices) { + if (connectedService.getService().getIdentifier().equals(service.getIdentifier())) + return connectedService; + } + } + return null; + } + + public boolean isSysTRKConnection() { + IConnectedService connectedService = getConnectedService(); + if (connectedService instanceof IConnectedService2) { + String value = ((IConnectedService2) connectedService).getProperties().get("is-system-trk"); //$NON-NLS-1$ + return Boolean.parseBoolean(value); + } + return false; + } + + private String getApplicableLaunchTypeId() { + if (exeSelection.equals(EExeSelection.ATTACH_TO_PROCESS)) + return SettingsData.ATTACH_LAUNCH_TYPE_ID; + else if (!installPackage || isSysTRKConnection()) + return SettingsData.SYS_TRK_LAUNCH_TYPE_ID; + else + return SettingsData.APP_TRK_LAUNCH_TYPE_ID; + } + + private void addBuildOptions(ILaunchConfigurationWorkingCopy config) { + int buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_USE_WORKSPACE_SETTING; + switch (buildBeforeLaunch) { + case NEVER: + buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_DISABLED; + break; + case ALWAYS: + buildBeforeLaunchValue = ICDTLaunchConfigurationConstants.BUILD_BEFORE_LAUNCH_ENABLED; + break; + } + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_BUILD_BEFORE_LAUNCH, buildBeforeLaunchValue); + } +} + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardHelpIds.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardHelpIds.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.cdt.internal.debug.launch.newwizard; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; + +// these are the help context id's for our launch wizard pages and dialogs + +public class LaunchWizardHelpIds { + /* + * Help context ID. Should be: PluginID + "." + + */ + private static final String HelpID_Prefix = LaunchPlugin.getUniqueIdentifier() + ".launch2_"; //$NON-NLS-1$ + + + public static final String WIZARD_DIALOG_CHANGE_DEBUG_PROCESS = HelpID_Prefix + "wizard_dialog_change_debug_process"; //$NON-NLS-1$ + public static final String WIZARD_DIALOG_CHANGE_RUN_PROCESS = HelpID_Prefix + "wizard_dialog_change_run_process"; //$NON-NLS-1$ + public static final String WIZARD_DIALOG_CHANGE_CONNECTION = HelpID_Prefix + "wizard_dialog_change_connection"; //$NON-NLS-1$ + + + public static final String WIZARD_DIALOG_OTHER_SETTINGS = HelpID_Prefix + "wizard_dialog_other_settings"; //$NON-NLS-1$ + +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/Messages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/Messages.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "com.nokia.cdt.internal.debug.launch.newwizard.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsDialog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsDialog.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,189 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.PreferencesUtil; + +import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EBuildBeforeLaunchOption; + +/** + * This dialog allows in-depth configuration of the other settings in the launch. + * Currently this only covers the build-before-launch options. + */ +public class OtherSettingsDialog extends AbstractLaunchSettingsDialog { + + private Button fDisableBuildButton; + private Button fEnableBuildButton; + private Button fWorkspaceSettingsButton; + private Link fWorkspaceSettingsLink; + + protected OtherSettingsDialog(Shell shell, LaunchWizardData data) { + super(shell, data); + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = initDialogArea(parent, + "Other Settings", + LaunchWizardHelpIds.WIZARD_DIALOG_OTHER_SETTINGS); + + String description = "Build the project before launch? " + + "This can take a very long time in some projects and build systems. " + + "On the other hand, you must remember to build the project yourself if you make changes."; + + final Label label = new Label(composite, SWT.WRAP); + label.setText(description); + GridData labelData = GridDataFactory.fillDefaults().grab(true, false).create(); + labelData.widthHint = 500; + label.setLayoutData(labelData); + + // spacer + new Label(composite, SWT.NONE); + + final Composite radio = new Composite(composite, SWT.NONE); + GridLayoutFactory.fillDefaults().numColumns(2).applyTo(radio); + GridDataFactory.fillDefaults().grab(true, true).applyTo(radio); + + composite.addControlListener(new ControlAdapter() { + @Override + public void controlResized(ControlEvent e) { + label.pack(); + } + }); + + fDisableBuildButton = new Button(radio, SWT.RADIO); + fDisableBuildButton.setText(Messages.getString("OtherSettingsDialog.DisableButtonLabel")); //$NON-NLS-1$ + fDisableBuildButton.setToolTipText(Messages.getString("OtherSettingsDialog.DisableButtonToolTip")); //$NON-NLS-1$ + fDisableBuildButton.setData(UID, "OtherSettingsDialog.disableBuildButton"); + + GridDataFactory.fillDefaults().span(2, 1).applyTo(fDisableBuildButton); + + fDisableBuildButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.NEVER); + } + }); + + + fEnableBuildButton = new Button(radio, SWT.RADIO); + fEnableBuildButton.setText(Messages.getString("OtherSettingsDialog.EnableButtonLabel")); //$NON-NLS-1$ + fEnableBuildButton.setToolTipText(Messages.getString("OtherSettingsDialog.EnableButtonToolTip")); //$NON-NLS-1$ + fEnableBuildButton.setData(UID, "OtherSettingsDialog.enableBuildButon"); + + GridDataFactory.fillDefaults().span(2, 1).applyTo(fEnableBuildButton); + + fEnableBuildButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.ALWAYS); + } + }); + + + fWorkspaceSettingsButton = new Button(radio, SWT.RADIO); + fWorkspaceSettingsButton.setText(Messages.getString("OtherSettingsDialog.WorkspaceSettingsButtonLabel")); //$NON-NLS-1$ + fWorkspaceSettingsButton.setToolTipText(Messages.getString("OtherSettingsDialog.WorkspaceSettingsButtonToolTip")); //$NON-NLS-1$ + fWorkspaceSettingsButton.setData(UID, "OtherSettingsDialog.workspaceSettingsButton"); + + GridDataFactory.swtDefaults().span(1, 1).applyTo(fWorkspaceSettingsButton); + + fWorkspaceSettingsButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING); + } + }); + + + fWorkspaceSettingsLink = new Link(radio, SWT.NONE); + fWorkspaceSettingsLink.setText(Messages.getString("OtherSettingsDialog.WorkspaceSettingsLinkLabel")); //$NON-NLS-1$ + fWorkspaceSettingsLink.setData(UID, "OtherSettingsDialog.workspaceSettingsLink"); + + GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(true, false).span(1, 1).applyTo(fWorkspaceSettingsLink); + + fWorkspaceSettingsLink.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + PreferencesUtil.createPreferenceDialogOn( + radio.getShell(), + Messages.getString("OtherSettingsDialog.WorkspaceSettingsPageID"), //$NON-NLS-1$ + null, + null).open(); + validate(); + } + }); + + switch (data.getBuildBeforeLaunch()) { + case ALWAYS: + fEnableBuildButton.setSelection(true); + fEnableBuildButton.setFocus(); + break; + case NEVER: + fDisableBuildButton.setSelection(true); + fDisableBuildButton.setFocus(); + break; + case USE_WORKSPACE_SETTING: + fWorkspaceSettingsButton.setSelection(true); + fWorkspaceSettingsButton.setFocus(); + break; + } + + validate(); + + return radio; + } + + @Override + protected void validate() { + IStatus status = Status.OK_STATUS; + updateStatus(status); + + String wsState = ""; + if (data.isWorkspaceBuildBeforeLaunch()) + wsState = " (enabled)"; + else + wsState = " (disabled)"; + + fWorkspaceSettingsButton.setText( + Messages.getString("OtherSettingsDialog.WorkspaceSettingsButtonLabel") + //$NON-NLS-1$ + wsState); + fWorkspaceSettingsButton.pack(); + + } +} + diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsSection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsSection.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import org.eclipse.core.runtime.Status; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EBuildBeforeLaunchOption; + +/** + * Present the "Build before debug" section with a short description. + */ +public class OtherSettingsSection extends AbstractLaunchWizardSection { + + /** + * + */ + public OtherSettingsSection(LaunchWizardData data) { + super(data, "Other settings"); + + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection#createComposite(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + createSection(parent, 2); + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#dispose() + */ + @Override + protected void dispose() { + } + + public void initializeSettings() { + data.setBuildBeforeLaunchOption(EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING); + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#validate() + */ + @Override + protected void validate() { + status = Status.OK_STATUS; + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#updateUI() + */ + @Override + protected void updateUI() { + String msg; + + String ifWorkspace = ""; + if (data.getBuildBeforeLaunch() == EBuildBeforeLaunchOption.USE_WORKSPACE_SETTING) + ifWorkspace = " (workspace setting)"; + + if (data.isCurrentBuildBeforeLaunch()) + msg = "Carbide will build the project before launch"; + else + msg = "Carbide will not build the project before launch"; + + descriptionLabel.setText(msg + ifWorkspace + "."); + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.AbstractLaunchWizardSection#createChangeSettingsDialog(org.eclipse.swt.widgets.Shell, com.nokia.cdt.internal.debug.launch.wizard2.LaunchOptionsData) + */ + @Override + protected AbstractLaunchSettingsDialog createChangeSettingsDialog( + Shell shell, LaunchWizardData dialogData) { + return new OtherSettingsDialog(shell, dialogData); + } + + protected void refresh() { + validate(); + updateUI(); + } +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,178 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.cdt.internal.debug.launch.newwizard; + +import java.text.MessageFormat; +import java.util.ArrayList; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; +import com.nokia.cdt.internal.debug.launch.newwizard.IWizardSection.ISectionChangeListener; + +/** + * This page presents three sections: + *

+ * Connection to use: container for the Remote Connection selection UI, plus a label + * explaining how to handle the case of no connections defined. + *

+ * Debug process: section explaining how the launch will happen, with a combo + * allowing selecting different process to launch, and a button allowing more + * in-depth configuration. + *

+ * Build before debug: section with the build-before-debug preference for this + * launch configuration. + */ +public class UnifiedLaunchOptionsPage extends WizardPage implements ISectionChangeListener { + + private final LaunchWizardData data; + private ArrayList sections; + + + /** + * @param mmps + * @param exes + * @param defaultExecutable + * @param project + * @param configurationName + */ + public UnifiedLaunchOptionsPage(LaunchWizardData data) { + super("Configure Launch Settings"); + + setDescription("Configure the connection and process to launch."); + + this.data = data; + this.sections = new ArrayList(); + + + IWizardSection section; + + section = new ConnectToDeviceSection(data, this); + sections.add(section); + + section = new DebugRunProcessSection(data); + sections.add(section); + + section = new OtherSettingsSection(data); + sections.add(section); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + + GridLayoutFactory.fillDefaults().applyTo(composite); + + setPageComplete(false); + + for (IWizardSection section : sections) { + section.createControl(composite); + section.setChangeListener(this); + GridDataFactory.fillDefaults().grab(true, true).applyTo(section.getControl()); + } + + + setControl(composite); + } + + /** + * @return + */ + public void validatePage() { + setMessage(null, INFORMATION); + setErrorMessage(null); + setPageComplete(true); + + IStatus pageStatus = null; + + // validate the subsections + StringBuilder builder = new StringBuilder(); + int severity = IStatus.OK; + for (IWizardSection section : sections) { + IStatus status = section.getStatus(); + if (status.isOK()) + continue; + if (builder.length() > 0) + builder.append("\n"); + + builder.append(MessageFormat.format("{0}: {1}", + section.getSectionName(), + status.getMessage())); + severity = Math.max(severity, status.getSeverity()); + } + if (severity != 0 || builder.length() > 0) { + // error from one or more sections + pageStatus = new Status(severity, LaunchPlugin.PLUGIN_ID, builder.toString()); + } else { + // sections are good; validate the page as a whole + pageStatus = data.validate(); + } + + setTitle("Configure launch configuration"); + + if (pageStatus != null && !pageStatus.isOK()) { + setMessage(pageStatus.getMessage(), severityToMsgType(pageStatus.getSeverity())); + setPageComplete(false); + } + } + + private int severityToMsgType(int severity) { + switch (severity) { + case IStatus.OK: + case IStatus.INFO: + return INFORMATION; + case IStatus.WARNING: + return WARNING; + case IStatus.ERROR: + default: + return ERROR; + } + } + + /* + private String getSeverityTag(int severity) { + if (severity == IStatus.OK || severity == IStatus.INFO || severity == IStatus.CANCEL) + return ""; + if (severity == IStatus.WARNING) + return "warning"; + return "error"; + } + */ + + public void initializeSettings() { + for (IWizardSection section : sections) { + section.initializeSettings(); + } + validatePage(); + } + + /* (non-Javadoc) + * @see com.nokia.cdt.internal.debug.launch.wizard2.IWizardSection.ISectionChangeListener#changed() + */ + public void changed() { + validatePage(); + } +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/messages.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/messages.properties Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,11 @@ +OtherSettingsDialog.Title=Build Options Selection +OtherSettingsDialog.Description=Select build options before launching +OtherSettingsDialog.OptionsGroupLabel=Build (if required) before launching +OtherSettingsDialog.DisableButtonLabel=Disable build before launch +OtherSettingsDialog.DisableButtonToolTip=Requires manually building project before launching (this may improve launch performance) +OtherSettingsDialog.EnableButtonLabel=Enable build before launch +OtherSettingsDialog.EnableButtonToolTip=Always build project before launching (this may impact launch performance) +OtherSettingsDialog.WorkspaceSettingsButtonLabel=Use workspace settings +OtherSettingsDialog.WorkspaceSettingsButtonToolTip=Use workspace setting for "Build (if required) before Launch" +OtherSettingsDialog.WorkspaceSettingsLinkLabel=Configure Workspace Settings... +OtherSettingsDialog.WorkspaceSettingsPageID=org.eclipse.debug.ui.LaunchingPreferencePage diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/ILaunchCreationWizard.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/ILaunchCreationWizard.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.cdt.internal.debug.launch.wizard; + +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.swt.widgets.Shell; + +public interface ILaunchCreationWizard { + + void init(); + + int openWizard(Shell shell); + + ILaunchConfigurationWorkingCopy getLaunchConfiguration(); + + boolean shouldOpenLaunchConfigurationDialog(); +} diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java Fri Feb 12 14:41:28 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchCreationWizard.java Mon Feb 15 13:49:01 2010 -0600 @@ -16,11 +16,8 @@ */ package com.nokia.cdt.internal.debug.launch.wizard; -import com.nokia.carbide.cpp.ui.CarbideUIPlugin; -import com.nokia.carbide.cpp.ui.ICarbideSharedImages; -import com.nokia.cdt.debug.cw.symbian.SettingsData; -import com.nokia.cdt.internal.debug.launch.LaunchPlugin; -import com.nokia.cpp.internal.api.utils.core.*; +import java.util.ArrayList; +import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -33,20 +30,22 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import java.util.ArrayList; -import java.util.List; +import com.nokia.carbide.cpp.ui.CarbideUIPlugin; +import com.nokia.carbide.cpp.ui.ICarbideSharedImages; +import com.nokia.cdt.debug.cw.symbian.SettingsData; +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; +import com.nokia.cpp.internal.api.utils.core.Check; +import com.nokia.cpp.internal.api.utils.core.Logging; +import com.nokia.cpp.internal.api.utils.core.Pair; -public class LaunchCreationWizard extends Wizard { +public class LaunchCreationWizard extends Wizard implements ILaunchCreationWizard { private MainExecutableSelectionWizardPage fBinarySelectionPage; private LaunchWizardSummaryPage fEmulationSummaryPage; - private LaunchCategorySelectionPage fCategorySelectionPage; private LaunchWizardSelectionPage fWizardSelectionPage; private BuildOptionsSelectionPage fBuildOptionsSelectionPage; private ILaunchConfigurationWorkingCopy launchConfig; @@ -54,6 +53,7 @@ private IProject project; private String configurationName; private List wizards = new ArrayList(); + private String categoryId; public LaunchCreationWizard(IProject project, String configurationName, List mmps, List exes, IPath defaultExecutable, @@ -74,7 +74,6 @@ fBinarySelectionPage = new MainExecutableSelectionWizardPage(mmps, exes, defaultExecutable, true, emulatorPath, emulatorOnly, fEmulationSummaryPage); } else { - fCategorySelectionPage = new LaunchCategorySelectionPage(this); fWizardSelectionPage = new LaunchWizardSelectionPage(this, mmps, exes, defaultExecutable, project, configurationName, mode); } } @@ -115,7 +114,6 @@ addPage(fEmulationSummaryPage); } else if (fWizardSelectionPage != null) { - addPage(fCategorySelectionPage); addPage(fWizardSelectionPage); } } @@ -125,7 +123,7 @@ return true; } - public void init(IWorkbench workbench, IStructuredSelection selection) { + public void init() { setWindowTitle(Messages.getString("LaunchCreationWizard.0")); //$NON-NLS-1$ setDefaultPageImageDescriptor(CarbideUIPlugin.getSharedImages().getImageDescriptor(ICarbideSharedImages.IMG_NEW_LAUNCH_CONFIG_WIZARD_BANNER)); } @@ -153,8 +151,12 @@ return shouldOpenLaunchDialog; } - public String getSelectedCategoryId() { - return fCategorySelectionPage.getSelectedCategoryId(); + public void setCategoryId(String categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryId() { + return categoryId; } public List getWizardsForCategory(String categoryId) { @@ -168,30 +170,12 @@ } private void loadWizards(List mmps, List exes, IPath defaultExecutable, String mode) { - AppTRKLaunchWizard appTRKWizard = new AppTRKLaunchWizard(mmps, exes, defaultExecutable, project, configurationName); - if (appTRKWizard.supportsMode(mode)) { - appTRKWizard.addPages(); - wizards.add(appTRKWizard); - } - - SystemTRKLaunchWizard sysTRKWizard = new SystemTRKLaunchWizard(mmps, exes, defaultExecutable, project, configurationName); - if (sysTRKWizard.supportsMode(mode)) { - sysTRKWizard.addPages(); - wizards.add(sysTRKWizard); - } - Trace32LaunchWizard trace32Wizard = new Trace32LaunchWizard(mmps, exes, defaultExecutable, project, configurationName); if (trace32Wizard.supportsMode(mode)) { trace32Wizard.addPages(); wizards.add(trace32Wizard); } - AttachTRKLaunchWizard attachTRKWizard = new AttachTRKLaunchWizard(mmps, exes, defaultExecutable, project, configurationName); - if (attachTRKWizard.supportsMode(mode)) { - attachTRKWizard.addPages(); - wizards.add(attachTRKWizard); - } - // load any wizard extensions IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(LaunchPlugin.PLUGIN_ID + ".launchWizardExtension"); //$NON-NLS-1$ diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchOptions.java Mon Feb 15 13:49:01 2010 -0600 @@ -0,0 +1,19 @@ +package com.nokia.cdt.internal.debug.launch.wizard; + +import java.util.List; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; + +public class LaunchOptions { + + public IProject project; + public String mode; + public String configurationName; + public boolean isEmulation; // aka isX86 + public boolean emulatorOnly; // aka useEmulationByDefault + public IPath defaultExecutable; + public List exes; + public List mmps; + +} \ No newline at end of file diff -r ee68c935ffb7 -r d1e221a2875f debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchWizardSelectionPage.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchWizardSelectionPage.java Fri Feb 12 14:41:28 2010 -0600 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/wizard/LaunchWizardSelectionPage.java Mon Feb 15 13:49:01 2010 -0600 @@ -146,7 +146,7 @@ public void setVisible(boolean visible) { super.setVisible(visible); if (visible && wizardSelectionTableViewer != null) { - wizardSelectionTableViewer.setInput(mainWizard.getWizardsForCategory(mainWizard.getSelectedCategoryId())); + wizardSelectionTableViewer.setInput(mainWizard.getWizardsForCategory(mainWizard.getCategoryId())); if (inputChanged) { wizardSelectionTableViewer.setSelection(new StructuredSelection(wizardSelectionTableViewer.getElementAt(0)), true); }