From fab88f3e75ff41eb20f38a16f5145de5b55f29a5 Mon Sep 17 00:00:00 2001 From: Michael Rennie Date: Thu, 22 Feb 2007 17:41:27 +0000 Subject: Bug 74480 [launching] Simplify the launch experience for less technical users of Eclipse --- .../debug/internal/ui/actions/ActionMessages.java | 4 +- .../internal/ui/actions/ActionMessages.properties | 3 +- .../ui/contextlaunching/ContextMessages.java | 1 + .../ui/contextlaunching/ContextMessages.properties | 3 + .../ui/contextlaunching/ContextRunner.java | 124 ++++----------------- .../LaunchConfigurationsMessages.java | 6 +- .../LaunchConfigurationsMessages.properties | 4 +- .../LaunchShortcutExtension.java | 13 ++- .../LaunchShortcutSelectionDialog.java | 21 ++++ .../DebugPreferencesMessages.properties | 6 +- .../ui/preferences/RunDebugPropertiesPage.java | 64 +++-------- .../SelectedResourceManager.java | 9 +- .../ui/actions/AbstractLaunchHistoryAction.java | 2 +- .../debug/ui/actions/ContextualLaunchAction.java | 32 +----- .../debug/ui/actions/LaunchShortcutsAction.java | 89 ++++----------- 15 files changed, 120 insertions(+), 261 deletions(-) (limited to 'org.eclipse.debug.ui/ui') diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java index 5a68a8af7..46a4cb188 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2000, 2007 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 http://www.eclipse.org/legal/epl-v10.html @@ -38,8 +38,6 @@ public class ActionMessages extends NLS { public static String ConfigureColumnsAction_0; public static String ConfigureColumnsAction_1; public static String ConfigureColumnsAction_2; - - public static String ContextualLaunchAction_0; public static String CopyToClipboardActionDelegate_Problem_Copying_to_Clipboard_1; public static String CopyToClipboardActionDelegate_There_was_a_problem_when_accessing_the_system_clipboard__Retry__2; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties index ab3c09730..95d756461 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2006 IBM Corporation and others. +# Copyright (c) 2000, 2007 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 @@ -166,4 +166,3 @@ SuspendAction_3=Suspend ConfigureColumnsAction_0=Select &Columns... ConfigureColumnsAction_1=Select the &columns to display: ConfigureColumnsAction_2=Select Columns -ContextualLaunchAction_0={0} (default) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java index 337d4703c..e08254915 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java @@ -27,6 +27,7 @@ public class ContextMessages extends NLS { public static String ContextRunner_13; public static String ContextRunner_14; public static String ContextRunner_15; + public static String ContextRunner_16; public static String ContextRunner_7; public static String ContextRunner_8; public static String ContextRunner_9; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties index 8ecb1e10c..f5c927f4a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties @@ -18,4 +18,7 @@ ContextRunner_12=&Always launch project if resource is not launchable ContextRunner_13=The resource [{0}] is not accessible for launching ContextRunner_14=As... ContextRunner_15=... + +#The possible values of {0} is the name of the resource that is the current context i.e. Main.java +ContextRunner_16={0} OpenLaunchDialogAction_0=Open {0} Dialog... diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java index f9722a7b2..0c679bca4 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java @@ -15,7 +15,6 @@ import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.internal.ui.DebugUIPlugin; @@ -25,23 +24,15 @@ import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationMan import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutSelectionDialog; +import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialogWithToggle; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.window.Window; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.dialogs.ListDialog; import com.ibm.icu.text.MessageFormat; @@ -50,9 +41,10 @@ import com.ibm.icu.text.MessageFormat; * Static runner for context launching to provide the base capability of context * launching to more than one form of action (drop down, toolbar, view, etc) * - * @see ContextLaunchingAction - * @see ContextLaunchingToolbarAction - * @see ILaunchListener + * @see org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction + * @see org.eclipse.debug.ui.actions.LaunchShortcutsAction + * @see org.eclipse.debug.ui.actions.ContextualLaunchAction + * @see org.eclipse.debug.internal.ui.preferences.ContextLaunchingPreferencePage * * @since 3.3 * EXPERIMENTAL @@ -88,26 +80,20 @@ public final class ContextRunner { */ public void launch(String mode) { try { + IResource resource = SelectedResourceManager.getDefault().getSelectedResource(); //1. resolve resource - Object context = getCurrentContext(); - ILaunchConfiguration config = null; - if(context != null) { - if(context instanceof IAdaptable) { - IResource resource = (IResource) ((IAdaptable)context).getAdapter(IResource.class); - if(resource != null) { - if(DEBUG_CONTEXTUAL_LAUNCH) { - System.out.println("LAUNCH -> Selecting and Launching with resource: "+resource.getName()+ " in mode: "+mode); //$NON-NLS-1$ //$NON-NLS-2$ - } - selectAndLaunch(resource, mode); - return; - } + if(resource != null) { + if(DEBUG_CONTEXTUAL_LAUNCH) { + System.out.println("LAUNCH -> Selecting and Launching with resource: "+resource.getName()+ " in mode: "+mode); //$NON-NLS-1$ //$NON-NLS-2$ } + selectAndLaunch(resource, mode); + return; } //2. launch last if no resource - config = getLastLaunch(mode); + ILaunchConfiguration config = getLastLaunch(mode); if(config != null) { if(DEBUG_CONTEXTUAL_LAUNCH) { - System.out.println("LAUNCH -> Using last launch, context: "+context+" is not valid"); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println("LAUNCH -> Using last launch, context is not valid"); //$NON-NLS-1$ } DebugUITools.launch(config, mode); return; @@ -173,7 +159,7 @@ public final class ContextRunner { DebugUITools.launch(config, mode); return true; } - List configs = getLaunchConfigurationManager().getApplicableLaunchConfigurations(resource); + List configs = getLaunchConfigurationManager().getApplicableLaunchConfigurations(resource); int csize = configs.size(); if(DEBUG_CONTEXTUAL_LAUNCH) { System.out.println("\tSELECTANDLAUNCH -> Selecting from "+csize+" possible launch configurations for "+resource.getName()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -258,7 +244,7 @@ public final class ContextRunner { ILaunchGroup group = resolveLaunchGroup(mode); if(group != null) { if(DEBUG_CONTEXTUAL_LAUNCH) { - System.out.println("\t\tGETMRUCONFIGURATION -> Looking up MRU for launchgroup "+DebugUIPlugin.removeAccelerators(group.getLabel())); //$NON-NLS-1$ + System.out.println("\t\tGETMRUCONFIGURATION -> Looking up MRU for launch group "+DebugUIPlugin.removeAccelerators(group.getLabel())); //$NON-NLS-1$ } ILaunchConfiguration config = getLastLaunch(mode); if(DEBUG_CONTEXTUAL_LAUNCH) { @@ -274,8 +260,6 @@ public final class ContextRunner { if(DEBUG_CONTEXTUAL_LAUNCH) { System.out.println("\t\tGETMRUCONFIGURATION -> Checking history"); //$NON-NLS-1$ } - //TODO favorites will be missed unless they were the last launch - //this is a limitation of the launch history, and due to be refactored if(history != null) { ILaunchConfiguration[] configs = history.getCompleteLaunchHistory(); for(int i = 0; i < configs.length; i++) { @@ -333,84 +317,22 @@ public final class ContextRunner { return false; } - /** - * Returns the current context to be considered for launching. - * The returned object will be one of: - *
null
, if the current context is unknownnull
.
- *
- */
- public Object getCurrentContext() {
- IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
- if(window != null) {
- IWorkbenchPage page = window.getActivePage();
- if(page!= null) {
- IWorkbenchPart part = page.getActivePart();
- if(part != null) {
- if(part instanceof IEditorPart) {
- return ((IEditorPart)part).getEditorInput();
- }
- IWorkbenchPartSite site = part.getSite();
- if(site != null) {
- ISelectionProvider provider = site.getSelectionProvider();
- if(provider != null) {
- ISelection sel = provider.getSelection();
- if(sel instanceof IStructuredSelection) {
- StructuredSelection ss = (StructuredSelection) sel;
- if(ss.isEmpty()) {
- return part;
- }
- else {
- return ss.getFirstElement();
- }
- }
- else if(sel instanceof ITextSelection) {
- return part;
- }
- }
- else {
- return part;
- }
- }
- }
- }
- }
- return null;
- }
-
/**
* Returns the associated launch configuration name of the currently selected context, or the empty string.
* @param mode
* @return the associated launch configuration name of the currently selected context or the empty string.
*/
- public String getContextName(String mode) {
- Object o = getCurrentContext();
- ILaunchConfiguration config = getLaunchConfigurationManager().isSharedConfig(o);
+ public String getContextLabel(String mode) {
+ IResource resource = SelectedResourceManager.getDefault().getSelectedResource();
+ ILaunchConfiguration config = getLaunchConfigurationManager().isSharedConfig(resource);
if(config != null) {
if(DEBUG_CONTEXTUAL_LAUNCH) {
System.out.println("GETCONTEXTNAME -> Shared config, return name"); //$NON-NLS-1$
}
return config.getName();
}
- else {
- if(o instanceof IAdaptable) {
- Object a = ((IAdaptable)o).getAdapter(IResource.class);
- if(a != null) {
- IResource res = (IResource) a;
- return getResourceLabel(res, mode);
- }
- else if(DEBUG_CONTEXTUAL_LAUNCH) {
- System.out.println("GETCONTEXTNAME -> Not adaptable to IResource: "+o.toString()); //$NON-NLS-1$
- }
- }
- else if(DEBUG_CONTEXTUAL_LAUNCH) {
- System.out.println("GETCONTEXTNAME -> Not adaptable: "+o.toString()); //$NON-NLS-1$
- }
+ if(resource != null) {
+ return getResourceLabel(resource, mode);
}
if(DEBUG_CONTEXTUAL_LAUNCH) {
System.out.println("GETCONTEXTNAME -> Not shared config or otherwise, use last launch name if one"); //$NON-NLS-1$
@@ -432,9 +354,6 @@ public final class ContextRunner {
if(DEBUG_CONTEXTUAL_LAUNCH) {
System.out.println("\tGETRESOURCELABEL -> Finding name for: "+resource.getName()); //$NON-NLS-1$
}
- if(DEBUG_CONTEXTUAL_LAUNCH) {
- System.out.println("\tGETRESOURCELABEL -> looking up name for "+resource.getName()); //$NON-NLS-1$
- }
List configs = getLaunchConfigurationManager().getApplicableLaunchConfigurations(resource);
int csize = configs.size();
if(DEBUG_CONTEXTUAL_LAUNCH) {
@@ -476,6 +395,9 @@ public final class ContextRunner {
}
}
}
+ if(esize == 1) {
+ return resource.getName();
+ }
else {
//TODO could cause TVT issues
return ContextMessages.ContextRunner_14;
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 218f50ed8..aa1c12a77 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -102,6 +102,10 @@ public class LaunchConfigurationsMessages extends NLS {
public static String LaunchShortcutSelectionDialog_1;
+ public static String LaunchShortcutSelectionDialog_2;
+
+ public static String LaunchShortcutSelectionDialog_3;
+
public static String PerspectiveManager_Error_1;
public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
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 bf70120af..b71c0dc25 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
+# Copyright (c) 2000, 2007 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
@@ -115,6 +115,8 @@ LaunchShortcutSelectionDialog_0={0} As...
# if you tried to launch a class named Main in the file Main.java and you were presented
# with the selection dialog, the value of {1} would be Main.java (the name of the IResource)
LaunchShortcutSelectionDialog_1=&Select a way to {0} ''{1}'':
+LaunchShortcutSelectionDialog_2=&Description:
+LaunchShortcutSelectionDialog_3=Description not available
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
index dd8d8cd11..c00716a8b 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -230,6 +230,17 @@ public class LaunchShortcutExtension implements ILaunchShortcut, IPluginContribu
return fAssociatedTypes;
}
+ /**
+ * Returns the contributed description of the launch delegate or null
+ * if one has not been provided
+ * @return the description of the shortcut or null
if one was not provided
+ *
+ * @since 3.3
+ */
+ public String getShortcutDescription() {
+ return fConfig.getAttribute(IConfigurationElementConstants.DESCRIPTION);
+ }
+
/**
* Evaluate the given expression within the given context and return
* the result. Returns true
iff result is either TRUE or NOT_LOADED.
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java
index da50df63d..bb0f48e78 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java
@@ -20,14 +20,19 @@ import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ListDialog;
@@ -52,6 +57,7 @@ public class LaunchShortcutSelectionDialog extends ListDialog {
*/
private String fMode = null;
private IResource fResource = null;
+ private Text fDescriptionText = null;
/**
* Constructor
@@ -118,6 +124,21 @@ public class LaunchShortcutSelectionDialog extends ListDialog {
try {
List input = new ArrayList(DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts(fResource));
getTableViewer().setInput(input);
+ SWTFactory.createWrapLabel(comp, LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_2, 1, 300);
+ fDescriptionText = SWTFactory.createText(comp, SWT.READ_ONLY | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL, 1, 200, 200, GridData.FILL_BOTH);
+ fDescriptionText.setBackground(comp.getBackground());
+ GridData gd = (GridData) fDescriptionText.getLayoutData();
+ gd.widthHint = 200;
+ getTableViewer().getTable().addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ public void widgetSelected(SelectionEvent e) {
+ Object o = e.item.getData();
+ if(o instanceof LaunchShortcutExtension) {
+ String txt = ((LaunchShortcutExtension)o).getShortcutDescription();
+ fDescriptionText.setText((txt == null ? LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_3 : txt));
+ }
+ }
+ });
}
catch(CoreException ce) {DebugUIPlugin.log(ce);}
return comp;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
index f7fd55a38..b456a2efb 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2006 IBM Corporation and others.
+# Copyright (c) 2000, 2007 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
@@ -135,8 +135,8 @@ LaunchDelegatesPreferencePage_0=Default Launcher
LaunchDelegatesPreferencePage_4=Launcher Description
LaunchPerspectivePreferencePage_0=There is no perspective information available to change.
LaunchPerspectivePreferencePage_1=The selected types/launchers do not have any common mode sets.
-DefaultLaunchConfigurationsPropertiesPage_0=This page allows you to select a default way to launch the currently selected resource.
-DefaultLaunchConfigurationsPropertiesPage_1=&Select default configuration for {0}:
+DefaultLaunchConfigurationsPropertiesPage_0=This page allows you to manage launch configurations associated with the currently selected resource.
+DefaultLaunchConfigurationsPropertiesPage_1=Con&figurations for ''{0}'':
DefaultLaunchConfigurationsPropertiesPage_2=&New...
DefaultLaunchConfigurationsPropertiesPage_3=Create new launch configuration
DefaultLaunchConfigurationsPropertiesPage_4=Du&plicate
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java
index 1d36c2f66..a77f6f159 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java
@@ -34,13 +34,12 @@ import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationCom
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
@@ -92,7 +91,7 @@ public class RunDebugPropertiesPage extends PropertyPage {
private List fTypeCandidates = null;
//widgets
- private CheckboxTableViewer fViewer;
+ private TableViewer fViewer;
private Button fNewButton = null;
private Button fEditButton = null;
private Button fDuplicateButton = null;
@@ -162,50 +161,30 @@ public class RunDebugPropertiesPage extends PropertyPage {
* @param parent parent composite to create the viewer in
* @return viewer viewer that will display possible default configurations
*/
- protected CheckboxTableViewer createViewer(Composite parent){
- CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ protected TableViewer createViewer(Composite parent){
+ TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
viewer.setLabelProvider(new DefaultLabelProvider());
viewer.setContentProvider(new ArrayContentProvider());
viewer.setComparator(new LaunchConfigurationComparator());
- viewer.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- if (event.getChecked()) {
- fViewer.setCheckedElements(new Object[] {event.getElement()});
- }
- else{
- fViewer.setCheckedElements(new Object[] {});
- }
- }
- });
Table builderTable = viewer.getTable();
GridData tableGridData = new GridData(GridData.FILL_BOTH);
tableGridData.heightHint = 300;
builderTable.setLayoutData(tableGridData);
-
IResource resource = getResource();
viewer.setInput(collectConfigCandidates(resource));
- try {
- ILaunchConfiguration configuration = getLaunchManager().getDefaultConfiguration(resource);
- if (configuration != null) {
- Iterator iterator = fOriginalCandidates.iterator();
- while (iterator.hasNext()) {
- ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
- if (configuration.equals(wc.getOriginal())) {
- viewer.setChecked(wc, true);
- break;
- }
- }
- }
- } catch (CoreException e) {setErrorMessage(e.getMessage());}
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
- boolean empty = event.getSelection().isEmpty();
- fEditButton.setEnabled(!empty);
- fDuplicateButton.setEnabled(!empty);
- fDeleteButton.setEnabled(!empty);
+ ISelection sel = event.getSelection();
+ if(sel instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) sel;
+ boolean empty = ss.isEmpty();
+ int size = ss.size();
+ fEditButton.setEnabled(!empty && size == 1);
+ fDuplicateButton.setEnabled(!empty && size == 1);
+ fDeleteButton.setEnabled(!empty);
+ }
}
});
-
return viewer;
}
@@ -229,7 +208,7 @@ public class RunDebugPropertiesPage extends PropertyPage {
*
* @return viewer
*/
- protected CheckboxTableViewer getViewer() {
+ protected TableViewer getViewer() {
return fViewer;
}
@@ -304,18 +283,6 @@ public class RunDebugPropertiesPage extends PropertyPage {
* @see org.eclipse.jface.preference.PreferencePage#performOk()
*/
public boolean performOk() {
- Object[] checked = fViewer.getCheckedElements();
- try {
- ILaunchConfiguration def = null;
- if (checked.length == 1) {
- def = (ILaunchConfiguration) checked[0];
- def = ((ILaunchConfigurationWorkingCopy)def).doSave();
- }
- DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
- } catch (CoreException e) {
- setErrorMessage(e.getMessage());
- return false;
- }
//delete
Iterator iter = fDeletedConfigurations.iterator();
while (iter.hasNext()) {
@@ -346,7 +313,6 @@ public class RunDebugPropertiesPage extends PropertyPage {
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
protected void performDefaults() {
- fViewer.setAllChecked(false);
setErrorMessage(null);
setValid(true);
super.performDefaults();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java
index f6cb38b82..383a09b51 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java
@@ -42,6 +42,9 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
private ITextSelection fSelectedText = null;
private Stack fWindowStack = new Stack();
+ /**
+ * Constructor
+ */
private SelectedResourceManager() {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) { //may be running headless
@@ -147,7 +150,7 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
/**
* Returns the currently selected resource in the active workbench window,
- * or null
if none. If an editor is active, the resource adapater
+ * or null
if none. If an editor is active, the resource adapter
* associated with the editor is returned.
*
* @return selected resource or null
@@ -175,8 +178,8 @@ public class SelectedResourceManager implements IWindowListener, ISelectionListe
public IWorkbenchWindow getActiveWindow() {
try {
return (IWorkbenchWindow) fWindowStack.peek();
- } catch (EmptyStackException e) {
- }
+ }
+ catch (EmptyStackException e) {}
return null;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java
index 479c07fcb..a4733e23e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java
@@ -187,7 +187,7 @@ public abstract class AbstractLaunchHistoryAction implements IWorkbenchWindowPul
String label = null;
//CONTEXTLAUNCHING
if(ContextRunner.getDefault().isContextLaunchEnabled() && !getLaunchGroupIdentifier().equals("org.eclipse.ui.externaltools.launchGroup")) { //$NON-NLS-1$
- launchName = ContextRunner.getDefault().getContextName(getMode());
+ launchName = ContextRunner.getDefault().getContextLabel(getMode());
}
String mode = getMode();
if (mode.equals(ILaunchManager.RUN_MODE)) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
index 20a2a826d..a25faef1d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java
@@ -20,14 +20,11 @@ import java.util.Set;
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.actions.LaunchConfigurationAction;
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
@@ -50,8 +47,6 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import com.ibm.icu.text.MessageFormat;
-
/**
* An action delegate that builds a context menu with applicable launch shortcuts
* for a specific launch mode.
@@ -183,21 +178,6 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, I
return DebugPlugin.getDefault().getLaunchManager();
}
- /**
- * Returns the resource this menu is open on.
- *
- * @return resource
- */
- private IResource getResource(Object element) {
- IResource resource = null;
- if (element instanceof IResource) {
- resource = (IResource) element;
- } else if (element instanceof IAdaptable) {
- resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
- }
- return resource;
- }
-
/**
* Fills the menu with applicable launch shortcuts
* @param menu The menu to fill
@@ -207,17 +187,9 @@ public abstract class ContextualLaunchAction implements IObjectActionDelegate, I
return;
}
IEvaluationContext context = createContext();
- //CONTEXTLAUNCHING
- Object obj = fSelection.getFirstElement();
int accelerator = 1;
- ILaunchConfiguration config = getLaunchManager().getDefaultConfiguration(getResource(obj));
- if(config != null && config.exists() && config.supportsMode(fMode)) {
- IAction action = new LaunchConfigurationAction(config, fMode, MessageFormat.format(ActionMessages.ContextualLaunchAction_0, new String[] {config.getName()}), DebugUITools.getDefaultImageDescriptor(config), accelerator++);
- ActionContributionItem item = new ActionContributionItem(action);
- item.fill(menu, -1);
- new MenuItem(menu, SWT.SEPARATOR);
- }
- config = getLaunchConfigurationManager().isSharedConfig(obj);
+ Object obj = fSelection.getFirstElement();
+ ILaunchConfiguration config = getLaunchConfigurationManager().isSharedConfig(obj);
if(config != null && config.exists() && config.supportsMode(fMode)) {
IAction action = new LaunchConfigurationAction(config, fMode, config.getName(), DebugUITools.getDefaultImageDescriptor(config), accelerator++);
ActionContributionItem item = new ActionContributionItem(action);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
index 4b063b664..e906f7d6d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchShortcutsAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2007 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
@@ -22,7 +22,6 @@ import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
@@ -31,9 +30,9 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.actions.LaunchConfigurationAction;
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
-import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
+import org.eclipse.debug.internal.ui.stringsubstitution.SelectedResourceManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.action.Action;
@@ -41,25 +40,17 @@ import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuAdapter;
import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.activities.WorkbenchActivityHelper;
-import com.ibm.icu.text.MessageFormat;
-
/**
* A cascading sub-menu that shows all launch shortcuts pertinent to a
* selection. This action is similar to ContextualLaunchAction
@@ -142,70 +133,29 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork
*/
private IEvaluationContext createContext() {
List list = null;
- IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IWorkbenchPart activePart = page.getActivePart();
- if (activePart instanceof IEditorPart) {
- list = new ArrayList();
- list.add(((IEditorPart)activePart).getEditorInput());
- } else if (activePart != null) {
- IWorkbenchPartSite site = activePart.getSite();
- if (site != null) {
- ISelectionProvider selectionProvider = site.getSelectionProvider();
- if (selectionProvider != null) {
- ISelection selection = selectionProvider.getSelection();
- if (selection instanceof IStructuredSelection) {
- list = ((IStructuredSelection)selection).toList();
- }
- }
- }
- }
- }
- }
- // create a default evaluation context with default variable
- // of the user selection or editor input
+ IResource resource = getResourceContext();
+ if(resource != null) {
+ list = new ArrayList();
+ list.add(resource);
+ }
+ // create a default evaluation context with default variable of the user selection or editor input
if (list == null) {
list = Collections.EMPTY_LIST;
}
IEvaluationContext context = new EvaluationContext(null, list);
context.setAllowPluginActivation(true);
context.addVariable("selection", list); //$NON-NLS-1$
-
return context;
}
- /**
- * Returns the resource this menu is open on.
- *
- * @return resource
- */
- private IResource getResource(Object element) {
- IResource resource = null;
- if (element instanceof IResource) {
- resource = (IResource) element;
- } else if (element instanceof IAdaptable) {
- resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
- }
- return resource;
- }
-
/**
* Fills the flyout menu
*/
private void fillMenu() {
+ IEvaluationContext context = createContext();
+ int accelerator = 1;
try {
- Object selection = ContextRunner.getDefault().getCurrentContext();
- int accelerator = 1;
- ILaunchConfiguration config = DebugPlugin.getDefault().getLaunchManager().getDefaultConfiguration(getResource(selection));
- if(config != null && config.exists() && config.supportsMode(getMode())) {
- IAction action = new LaunchConfigurationAction(config, getMode(), MessageFormat.format(ActionMessages.ContextualLaunchAction_0, new String[] {config.getName()}), DebugUITools.getDefaultImageDescriptor(config), accelerator++);
- ActionContributionItem item = new ActionContributionItem(action);
- item.fill(fCreatedMenu, -1);
- new MenuItem(fCreatedMenu, SWT.SEPARATOR);
- }
- config = getLaunchConfigurationManager().isSharedConfig(selection);
+ ILaunchConfiguration config = getLaunchConfigurationManager().isSharedConfig(getResourceContext());
if(config != null && config.exists() && config.supportsMode(getMode())) {
IAction action = new LaunchConfigurationAction(config, getMode(), config.getName(), DebugUITools.getDefaultImageDescriptor(config), accelerator++);
ActionContributionItem item = new ActionContributionItem(action);
@@ -214,7 +164,6 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork
}
}
catch(CoreException ce) {DebugUIPlugin.log(ce);}
- IEvaluationContext context = createContext();
List allShortCuts = getLaunchConfigurationManager().getLaunchShortcuts(fGroup.getCategory());
Iterator iter = allShortCuts.iterator();
List filteredShortCuts = new ArrayList(10);
@@ -224,12 +173,9 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork
if (!WorkbenchActivityHelper.filterItem(ext) && isApplicable(ext, context)) {
filteredShortCuts.add(ext);
}
- } catch (CoreException e) {
- // not supported
- }
+ } catch (CoreException e) {/*not supported*/}
}
iter = filteredShortCuts.iterator();
- int accelerator = 1;
while (iter.hasNext()) {
LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next();
Set modes = ext.getModes(); // supported launch modes
@@ -304,6 +250,17 @@ public class LaunchShortcutsAction extends Action implements IMenuCreator, IWork
});
}
+ /**
+ * Returns the currently selected IResource
+ * @return the selected IResource
or null
if the selected
+ * item cannot be adapted to IResource
, or is not itself an IResource
+ *
+ * @since 3.3
+ */
+ private IResource getResourceContext() {
+ return SelectedResourceManager.getDefault().getSelectedResource();
+ }
+
/**
* Returns the mode of this action - run or debug
*
--
cgit v1.2.3