# HG changeset patch # User dadubrow # Date 1287439129 18000 # Node ID 3a82092877eae1f63f0a72073a2c2e1e374b4966 # Parent db61d072b92b6a05acdd3fb10dfe92ba627b531d initial commit for PS wizard diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchWizard.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/AbstractLaunchWizard.java Mon Oct 18 16:58:49 2010 -0500 @@ -0,0 +1,213 @@ +/* +* 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.cpp.ui.CarbideUIPlugin; +import com.nokia.carbide.cpp.ui.ICarbideSharedImages; +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 abstract class AbstractLaunchWizard extends Wizard implements ILaunchCreationWizard { + + private LaunchWizardData launchData; + private AbstractUnifiedLaunchOptionsPage mainPage; + private Button advancedButton; + private boolean advancedEdit; + private IPageChangedListener pageChangedListener; + private boolean hasFinished; + + public AbstractLaunchWizard(LaunchOptions launchOptions, IService dbgService, String title) { + launchData = new LaunchWizardData(launchOptions, dbgService); + mainPage = createMainPage(launchData); + mainPage.initializeSettings(); + setWindowTitle(title); + } + + protected abstract AbstractUnifiedLaunchOptionsPage createMainPage(LaunchWizardData data); + + /* (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).indent(6, 0).applyTo(advancedButton); + ((GridLayout) parent.getLayout()).numColumns++; + advancedButton.moveBelow(parent.getChildren()[0]); + + advancedButton.setText(Messages.getString("LaunchWizard.AdvancedLabel")); //$NON-NLS-1$ + advancedButton.setToolTipText(MessageFormat.format( + Messages.getString("LaunchWizard.AdvancedTip"), //$NON-NLS-1$ + 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(); + updateDebugEditButton(); + } + } + + @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(Messages.getString("LaunchWizard.EditLabel")); //$NON-NLS-1$ + finishButton.setToolTipText(Messages.getString("LaunchWizard.EditTip")); //$NON-NLS-1$ + getContainer().updateButtons(); + } else { + finishButton.setText(launchData.getModeLabel()); + finishButton.setToolTipText(Messages.getString("LaunchWizard.FinishTip")); //$NON-NLS-1$ + 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() { + setDefaultPageImageDescriptor(CarbideUIPlugin.getSharedImages().getImageDescriptor(ICarbideSharedImages.IMG_NEW_LAUNCH_CONFIG_WIZARD_BANNER)); + } + + public int openWizard(Shell shell) { + WizardDialog dialog = new WizardDialog(shell, this); + return dialog.open(); + } +} diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchWizardSection.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchWizardSection.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractLaunchWizardSection.java Mon Oct 18 16:58:49 2010 -0500 @@ -56,10 +56,10 @@ protected Button changeButton; protected Composite control; private ISectionChangeListener changeListener; - protected final UnifiedLaunchOptionsPage launchOptionsPage; + protected final AbstractUnifiedLaunchOptionsPage launchOptionsPage; - public AbstractLaunchWizardSection(LaunchWizardData data, String sectionName, UnifiedLaunchOptionsPage launchOptionsPage) { + public AbstractLaunchWizardSection(LaunchWizardData data, String sectionName, AbstractUnifiedLaunchOptionsPage launchOptionsPage) { this.data = data; this.sectionName = sectionName; this.launchOptionsPage = launchOptionsPage; diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/AbstractUnifiedLaunchOptionsPage.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/AbstractUnifiedLaunchOptionsPage.java Mon Oct 18 16:58:49 2010 -0500 @@ -0,0 +1,143 @@ +/* +* 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 org.eclipse.swt.widgets.Control; + +import com.nokia.cdt.internal.debug.launch.LaunchPlugin; +import com.nokia.cdt.internal.debug.launch.newwizard.IWizardSection.ISectionChangeListener; +import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; + +public abstract class AbstractUnifiedLaunchOptionsPage extends WizardPage implements ISectionChangeListener { + + protected LaunchWizardData data; + protected ArrayList sections; + + protected AbstractUnifiedLaunchOptionsPage(String pageName, LaunchWizardData data) { + super(pageName); + this.data = data; + this.sections = new ArrayList(); + } + + protected void addSection(IWizardSection section) { + sections.add(section); + } + + 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()); + } + + WorkbenchUtils.setHelpContextId(composite, LaunchWizardHelpIds.WIZARD_DIALOG_LAUNCH_OPTIONS_PAGE); + + setControl(composite); + } + + public void initializeSettings() { + for (IWizardSection section : sections) { + section.initializeSettings(); + } + validatePage(); + } + + 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"); //$NON-NLS-1$ + + builder.append(MessageFormat.format("{0}: {1}", //$NON-NLS-1$ + section.getSectionName(), + status.getMessage())); + severity = Math.max(severity, status.getSeverity()); + } + if (severity == IStatus.OK) { + IStatus status = getStatus(); + if (!status.isOK()) { + builder.append(status.getMessage()); + 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(Messages.getString("UnifiedLaunchOptionsPage.TitleText")); //$NON-NLS-1$ + + if (pageStatus != null && !pageStatus.isOK()) { + setMessage(pageStatus.getMessage(), severityToMsgType(pageStatus.getSeverity())); + setPageComplete(pageStatus.getSeverity() < IStatus.ERROR); + } + } + + 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; + } + } + + protected abstract IStatus getStatus(); + + public void changed() { + validatePage(); + Control control = getControl(); + if (control != null && !control.isDisposed()) + getWizard().getContainer().getShell().pack(); + } +} \ No newline at end of file diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java Mon Oct 18 16:58:49 2010 -0500 @@ -43,7 +43,7 @@ * @param unifiedLaunchOptionsPage * */ - public ConnectToDeviceSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) { + public ConnectToDeviceSection(LaunchWizardData data, AbstractUnifiedLaunchOptionsPage launchOptionsPage) { super(data, Messages.getString("ConnectToDeviceSection.Title"), launchOptionsPage); //$NON-NLS-1$ manager = RemoteConnectionsActivator.getConnectionsManager(); } diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/DebugRunProcessSection.java Mon Oct 18 16:58:49 2010 -0500 @@ -37,7 +37,7 @@ */ public class DebugRunProcessSection extends AbstractLaunchWizardSection { - public DebugRunProcessSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) { + public DebugRunProcessSection(LaunchWizardData data, AbstractUnifiedLaunchOptionsPage launchOptionsPage) { super(data, MessageFormat.format(Messages.getString("DebugRunProcessSection.Title"), data.getModeLabel()), launchOptionsPage); //$NON-NLS-1$ } diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizard.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizard.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizard.java Mon Oct 18 16:58:49 2010 -0500 @@ -17,32 +17,7 @@ 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.cpp.ui.CarbideUIPlugin; -import com.nokia.carbide.cpp.ui.ICarbideSharedImages; 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; /** @@ -50,162 +25,15 @@ * * See https://xdabug001.ext.nokia.com/bugzilla/show_bug.cgi?id=10419 */ -public class LaunchWizard extends Wizard implements ILaunchCreationWizard { +public class LaunchWizard extends AbstractLaunchWizard { - 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(Messages.getString("LaunchWizard.Title")); //$NON-NLS-1$ + super(launchOptions, trkService, Messages.getString("LaunchWizard.Title")); //$NON-NLS-1$ } - /* (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 AbstractUnifiedLaunchOptionsPage createMainPage(LaunchWizardData data) { + return new UnifiedLaunchOptionsPage(data); } - 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).indent(6, 0).applyTo(advancedButton); - ((GridLayout) parent.getLayout()).numColumns++; - advancedButton.moveBelow(parent.getChildren()[0]); - - advancedButton.setText(Messages.getString("LaunchWizard.AdvancedLabel")); //$NON-NLS-1$ - advancedButton.setToolTipText(MessageFormat.format( - Messages.getString("LaunchWizard.AdvancedTip"), //$NON-NLS-1$ - 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(); - updateDebugEditButton(); - } - } - - @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(Messages.getString("LaunchWizard.EditLabel")); //$NON-NLS-1$ - finishButton.setToolTipText(Messages.getString("LaunchWizard.EditTip")); //$NON-NLS-1$ - getContainer().updateButtons(); - } else { - finishButton.setText(launchData.getModeLabel()); - finishButton.setToolTipText(Messages.getString("LaunchWizard.FinishTip")); //$NON-NLS-1$ - 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() { - setDefaultPageImageDescriptor(CarbideUIPlugin.getSharedImages().getImageDescriptor(ICarbideSharedImages.IMG_NEW_LAUNCH_CONFIG_WIZARD_BANNER)); - } - - public int openWizard(Shell shell) { - WizardDialog dialog = new WizardDialog(shell, this); - return dialog.open(); - } } diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/LaunchWizardData.java Mon Oct 18 16:58:49 2010 -0500 @@ -116,7 +116,7 @@ USE_WORKSPACE_SETTING, } - public LaunchWizardData(LaunchOptions launchOptions, IService trkService) { + public LaunchWizardData(LaunchOptions launchOptions, IService dbgService) { this.mmps = launchOptions.mmps; this.exes = launchOptions.exes; this.defaultExecutable = launchOptions.defaultExecutable; @@ -125,7 +125,7 @@ this.isEmulation = launchOptions.isEmulation; this.emulatorOnly = launchOptions.emulatorOnly; this.mode = launchOptions.mode; - this.service = trkService; + this.service = dbgService; } /** diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsSection.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsSection.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/OtherSettingsSection.java Mon Oct 18 16:58:49 2010 -0500 @@ -31,7 +31,7 @@ /** * */ - public OtherSettingsSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) { + public OtherSettingsSection(LaunchWizardData data, AbstractUnifiedLaunchOptionsPage launchOptionsPage) { super(data, Messages.getString("OtherSettingsSection.Title"), launchOptionsPage); //$NON-NLS-1$ } diff -r db61d072b92b -r 3a82092877ea debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java --- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java Fri Oct 15 13:04:49 2010 -0500 +++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java Mon Oct 18 16:58:49 2010 -0500 @@ -18,22 +18,12 @@ package com.nokia.cdt.internal.debug.launch.newwizard; import java.io.File; -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 org.eclipse.swt.widgets.Control; import com.nokia.cdt.internal.debug.launch.LaunchPlugin; -import com.nokia.cdt.internal.debug.launch.newwizard.IWizardSection.ISectionChangeListener; import com.nokia.cdt.internal.debug.launch.newwizard.LaunchWizardData.EExeSelection; -import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils; /** * This page presents three sections: @@ -51,120 +41,15 @@ * Each section is validated separately and editable with its own dialog. Changes in * the dialog are not applied until the dialog is accepted. */ -public class UnifiedLaunchOptionsPage extends WizardPage implements ISectionChangeListener { +public class UnifiedLaunchOptionsPage extends AbstractUnifiedLaunchOptionsPage { - private final LaunchWizardData data; - private ArrayList sections; - - - /** - * @param mmps - * @param exes - * @param defaultExecutable - * @param project - * @param configurationName - */ public UnifiedLaunchOptionsPage(LaunchWizardData data) { - super(Messages.getString("UnifiedLaunchOptionsPage.Title")); //$NON-NLS-1$ - + super(Messages.getString("UnifiedLaunchOptionsPage.Title"), data); //$NON-NLS-1$ setDescription(Messages.getString("UnifiedLaunchOptionsPage.Desc")); //$NON-NLS-1$ - this.data = data; - this.sections = new ArrayList(); - - - IWizardSection section; - - section = new ConnectToDeviceSection(data, this); - sections.add(section); - - section = new DebugRunProcessSection(data, this); - sections.add(section); - - section = new OtherSettingsSection(data, this); - 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()); - } - - WorkbenchUtils.setHelpContextId(composite, LaunchWizardHelpIds.WIZARD_DIALOG_LAUNCH_OPTIONS_PAGE); - - 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"); //$NON-NLS-1$ - - builder.append(MessageFormat.format("{0}: {1}", //$NON-NLS-1$ - section.getSectionName(), - status.getMessage())); - severity = Math.max(severity, status.getSeverity()); - } - if (severity == IStatus.OK) { - IStatus status = getStatus(); - if (!status.isOK()) { - builder.append(status.getMessage()); - 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(Messages.getString("UnifiedLaunchOptionsPage.TitleText")); //$NON-NLS-1$ - - if (pageStatus != null && !pageStatus.isOK()) { - setMessage(pageStatus.getMessage(), severityToMsgType(pageStatus.getSeverity())); - setPageComplete(pageStatus.getSeverity() < IStatus.ERROR); - } - } - - 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; - } + addSection(new ConnectToDeviceSection(data, this)); + addSection(new DebugRunProcessSection(data, this)); + addSection(new OtherSettingsSection(data, this)); } protected IStatus getStatus() { @@ -185,28 +70,9 @@ !data.getExePath().toFile().exists()) { return new Status(IStatus.WARNING, LaunchPlugin.PLUGIN_ID, Messages.getString("UnifiedLaunchOptionsPage.ExeFileMissingWarning")); //$NON-NLS-1$ - } } return Status.OK_STATUS; } - - 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(); - Control control = getControl(); - if (control != null && !control.isDisposed()) - getWizard().getContainer().getShell().pack(); - - } }