KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > menus > WorkbenchWindowControlContribution


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.menus;
13
14 import org.eclipse.jface.action.ControlContribution;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.ui.IWorkbenchWindow;
17 import org.eclipse.ui.internal.menus.InternalControlContribution;
18
19 /**
20  * Abstract base class from which all controls contributions to
21  * the workbench through the 'org.eclipse.ui.menus' extension
22  * point must derive.
23  * <p>
24  * The extends the {@link ControlContribution} by adding accessor
25  * methods that provide extra state information about the placement
26  * of the control:
27  * <ul>
28  * <li>getWorkbenchWindow() - indicates which workbench window this control
29  * is being hosted by</li>
30  * <li>getCurSide() - indicates which side of the workbench window the
31  * control is being displayed on</li>
32  * </ul>
33  * </p>
34  *
35  * @since 3.3
36  *
37  * @see ControlContribution
38  */

39 public abstract class WorkbenchWindowControlContribution extends InternalControlContribution {
40
41     /**
42      * Default contstructor that allows the use of this class as
43      * the basis for XML contributions and will be used by the
44      * workbench implementation. This is public only by necessity
45      * and should not be used outside of the workbench implemenation
46      * code.
47      */

48     public WorkbenchWindowControlContribution() {
49         this("unknown ID"); //$NON-NLS-1$
50
}
51
52     /**
53      * Constructor for use by clients programmatically creating
54      * control contributions in the workbench.
55      *
56      * @param id The id of this contribution
57      */

58     public WorkbenchWindowControlContribution(String JavaDoc id) {
59         super(id);
60     }
61
62     /**
63      * @return Returns the workbench window currently hosting
64      * the control.
65      */

66     public final IWorkbenchWindow getWorkbenchWindow() {
67         return super.getWorkbenchWindow();
68     }
69
70     /**
71      * @return Returns the side of the workbench window that the
72      * control is currently being display on. This allows derivatives
73      * to tailor their created control based on the orientation...
74      */

75     public final int getCurSide() {
76         return super.getCurSide();
77     }
78     
79     public final int getOrientation() {
80         if (getCurSide() == SWT.LEFT || getCurSide() == SWT.RIGHT)
81             return SWT.VERTICAL;
82         
83         return SWT.HORIZONTAL;
84     }
85 }
86
Popular Tags