mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 11:15:38 +02:00
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
This commit is contained in:
parent
210058b955
commit
e1fdb68ea3
7 changed files with 120 additions and 69 deletions
|
@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.swt,
|
org.eclipse.swt,
|
||||||
org.eclipse.ui.navigator,
|
org.eclipse.ui.navigator,
|
||||||
org.eclipse.remote.core;bundle-version="2.0.0",
|
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-RequiredExecutionEnvironment: JavaSE-1.7
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
||||||
defaultHandler="org.eclipse.launchbar.ui.internal.commands.BuildActiveCommandHandler"
|
defaultHandler="org.eclipse.launchbar.ui.internal.commands.BuildActiveCommandHandler"
|
||||||
id="org.eclipse.launchbar.ui.command.buildActive"
|
id="org.eclipse.launchbar.ui.command.buildActive"
|
||||||
name="Build for Active Launch Configuration">
|
name="Build Active Launch Configuration">
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
||||||
defaultHandler="org.eclipse.launchbar.ui.internal.commands.LaunchActiveCommandHandler"
|
defaultHandler="org.eclipse.launchbar.ui.internal.commands.LaunchActiveCommandHandler"
|
||||||
id="org.eclipse.launchbar.ui.command.launchActive"
|
id="org.eclipse.launchbar.ui.command.launchActive"
|
||||||
name="Launch Active Configuration">
|
name="Launch Active Launch Configuration">
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
||||||
|
@ -36,9 +36,16 @@
|
||||||
name="Stop">
|
name="Stop">
|
||||||
</command>
|
</command>
|
||||||
<command
|
<command
|
||||||
|
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
||||||
defaultHandler="org.eclipse.launchbar.ui.internal.commands.ConfigureActiveLaunchHandler"
|
defaultHandler="org.eclipse.launchbar.ui.internal.commands.ConfigureActiveLaunchHandler"
|
||||||
id="org.eclipse.launchbar.ui.command.configureActiveLaunch"
|
id="org.eclipse.launchbar.ui.command.configureActiveLaunch"
|
||||||
name="Configure Active Launch Configuration">
|
name="Edit Active Launch Configuration">
|
||||||
|
</command>
|
||||||
|
<command
|
||||||
|
categoryId="org.eclipse.launchbar.ui.category.launchBar"
|
||||||
|
defaultHandler="org.eclipse.launchbar.ui.internal.commands.OpenLaunchSelector"
|
||||||
|
id="org.eclipse.launchbar.ui.command.openLaunchSelector"
|
||||||
|
name="Open Launch Bar Config Selector">
|
||||||
</command>
|
</command>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||||
import org.eclipse.launchbar.core.internal.Activator;
|
import org.eclipse.launchbar.core.internal.Activator;
|
||||||
import org.eclipse.launchbar.core.internal.DefaultLaunchDescriptor;
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
public class DefaultDescriptorLabelProvider extends LabelProvider {
|
public class DefaultDescriptorLabelProvider extends LabelProvider {
|
||||||
|
|
|
@ -16,35 +16,71 @@ import org.eclipse.core.commands.ExecutionException;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.debug.core.ILaunchMode;
|
import org.eclipse.debug.core.ILaunchMode;
|
||||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
import org.eclipse.debug.ui.ILaunchGroup;
|
||||||
import org.eclipse.jface.window.Window;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
||||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||||
import org.eclipse.launchbar.ui.internal.Activator;
|
import org.eclipse.launchbar.ui.internal.Activator;
|
||||||
import org.eclipse.ui.handlers.HandlerUtil;
|
import org.eclipse.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
public class ConfigureActiveLaunchHandler extends AbstractHandler {
|
public class ConfigureActiveLaunchHandler extends AbstractHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
try {
|
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||||
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
ILaunchDescriptor launchDesc = launchBarManager.getActiveLaunchDescriptor();
|
||||||
ILaunchConfiguration launchConfiguration = launchBarManager.getActiveLaunchConfiguration();
|
if (launchDesc == null)
|
||||||
if (launchConfiguration == null)
|
return Status.OK_STATUS;
|
||||||
return Status.OK_STATUS;
|
openConfigurationEditor(launchDesc);
|
||||||
ILaunchConfigurationWorkingCopy wc = launchConfiguration.getWorkingCopy();
|
|
||||||
|
|
||||||
ILaunchMode activeLaunchMode = launchBarManager.getActiveLaunchMode();
|
|
||||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(launchConfiguration.getType(), activeLaunchMode.getIdentifier());
|
|
||||||
|
|
||||||
if (DebugUITools.openLaunchConfigurationPropertiesDialog(HandlerUtil.getActiveShell(event), wc, group.getIdentifier()) == Window.OK)
|
|
||||||
wc.doSave();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
return e.getStatus();
|
|
||||||
}
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void openConfigurationEditor(ILaunchDescriptor desc) {
|
||||||
|
if (desc == null)
|
||||||
|
return;
|
||||||
|
try {
|
||||||
|
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||||
|
LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||||
|
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();
|
||||||
|
} else {
|
||||||
|
MessageDialog.openError(shell, "Cannot determine mode", "Cannot edit this configuration");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (CoreException e2) {
|
||||||
|
Activator.log(e2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2015 QNX Software Systems and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Alena Laskavaia
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.launchbar.ui.internal.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
||||||
|
import org.eclipse.e4.ui.internal.workbench.E4Workbench;
|
||||||
|
import org.eclipse.e4.ui.model.application.MApplication;
|
||||||
|
import org.eclipse.e4.ui.model.application.ui.menu.MToolControl;
|
||||||
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||||
|
import org.eclipse.launchbar.ui.internal.controls.LaunchBarControl;
|
||||||
|
|
||||||
|
public class OpenLaunchSelector extends AbstractHandler {
|
||||||
|
@Override
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
IEclipseContext serviceContext = E4Workbench.getServiceContext();
|
||||||
|
MApplication application = serviceContext.get(MApplication.class);
|
||||||
|
EModelService service = application.getContext().get(EModelService.class);
|
||||||
|
List<Object> 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,14 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
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.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.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
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.window.Window;
|
||||||
import org.eclipse.jface.wizard.WizardDialog;
|
import org.eclipse.jface.wizard.WizardDialog;
|
||||||
import org.eclipse.launchbar.core.ILaunchDescriptor;
|
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.Activator;
|
||||||
import org.eclipse.launchbar.ui.internal.DefaultDescriptorLabelProvider;
|
import org.eclipse.launchbar.ui.internal.DefaultDescriptorLabelProvider;
|
||||||
import org.eclipse.launchbar.ui.internal.LaunchBarUIManager;
|
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.launchbar.ui.internal.dialogs.NewLaunchConfigWizard;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.MouseAdapter;
|
import org.eclipse.swt.events.MouseAdapter;
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
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.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class ConfigSelector extends CSelector {
|
public class ConfigSelector extends CSelector {
|
||||||
|
@ -164,39 +153,7 @@ public class ConfigSelector extends CSelector {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEdit(Object element) {
|
public void handleEdit(Object element) {
|
||||||
try {
|
ConfigureActiveLaunchHandler.openConfigurationEditor((ILaunchDescriptor) element);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -285,4 +242,8 @@ public class ConfigSelector extends CSelector {
|
||||||
super.setSelection(element);
|
super.setSelection(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openPopup() {
|
||||||
|
super.openPopup();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,4 +145,8 @@ public class LaunchBarControl implements Listener {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigSelector getConfigSelector() {
|
||||||
|
return configSelector;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue