From fd58fed7e44a0f6fdb49279418c8610e624861a5 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Tue, 5 May 2015 12:02:34 -0400 Subject: [PATCH] launch bar: corrected edit dialog handling of adding of new LC - launch bar launch config was not handling add of another launch config correctly - it was just resetting itself to handle new LC. This cannot really be done because this dialog is bound to launch group and new lc may not be part of it and may not even support the mode current dialog is in. Also that make missyncronization between LC stored in parent and LC stored in getTabViewer which can cause other nasty problems. So let parent handle adding (which only handles locatio change) and for duplication we just open a new dialog and close current one. Change-Id: I2dde5c3af26d901d1f4b18cad84a83a9857a6ca9 --- .../LaunchConfigurationEditDialog.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/LaunchConfigurationEditDialog.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/LaunchConfigurationEditDialog.java index 2f474f1bc50..067035ca4f1 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/LaunchConfigurationEditDialog.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/dialogs/LaunchConfigurationEditDialog.java @@ -35,6 +35,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.UIJob; @SuppressWarnings("restriction") public class LaunchConfigurationEditDialog extends LaunchConfigurationPropertiesDialog { @@ -104,21 +105,11 @@ public class LaunchConfigurationEditDialog extends LaunchConfigurationProperties return composite; } - protected String getLaunchButtonText() { - return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(getMode()).getLabel(); - } - @Override protected void createButtonsForButtonBar(Composite parent) { // Do nothing since we now have the buttons created above. } - @Override - public void launchConfigurationAdded(ILaunchConfiguration configuration) { - // update the dialog with the new config - getTabViewer().setInput(configuration); - } - @Override protected void buttonPressed(int buttonId) { switch (buttonId) { @@ -145,17 +136,23 @@ public class LaunchConfigurationEditDialog extends LaunchConfigurationProperties case DUPLICATE_ID: final ILaunchConfiguration original = getLaunchConfiguration(); final String newName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(original.getName()); - new Job(Messages.LaunchConfigurationEditDialog_6) { - protected IStatus run(IProgressMonitor monitor) { + final Shell shell = getParentShell(); + final LaunchGroupExtension group = getLaunchGroup(); + + new UIJob(Messages.LaunchConfigurationEditDialog_6) { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { try { - ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName); - newWorkingCopy.doSave(); - return Status.OK_STATUS; + final ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName); + final ILaunchConfiguration newConfig = newWorkingCopy.doSave(); + new LaunchConfigurationEditDialog(shell, newConfig, group).open(); } catch (CoreException e) { return e.getStatus(); } - }; + return Status.OK_STATUS; + } }.schedule(); + cancelPressed(); break; case LAUNCH_ID: okPressed();