Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java147
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java11
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java50
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java30
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java66
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties42
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java159
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java129
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java128
11 files changed, 786 insertions, 21 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java
new file mode 100644
index 000000000..d817072d6
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Creates a new launch configuration prototype based on the selection.
+ *
+ * @since 3.13
+ */
+public class CreateLaunchConfigurationPrototypeAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_CREATE_PROTOTYPE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_CREATE_PROTOTYPE_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to create a launch configuration prototype
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public CreateLaunchConfigurationPrototypeAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.CreateLaunchConfigurationPrototypeAction_Ne_w_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ Object object = getStructuredSelection().getFirstElement();
+ // double click with Ctrl key mask results in empty selection: bug
+ // 156087 do no work if the selection is null
+ if (object != null) {
+ ILaunchConfigurationType type = null;
+ // Construct a new configuration prototype of the selected type
+ if (object instanceof ILaunchConfiguration) {
+ ILaunchConfiguration config = (ILaunchConfiguration) object;
+ try {
+ type = config.getType();
+ } catch (CoreException e) {
+ errorDialog(e);
+ return;
+ }
+ } else {
+ type = (ILaunchConfigurationType) object;
+ }
+ try {
+ ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(null, DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(LaunchConfigurationsMessages.CreateLaunchConfigurationPrototypeAction_New_prototype_2));
+ ILaunchConfigurationTabGroup tabGroup = LaunchConfigurationPresentationManager.getDefault().getTabGroup(wc, getMode());
+ // this only works because this action is only present when the
+ // dialog is open
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ tabGroup.createTabs(dialog, dialog.getMode());
+ ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
+ for (int i = 0; i < tabs.length; i++) {
+ tabs[i].setLaunchConfigurationDialog(dialog);
+ }
+ tabGroup.setDefaults(wc);
+ tabGroup.dispose();
+ wc.doSave();
+ } catch (CoreException e) {
+ errorDialog(e);
+ return;
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if (selection.size() == 1) {
+ Object object = getStructuredSelection().getFirstElement();
+ if (object != null) {
+ ILaunchConfigurationType type = null;
+ // Construct a new configuration prototype of the selected type
+ if (object instanceof ILaunchConfiguration) {
+ ILaunchConfiguration config = (ILaunchConfiguration) object;
+ try {
+ type = config.getType();
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ } else {
+ type = (ILaunchConfigurationType) object;
+ }
+ if (type != null) {
+ return type.supportsPrototypes();
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_NEW_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_NEW_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_2;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java
index 0c1eebba3..9f1ebac3f 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeleteLaunchConfigurationAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -70,7 +71,7 @@ public class DeleteLaunchConfigurationAction extends AbstractLaunchConfiguration
while (iterator.hasNext()) {
ILaunchConfiguration configuration = (ILaunchConfiguration)iterator.next();
try {
- configuration.delete();
+ configuration.delete(ILaunchConfiguration.UPDATE_PROTOTYPE_CHILDREN);
} catch (CoreException e) {
errorDialog(e);
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java
index f3ba24630..2a02359e6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java
@@ -10,6 +10,7 @@
* Mohamed Hussein (Mentor Graphics) - Added getWarningMessage (Bug 386673)
* Robert Roth - Used consistent apply button location (Bug 432832)
* Lucas Bullen (Red Hat Inc.) - Added export configuration message (Bug 518652)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -347,11 +348,15 @@ public class LaunchConfigurationTabGroupViewer {
int width = parent.getBounds().width - 30;
SWTFactory.createWrapLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1, 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_PROTO), 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_7, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_EXPORT_CONFIG), 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), 1, width);
SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), 1, width);
- SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width);
- SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_10, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_LINK_PROTO), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_11, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_UNLINK_PROTO), 1, width);
+ SWTFactory.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_12, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_RESET_PROTO), 1, width);
SWTFactory.createHorizontalSpacer(parent, 2);
Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
@@ -1511,7 +1516,7 @@ public class LaunchConfigurationTabGroupViewer {
getLaunchConfigurationDialog().run(true, false, runnable);
}
else {
- saved[0] = fWorkingCopy.doSave();
+ saved[0] = fWorkingCopy.doSave(ILaunchConfiguration.UPDATE_PROTOTYPE_CHILDREN);
}
}
updateButtons();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java
index 14a06251d..2f655af3c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@vogella.com> - Bug 490755
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -74,17 +75,30 @@ public class LaunchConfigurationTreeContentProvider implements ITreeContentProvi
*/
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof ILaunchConfiguration) {
- return EMPTY_ARRAY;
- } else if (parentElement instanceof ILaunchConfigurationType) {
- try {
- ILaunchConfigurationType type = (ILaunchConfigurationType)parentElement;
- return getLaunchManager().getLaunchConfigurations(type);
- } catch (CoreException e) {
- DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
+ try {
+ if (parentElement instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) parentElement).isPrototype()) {
+ return ((ILaunchConfiguration) parentElement).getPrototypeChildren().toArray();
+ }
+ } else if (parentElement instanceof ILaunchConfigurationType) {
+ List<ILaunchConfiguration> configs = new ArrayList<>();
+ ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement;
+ ILaunchConfiguration[] launchConfigurations = getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION);
+ for (ILaunchConfiguration launchConfig : launchConfigurations) {
+ if (launchConfig.getPrototype() == null) {
+ configs.add(launchConfig);
+ }
+ }
+ ILaunchConfiguration[] prototypes = getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.PROTOTYPE);
+ for (ILaunchConfiguration prototype : prototypes) {
+ configs.add(prototype);
+ }
+ return configs.toArray(new ILaunchConfiguration[0]);
+ } else {
+ return getLaunchManager().getLaunchConfigurationTypes();
}
- } else {
- return getLaunchManager().getLaunchConfigurationTypes();
+ } catch (CoreException e) {
+ DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
}
return EMPTY_ARRAY;
}
@@ -99,7 +113,12 @@ public class LaunchConfigurationTreeContentProvider implements ITreeContentProvi
return null;
}
try {
- return ((ILaunchConfiguration)element).getType();
+ ILaunchConfiguration prototype = ((ILaunchConfiguration) element).getPrototype();
+ if (prototype != null) {
+ return prototype;
+ } else {
+ return ((ILaunchConfiguration) element).getType();
+ }
} catch (CoreException e) {
DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
}
@@ -115,6 +134,13 @@ public class LaunchConfigurationTreeContentProvider implements ITreeContentProvi
@Override
public boolean hasChildren(Object element) {
if (element instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) element).isPrototype()) {
+ try {
+ return ((ILaunchConfiguration) element).getPrototypeChildren().size() > 0;
+ } catch (CoreException e) {
+ DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20, e); //
+ }
+ }
return false;
}
return getChildren(element).length > 0;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
index 73f7087c1..ab40eec23 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Ian Pun (Red Hat Inc.) - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -76,10 +77,14 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
* Actions
*/
private CreateLaunchConfigurationAction fCreateAction;
+ private CreateLaunchConfigurationPrototypeAction fCreatePrototypeAction;
private DeleteLaunchConfigurationAction fDeleteAction;
private DuplicateLaunchConfigurationAction fDuplicateAction;
private ExportLaunchConfigurationAction fExportAction;
private CollapseAllLaunchConfigurationAction fCollapseAllAction;
+ private LinkPrototypeAction fLinkPrototypeAction;
+ private UnlinkPrototypeAction fUnlinkPrototypeAction;
+ private ResetWithPrototypeValuesAction fResetWithPrototypeValuesAction;
/**
* Action for providing filtering to the Launch Configuration Dialog
@@ -196,6 +201,9 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
fCreateAction = new CreateLaunchConfigurationAction(getViewer(), getLaunchGroup().getMode());
setAction(CreateLaunchConfigurationAction.ID_CREATE_ACTION, fCreateAction);
+ fCreatePrototypeAction = new CreateLaunchConfigurationPrototypeAction(getViewer(), getLaunchGroup().getMode());
+ setAction(CreateLaunchConfigurationPrototypeAction.ID_CREATE_PROTOTYPE_ACTION, fCreatePrototypeAction);
+
fDeleteAction = new DeleteLaunchConfigurationAction(getViewer(), getLaunchGroup().getMode());
setAction(DeleteLaunchConfigurationAction.ID_DELETE_ACTION, fDeleteAction);
setAction(IDebugView.REMOVE_ACTION, fDeleteAction);
@@ -212,6 +220,14 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
fFilterAction = new FilterLaunchConfigurationAction();
setAction(FilterLaunchConfigurationAction.ID_FILTER_ACTION, fFilterAction);
+ fLinkPrototypeAction = new LinkPrototypeAction(getViewer(), getLaunchGroup().getMode());
+ setAction(LinkPrototypeAction.ID_LINK_PROTOTYPE_ACTION, fLinkPrototypeAction);
+
+ fUnlinkPrototypeAction = new UnlinkPrototypeAction(getViewer(), getLaunchGroup().getMode());
+ setAction(UnlinkPrototypeAction.ID_UNLINK_PROTOTYPE_ACTION, fUnlinkPrototypeAction);
+
+ fResetWithPrototypeValuesAction = new ResetWithPrototypeValuesAction(getViewer(), getLaunchGroup().getMode());
+ setAction(ResetWithPrototypeValuesAction.ID_RESET_WITH_PROTOTYPE_VALUES_ACTION, fResetWithPrototypeValuesAction);
}
/**
@@ -228,10 +244,14 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
@Override
protected void fillContextMenu(IMenuManager menu) {
menu.add(fCreateAction);
+ menu.add(fCreatePrototypeAction);
menu.add(fExportAction);
menu.add(fDuplicateAction);
menu.add(fDeleteAction);
menu.add(new Separator());
+ menu.add(fLinkPrototypeAction);
+ menu.add(fUnlinkPrototypeAction);
+ menu.add(fResetWithPrototypeValuesAction);
}
/**
@@ -255,11 +275,15 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
@Override
public void dispose() {
fCreateAction.dispose();
+ fCreatePrototypeAction.dispose();
fDeleteAction.dispose();
fDuplicateAction.dispose();
fExportAction.dispose();
fFilterAction = null;
fCollapseAllAction = null;
+ fLinkPrototypeAction.dispose();
+ fUnlinkPrototypeAction.dispose();
+ fResetWithPrototypeValuesAction.dispose();
getLaunchManager().removeLaunchConfigurationListener(this);
}
@@ -295,7 +319,11 @@ public class LaunchConfigurationView extends AbstractDebugView implements ILaunc
if (viewer != null) {
try {
viewer.getControl().setRedraw(false);
- viewer.add(configuration.getType(), configuration);
+ if (configuration.getPrototype() != null) {
+ viewer.add(configuration.getPrototype(), configuration);
+ } else {
+ viewer.add(configuration.getType(), configuration);
+ }
// if moved, remove original now
if (from != null) {
viewer.remove(from);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
index 3d3a9d78a..e889e8d76 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Sebastian Davids - Bug 137923
* Mohamed Hussein (Mentor Graphics) - Added s/getWarningMessage (Bug 386673)
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -516,6 +517,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
protected void createToolbarActions(ToolBarManager tmanager) {
tmanager.add(getNewAction());
+ tmanager.add(getNewPrototypeAction());
tmanager.add(getExportAction());
tmanager.add(getDuplicateAction());
tmanager.add(getDeleteAction());
@@ -617,14 +619,22 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
getDuplicateAction().setConfirmationRequestor(requestor);
getExportAction().setConfirmationRequestor(requestor);
getNewAction().setConfirmationRequestor(requestor);
+ getNewPrototypeAction().setConfirmationRequestor(requestor);
+ getLinkPrototypeAction().setConfirmationRequestor(requestor);
+ getUnlinkPrototypeAction().setConfirmationRequestor(requestor);
+ getResetWithPrototypeValuesAction().setConfirmationRequestor(requestor);
((StructuredViewer) viewer).addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleLaunchConfigurationSelectionChanged(event);
getNewAction().setEnabled(getNewAction().isEnabled());
+ getNewPrototypeAction().setEnabled(getNewPrototypeAction().isEnabled());
getDeleteAction().setEnabled(getDeleteAction().isEnabled());
getExportAction().setEnabled(getExportAction().isEnabled());
getDuplicateAction().setEnabled(getDuplicateAction().isEnabled());
+ getLinkPrototypeAction().setEnabled(getLinkPrototypeAction().isEnabled());
+ getUnlinkPrototypeAction().setEnabled(getUnlinkPrototypeAction().isEnabled());
+ getResetWithPrototypeValuesAction().setEnabled(getResetWithPrototypeValuesAction().isEnabled());
}
});
return comp;
@@ -875,6 +885,50 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
/**
+ * Gets the new prototype menu action
+ *
+ * @return the new prototype menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getNewPrototypeAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(CreateLaunchConfigurationPrototypeAction.ID_CREATE_PROTOTYPE_ACTION);
+ }
+
+ /**
+ * Gets the link prototype menu action
+ *
+ * @return the link prototype menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getLinkPrototypeAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(LinkPrototypeAction.ID_LINK_PROTOTYPE_ACTION);
+ }
+
+ /**
+ * Gets the unlink prototype menu action
+ *
+ * @return the unlink prototype menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getUnlinkPrototypeAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(UnlinkPrototypeAction.ID_UNLINK_PROTOTYPE_ACTION);
+ }
+
+ /**
+ * Gets the reset with prototype values menu action
+ *
+ * @return the reset with prototype values menu action
+ *
+ * @since 3.13
+ */
+ protected AbstractLaunchConfigurationAction getResetWithPrototypeValuesAction() {
+ return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(ResetWithPrototypeValuesAction.ID_RESET_WITH_PROTOTYPE_VALUES_ACTION);
+ }
+
+ /**
* Returns the reserved name set (if there is one), <code>null</code> otherwise
* @return the reserved name set or <code>null</code>
* @since 3.3
@@ -1312,6 +1366,15 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
/**
+ * Refresh the launch configurations' tree viewer
+ *
+ * @since 3.13
+ */
+ protected void refreshLaunchConfigurationView() {
+ fLaunchConfigurationView.getTreeViewer().refresh();
+ }
+
+ /**
* resize the dialog to show all relevant content
*/
protected void resize() {
@@ -1604,6 +1667,9 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
getExportAction().setEnabled(getExportAction().isEnabled());
getDeleteAction().setEnabled(getDeleteAction().isEnabled());
getDuplicateAction().setEnabled(getDuplicateAction().isEnabled());
+ getLinkPrototypeAction().setEnabled(getLinkPrototypeAction().isEnabled());
+ getUnlinkPrototypeAction().setEnabled(getUnlinkPrototypeAction().isEnabled());
+ getResetWithPrototypeValuesAction().setEnabled(getResetWithPrototypeValuesAction().isEnabled());
fTabViewer.refresh();
getButton(ID_LAUNCH_BUTTON).setEnabled(fTabViewer.canLaunch() & fTabViewer.canLaunchWithModes() & !fTabViewer.hasDuplicateDelegates());
} else {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
index eacb87f84..8bbe5942a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
* Ian Pun & Lucas Bullen (Red Hat Inc.) - Bug 518652
+ * Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
*******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;
@@ -49,6 +50,15 @@ public class LaunchConfigurationsMessages extends NLS {
public static String CommonTab_8;
public static String CommonTab_9;
+ public static String CommonTab_AttributeLabel_ConsoleEncoding;
+ public static String CommonTab_AttributeLabel_CaptureOutput;
+ public static String CommonTab_AttributeLabel_CaptureInConsole;
+ public static String CommonTab_AttributeLabel_CaptureStdInFile;
+ public static String CommonTab_AttributeLabel_CaptureInFile;
+ public static String CommonTab_AttributeLabel_AppendToFile;
+ public static String CommonTab_AttributeLabel_LaunchInBackground;
+ public static String CommonTab_AttributeLabel_FavoriteGroups;
+
public static String CompileErrorProjectPromptStatusHandler_0;
public static String CompileErrorProjectPromptStatusHandler_1;
public static String CompileErrorPromptStatusHandler_0;
@@ -140,6 +150,11 @@ public class LaunchConfigurationsMessages extends NLS {
public static String CreateLaunchConfigurationAction_Ne_w_1;
public static String ExportLaunchConfigurationAction_Export_1;
public static String CreateLaunchConfigurationAction_New_configuration_2;
+ public static String CreateLaunchConfigurationPrototypeAction_Ne_w_1;
+ public static String CreateLaunchConfigurationPrototypeAction_New_prototype_2;
+ public static String LinkPrototypeAction_Link_prototype_1;
+ public static String UnlinkPrototypeAction_Unlink_prototype_1;
+ public static String ResetWithPrototypeValuesAction_Reset_with_prototype_values_1;
public static String EnvironmentTab_Variable_1;
public static String EnvironmentTab_Value_2;
@@ -158,6 +173,21 @@ public class LaunchConfigurationsMessages extends NLS {
public static String EnvironmentTab_18;
public static String EnvironmentTab_19;
public static String EnvironmentTab_20;
+ public static String EnvironmentTab_AttributeLabel_AppendEnvironmentVariables;
+ public static String EnvironmentTab_AttributeLabel_EnvironmentVariables;
+
+ public static String PrototypeTab_Prototype_1;
+ public static String PrototypeTab_Label_2;
+ public static String PrototypeTab_Link_Button_Label_3;
+ public static String PrototypeTab_Unlink_Button_Label_4;
+ public static String PrototypeTab_Select_Message_5;
+ public static String PrototypeTab_Select_Empty_Message_6;
+ public static String PrototypeTab_Select_Prototype_Error_7;
+ public static String PrototypeTab_Reset_Button_Label_8;
+ public static String PrototypeTab_Reset_Menu_Action_9;
+ public static String PrototypeTab_Explanation_Label_10;
+ public static String PrototypeTab_Explanation_Label_11;
+ public static String PrototypeTab_Explanation_Label_12;
public static String FavoritesDialog_1;
public static String FavoritesDialog_2;
@@ -189,7 +219,11 @@ public class LaunchConfigurationsMessages extends NLS {
public static String LaunchConfigurationTabGroupViewer_3;
public static String LaunchConfigurationTabGroupViewer_4;
public static String LaunchConfigurationTabGroupViewer_5;
- public static String LaunchConfigurationTabGroupViewer_6;
+ public static String LaunchConfigurationTabGroupViewer_6;
+ public static String LaunchConfigurationTabGroupViewer_9;
+ public static String LaunchConfigurationTabGroupViewer_10;
+ public static String LaunchConfigurationTabGroupViewer_11;
+ public static String LaunchConfigurationTabGroupViewer_12;
public static String LaunchConfigurationTabGroupViewer_7;
public static String SaveScopeResourcesHandler_1;
@@ -200,9 +234,13 @@ public class LaunchConfigurationsMessages extends NLS {
public static String LaunchConfigurationsDialog_0;
public static String LaunchConfigurationsDialog_1;
+ public static String LaunchConfigurationsDialog_2;
public static String LaunchConfigurationsDialog_4;
public static String LaunchConfigurationsDialog_5;
public static String LaunchConfigurationsDialog_6;
+ public static String LaunchConfigurationsDialog_7;
+ public static String LaunchConfigurationsDialog_8;
+ public static String LaunchConfigurationsDialog_9;
public static String FilterLaunchConfigurationAction_0;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
index 72d08e819..c7451e5d9 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
# Ian Pun & Lucas Bullen (Red Hat Inc.) - Bug 518652
+# Axel Richard (Obeo) - Bug 41353 - Launch configurations prototypes
###############################################################################
CommonTab__Browse_6=&Browse...
@@ -41,6 +42,14 @@ CommonTab_6=Output Fi&le:
CommonTab_7=File &System...
CommonTab_8=No file specified for process output
CommonTab_9=Variables...
+CommonTab_AttributeLabel_ConsoleEncoding=Console encoding
+CommonTab_AttributeLabel_CaptureOutput=Capture output
+CommonTab_AttributeLabel_CaptureInConsole=Capture in console
+CommonTab_AttributeLabel_CaptureStdInFile=Capture standard input file
+CommonTab_AttributeLabel_CaptureInFile=Capture in file
+CommonTab_AttributeLabel_AppendToFile=Append to file
+CommonTab_AttributeLabel_LaunchInBackground=Launch in background
+CommonTab_AttributeLabel_FavoriteGroups=Favorite groups
CompileErrorPromptStatusHandler_0=Errors in Workspace
CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch?
@@ -56,13 +65,17 @@ LaunchConfigurationDialog__Name__16=&Name:
LaunchConfigurationDialog_An_exception_occurred_while_retrieving_launch_configurations_20=An exception occurred while retrieving launch configurations
LaunchConfigurationTabGroupViewer_1=Configure launch settings from this dialog:
-LaunchConfigurationTabGroupViewer_2=- Press the 'New' button to create a configuration of the selected type.
+LaunchConfigurationTabGroupViewer_2=- Press the 'New configuration' button to create a configuration of the selected type.
LaunchConfigurationTabGroupViewer_3=- Edit or view an existing configuration by selecting it.
LaunchConfigurationTabGroupViewer_4=- Press the 'Delete' button to remove the selected configuration.
LaunchConfigurationTabGroupViewer_6=- Press the 'Duplicate' button to copy the selected configuration.
LaunchConfigurationTabGroupViewer_5=Configure launch perspective settings from the <a>'Perspectives'</a> preference page.
LaunchConfigurationTabGroupViewer_7=- Press the 'Export' button to export the selected configurations.
LaunchConfigurationTabGroupViewer_8=- Press the 'Filter' button to configure filtering options.
+LaunchConfigurationTabGroupViewer_9=- Press the 'New prototype' button to create a launch configuration prototype of the selected type.
+LaunchConfigurationTabGroupViewer_10=- Select launch configuration(s) and then select 'Link prototype' menu item to link a prototype.
+LaunchConfigurationTabGroupViewer_11=- Select launch configuration(s) and then select 'Unlink prototype' menu item to unlink a prototype.
+LaunchConfigurationTabGroupViewer_12=- Select launch configuration(s) and then select 'Reset with prototype values' menu item to reset with prototype values.
LaunchConfigurationTabGroupViewer_13=Select a supported <a>launch mode</a>.
LaunchConfigurationTabGroupViewer_14=This configuration does not support some of the launch modes: {0}
LaunchConfigurationTabGroupViewer_15=More than one launcher available - <a>Select other...</a>
@@ -104,9 +117,13 @@ LaunchConfigurationsDialog_Warning_2=Warning
LaunchConfigurationsDialog_Information_3=Information
LaunchConfigurationsDialog_0=New launch configuration
LaunchConfigurationsDialog_1=Delete selected launch configuration(s)
+LaunchConfigurationsDialog_2=New launch configuration prototype
LaunchConfigurationsDialog_4=Filter launch configurations...
LaunchConfigurationsDialog_5=Duplicates the currently selected launch configuration
LaunchConfigurationsDialog_6=Export launch configuration
+LaunchConfigurationsDialog_7=Link prototype
+LaunchConfigurationsDialog_8=Unlink prototype
+LaunchConfigurationsDialog_9=Reset with prototype values
LaunchConfigurationSelectionDialog_0=Select Configuration
LaunchConfigurationSelectionDialog_1=&Select a configuration to launch:
LaunchConfigurationView_0=Filter matched {0} of {1} items
@@ -150,9 +167,14 @@ DuplicateLaunchConfigurationAction__Duplicate_1=&Duplicate
DeleteLaunchConfigurationAction_Dele_te_1=Dele&te
-CreateLaunchConfigurationAction_Ne_w_1=Ne&w
+CreateLaunchConfigurationAction_Ne_w_1=Ne&w configuration
ExportLaunchConfigurationAction_Export_1=E&xport
CreateLaunchConfigurationAction_New_configuration_2=New_configuration
+CreateLaunchConfigurationPrototypeAction_Ne_w_1=New &prototype
+CreateLaunchConfigurationPrototypeAction_New_prototype_2=New_prototype
+LinkPrototypeAction_Link_prototype_1=&Link prototype
+UnlinkPrototypeAction_Unlink_prototype_1=&Unlink prototype
+ResetWithPrototypeValuesAction_Reset_with_prototype_values_1=&Reset with prototype values
EnvironmentTab_Variable_1=Variable
EnvironmentTab_Value_2=Value
@@ -177,6 +199,22 @@ EnvironmentTab_17=Re&place native environment with specified environment
EnvironmentTab_18=Se&lect...
EnvironmentTab_19=Select &environment variables to add:
EnvironmentTab_20=Select Environment Variables
+EnvironmentTab_AttributeLabel_AppendEnvironmentVariables=Append environment to native environment
+EnvironmentTab_AttributeLabel_EnvironmentVariables=Environment variables
+
+#PrototypeTab
+PrototypeTab_Prototype_1=Prototype
+PrototypeTab_Label_2=Prototype:
+PrototypeTab_Link_Button_Label_3=Link...
+PrototypeTab_Unlink_Button_Label_4=Unlink
+PrototypeTab_Select_Message_5=Please select a prototype
+PrototypeTab_Select_Empty_Message_6=You have to select a prototype
+PrototypeTab_Select_Prototype_Error_7=The prototype doesn't exists. Please select a valid prototype.
+PrototypeTab_Reset_Button_Label_8=Reset
+PrototypeTab_Reset_Menu_Action_9=Reset selected checked attribute(s) with prototype value(s)
+PrototypeTab_Explanation_Label_10=- Values of checked attributes from prototype are applied on associated launch configurations.
+PrototypeTab_Explanation_Label_11=- Values of unchecked attributes from prototype are not applied on associated launch configurations.
+PrototypeTab_Explanation_Label_12=- Grayed state attributes have different values in the launch configuration and the associated prototype.
FavoritesDialog_1=Organize {0} Favorites
FavoritesDialog_2=Fa&vorites:
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java
new file mode 100644
index 000000000..a1b28b72d
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LinkPrototypeAction.java
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * Link attributes from a prototype to the selected launch configuration(s).
+ *
+ * @since 3.13
+ */
+public class LinkPrototypeAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_LINK_PROTOTYPE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_LINK_PROTOTYPE_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to apply a prototype to a launch configuration
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public LinkPrototypeAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.LinkPrototypeAction_Link_prototype_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ try {
+ ILaunchConfiguration firstLaunchConfiguration = (ILaunchConfiguration) getStructuredSelection().getFirstElement();
+ ILaunchConfigurationType type = firstLaunchConfiguration.getType();
+ ILaunchConfiguration[] prototypes = type.getPrototypes();
+ // Select the prototype
+ DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(DebugUITools.newDebugModelPresentation(), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
+ ElementListSelectionDialog selectPrototypeDialog = new ElementListSelectionDialog(getShell(), labelProvider);
+ selectPrototypeDialog.setElements(prototypes);
+ selectPrototypeDialog.setMultipleSelection(false);
+ selectPrototypeDialog.setEmptySelectionMessage("You have to select a prototype."); //$NON-NLS-1$
+ selectPrototypeDialog.setTitle("Please select a prototype"); //$NON-NLS-1$
+ int open = selectPrototypeDialog.open();
+ if (open == Window.OK) {
+ Object selectedPrototype = selectPrototypeDialog.getFirstResult();
+ for (Object launchConfiguration : getStructuredSelection().toList()) {
+ if (launchConfiguration instanceof ILaunchConfiguration) {
+ // Link the prototype attributes to the selected launch
+ // configuration
+ ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfiguration) launchConfiguration).getWorkingCopy();
+ workingCopy.setPrototype((ILaunchConfiguration) selectedPrototype, true);
+ workingCopy.doSave();
+ // if only one configuration is selected, refresh the
+ // tabs to display visible attributes values from the
+ // prototype
+ if (getStructuredSelection().size() == 1) {
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ if (dialog instanceof LaunchConfigurationsDialog) {
+ ((LaunchConfigurationsDialog) dialog).getTabViewer().setInput(workingCopy);
+ }
+ }
+ }
+ }
+ getViewer().refresh();
+ }
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ // Enable action only if launch configuration(s) of the same type
+ // is(are) selected and the launch configuration type allows prototypes
+ Collection<ILaunchConfigurationType> launchConfigurationTypes = new HashSet<>();
+ for (Object object : selection.toList()) {
+ if (object instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) object).isPrototype()) {
+ return false;
+ } else {
+ ILaunchConfigurationType type = null;
+ try {
+ type = ((ILaunchConfiguration) object).getType();
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ if (type != null) {
+ launchConfigurationTypes.add(type);
+ } else {
+ return false;
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ if (launchConfigurationTypes.size() == 1) {
+ return launchConfigurationTypes.iterator().next().supportsPrototypes();
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_LINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_LINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_7;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java
new file mode 100644
index 000000000..944182212
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ResetWithPrototypeValuesAction.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Reset selected launch configuration(s) attributes with values from associated
+ * prototype(s).
+ *
+ * @since 3.13
+ */
+public class ResetWithPrototypeValuesAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_RESET_WITH_PROTOTYPE_VALUES_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_RESET_WITH_PROTOTYPE_VALUES_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to reset a launch configuration with prototype
+ * values
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public ResetWithPrototypeValuesAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.ResetWithPrototypeValuesAction_Reset_with_prototype_values_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ try {
+ for (Object launchConfiguration : getStructuredSelection().toList()) {
+ if (launchConfiguration instanceof ILaunchConfiguration) {
+ ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfiguration) launchConfiguration).getWorkingCopy();
+ workingCopy.setPrototype(((ILaunchConfiguration) launchConfiguration).getPrototype(), true);
+ workingCopy.doSave();
+ // if only one configuration is selected, refresh the
+ // tabs to display visible attributes values from the
+ // prototype
+ if (getStructuredSelection().size() == 1) {
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ if (dialog instanceof LaunchConfigurationsDialog) {
+ ((LaunchConfigurationsDialog) dialog).getTabViewer().setInput(workingCopy);
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean onlyLaunchConfigurationWithPrototypeSelected = false;
+ for (Object object : selection.toList()) {
+ if (object instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) object).isPrototype()) {
+ return false;
+ } else {
+ try {
+ if (((ILaunchConfiguration) object).getPrototype() != null) {
+ onlyLaunchConfigurationWithPrototypeSelected = true;
+ } else {
+ return false;
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ return onlyLaunchConfigurationWithPrototypeSelected;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RESET_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RESET_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_9;
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java
new file mode 100644
index 000000000..f1cbc5d50
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/UnlinkPrototypeAction.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.launchConfigurations;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Unlink prototype to the selected launch configuration(s).
+ *
+ * @since 3.13
+ */
+public class UnlinkPrototypeAction extends AbstractLaunchConfigurationAction {
+
+ /**
+ * Action identifier for IDebugView#getAction(String)
+ */
+ public static final String ID_UNLINK_PROTOTYPE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_UNLINK_PROTOTYPE_ACTION"; //$NON-NLS-1$
+
+ /**
+ * Constructs an action to unlink a prototype to a launch configuration
+ *
+ * @param viewer the viewer
+ * @param mode the mode the action applies to
+ */
+ public UnlinkPrototypeAction(Viewer viewer, String mode) {
+ super(LaunchConfigurationsMessages.UnlinkPrototypeAction_Unlink_prototype_1, viewer, mode);
+ }
+
+ /**
+ * @see AbstractLaunchConfigurationAction#performAction()
+ */
+ @Override
+ protected void performAction() {
+ try {
+ for (Object launchConfiguration : getStructuredSelection().toList()) {
+ if (launchConfiguration instanceof ILaunchConfiguration) {
+ ILaunchConfigurationWorkingCopy workingCopy = ((ILaunchConfiguration) launchConfiguration).getWorkingCopy();
+ workingCopy.setPrototype(null, false);
+ workingCopy.doSave();
+ // if only one configuration is selected, refresh the
+ // tabs to display visible attributes values from the
+ // prototype
+ if (getStructuredSelection().size() == 1) {
+ ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
+ if (dialog instanceof LaunchConfigurationsDialog) {
+ ((LaunchConfigurationsDialog) dialog).getTabViewer().setInput(workingCopy);
+ }
+ }
+ }
+ }
+ getViewer().refresh();
+ } catch (CoreException e) {
+ errorDialog(e);
+ }
+ }
+
+ /**
+ * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ boolean onlyLaunchConfigurationWithPrototypeSelected = false;
+ for (Object object : selection.toList()) {
+ if (object instanceof ILaunchConfiguration) {
+ if (((ILaunchConfiguration) object).isPrototype()) {
+ return false;
+ } else {
+ try {
+ if (((ILaunchConfiguration) object).getPrototype() != null) {
+ onlyLaunchConfigurationWithPrototypeSelected = true;
+ } else {
+ return false;
+ }
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e.getStatus());
+ }
+ }
+ } else {
+ return false;
+ }
+ }
+ return onlyLaunchConfigurationWithPrototypeSelected;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getDisabledImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_UNLINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_UNLINK_PROTO);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return LaunchConfigurationsMessages.LaunchConfigurationsDialog_8;
+ }
+}

Back to the top