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 124983 Details for
Bug 60833
[EditorMgmt] [ViewMgmt] Right click on part tab should not realize part
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Prevent part activation on context menu patch v2
bug60833-patch-v2.txt (text/plain), 11.36 KB, created by
Remy Suen
on 2009-02-06 13:15:20 EST
(
hide
)
Description:
Prevent part activation on context menu patch v2
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2009-02-06 13:15:20 EST
Size:
11.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java,v >retrieving revision 1.8 >diff -u -r1.8 StandardViewSystemMenu.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java 11 Apr 2007 15:09:44 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java 6 Feb 2009 18:14:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2007 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 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 >@@ -89,6 +89,9 @@ > > Menu aMenu = menuManager.createContextMenu(parent); > menuManager.update(true); >+ // set the part as the menu's data so that others can retrieve it and >+ // identify which part has been selected by the user >+ aMenu.setData(currentSelection); > aMenu.setLocation(displayCoordinates.x, displayCoordinates.y); > aMenu.setVisible(true); > } >Index: Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java,v >retrieving revision 1.20 >diff -u -r1.20 TabbedStackPresentation.java >--- Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java 22 Nov 2007 17:38:13 -0000 1.20 >+++ Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java 6 Feb 2009 18:14:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 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 >@@ -27,11 +27,13 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.IMemento; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.PartStack; > import org.eclipse.ui.internal.preferences.IDynamicPropertyMap; > import org.eclipse.ui.internal.preferences.PreferenceStoreAdapter; > import org.eclipse.ui.internal.preferences.PreferencesAdapter; > import org.eclipse.ui.internal.preferences.PropertyMapAdapter; > import org.eclipse.ui.internal.preferences.ThemeManagerAdapter; >+import org.eclipse.ui.internal.presentations.PresentablePart; > import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultPartList; > import org.eclipse.ui.internal.util.PrefUtil; > import org.eclipse.ui.presentations.IPartMenu; >@@ -486,7 +488,11 @@ > > public void showSystemMenu(Point displayCoordinates, IPresentablePart context) { > if (context != getSite().getSelectedPart()) { >- getSite().selectPart(context); >+ PresentablePart part = (PresentablePart) context; >+ PartStack stack = part.getPane().getStack(); >+ // if the part isn't the currently selected part, we need to update >+ // the stack's actions so that they will target the correct part >+ stack.updateActions(part); > } > systemMenu.show(getControl(), displayCoordinates, context); > } >Index: Eclipse UI/org/eclipse/ui/internal/ViewStack.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ViewStack.java,v >retrieving revision 1.29 >diff -u -r1.29 ViewStack.java >--- Eclipse UI/org/eclipse/ui/internal/ViewStack.java 13 Sep 2007 12:35:13 -0000 1.29 >+++ Eclipse UI/org/eclipse/ui/internal/ViewStack.java 6 Feb 2009 18:14:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -108,7 +108,7 @@ > return !perspective.isFixedLayout(); > } > >- protected void updateActions(PresentablePart current) { >+ public void updateActions(PresentablePart current) { > ViewPane pane = null; > > if (current != null && current.getPane() instanceof ViewPane) { >Index: Eclipse UI/org/eclipse/ui/internal/PartStack.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/PartStack.java,v >retrieving revision 1.105 >diff -u -r1.105 PartStack.java >--- Eclipse UI/org/eclipse/ui/internal/PartStack.java 24 Mar 2008 19:21:57 -0000 1.105 >+++ Eclipse UI/org/eclipse/ui/internal/PartStack.java 6 Feb 2009 18:14:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2008 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 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 >@@ -1211,9 +1211,14 @@ > > /** > * Subclasses should override this method to update the enablement state of their >- * actions >+ * actions. >+ * <p> >+ * Made public in 3.5 so that other classes can force the actions to be >+ * updated to target a specific part instead of the part that is active in >+ * the stack. See bug 60833 for more details. >+ * </p> > */ >- protected abstract void updateActions(PresentablePart current); >+ public abstract void updateActions(PresentablePart current); > > /* (non-Javadoc) > * @see org.eclipse.ui.internal.LayoutPart#handleDeferredEvents() >Index: Eclipse UI/org/eclipse/ui/internal/EditorStack.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/EditorStack.java,v >retrieving revision 1.28 >diff -u -r1.28 EditorStack.java >--- Eclipse UI/org/eclipse/ui/internal/EditorStack.java 9 Apr 2007 20:41:35 -0000 1.28 >+++ Eclipse UI/org/eclipse/ui/internal/EditorStack.java 6 Feb 2009 18:14:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -116,7 +116,7 @@ > } > } > >- protected void updateActions(PresentablePart current) { >+ public void updateActions(PresentablePart current) { > EditorPane pane = null; > if (current != null && current.getPane() instanceof EditorPane) { > pane = (EditorPane) current.getPane(); >Index: Eclipse UI/org/eclipse/ui/internal/handlers/NewEditorHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/handlers/NewEditorHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 NewEditorHandler.java >--- Eclipse UI/org/eclipse/ui/internal/handlers/NewEditorHandler.java 3 Oct 2007 15:21:29 -0000 1.1 >+++ Eclipse UI/org/eclipse/ui/internal/handlers/NewEditorHandler.java 6 Feb 2009 18:14:15 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2009 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 >@@ -14,25 +14,71 @@ > import org.eclipse.core.commands.AbstractHandler; > import org.eclipse.core.commands.ExecutionEvent; > import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; >+import org.eclipse.swt.widgets.Widget; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IPersistableEditor; > import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.XMLMemento; > import org.eclipse.ui.handlers.HandlerUtil; > import org.eclipse.ui.internal.IWorkbenchConstants; >+import org.eclipse.ui.internal.PartPane; > import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.WorkbenchPage; > import org.eclipse.ui.internal.dialogs.DialogUtil; >+import org.eclipse.ui.internal.presentations.PresentablePart; > > /** >- * Open a new editor on the active editor's input. >+ * Open a new editor on the input of the active editor or the editor that has >+ * been selected by the mouse. >+ * <p> >+ * Since 3.5, this handler has been modified to monitor the contents of the >+ * popup menu that has instantiated this handler (if applicable) so that the >+ * handler will create a new editor for the editor that has been selected >+ * instead of the workbench page's active editor. See bug 60833 for more >+ * details. >+ * </p> > * > * @since 3.4 > * > */ > public class NewEditorHandler extends AbstractHandler { >+ >+ /** >+ * Retrieves the editor that should the workbench should create a new editor >+ * for. >+ * @param event the current state of the application >+ * @return the editor that a new editor should be created for, or <code>null</code> if no valid editor could be found >+ * @since 3.5 >+ */ >+ private IEditorPart getEditor(ExecutionEvent event) { >+ IEditorPart editor = HandlerUtil.getActiveEditor(event); >+ Object trigger = event.getTrigger(); >+ if (trigger instanceof Event) { >+ Event swtEvent = (Event) trigger; >+ Widget widget = swtEvent.widget; >+ // make sure it's actually a menu item, if a user invokes this >+ // handler from a keybinding, there are no popup menus >+ if (widget instanceof MenuItem) { >+ MenuItem menuItem = (MenuItem) widget; >+ Menu menu = menuItem.getParent(); >+ Object data = menu.getData(); >+ // retrieve the part that owns the context menu >+ if (data instanceof PresentablePart) { >+ PresentablePart part = (PresentablePart) data; >+ PartPane pane = part.getPane(); >+ IWorkbenchPart workbenchPart = pane.getPartReference().getPart(true); >+ editor = workbenchPart instanceof IEditorPart ? (IEditorPart) workbenchPart : null; >+ } >+ } >+ } >+ return editor; >+ } > > /* > * (non-Javadoc) >@@ -46,7 +92,7 @@ > if (page == null) { > return null; > } >- IEditorPart editor = page.getActiveEditor(); >+ IEditorPart editor = getEditor(event); > if (editor == null) { > return null; > }
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 60833
:
124918
| 124983