01: /*******************************************************************************
02: * Copyright (c) 2007 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.menus;
11:
12: import org.eclipse.jface.action.ControlContribution;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.ui.IWorkbenchWindow;
15: import org.eclipse.ui.internal.menus.InternalControlContribution;
16:
17: /**
18: * Abstract base class from which all controls contributions to
19: * the workbench through the 'org.eclipse.ui.menus' extension
20: * point must derive.
21: * <p>
22: * The extends the {@link ControlContribution} by adding accessor
23: * methods that provide extra state information about the placement
24: * of the control:
25: * <ul>
26: * <li>getWorkbenchWindow() - indicates which workbench window this control
27: * is being hosted by</li>
28: * <li>getCurSide() - indicates which side of the workbench window the
29: * control is being displayed on</li>
30: * </ul>
31: * </p>
32: *
33: * @since 3.3
34: *
35: * @see ControlContribution
36: */
37: public abstract class WorkbenchWindowControlContribution extends
38: InternalControlContribution {
39:
40: /**
41: * Default contstructor that allows the use of this class as
42: * the basis for XML contributions and will be used by the
43: * workbench implementation. This is public only by necessity
44: * and should not be used outside of the workbench implemenation
45: * code.
46: */
47: public WorkbenchWindowControlContribution() {
48: this ("unknown ID"); //$NON-NLS-1$
49: }
50:
51: /**
52: * Constructor for use by clients programmatically creating
53: * control contributions in the workbench.
54: *
55: * @param id The id of this contribution
56: */
57: public WorkbenchWindowControlContribution(String id) {
58: super (id);
59: }
60:
61: /**
62: * @return Returns the workbench window currently hosting
63: * the control.
64: */
65: public final IWorkbenchWindow getWorkbenchWindow() {
66: return super .getWorkbenchWindow();
67: }
68:
69: /**
70: * @return Returns the side of the workbench window that the
71: * control is currently being display on. This allows derivatives
72: * to tailor their created control based on the orientation...
73: */
74: public final int getCurSide() {
75: return super .getCurSide();
76: }
77:
78: public final int getOrientation() {
79: if (getCurSide() == SWT.LEFT || getCurSide() == SWT.RIGHT)
80: return SWT.VERTICAL;
81:
82: return SWT.HORIZONTAL;
83: }
84: }
|