01: /*******************************************************************************
02: * Copyright (c) 2000, 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.ui.examples.propertysheet;
11:
12: import org.eclipse.core.runtime.IAdaptable;
13: import org.eclipse.jface.action.MenuManager;
14: import org.eclipse.jface.action.Separator;
15: import org.eclipse.jface.viewers.TreeViewer;
16: import org.eclipse.swt.widgets.Composite;
17: import org.eclipse.swt.widgets.Menu;
18: import org.eclipse.ui.IWorkbenchActionConstants;
19: import org.eclipse.ui.model.WorkbenchContentProvider;
20: import org.eclipse.ui.model.WorkbenchLabelProvider;
21: import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
22:
23: /**
24: * Page for the content outliner
25: */
26: public class PropertySheetContentOutlinePage extends ContentOutlinePage {
27:
28: private IAdaptable model;
29:
30: /**
31: * Create a new instance of the reciver using adapatable
32: * as the model.
33: */
34: public PropertySheetContentOutlinePage(IAdaptable adaptable) {
35: this .model = adaptable;
36: }
37:
38: /**
39: * Creates the control and registers the popup menu for this page
40: * Menu id "org.eclipse.ui.examples.propertysheet.outline"
41: */
42: public void createControl(Composite parent) {
43: super .createControl(parent);
44: TreeViewer viewer = getTreeViewer();
45: viewer.setContentProvider(new WorkbenchContentProvider());
46: viewer.setLabelProvider(new WorkbenchLabelProvider());
47: viewer.setInput(this .model);
48: viewer.expandAll();
49:
50: // Configure the context menu.
51: MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
52: menuMgr.add(new Separator(
53: IWorkbenchActionConstants.MB_ADDITIONS));
54: menuMgr.add(new Separator(
55: IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
56:
57: Menu menu = menuMgr.createContextMenu(viewer.getTree());
58: viewer.getTree().setMenu(menu);
59: // Be sure to register it so that other plug-ins can add actions.
60: getSite()
61: .registerContextMenu(
62: "org.eclipse.ui.examples.propertysheet.outline", menuMgr, viewer); //$NON-NLS-1$
63: }
64: }
|