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.internal.menus;
11:
12: import org.eclipse.jface.action.ControlContribution;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.ui.IWorkbenchWindow;
15:
16: /**
17: * Add workbench specific information to a standard control contribution.
18: * Allows the client derivatives to access the IWorkbenchWindow hosting
19: * the control as well as the side of the workbench that the control is
20: * currently being displayed on.
21: *
22: * @since 3.3
23: *
24: */
25: public abstract class InternalControlContribution extends
26: ControlContribution {
27: private String id;
28: private IWorkbenchWindow wbw;
29: private int curSide;
30:
31: /**
32: * @param id
33: */
34: protected InternalControlContribution(String id) {
35: super (id);
36: this .id = id;
37: }
38:
39: public InternalControlContribution() {
40: this ("unknown ID"); //$NON-NLS-1$
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.jface.action.ContributionItem#getId()
45: */
46: public String getId() {
47: return id;
48: }
49:
50: /**
51: * @param id The id to set.
52: */
53: /*package*/void setId(String id) {
54: this .id = id;
55: }
56:
57: /**
58: * @return Returns the wbw.
59: */
60: public IWorkbenchWindow getWorkbenchWindow() {
61: return wbw;
62: }
63:
64: /**
65: * @param wbw The wbw to set.
66: */
67: /*package*/void setWorkbenchWindow(IWorkbenchWindow wbw) {
68: this .wbw = wbw;
69: }
70:
71: /**
72: * @return Returns the curSide.
73: */
74: public int getCurSide() {
75: return curSide;
76: }
77:
78: /**
79: * @param curSide The curSide to set.
80: */
81: /*package*/void setCurSide(int curSide) {
82: this .curSide = curSide;
83: }
84:
85: public int getOrientation() {
86: if (getCurSide() == SWT.LEFT || getCurSide() == SWT.RIGHT)
87: return SWT.VERTICAL;
88:
89: return SWT.HORIZONTAL;
90: }
91: }
|