From e1fdb68ea30beec9ad7dcdb68c960cdded78e111 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Tue, 17 Mar 2015 11:29:36 -0400 Subject: [PATCH] launchbar: command to open config selector plus more - added command to open config selector (unbound now) - refactored common code to edit config (move into edit config command) - removed unused includes - changed wording on other launch bar command for consistency Change-Id: I9af26cc307cfde4e63d8caa3822a169f42638ef3 --- .../META-INF/MANIFEST.MF | 3 +- bundles/org.eclipse.launchbar.ui/plugin.xml | 13 +++- .../DefaultDescriptorLabelProvider.java | 1 - .../ConfigureActiveLaunchHandler.java | 74 ++++++++++++++----- .../internal/commands/OpenLaunchSelector.java | 43 +++++++++++ .../ui/internal/controls/ConfigSelector.java | 51 ++----------- .../internal/controls/LaunchBarControl.java | 4 + 7 files changed, 120 insertions(+), 69 deletions(-) create mode 100644 bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/OpenLaunchSelector.java diff --git a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF index d8805c9e61e..db5c174c759 100644 --- a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF @@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.swt, org.eclipse.ui.navigator, org.eclipse.remote.core;bundle-version="2.0.0", - org.eclipse.remote.ui;bundle-version="1.1.0" + org.eclipse.remote.ui;bundle-version="1.1.0", + org.eclipse.e4.core.contexts Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/bundles/org.eclipse.launchbar.ui/plugin.xml b/bundles/org.eclipse.launchbar.ui/plugin.xml index b71b2ecdb12..8a63efff54a 100644 --- a/bundles/org.eclipse.launchbar.ui/plugin.xml +++ b/bundles/org.eclipse.launchbar.ui/plugin.xml @@ -21,13 +21,13 @@ categoryId="org.eclipse.launchbar.ui.category.launchBar" defaultHandler="org.eclipse.launchbar.ui.internal.commands.BuildActiveCommandHandler" id="org.eclipse.launchbar.ui.command.buildActive" - name="Build for Active Launch Configuration"> + name="Build Active Launch Configuration"> + name="Launch Active Launch Configuration"> + name="Edit Active Launch Configuration"> + + findElements = service.findElements(application, LaunchBarControl.ID, + null, null); + if (findElements.size() > 0) { + MToolControl mpart = (MToolControl) findElements.get(0); + Object bar = mpart.getObject(); + if (bar instanceof LaunchBarControl) { + ((LaunchBarControl) bar).getConfigSelector().openPopup(); + } + } + return Status.OK_STATUS; + } +} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java index 65416182f7e..e0d867da78e 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/ConfigSelector.java @@ -17,14 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchMode; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension; -import org.eclipse.debug.ui.ILaunchGroup; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; @@ -32,13 +25,11 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.launchbar.core.ILaunchDescriptor; -import org.eclipse.launchbar.core.internal.LaunchBarManager; import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.internal.DefaultDescriptorLabelProvider; import org.eclipse.launchbar.ui.internal.LaunchBarUIManager; -import org.eclipse.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog; +import org.eclipse.launchbar.ui.internal.commands.ConfigureActiveLaunchHandler; import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigWizard; -import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -54,8 +45,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; @SuppressWarnings("restriction") public class ConfigSelector extends CSelector { @@ -164,39 +153,7 @@ public class ConfigSelector extends CSelector { @Override public void handleEdit(Object element) { - try { - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - LaunchBarManager manager = uiManager.getManager(); - ILaunchDescriptor desc = (ILaunchDescriptor) element; - ILaunchMode mode = manager.getActiveLaunchMode(); - IRemoteConnection target = manager.getActiveLaunchTarget(); - if (target == null) { - MessageDialog.openError(shell, "No Active Target", "You must create a target to edit this launch configuration."); - return; - } - ILaunchConfigurationType configType = manager.getLaunchConfigurationType(desc, target); - if (configType == null) { - MessageDialog.openError(shell, "No launch configuration type", "Cannot edit this configuration"); - return; - } - ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier()); - LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier()); - if (groupExt != null) { - ILaunchConfiguration config = manager.getLaunchConfiguration(desc, target); - if (config == null) { - MessageDialog.openError(shell, "No launch configuration", "Cannot edit this configuration"); - return; - } - if (config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).isDirty()) { - config = ((ILaunchConfigurationWorkingCopy) config).doSave(); - } - final LaunchConfigurationEditDialog dialog = new LaunchConfigurationEditDialog(shell, config, groupExt); - dialog.setInitialStatus(Status.OK_STATUS); - dialog.open(); - } - } catch (CoreException e2) { - Activator.log(e2); - } + ConfigureActiveLaunchHandler.openConfigurationEditor((ILaunchDescriptor) element); } @Override @@ -285,4 +242,8 @@ public class ConfigSelector extends CSelector { super.setSelection(element); } + public void openPopup() { + super.openPopup(); + } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java index 3993dfc3ba8..d6ca90c3dd0 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/controls/LaunchBarControl.java @@ -145,4 +145,8 @@ public class LaunchBarControl implements Listener { // TODO Auto-generated method stub } + + public ConfigSelector getConfigSelector() { + return configSelector; + } }