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 Listnull
+ */
+ 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+ * 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