mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Bug 312427 Launch groups should have better validation/filtering of referenced launch configuration (patch from Teodor Madan)
This commit is contained in:
parent
c57fd263bd
commit
204093e764
4 changed files with 53 additions and 2 deletions
|
@ -44,6 +44,7 @@ import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.activities.WorkbenchActivityHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group Launch delegate. Launches each configuration in the user selected mode
|
* 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) {
|
public static String getProp(int index, String string) {
|
||||||
return MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX + "." + index + "." + string; //$NON-NLS-1$ //$NON-NLS-2$
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,5 +194,8 @@ MultiLaunchConfigurationTabGroup.10=Launches
|
||||||
MultiLaunchConfigurationTabGroup.11=seconds
|
MultiLaunchConfigurationTabGroup.11=seconds
|
||||||
MultiLaunchConfigurationTabGroup.12=Action
|
MultiLaunchConfigurationTabGroup.12=Action
|
||||||
MultiLaunchConfigurationTabGroup.13=Delay {0} seconds
|
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.name=Update launch configuration "{0}"
|
||||||
ProjectRenameChange.saveFailed=Failed to save updated launch configuration "{0}"
|
ProjectRenameChange.saveFailed=Failed to save updated launch configuration "{0}"
|
||||||
|
|
|
@ -97,6 +97,8 @@ public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog imp
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if (element instanceof ILaunchConfiguration) {
|
||||||
|
return MultiLaunchConfigurationDelegate.isValidLaunchReference((ILaunchConfiguration) element);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.launch.internal.ui;
|
package org.eclipse.cdt.launch.internal.ui;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -94,7 +95,7 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
return null;
|
return null;
|
||||||
if (columnIndex == 0) {
|
if (columnIndex == 0) {
|
||||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
|
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);
|
Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
|
||||||
return errorImage;
|
return errorImage;
|
||||||
}
|
}
|
||||||
|
@ -314,7 +315,9 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
MultiLaunchConfigurationSelectionDialog dialog =
|
MultiLaunchConfigurationSelectionDialog dialog =
|
||||||
MultiLaunchConfigurationSelectionDialog.createDialog(
|
MultiLaunchConfigurationSelectionDialog.createDialog(
|
||||||
treeViewer.getControl().getShell(), el.mode, true);
|
treeViewer.getControl().getShell(), el.mode, true);
|
||||||
|
if (MultiLaunchConfigurationDelegate.isValidLaunchReference(el.data)) {
|
||||||
dialog.setInitialSelection(el);
|
dialog.setInitialSelection(el);
|
||||||
|
}
|
||||||
if (dialog.open() == Dialog.OK) {
|
if (dialog.open() == Dialog.OK) {
|
||||||
ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations();
|
ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations();
|
||||||
if (confs.length < 0)
|
if (confs.length < 0)
|
||||||
|
@ -457,6 +460,39 @@ public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfiguratio
|
||||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
||||||
// defaults is empty list
|
// 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() {
|
public MultiLaunchConfigurationTabGroup() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue