mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
Bug 466488 - Clicking edit on launches that have no launch group, tabs,
or have other errors, causes several error dialogs to pop up. Change-Id: Id5b56c2696e4911143a4daeb93cc8a442b3ebe33 Signed-off-by: Rob Stryker <rob.stryker@jboss.com>
This commit is contained in:
parent
d7a91f70ee
commit
899208ac28
4 changed files with 111 additions and 29 deletions
|
@ -948,7 +948,9 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchConfiguration
|
|||
Activator.trace("launch config not claimed"); //$NON-NLS-1$
|
||||
try {
|
||||
ILaunchDescriptor desc = defaultDescriptorType.getDescriptor(configuration);
|
||||
addDescriptor(configuration, desc);
|
||||
if( desc != null ) {
|
||||
addDescriptor(configuration, desc);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e.getStatus());
|
||||
}
|
||||
|
|
|
@ -55,6 +55,22 @@ public class Messages extends NLS {
|
|||
public static String StopActiveCommandHandler_0;
|
||||
public static String StopActiveCommandHandler_1;
|
||||
public static String TargetSelector_CreateNewTarget;
|
||||
|
||||
public static String DescriptorMustNotBeNull;
|
||||
public static String DescriptorMustNotBeNullDesc;
|
||||
public static String NoActiveTarget;
|
||||
public static String NoActiveTargetDesc;
|
||||
public static String NoLaunchConfigType;
|
||||
public static String CannotEditLaunchConfiguration;
|
||||
public static String NoLaunchModeSelected;
|
||||
public static String NoLaunchGroupSelected;
|
||||
public static String LaunchConfigurationNotFound;
|
||||
public static String LaunchConfigurationNotFoundDesc;
|
||||
public static String NoLaunchTabsDefined;
|
||||
public static String NoLaunchTabsDefinedDesc;
|
||||
|
||||
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
|
|
|
@ -14,18 +14,22 @@ import org.eclipse.core.commands.AbstractHandler;
|
|||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
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.LaunchConfigurationPresentationManager;
|
||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.ILaunchGroup;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
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.Messages;
|
||||
import org.eclipse.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -42,43 +46,90 @@ public class ConfigureActiveLaunchHandler extends AbstractHandler {
|
|||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
public static IStatus canOpenConfigurationEditor(ILaunchDescriptor desc) {
|
||||
if (desc == null)
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.DescriptorMustNotBeNull, new Exception(Messages.DescriptorMustNotBeNullDesc));
|
||||
LaunchBarManager manager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||
ILaunchMode mode = manager.getActiveLaunchMode();
|
||||
IRemoteConnection target = manager.getActiveLaunchTarget();
|
||||
if (target == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoActiveTarget, new Exception(Messages.NoActiveTargetDesc));
|
||||
}
|
||||
|
||||
ILaunchConfigurationType configType = null;
|
||||
try {
|
||||
configType = manager.getLaunchConfigurationType(desc, target);
|
||||
} catch(CoreException ce) {/* ignore */ };
|
||||
if (configType == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchConfigType, new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
}
|
||||
|
||||
if( mode == null ) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected, new Exception(Messages.NoLaunchModeSelected));
|
||||
}
|
||||
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier());
|
||||
if( group == null ) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchGroupSelected, new Exception(Messages.NoLaunchGroupSelected));
|
||||
}
|
||||
|
||||
String mode2 = group.getMode();
|
||||
if( mode2 == null ) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NoLaunchModeSelected, new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
}
|
||||
|
||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
|
||||
if (groupExt != null) {
|
||||
ILaunchConfiguration config = null;
|
||||
try {
|
||||
config = manager.getLaunchConfiguration(desc, target);
|
||||
} catch(CoreException ce) {
|
||||
// Ignore
|
||||
}
|
||||
if (config == null) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LaunchConfigurationNotFound, new Exception(Messages.LaunchConfigurationNotFoundDesc));
|
||||
}
|
||||
try {
|
||||
LaunchConfigurationPresentationManager mgr = LaunchConfigurationPresentationManager.getDefault();
|
||||
ILaunchConfigurationTabGroup tabgroup = mgr.getTabGroup(config, mode.getIdentifier());
|
||||
} catch(CoreException ce) {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID,Messages.NoLaunchTabsDefined, new Exception(Messages.NoLaunchTabsDefinedDesc));
|
||||
}
|
||||
} else {
|
||||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CannotEditLaunchConfiguration, new Exception(Messages.CannotEditLaunchConfiguration));
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
|
||||
public static void openConfigurationEditor(ILaunchDescriptor desc) {
|
||||
if (desc == null)
|
||||
return;
|
||||
|
||||
// Display the error message
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||
IStatus s = canOpenConfigurationEditor(desc);
|
||||
if( !s.isOK()) {
|
||||
MessageDialog.openError(shell, s.getMessage(), s.getException() == null ? s.getMessage() : s.getException().getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
// At this point, no error handling should be needed.
|
||||
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;
|
||||
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType, mode.getIdentifier());
|
||||
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(group.getIdentifier());
|
||||
ILaunchConfiguration config = manager.getLaunchConfiguration(desc, target);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -39,3 +39,16 @@ NewLaunchConfigWizard_0=Create Launch Configuration
|
|||
StopActiveCommandHandler_0=Stopping launches
|
||||
StopActiveCommandHandler_1=Stopping build
|
||||
TargetSelector_CreateNewTarget=Create New Connection...
|
||||
|
||||
DescriptorMustNotBeNull=Descriptor must not be null
|
||||
DescriptorMustNotBeNullDesc=The launch descriptor must not be null.
|
||||
NoActiveTarget=No Active Target
|
||||
NoActiveTargetDesc=You must create a target to edit this launch configuration.
|
||||
NoLaunchConfigType=No launch configuration type matches selected launch descriptor.
|
||||
CannotEditLaunchConfiguration=Cannot edit this configuration.
|
||||
NoLaunchModeSelected=No launch mode selected.
|
||||
NoLaunchGroupSelected=No launch group found for the current selection.
|
||||
LaunchConfigurationNotFound=Launch Configuration Not Found
|
||||
LaunchConfigurationNotFoundDesc=No launch configuration is found for the given launch descriptor and target.
|
||||
NoLaunchTabsDefined=No launch tabs defined.
|
||||
NoLaunchTabsDefinedDesc=No launch tabs have been defined for this launch configuration type.
|
||||
|
|
Loading…
Add table
Reference in a new issue