01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor;
11:
12: import org.eclipse.jface.action.IMenuListener;
13: import org.eclipse.jface.action.IMenuManager;
14: import org.eclipse.jface.action.IStatusLineManager;
15: import org.eclipse.jface.action.IToolBarManager;
16: import org.eclipse.jface.action.MenuManager;
17: import org.eclipse.jface.viewers.ISelection;
18: import org.eclipse.pde.internal.ui.search.PluginSearchActionGroup;
19: import org.eclipse.swt.widgets.Control;
20: import org.eclipse.swt.widgets.Menu;
21: import org.eclipse.ui.actions.ActionContext;
22: import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
23:
24: public abstract class PDEOutlinePage extends ContentOutlinePage {
25:
26: protected PDEFormEditor fEditor;
27:
28: public PDEOutlinePage(PDEFormEditor editor) {
29: fEditor = editor;
30: }
31:
32: public PDEOutlinePage() {
33: }
34:
35: public void makeContributions(IMenuManager menuManager,
36: IToolBarManager toolBarManager,
37: IStatusLineManager statusLineManager) {
38:
39: MenuManager popupMenuManager = new MenuManager();
40: IMenuListener listener = new IMenuListener() {
41: public void menuAboutToShow(IMenuManager manager) {
42: ISelection selection = getSelection();
43: PluginSearchActionGroup actionGroup = new PluginSearchActionGroup();
44: if (fEditor != null)
45: actionGroup.setBaseModel(fEditor
46: .getAggregateModel());
47: actionGroup.setContext(new ActionContext(selection));
48: actionGroup.fillContextMenu(manager);
49: }
50: };
51:
52: popupMenuManager.addMenuListener(listener);
53: popupMenuManager.setRemoveAllWhenShown(true);
54: Control control = getTreeViewer().getControl();
55: Menu menu = popupMenuManager.createContextMenu(control);
56: control.setMenu(menu);
57: }
58:
59: }
|