KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > menus > InternalControlContribution


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.internal.menus;
13
14 import org.eclipse.jface.action.ControlContribution;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.ui.IWorkbenchWindow;
17
18 /**
19  * Add workbench specific information to a standard control contribution.
20  * Allows the client derivatives to access the IWorkbenchWindow hosting
21  * the control as well as the side of the workbench that the control is
22  * currently being displayed on.
23  *
24  * @since 3.3
25  *
26  */

27 public abstract class InternalControlContribution extends ControlContribution {
28     private String JavaDoc id;
29     private IWorkbenchWindow wbw;
30     private int curSide;
31     
32     /**
33      * @param id
34      */

35     protected InternalControlContribution(String JavaDoc id) {
36         super(id);
37         this.id = id;
38     }
39
40     public InternalControlContribution() {
41         this("unknown ID"); //$NON-NLS-1$
42
}
43     
44     /* (non-Javadoc)
45      * @see org.eclipse.jface.action.ContributionItem#getId()
46      */

47     public String JavaDoc getId() {
48         return id;
49     }
50
51     /**
52      * @param id The id to set.
53      */

54     /*package*/ void setId(String JavaDoc id) {
55         this.id = id;
56     }
57
58     /**
59      * @return Returns the wbw.
60      */

61     public IWorkbenchWindow getWorkbenchWindow() {
62         return wbw;
63     }
64
65     /**
66      * @param wbw The wbw to set.
67      */

68     /*package*/ void setWorkbenchWindow(IWorkbenchWindow wbw) {
69         this.wbw = wbw;
70     }
71
72     /**
73      * @return Returns the curSide.
74      */

75     public int getCurSide() {
76         return curSide;
77     }
78
79     /**
80      * @param curSide The curSide to set.
81      */

82     /*package*/ void setCurSide(int curSide) {
83         this.curSide = curSide;
84     }
85     
86     public int getOrientation() {
87         if (getCurSide() == SWT.LEFT || getCurSide() == SWT.RIGHT)
88             return SWT.VERTICAL;
89         
90         return SWT.HORIZONTAL;
91     }
92 }
93
Popular Tags