Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9b459e85e13f3d7ef97c6a2be93646cebd018913 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*******************************************************************************
 * Copyright (c) 2004, 2005 Sybase, Inc. and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/

package org.eclipse.jst.jsf.facesconfig.ui;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.SubActionBars;
import org.eclipse.ui.part.IPageSite;

/**
 * 
 * This implementation of <code>IPageSite</code> provides a site for a sub
 * page within a <code>Page</code>. Most methods are forwarded to the parent
 * page's site.
 * 
 * @author Xiao-guang Zhang
 */
public class SubPageSite implements IPageSite {

	/**
	 * The "parent" Page site
	 */
	private IPageSite parentSite;

	/**
	 * A selection provider set by the page. Value is <code>null</code> until
	 * set.
	 */
	private ISelectionProvider selectionProvider;

	/**
	 * The action bars for this site
	 */
	private SubActionBars subActionBars;

	/**
	 * The list of menu extender for each registered menu.
	 */
//	private ArrayList menuExtenders;

	/**
	 * Creates a new sub page site of the given parent page site.
	 * 
	 * @param parentSite
	 *            the parent view site
	 */
	public SubPageSite(IPageSite parentSite) {
		Assert.isNotNull(parentSite);
		this.parentSite = parentSite;
		subActionBars = new SubActionBars(this.parentSite.getActionBars());
	}

	/**
	 * Disposes of the menu extender contributions.
	 */
	protected void dispose() {
		// if (menuExtenders != null) {
		// for (int i = 0; i < menuExtenders.size(); i++) {
		// ((PopupMenuExtender) menuExtenders.get(i)).dispose();
		// }
		// menuExtenders = null;
		//		}
		subActionBars.dispose();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.part.IPageSite#registerContextMenu(java.lang.String,
	 *      org.eclipse.jface.action.MenuManager,
	 *      org.eclipse.jface.viewers.ISelectionProvider)
	 */
	public void registerContextMenu(String menuId, MenuManager menuManager,
			ISelectionProvider selectionProvider1) {

		parentSite.registerContextMenu(menuId, menuManager, selectionProvider1);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.part.IPageSite#getActionBars()
	 */
	public IActionBars getActionBars() {
		return subActionBars;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchSite#getPage()
	 */
	public IWorkbenchPage getPage() {
		return parentSite.getPage();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchSite#getSelectionProvider()
	 */
	public ISelectionProvider getSelectionProvider() {
		return selectionProvider;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchSite#getShell()
	 */
	public Shell getShell() {
		return parentSite.getShell();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchSite#getWorkbenchWindow()
	 */
	public IWorkbenchWindow getWorkbenchWindow() {
		return parentSite.getWorkbenchWindow();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchSite#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)
	 */
	public void setSelectionProvider(ISelectionProvider provider) {
		selectionProvider = provider;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
	 */
	public Object getAdapter(Class adapter) {
		return parentSite.getAdapter(adapter);
	}

	public Object getService(Class api) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean hasService(Class api) {
		// TODO Auto-generated method stub
		return false;
	}

}

Back to the top