Skip to main content
summaryrefslogtreecommitdiffstats
blob: c86a3ddd7a2d501442cfdb4436675f980f49fb39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.eclipse.ui.examples.propertysheet;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;

/**
 * Page for the content outliner
 */
public class PropertySheetContentOutlinePage extends ContentOutlinePage {

	private IAdaptable model;
/**
 * Create a new instance of the reciver using adapatable
 * as the model.
 */
public PropertySheetContentOutlinePage(IAdaptable adaptable) {
	this.model = adaptable;
}
/** 
 * Creates the control and registers the popup menu for this page
 * Menu id "org.eclipse.ui.examples.propertysheet.outline"
 */
public void createControl(Composite parent) {
	super.createControl(parent);
	TreeViewer viewer = getTreeViewer();
	viewer.setContentProvider(new WorkbenchContentProvider());
	viewer.setLabelProvider(new WorkbenchLabelProvider());
	viewer.setInput(this.model); 
	viewer.expandAll();
	
	// Configure the context menu.
	MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
	menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));	
	menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));	 //$NON-NLS-1$

	Menu menu = menuMgr.createContextMenu(viewer.getTree());
	viewer.getTree().setMenu(menu);
	// Be sure to register it so that other plug-ins can add actions.
	getSite().registerContextMenu("org.eclipse.ui.examples.propertysheet.outline", menuMgr, viewer); //$NON-NLS-1$
}
}

Back to the top