001: /*******************************************************************************
002: * Copyright (c) 2005, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal;
011:
012: import org.eclipse.swt.SWT;
013: import org.eclipse.swt.widgets.Control;
014: import org.eclipse.ui.internal.layout.IWindowTrim;
015:
016: /**
017: * A transition class for any control that wants to participate in the workbench
018: * window trim. It must supply a unique ID so that it's position can be
019: * saved/restored.
020: *
021: * @since 3.2
022: */
023: public class WindowTrimProxy implements IWindowTrim {
024:
025: private Control fTrimControl;
026:
027: private String fId;
028:
029: private String fDisplayName;
030:
031: private int fValidSides;
032:
033: private boolean fIsResizeable = false;
034:
035: private int fWidthHint = SWT.DEFAULT;
036:
037: private int fHeightHint = SWT.DEFAULT;
038:
039: /**
040: * Create the trim proxy for a control.
041: *
042: * @param c
043: * the trim control
044: * @param id
045: * an ID that it's known by
046: * @param displayName
047: * the NLS name, for use in created menus
048: * @param validSides
049: * bitwise or of valid sides
050: * @see #getValidSides()
051: */
052: public WindowTrimProxy(Control c, String id, String displayName,
053: int validSides) {
054: fTrimControl = c;
055: fId = id;
056: fDisplayName = displayName;
057: fValidSides = validSides;
058: }
059:
060: /**
061: * Create a trim proxy for a control.
062: *
063: * @param c
064: * @param id
065: * @param displayName
066: * @param validSides
067: * @param resizeable
068: */
069: public WindowTrimProxy(Control c, String id, String displayName,
070: int validSides, boolean resizeable) {
071: this (c, id, displayName, validSides);
072: fIsResizeable = resizeable;
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see org.eclipse.ui.internal.IWindowTrim#getControl()
079: */
080: public Control getControl() {
081: return fTrimControl;
082: }
083:
084: /*
085: * (non-Javadoc)
086: *
087: * @see org.eclipse.ui.internal.IWindowTrim#getValidSides()
088: */
089: public int getValidSides() {
090: return fValidSides;
091: }
092:
093: /**
094: * The default for a proxied window trim is to do nothing, as it can't be
095: * moved around.
096: *
097: * @see org.eclipse.ui.internal.layout.IWindowTrim#dock(int)
098: */
099: public void dock(int dropSide) {
100: }
101:
102: /*
103: * (non-Javadoc)
104: *
105: * @see org.eclipse.ui.internal.IWindowTrim#getId()
106: */
107: public String getId() {
108: return fId;
109: }
110:
111: /*
112: * (non-Javadoc)
113: *
114: * @see org.eclipse.ui.internal.IWindowTrim#getDisplayName()
115: */
116: public String getDisplayName() {
117: return fDisplayName;
118: }
119:
120: /*
121: * (non-Javadoc)
122: *
123: * @see org.eclipse.ui.internal.IWindowTrim#isCloseable()
124: */
125: public boolean isCloseable() {
126: return false;
127: }
128:
129: /*
130: * (non-Javadoc)
131: *
132: * @see org.eclipse.ui.internal.IWindowTrim#handleClose()
133: */
134: public void handleClose() {
135: // nothing to do...
136: }
137:
138: /*
139: * (non-Javadoc)
140: *
141: * @see org.eclipse.ui.IWindowTrim#getWidthHint()
142: */
143: public int getWidthHint() {
144: return fWidthHint;
145: }
146:
147: /**
148: * Update the width hint for this control.
149: * @param w pixels, or SWT.DEFAULT
150: */
151: public void setWidthHint(int w) {
152: fWidthHint = w;
153: }
154:
155: /*
156: * (non-Javadoc)
157: *
158: * @see org.eclipse.ui.IWindowTrim#getHeightHint()
159: */
160: public int getHeightHint() {
161: return fHeightHint;
162: }
163:
164: /**
165: * Update the height hint for this control.
166: * @param h pixels, or SWT.DEFAULT
167: */
168: public void setHeightHint(int h) {
169: fHeightHint = h;
170: }
171:
172: /*
173: * (non-Javadoc)
174: *
175: * @see org.eclipse.ui.IWindowTrim#isResizeable()
176: */
177: public boolean isResizeable() {
178: return fIsResizeable;
179: }
180: }
|