From a104dc4f6db705ce64cb91fa96e8eaa4150f0bcd Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Sat, 27 Sep 2014 23:52:17 -0400 Subject: [PATCH] Launch Bar - fix up how the new config wizard runs. Only change the type when we're flipping to the next page. Also fixes the order of initialization of the tabs to eliminate the NPEs that were happening. Change-Id: I9bb0a5d3ff646e4ca340f9c461e3a3c88f89e557 Reviewed-on: https://git.eclipse.org/r/34010 Tested-by: Hudson CI Reviewed-by: Doug Schaefer --- .../dialogs/NewLaunchConfigEditPage.java | 6 ++- .../dialogs/NewLaunchConfigTypePage.java | 51 +++++++++---------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java b/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java index 76d52cabc29..406286e200e 100644 --- a/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java +++ b/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigEditPage.java @@ -135,7 +135,6 @@ public class NewLaunchConfigEditPage extends WizardPage { // tab.setDefaults likely renames it nameText.setText(workingCopy.getName()); } - tab.initializeFrom(workingCopy); CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE); tabItem.setText(tab.getName()); @@ -144,6 +143,11 @@ public class NewLaunchConfigEditPage extends WizardPage { tabItem.setControl(tab.getControl()); } + // Do this after all the tabs have their controls created + for (ILaunchConfigurationTab tab : tabGroup.getTabs()) { + tab.initializeFrom(workingCopy); + } + tabFolder.setSelection(0); } catch (CoreException e) { Activator.log(e); diff --git a/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java b/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java index 9ef61a544ea..0936dd9162a 100644 --- a/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java +++ b/launch/org.eclipse.cdt.launchbar.ui/src/org/eclipse/cdt/launchbar/ui/internal/dialogs/NewLaunchConfigTypePage.java @@ -10,24 +10,19 @@ *******************************************************************************/ package org.eclipse.cdt.launchbar.ui.internal.dialogs; -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.ILaunchConfigurationType; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.progress.UIJob; public class NewLaunchConfigTypePage extends WizardPage { @@ -52,26 +47,6 @@ public class NewLaunchConfigTypePage extends WizardPage { populateItems(); - table.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - super.widgetSelected(e); - type = (ILaunchConfigurationType)table.getSelection()[0].getData(); - setMessage("Initializing. Please wait...", INFORMATION); - UIJob job = new UIJob("Updating Page") { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - ((NewLaunchConfigWizard)getWizard()).editPage.changeLaunchConfigType(); - setPageComplete(true); - setMessage(null); - return Status.OK_STATUS; - } - }; - job.setUser(true); - job.schedule(); - } - }); - setControl(comp); } @@ -81,11 +56,13 @@ public class NewLaunchConfigTypePage extends WizardPage { return; table.removeAll(); - + + boolean haveItems = false; for (ILaunchConfigurationType type : DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes()) { if (!type.isPublic() || type.getCategory() != null || !type.supportsMode(group.getMode())) continue; + haveItems = true; TableItem item = new TableItem(table, SWT.NONE); item.setText(type.getName()); ImageDescriptor imageDesc = DebugUITools.getDefaultImageDescriptor(type); @@ -94,8 +71,26 @@ public class NewLaunchConfigTypePage extends WizardPage { item.setData(type); } + if (haveItems) { + table.select(0); + } + setPageComplete(haveItems); + type = null; - setPageComplete(false); + } + + @Override + public boolean canFlipToNextPage() { + return isPageComplete(); + } + + @Override + public IWizardPage getNextPage() { + setMessage("Initializing. Please wait...", INFORMATION); + type = (ILaunchConfigurationType)table.getSelection()[0].getData(); + NewLaunchConfigEditPage editPage = ((NewLaunchConfigWizard)getWizard()).editPage; + editPage.changeLaunchConfigType(); + return editPage; } }