View | Details | Raw Unified | Return to bug 60833 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/presentations/util/StandardViewSystemMenu.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 89-94 Link Here
89
        
89
        
90
        Menu aMenu = menuManager.createContextMenu(parent);
90
        Menu aMenu = menuManager.createContextMenu(parent);
91
        menuManager.update(true);
91
        menuManager.update(true);
92
        // set the part as the menu's data so that others can retrieve it and
93
        // identify which part has been selected by the user
94
        aMenu.setData(currentSelection);
92
        aMenu.setLocation(displayCoordinates.x, displayCoordinates.y);
95
        aMenu.setLocation(displayCoordinates.x, displayCoordinates.y);
93
        aMenu.setVisible(true);
96
        aMenu.setVisible(true);
94
    }
97
    }
(-)Eclipse UI/org/eclipse/ui/internal/presentations/util/TabbedStackPresentation.java (-2 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 27-37 Link Here
27
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.ui.IMemento;
28
import org.eclipse.ui.IMemento;
29
import org.eclipse.ui.PlatformUI;
29
import org.eclipse.ui.PlatformUI;
30
import org.eclipse.ui.internal.PartStack;
30
import org.eclipse.ui.internal.preferences.IDynamicPropertyMap;
31
import org.eclipse.ui.internal.preferences.IDynamicPropertyMap;
31
import org.eclipse.ui.internal.preferences.PreferenceStoreAdapter;
32
import org.eclipse.ui.internal.preferences.PreferenceStoreAdapter;
32
import org.eclipse.ui.internal.preferences.PreferencesAdapter;
33
import org.eclipse.ui.internal.preferences.PreferencesAdapter;
33
import org.eclipse.ui.internal.preferences.PropertyMapAdapter;
34
import org.eclipse.ui.internal.preferences.PropertyMapAdapter;
34
import org.eclipse.ui.internal.preferences.ThemeManagerAdapter;
35
import org.eclipse.ui.internal.preferences.ThemeManagerAdapter;
36
import org.eclipse.ui.internal.presentations.PresentablePart;
35
import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultPartList;
37
import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultPartList;
36
import org.eclipse.ui.internal.util.PrefUtil;
38
import org.eclipse.ui.internal.util.PrefUtil;
37
import org.eclipse.ui.presentations.IPartMenu;
39
import org.eclipse.ui.presentations.IPartMenu;
Lines 486-492 Link Here
486
    
488
    
487
    public void showSystemMenu(Point displayCoordinates, IPresentablePart context) {
489
    public void showSystemMenu(Point displayCoordinates, IPresentablePart context) {
488
        if (context != getSite().getSelectedPart()) {
490
        if (context != getSite().getSelectedPart()) {
489
            getSite().selectPart(context);
491
        	PresentablePart part = (PresentablePart) context;
492
        	PartStack stack = part.getPane().getStack();
493
        	// if the part isn't the currently selected part, we need to update
494
        	// the stack's actions so that they will target the correct part
495
        	stack.updateActions(part);
490
        }
496
        }
491
        systemMenu.show(getControl(), displayCoordinates, context);
497
        systemMenu.show(getControl(), displayCoordinates, context);
492
    }
498
    }
(-)Eclipse UI/org/eclipse/ui/internal/ViewStack.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 108-114 Link Here
108
        return !perspective.isFixedLayout();
108
        return !perspective.isFixedLayout();
109
    }
109
    }
110
110
111
    protected void updateActions(PresentablePart current) {
111
    public void updateActions(PresentablePart current) {
112
        ViewPane pane = null;
112
        ViewPane pane = null;
113
113
114
        if (current != null && current.getPane() instanceof ViewPane) {
114
        if (current != null && current.getPane() instanceof ViewPane) {
(-)Eclipse UI/org/eclipse/ui/internal/PartStack.java (-3 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1211-1219 Link Here
1211
1211
1212
    /**
1212
    /**
1213
     * Subclasses should override this method to update the enablement state of their
1213
     * Subclasses should override this method to update the enablement state of their
1214
     * actions
1214
     * actions.
1215
     * <p>
1216
     * Made public in 3.5 so that other classes can force the actions to be
1217
     * updated to target a specific part instead of the part that is active in
1218
     * the stack. See bug 60833 for more details.
1219
     * </p>
1215
     */
1220
     */
1216
    protected abstract void updateActions(PresentablePart current);
1221
    public abstract void updateActions(PresentablePart current);
1217
1222
1218
    /* (non-Javadoc)
1223
    /* (non-Javadoc)
1219
	 * @see org.eclipse.ui.internal.LayoutPart#handleDeferredEvents()
1224
	 * @see org.eclipse.ui.internal.LayoutPart#handleDeferredEvents()
(-)Eclipse UI/org/eclipse/ui/internal/EditorStack.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 116-122 Link Here
116
        }
116
        }
117
    }
117
    }
118
118
119
    protected void updateActions(PresentablePart current) {
119
    public void updateActions(PresentablePart current) {
120
        EditorPane pane = null;
120
        EditorPane pane = null;
121
        if (current != null && current.getPane() instanceof EditorPane) {
121
        if (current != null && current.getPane() instanceof EditorPane) {
122
            pane = (EditorPane) current.getPane();
122
            pane = (EditorPane) current.getPane();
(-)Eclipse UI/org/eclipse/ui/internal/handlers/NewEditorHandler.java (-3 / +49 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-38 Link Here
14
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.swt.widgets.Event;
18
import org.eclipse.swt.widgets.Menu;
19
import org.eclipse.swt.widgets.MenuItem;
20
import org.eclipse.swt.widgets.Widget;
17
import org.eclipse.ui.IEditorPart;
21
import org.eclipse.ui.IEditorPart;
18
import org.eclipse.ui.IPersistableEditor;
22
import org.eclipse.ui.IPersistableEditor;
19
import org.eclipse.ui.IWorkbenchPage;
23
import org.eclipse.ui.IWorkbenchPage;
24
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.IWorkbenchWindow;
25
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.PartInitException;
26
import org.eclipse.ui.PartInitException;
22
import org.eclipse.ui.XMLMemento;
27
import org.eclipse.ui.XMLMemento;
23
import org.eclipse.ui.handlers.HandlerUtil;
28
import org.eclipse.ui.handlers.HandlerUtil;
24
import org.eclipse.ui.internal.IWorkbenchConstants;
29
import org.eclipse.ui.internal.IWorkbenchConstants;
30
import org.eclipse.ui.internal.PartPane;
25
import org.eclipse.ui.internal.WorkbenchMessages;
31
import org.eclipse.ui.internal.WorkbenchMessages;
26
import org.eclipse.ui.internal.WorkbenchPage;
32
import org.eclipse.ui.internal.WorkbenchPage;
27
import org.eclipse.ui.internal.dialogs.DialogUtil;
33
import org.eclipse.ui.internal.dialogs.DialogUtil;
34
import org.eclipse.ui.internal.presentations.PresentablePart;
28
35
29
/**
36
/**
30
 * Open a new editor on the active editor's input.
37
 * Open a new editor on the input of the active editor or the editor that has
38
 * been selected by the mouse.
39
 * <p>
40
 * Since 3.5, this handler has been modified to monitor the contents of the
41
 * popup menu that has instantiated this handler (if applicable) so that the
42
 * handler will create a new editor for the editor that has been selected
43
 * instead of the workbench page's active editor. See bug 60833 for more
44
 * details.
45
 * </p>
31
 * 
46
 * 
32
 * @since 3.4
47
 * @since 3.4
33
 * 
48
 * 
34
 */
49
 */
35
public class NewEditorHandler extends AbstractHandler {
50
public class NewEditorHandler extends AbstractHandler {
51
	
52
	/**
53
	 * Retrieves the editor that should the workbench should create a new editor
54
	 * for.
55
	 * @param event the current state of the application
56
	 * @return the editor that a new editor should be created for, or <code>null</code> if no valid editor could be found
57
	 * @since 3.5
58
	 */
59
	private IEditorPart getEditor(ExecutionEvent event) {
60
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
61
		Object trigger = event.getTrigger();
62
		if (trigger instanceof Event) {
63
			Event swtEvent = (Event) trigger;
64
			Widget widget = swtEvent.widget;
65
			// make sure it's actually a menu item, if a user invokes this
66
			// handler from a keybinding, there are no popup menus
67
			if (widget instanceof MenuItem) {
68
				MenuItem menuItem = (MenuItem) widget;
69
				Menu menu = menuItem.getParent();
70
				Object data = menu.getData();
71
				// retrieve the part that owns the context menu
72
				if (data instanceof PresentablePart) {
73
					PresentablePart part = (PresentablePart) data;
74
					PartPane pane = part.getPane();
75
					IWorkbenchPart workbenchPart = pane.getPartReference().getPart(true);
76
					editor = workbenchPart instanceof IEditorPart ? (IEditorPart) workbenchPart : null;	
77
				}	
78
			}
79
		}
80
		return editor;
81
	}
36
82
37
	/*
83
	/*
38
	 * (non-Javadoc)
84
	 * (non-Javadoc)
Lines 46-52 Link Here
46
		if (page == null) {
92
		if (page == null) {
47
			return null;
93
			return null;
48
		}
94
		}
49
		IEditorPart editor = page.getActiveEditor();
95
		IEditorPart editor = getEditor(event);
50
		if (editor == null) {
96
		if (editor == null) {
51
			return null;
97
			return null;
52
		}
98
		}

Return to bug 60833