KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > WindowTrimProxy


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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;
13
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.ui.internal.layout.IWindowTrim;
17
18 /**
19  * A transition class for any control that wants to participate in the workbench
20  * window trim. It must supply a unique ID so that it's position can be
21  * saved/restored.
22  *
23  * @since 3.2
24  */

25 public class WindowTrimProxy implements IWindowTrim {
26
27     private Control fTrimControl;
28
29     private String JavaDoc fId;
30
31     private String JavaDoc fDisplayName;
32
33     private int fValidSides;
34
35     private boolean fIsResizeable = false;
36     
37     private int fWidthHint = SWT.DEFAULT;
38     
39     private int fHeightHint = SWT.DEFAULT;
40
41     /**
42      * Create the trim proxy for a control.
43      *
44      * @param c
45      * the trim control
46      * @param id
47      * an ID that it's known by
48      * @param displayName
49      * the NLS name, for use in created menus
50      * @param validSides
51      * bitwise or of valid sides
52      * @see #getValidSides()
53      */

54     public WindowTrimProxy(Control c, String JavaDoc id, String JavaDoc displayName,
55             int validSides) {
56         fTrimControl = c;
57         fId = id;
58         fDisplayName = displayName;
59         fValidSides = validSides;
60     }
61
62     /**
63      * Create a trim proxy for a control.
64      *
65      * @param c
66      * @param id
67      * @param displayName
68      * @param validSides
69      * @param resizeable
70      */

71     public WindowTrimProxy(Control c, String JavaDoc id, String JavaDoc displayName,
72             int validSides, boolean resizeable) {
73         this(c, id, displayName, validSides);
74         fIsResizeable = resizeable;
75     }
76
77     /*
78      * (non-Javadoc)
79      *
80      * @see org.eclipse.ui.internal.IWindowTrim#getControl()
81      */

82     public Control getControl() {
83         return fTrimControl;
84     }
85
86     /*
87      * (non-Javadoc)
88      *
89      * @see org.eclipse.ui.internal.IWindowTrim#getValidSides()
90      */

91     public int getValidSides() {
92         return fValidSides;
93     }
94
95     /**
96      * The default for a proxied window trim is to do nothing, as it can't be
97      * moved around.
98      *
99      * @see org.eclipse.ui.internal.layout.IWindowTrim#dock(int)
100      */

101     public void dock(int dropSide) {
102     }
103
104     /*
105      * (non-Javadoc)
106      *
107      * @see org.eclipse.ui.internal.IWindowTrim#getId()
108      */

109     public String JavaDoc getId() {
110         return fId;
111     }
112
113     /*
114      * (non-Javadoc)
115      *
116      * @see org.eclipse.ui.internal.IWindowTrim#getDisplayName()
117      */

118     public String JavaDoc getDisplayName() {
119         return fDisplayName;
120     }
121
122     /*
123      * (non-Javadoc)
124      *
125      * @see org.eclipse.ui.internal.IWindowTrim#isCloseable()
126      */

127     public boolean isCloseable() {
128         return false;
129     }
130
131     /*
132      * (non-Javadoc)
133      *
134      * @see org.eclipse.ui.internal.IWindowTrim#handleClose()
135      */

136     public void handleClose() {
137         // nothing to do...
138
}
139
140     /*
141      * (non-Javadoc)
142      *
143      * @see org.eclipse.ui.IWindowTrim#getWidthHint()
144      */

145     public int getWidthHint() {
146         return fWidthHint;
147     }
148     
149     /**
150      * Update the width hint for this control.
151      * @param w pixels, or SWT.DEFAULT
152      */

153     public void setWidthHint(int w) {
154         fWidthHint = w;
155     }
156
157     /*
158      * (non-Javadoc)
159      *
160      * @see org.eclipse.ui.IWindowTrim#getHeightHint()
161      */

162     public int getHeightHint() {
163         return fHeightHint;
164     }
165     
166     /**
167      * Update the height hint for this control.
168      * @param h pixels, or SWT.DEFAULT
169      */

170     public void setHeightHint(int h) {
171         fHeightHint = h;
172     }
173
174     /*
175      * (non-Javadoc)
176      *
177      * @see org.eclipse.ui.IWindowTrim#isResizeable()
178      */

179     public boolean isResizeable() {
180         return fIsResizeable;
181     }
182 }
183
Popular Tags