KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > PDEOutlinePage


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor;
12
13 import org.eclipse.jface.action.IMenuListener;
14 import org.eclipse.jface.action.IMenuManager;
15 import org.eclipse.jface.action.IStatusLineManager;
16 import org.eclipse.jface.action.IToolBarManager;
17 import org.eclipse.jface.action.MenuManager;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.pde.internal.ui.search.PluginSearchActionGroup;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Menu;
22 import org.eclipse.ui.actions.ActionContext;
23 import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
24
25 public abstract class PDEOutlinePage extends ContentOutlinePage {
26
27     protected PDEFormEditor fEditor;
28     
29     public PDEOutlinePage(PDEFormEditor editor) {
30         fEditor = editor;
31     }
32
33     public PDEOutlinePage() {
34     }
35     
36     public void makeContributions(
37             IMenuManager menuManager,
38             IToolBarManager toolBarManager,
39             IStatusLineManager statusLineManager) {
40         
41         MenuManager popupMenuManager = new MenuManager();
42         IMenuListener listener = new IMenuListener() {
43             public void menuAboutToShow(IMenuManager manager) {
44                 ISelection selection = getSelection();
45                 PluginSearchActionGroup actionGroup = new PluginSearchActionGroup();
46                 if (fEditor != null)
47                     actionGroup.setBaseModel(fEditor.getAggregateModel());
48                 actionGroup.setContext(new ActionContext(selection));
49                 actionGroup.fillContextMenu(manager);
50             }
51         };
52         
53         popupMenuManager.addMenuListener(listener);
54         popupMenuManager.setRemoveAllWhenShown(true);
55         Control control = getTreeViewer().getControl();
56         Menu menu = popupMenuManager.createContextMenu(control);
57         control.setMenu(menu);
58     }
59     
60 }
61
Popular Tags