Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 53335 Details for
Bug 74480
[launching] Simplify the launch experience for less technical users of Eclipse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
prototype for experimentation
bug74480.patch (text/plain), 19.08 KB, created by
Darin Wright
on 2006-11-06 16:50:02 EST
(
hide
)
Description:
prototype for experimentation
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2006-11-06 16:50:02 EST
Size:
19.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java,v >retrieving revision 1.13 >diff -u -r1.13 AbstractLaunchToolbarAction.java >--- ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java 8 Apr 2005 16:08:20 -0000 1.13 >+++ ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java 6 Nov 2006 21:50:52 -0000 >@@ -11,13 +11,29 @@ > package org.eclipse.debug.ui.actions; > > >+import org.eclipse.core.resources.IResource; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.contexts.launch.LaunchContext; >+import org.eclipse.debug.internal.ui.contexts.launch.LaunchContextManager; >+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension; > import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction; > import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.ILaunchShortcut; > import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.BaseLabelProvider; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Menu; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.dialogs.ListSelectionDialog; > > /** > * A launch history action that also includes launch shortcut actions (run/debug >@@ -29,6 +45,26 @@ > */ > public class AbstractLaunchToolbarAction extends AbstractLaunchHistoryAction { > >+ private IWorkbenchWindow fWindow = null; >+ >+ private class LabelProvider extends BaseLabelProvider implements ILabelProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ // TODO Auto-generated method stub >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ return ((LaunchShortcutExtension)element).getLabel(); >+ } >+ >+ } > > /** > * Constructs a launch toolbar action. >@@ -41,6 +77,22 @@ > super(launchGroupIdentifier); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction#dispose() >+ */ >+ public void dispose() { >+ super.dispose(); >+ fWindow = null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.actions.AbstractLaunchHistoryAction#init(org.eclipse.ui.IWorkbenchWindow) >+ */ >+ public void init(IWorkbenchWindow window) { >+ super.init(window); >+ fWindow = window; >+ } >+ > /** > * Fills the drop-down menu with favorites and launch history, > * launch shortcuts, and an action to open the launch configuration dialog. >@@ -74,6 +126,67 @@ > * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) > */ > public void run(IAction action) { >+ IWorkbenchPage page = fWindow.getActivePage(); >+ if (page != null) { >+ IStructuredSelection selection = null; >+ IEditorPart editor = null; >+ if (page.getActivePart() == page.getActiveEditor()) { >+ editor = page.getActiveEditor(); >+ if (editor != null) { >+ selection = new StructuredSelection(editor.getEditorInput()); >+ } >+ } else { >+ ISelection sel = page.getSelection(); >+ if (sel instanceof IStructuredSelection) { >+ selection = (IStructuredSelection) sel; >+ } >+ } >+ if (selection != null) { >+ LaunchContext context = new LaunchContext(selection, getMode()); >+ LaunchContextManager manager = LaunchContextManager.getDefault(); >+ ILaunchShortcut shortcut = manager.getCachedShortcut(context); >+ if (shortcut == null) { >+ ILaunchShortcut[] shortcuts = context.getApplicableShortcuts(); >+ if (shortcuts.length == 1) { >+ shortcut = shortcuts[0]; >+ } else { >+ if (shortcuts.length == 0) { >+ IResource resource = context.getResource(); >+ if (resource != null) { >+ context = new LaunchContext(new StructuredSelection(resource.getProject()), getMode()); >+ shortcut = manager.getCachedShortcut(context); >+ if (shortcut == null) { >+ shortcuts = context.getApplicableShortcuts(); >+ } >+ } >+ } >+ if (shortcuts.length > 0) { >+ ListSelectionDialog dialog = new ListSelectionDialog(fWindow.getShell(), shortcuts, new ArrayContentProvider(), >+ new LabelProvider(), "What do you want to launch today?"); >+ int open = dialog.open(); >+ if (open == Window.OK) { >+ Object[] result = dialog.getResult(); >+ if (result.length == 1) { >+ shortcut = (ILaunchShortcut) result[0]; >+ manager.cacheShortcut(context, shortcut); >+ } >+ } else { >+ return; >+ } >+ } >+ } >+ } >+ if (shortcut != null) { >+ if (editor != null) { >+ shortcut.launch(editor, getMode()); >+ } else { >+ shortcut.launch(selection, getMode()); >+ } >+ return; >+ } >+ } >+ } >+ > ILaunchConfiguration configuration = getLastLaunch(); > if (configuration == null) { > DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier()); >Index: ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java,v >retrieving revision 1.11 >diff -u -r1.11 LaunchShortcutAction.java >--- ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java 8 May 2006 20:07:19 -0000 1.11 >+++ ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java 6 Nov 2006 21:50:52 -0000 >@@ -18,10 +18,13 @@ > import org.eclipse.core.expressions.IEvaluationContext; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.contexts.launch.LaunchContext; >+import org.eclipse.debug.internal.ui.contexts.launch.LaunchContextManager; > import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; >@@ -57,17 +60,24 @@ > if (wb != null) { > IWorkbenchPage page = wb.getActivePage(); > if (page != null) { >+ IStructuredSelection contextSelection = null; > if (page.getActivePart() == page.getActiveEditor()) { > IEditorPart editor = page.getActiveEditor(); > if (editor != null) { >+ contextSelection = new StructuredSelection(editor.getEditorInput()); > fShortcut.launch(editor, fMode); > } > } else { > ISelection selection = page.getSelection(); > if (selection instanceof IStructuredSelection) { >+ contextSelection = (IStructuredSelection) selection; > fShortcut.launch(selection, fMode); > } > } >+ if (contextSelection != null) { >+ LaunchContext context = new LaunchContext(contextSelection, fMode); >+ LaunchContextManager.getDefault().cacheShortcut(context, fShortcut); >+ } > } > } > } >Index: ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContextManager.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContextManager.java >diff -N ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContextManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContextManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.contexts.launch; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.debug.ui.ILaunchShortcut; >+ >+/** >+ * @since 3.3 >+ */ >+public class LaunchContextManager { >+ >+ private static LaunchContextManager fgDefault = null; >+ >+ private Map fMap = new HashMap(); >+ >+ public static LaunchContextManager getDefault() { >+ if (fgDefault == null) { >+ fgDefault = new LaunchContextManager(); >+ } >+ return fgDefault; >+ } >+ >+ /** >+ * Caches the shortcut to use for the given context. >+ * >+ * @param context >+ * @param shortcut >+ */ >+ public void cacheShortcut(LaunchContext context, ILaunchShortcut shortcut) { >+ fMap.put(context.getContextKey(), shortcut); >+ fMap.put(context.getResourceContextKey(), shortcut); >+ } >+ >+ /** >+ * Returns the cached shortcut for the given context, or <code>null</code>. >+ * >+ * @param context >+ * @return shortcut or <code>null</code>. >+ */ >+ public ILaunchShortcut getCachedShortcut(LaunchContext context) { >+ ILaunchShortcut shortcut = (ILaunchShortcut) fMap.get(context.getResourceContextKey()); >+ if (shortcut == null) { >+ shortcut = (ILaunchShortcut) fMap.get(context.getContextKey()); >+ } >+ return shortcut; >+ } >+ >+} >Index: ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContext.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContext.java >diff -N ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContext.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/contexts/launch/LaunchContext.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,261 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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 >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.contexts.launch; >+ >+import java.util.ArrayList; >+import java.util.HashSet; >+import java.util.Iterator; >+import java.util.List; >+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.IFile; >+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.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; >+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension; >+import org.eclipse.debug.ui.ILaunchShortcut; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.IFileEditorInput; >+import org.eclipse.ui.activities.WorkbenchActivityHelper; >+ >+/** >+ * @since 3.3 >+ */ >+public class LaunchContext { >+ >+ private IStructuredSelection fSelection; >+ private String fMode; >+ private Set fNatures; >+ private IResource fResource; >+ >+ private ILaunchShortcut[] fShortcuts; >+ >+ /** >+ * Constructs a launch context for the given selection. >+ * >+ * @param selection >+ */ >+ public LaunchContext(IStructuredSelection selection, String mode) { >+ fSelection = selection; >+ fMode = mode; >+ } >+ >+ /** >+ * Returns a collection of project nature id's associated with this context's project >+ * or <code>null</code> if none. >+ * >+ * @return project natures or <code>null</code> >+ */ >+ public Set getProjectNatureIds() { >+ if (fNatures == null) { >+ fNatures = new HashSet(); >+ IResource resource = getResource(); >+ if (resource != null) { >+ IProject project = resource.getProject(); >+ try { >+ String[] natureIds = project.getDescription().getNatureIds(); >+ for (int i = 0; i < natureIds.length; i++) { >+ fNatures.add(natureIds[i]); >+ } >+ } catch (CoreException e) { >+ } >+ } >+ } >+ return fNatures; >+ } >+ >+ /** >+ * Return's this context's associated resource or <code>null</code>. >+ * >+ * @return resource or <code>null</code> >+ */ >+ public IResource getResource() { >+ if (fResource == null) { >+ Object element = fSelection.getFirstElement(); >+ if (element != null) { >+ if (element instanceof IResource) { >+ fResource = (IResource) element; >+ } else if (element instanceof IAdaptable) { >+ fResource = (IResource) ((IAdaptable)element).getAdapter(IResource.class); >+ } >+ } >+ } >+ return fResource; >+ } >+ >+ /** >+ * Returns launch shortcuts applicable to this context, possibly an empty collection. >+ * >+ * @param mode launch mode >+ * @return launch shortcuts >+ */ >+ public ILaunchShortcut[] getApplicableShortcuts() { >+ if (fShortcuts == null) { >+ IEvaluationContext context = createContext(); >+ >+ //add in any selected shared config's before the rest of the items to launch as >+ //feature fix for >+ if(!fSelection.isEmpty()) { >+ Object obj = fSelection.getFirstElement(); >+ if(isSharedConfig(obj)) { >+ // TODO: just run the config >+ } >+ else if(isSharedConfigEditorInput(obj)) { >+ // TODO: just run the config >+ } >+ } >+ >+ // gather all shortcuts and run their filters so that we only run the >+ // filters one time for each shortcut. Running filters can be expensive. >+ // Also, only *LOADED* plug-ins get their filters run. >+ List /* <LaunchShortcutExtension> */ allShortCuts = getLaunchConfigurationManager().getLaunchShortcuts(); >+ Iterator iter = allShortCuts.iterator(); >+ List filteredShortCuts = new ArrayList(10); >+ while (iter.hasNext()) { >+ LaunchShortcutExtension ext = (LaunchShortcutExtension) iter.next(); >+ if (ext.getModes().contains(fMode)) { >+ try { >+ if (!WorkbenchActivityHelper.filterItem(ext) && isApplicable(ext, context)) { >+ filteredShortCuts.add(ext); >+ } >+ } catch (CoreException e) { >+ // not supported >+ } >+ } >+ } >+ fShortcuts = (ILaunchShortcut[]) filteredShortCuts.toArray(new ILaunchShortcut[filteredShortCuts.size()]); >+ } >+ return fShortcuts; >+ } >+ >+ /** >+ * Returns the launch configuration manager. >+ * >+ * @return launch configuration manager >+ */ >+ private LaunchConfigurationManager getLaunchConfigurationManager() { >+ return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); >+ } >+ >+ /** >+ * Returns a key used to this launch context that does *not* include the specific >+ * resource to be launched. The key considers associated project natures >+ * and applicable launch shortcuts. >+ * >+ * @return key >+ */ >+ public Object getContextKey() { >+ Set key = new HashSet(); >+ key.addAll(getProjectNatureIds()); >+ ILaunchShortcut[] applicableShortcuts = getApplicableShortcuts(); >+ for (int i = 0; i < applicableShortcuts.length; i++) { >+ key.add(((LaunchShortcutExtension)applicableShortcuts[i]).getId()); >+ } >+ return key; >+ } >+ >+ /** >+ * Returns a key used to this launch context that *does* include the specific >+ * resource to be launched. >+ * >+ * @return key >+ */ >+ public Object getResourceContextKey() { >+ Set key = new HashSet(); >+ key.addAll((Set)getContextKey()); >+ IResource resource = getResource(); >+ if (resource != null) { >+ key.add(resource.getFullPath().toPortableString()); >+ } >+ return key; >+ } >+ >+ /** >+ * @return an Evaluation context with default variable = selection >+ */ >+ private IEvaluationContext createContext() { >+ // create a default evaluation context with default variable of the user selection >+ List selection = getSelectedElements(); >+ IEvaluationContext context = new EvaluationContext(null, selection); >+ context.setAllowPluginActivation(true); >+ context.addVariable("selection", selection); //$NON-NLS-1$ >+ >+ return context; >+ } >+ >+ /** >+ * @return current selection as a List. >+ */ >+ private List getSelectedElements() { >+ ArrayList result = new ArrayList(); >+ Iterator iter = fSelection.iterator(); >+ while (iter.hasNext()) { >+ result.add(iter.next()); >+ } >+ return result; >+ } >+ >+ /** >+ * This method is used to determine if the selected object is in fact a shared launch >+ * configuration that can be launched >+ * @return true if the item is a shared config , false otherwise >+ * @since 3.3 >+ */ >+ private boolean isSharedConfig(Object receiver) { >+ if(receiver instanceof IFile) { >+ IFile file = (IFile) receiver; >+ String ext = file.getFileExtension(); >+ if(ext == null) { >+ return false; >+ } >+ if(ext.equals("launch")) { //$NON-NLS-1$ >+ ILaunchConfiguration config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(file); >+ if(config != null && config.exists()) { >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * This method return if the editor input is from a shared java launch configuration file or not >+ * @param receiver the editor input to examine >+ * @return true if the editor input is from a shared launch configuration file, false otherwise. >+ */ >+ private boolean isSharedConfigEditorInput(Object receiver) { >+ if(receiver instanceof IFileEditorInput) { >+ IFileEditorInput input = (IFileEditorInput) receiver; >+ return isSharedConfig(input.getFile()); >+ } >+ return false; >+ } >+ >+ /** >+ * Evaluate the enabled logic in the contextualLaunch >+ * element description. A true result means that we should >+ * include this shortcut in the context menu. >+ * @return true iff shortcut should appear in context menu >+ */ >+ private boolean isApplicable(LaunchShortcutExtension ext, IEvaluationContext context) throws CoreException { >+ Expression expr = ext.getContextualLaunchEnablementExpression(); >+ return ext.evalEnablementExpression(context, expr); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 74480
:
53335
|
54442
|
54503
|
55420
|
56341
|
56426
|
56666
|
56675
|
56736
|
56804
|
56849
|
56854
|
57047
|
57181
|
57350
|
58480
|
58788
|
58895