Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2010-05-11 16:12:26 +0000
committerAlena Laskavaia2010-05-11 16:12:26 +0000
commit204093e764f955c62ec1b5b5f9f8af7f81214b22 (patch)
tree13c62533b22e2f22a8040e0cd65b207f091f3867 /launch/org.eclipse.cdt.launch
parentc57fd263bd4b4dd1e89334fc4d7e342fec420852 (diff)
downloadorg.eclipse.cdt-204093e764f955c62ec1b5b5f9f8af7f81214b22.tar.gz
org.eclipse.cdt-204093e764f955c62ec1b5b5f9f8af7f81214b22.tar.xz
org.eclipse.cdt-204093e764f955c62ec1b5b5f9f8af7f81214b22.zip
Bug 312427 Launch groups should have better validation/filtering of referenced launch configuration (patch from Teodor Madan)
Diffstat (limited to 'launch/org.eclipse.cdt.launch')
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/MultiLaunchConfigurationDelegate.java10
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties3
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationSelectionDialog.java2
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationTabGroup.java40
4 files changed, 53 insertions, 2 deletions
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/MultiLaunchConfigurationDelegate.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/MultiLaunchConfigurationDelegate.java
index 87a7522d15..e57cce938d 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/MultiLaunchConfigurationDelegate.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/MultiLaunchConfigurationDelegate.java
@@ -44,6 +44,7 @@ import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
/**
* Group Launch delegate. Launches each configuration in the user selected mode
@@ -571,4 +572,13 @@ public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegat
public static String getProp(int index, String string) {
return MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX + "." + index + "." + string; //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ /**
+ * Test if a launch configuration is a valid reference.
+ * @param config configuration reference
+ * @return <code>true</code> if it is a valid reference, <code>false</code> if launch configuration should be filtered
+ */
+ public static boolean isValidLaunchReference(ILaunchConfiguration config) {
+ return DebugUIPlugin.doLaunchConfigurationFiltering( config) && !WorkbenchActivityHelper.filterItem(config);
+ }
}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
index 1b1e7cb817..c9b1b62b42 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LaunchMessages.properties
@@ -194,5 +194,8 @@ MultiLaunchConfigurationTabGroup.10=Launches
MultiLaunchConfigurationTabGroup.11=seconds
MultiLaunchConfigurationTabGroup.12=Action
MultiLaunchConfigurationTabGroup.13=Delay {0} seconds
+MultiLaunchConfigurationTabGroup.14=Launch {0} does not exist.
+MultiLaunchConfigurationTabGroup.15=Launch {0} is filtered.
+MultiLaunchConfigurationTabGroup.16=Must have at least one valid enabled launch.
ProjectRenameChange.name=Update launch configuration "{0}"
ProjectRenameChange.saveFailed=Failed to save updated launch configuration "{0}"
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationSelectionDialog.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationSelectionDialog.java
index 8934df80ac..0d82bac128 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationSelectionDialog.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationSelectionDialog.java
@@ -97,6 +97,8 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
} catch (CoreException e) {
return false;
}
+ } else if (element instanceof ILaunchConfiguration) {
+ return MultiLaunchConfigurationDelegate.isValidLaunchReference((ILaunchConfiguration) element);
}
return true;
}
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationTabGroup.java
index 73377c5574..9538bae8ac 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/MultiLaunchConfigurationTabGroup.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.launch.internal.ui;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -94,7 +95,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
return null;
if (columnIndex == 0) {
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
- if (el.data == null) {
+ if (el.data == null || !MultiLaunchConfigurationDelegate.isValidLaunchReference(el.data)) {
Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
return errorImage;
}
@@ -314,7 +315,9 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
MultiLaunchConfigurationSelectionDialog dialog =
MultiLaunchConfigurationSelectionDialog.createDialog(
treeViewer.getControl().getShell(), el.mode, true);
- dialog.setInitialSelection(el);
+ if (MultiLaunchConfigurationDelegate.isValidLaunchReference(el.data)) {
+ dialog.setInitialSelection(el);
+ }
if (dialog.open() == Dialog.OK) {
ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations();
if (confs.length < 0)
@@ -457,6 +460,39 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
// defaults is empty list
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ setMessage(null);
+ setErrorMessage(null);
+ int validLaunches = 0;
+ // test if each launch is valid
+ for (LaunchElement element : input) {
+ if (element.enabled) {
+ if ( element.data == null) {
+ // error referencing invalid launch
+ setErrorMessage(MessageFormat.format(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.14"), //$NON-NLS-1$
+ element.name));
+ return false;
+ } else if (!MultiLaunchConfigurationDelegate.isValidLaunchReference(element.data)) {
+ // error referencing invalid launch
+ setErrorMessage(MessageFormat.format(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.15"), //$NON-NLS-1$
+ element.name));
+ return false;
+ }
+ validLaunches++;
+ }
+ }
+ if (validLaunches < 1) {
+ // must have at least one valid and enabled launch
+ setErrorMessage(LaunchMessages.getString("MultiLaunchConfigurationTabGroup.16")); //$NON-NLS-1$
+ return false;
+ }
+ return true;
+ }
}
public MultiLaunchConfigurationTabGroup() {

Back to the top