001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: WindowBarProperties.java,v 1.33 2005/12/04 13:46:04 jesper Exp $
023: package net.infonode.docking.properties;
024:
025: import net.infonode.properties.gui.util.ComponentProperties;
026: import net.infonode.properties.propertymap.*;
027: import net.infonode.properties.types.BooleanProperty;
028: import net.infonode.properties.types.ColorProperty;
029: import net.infonode.properties.types.IntegerProperty;
030: import net.infonode.util.Direction;
031:
032: import java.awt.*;
033:
034: /**
035: * Properties and property values for window bars.
036: *
037: * @author $Author: jesper $
038: * @version $Revision: 1.33 $
039: */
040: public class WindowBarProperties extends PropertyMapContainer {
041: /**
042: * Property group containing all window bar properties.
043: */
044: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
045: "Window Bar Properties", "");
046:
047: /**
048: * The window bar component property values.
049: */
050: public static final PropertyMapProperty COMPONENT_PROPERTIES = new PropertyMapProperty(
051: PROPERTIES, "Component Properties",
052: "The WindowBar component properties.",
053: ComponentProperties.PROPERTIES);
054:
055: /**
056: * Inside this distance from the content panel edge the user can resize the content panel.
057: */
058: public static final IntegerProperty CONTENT_PANEL_EDGE_RESIZE_DISTANCE = IntegerProperty
059: .createPositive(
060: PROPERTIES,
061: "Content Panel Edge Resize Distance",
062: "Inside this distance from the content panel edge the user can resize the content panel.",
063: 2, PropertyMapValueHandler.INSTANCE);
064:
065: /**
066: * The minimum width of the window bar. If greater than 0, the window bar will always be visible and the user can drag
067: * windows to it.
068: */
069: public static final IntegerProperty MINIMUM_WIDTH = IntegerProperty
070: .createPositive(
071: PROPERTIES,
072: "Minimum Width",
073: "The minimum width of the window bar. If greater than 0, the window bar will "
074: + "always be visible and the user can drag windows to it.",
075: 2, PropertyMapValueHandler.INSTANCE);
076:
077: /**
078: * When enabled causes the windows to change size continuously while dragging the split window divider.
079: *
080: * @since IDW 1.4.0
081: */
082: public static final BooleanProperty CONTINUOUS_LAYOUT_ENABLED = new BooleanProperty(
083: PROPERTIES,
084: "Continuous Layout Enabled",
085: "When enabled causes the selected tab's content to change size continuously while resizing it.",
086: PropertyMapValueHandler.INSTANCE);
087:
088: /**
089: * The drag indicator color.
090: *
091: * @since IDW 1.4.0
092: */
093: public static final ColorProperty DRAG_INDICATOR_COLOR = new ColorProperty(
094: PROPERTIES,
095: "Drag Indicator Color",
096: "The color for the resizer's drag indicator that is shown when continuous layout is disabled.",
097: PropertyMapValueHandler.INSTANCE);
098:
099: /**
100: * Properties for the tab window used by this window bar.
101: */
102: public static final PropertyMapProperty TAB_WINDOW_PROPERTIES = new PropertyMapProperty(
103: PROPERTIES, "Tab Window Properties", "",
104: TabWindowProperties.PROPERTIES);
105:
106: private static WindowBarProperties[] DEFAULT_VALUES = new WindowBarProperties[4];
107:
108: static {
109: final Direction[] directions = Direction.getDirections();
110:
111: for (int i = 0; i < directions.length; i++) {
112: Direction dir = directions[i];
113: WindowBarProperties properties = new WindowBarProperties();
114: properties.getTabWindowProperties()
115: .getTabbedPanelProperties().setTabAreaOrientation(
116: dir);
117: properties.getTabWindowProperties().getTabProperties()
118: .getTitledTabProperties().getNormalProperties()
119: .setDirection(
120: dir.isHorizontal() ? Direction.DOWN
121: : Direction.RIGHT);
122: /* properties.getTabWindowProperties().getTabbedPanelProperties().getContentPanelProperties().
123: getComponentProperties().setInsets(new Insets(dir == Direction.DOWN ? 40 : 0,
124: dir == Direction.RIGHT ? 40 : 0,
125: dir == Direction.UP ? 40 : 0,
126: dir == Direction. LEFT ? 40 : 0));*/
127: DEFAULT_VALUES[dir.getValue()] = properties;
128: }
129: }
130:
131: /**
132: * Creates a property object which inherits the default property values.
133: *
134: * @param location the location of the window bar
135: * @return a property object which inherits the default property values
136: */
137: public static WindowBarProperties createDefault(Direction location) {
138: return new WindowBarProperties(DEFAULT_VALUES[location
139: .getValue()]);
140: }
141:
142: /**
143: * Creates an empty property object.
144: */
145: public WindowBarProperties() {
146: super (PropertyMapFactory.create(PROPERTIES));
147: }
148:
149: /**
150: * Creates a property object containing the map.
151: *
152: * @param map the property map
153: */
154: public WindowBarProperties(PropertyMap map) {
155: super (map);
156: }
157:
158: /**
159: * Creates a property object that inherit values from another property object.
160: *
161: * @param inheritFrom the object from which to inherit property values
162: */
163: public WindowBarProperties(WindowBarProperties inheritFrom) {
164: super (PropertyMapFactory.create(inheritFrom.getMap()));
165: }
166:
167: /**
168: * Adds a super object from which property values are inherited.
169: *
170: * @param properties the object from which to inherit property values
171: * @return this
172: */
173: public WindowBarProperties addSuperObject(
174: WindowBarProperties properties) {
175: getMap().addSuperMap(properties.getMap());
176: return this ;
177: }
178:
179: /**
180: * Removes the last added super object.
181: *
182: * @return this
183: * @since IDW 1.1.0
184: * @deprecated Use {@link #removeSuperObject(WindowBarProperties)} instead.
185: */
186: public WindowBarProperties removeSuperObject() {
187: getMap().removeSuperMap();
188: return this ;
189: }
190:
191: /**
192: * Removes a super object.
193: *
194: * @param superObject the super object to remove
195: * @return this
196: * @since IDW 1.3.0
197: */
198: public WindowBarProperties removeSuperObject(
199: WindowBarProperties super Object) {
200: getMap().removeSuperMap(super Object.getMap());
201: return this ;
202: }
203:
204: /**
205: * Returns the distance from the content panel edge which inside the user can resize the content panel.
206: *
207: * @return the distance from the content panel edge which inside the user can resize the content panel
208: */
209: public int getContentPanelEdgeResizeDistance() {
210: return CONTENT_PANEL_EDGE_RESIZE_DISTANCE.get(getMap());
211: }
212:
213: /**
214: * Sets the distance from the content panel edge which inside the user can resize the content panel.
215: *
216: * @param width the distance from the content panel edge which inside the user can resize the content panel
217: * @return this
218: */
219: public WindowBarProperties setContentPanelEdgeResizeEdgeDistance(
220: int width) {
221: CONTENT_PANEL_EDGE_RESIZE_DISTANCE.set(getMap(), width);
222: return this ;
223: }
224:
225: /**
226: * Returns the minimum width of the window bar.
227: *
228: * @return the minimum width of the window bar
229: */
230: public int getMinimumWidth() {
231: return MINIMUM_WIDTH.get(getMap());
232: }
233:
234: /**
235: * Sets the minimum width of the window bar.
236: *
237: * @param width the minimum width of the window bar
238: * @return this
239: */
240: public WindowBarProperties setMinimumWidth(int width) {
241: MINIMUM_WIDTH.set(getMap(), width);
242: return this ;
243: }
244:
245: /**
246: * Returns the tab window property values.
247: *
248: * @return the tab window property values
249: */
250: public TabWindowProperties getTabWindowProperties() {
251: return new TabWindowProperties(TAB_WINDOW_PROPERTIES
252: .get(getMap()));
253: }
254:
255: /**
256: * Returns the property values for the window bar component.
257: *
258: * @return the property values for the window bar component
259: */
260: public ComponentProperties getComponentProperties() {
261: return new ComponentProperties(COMPONENT_PROPERTIES
262: .get(getMap()));
263: }
264:
265: /**
266: * Sets the resizer's drag indicator color.
267: *
268: * @param color the color for the drag indicator
269: * @return this
270: * @since IDW 1.4.0
271: */
272: public WindowBarProperties setDragIndicatorColor(Color color) {
273: DRAG_INDICATOR_COLOR.set(getMap(), color);
274: return this ;
275: }
276:
277: /**
278: * Returns the resizer's drag indicator color.
279: *
280: * @return the drag indicator color
281: * @since IDW 1.4.0
282: */
283: public Color getDragIndicatorColor() {
284: return DRAG_INDICATOR_COLOR.get(getMap());
285: }
286:
287: /**
288: * Returns true if continuous layout is enabled.
289: *
290: * @return true if continuous layout is enabled
291: * @since IDW 1.4.0
292: */
293: public boolean getContinuousLayoutEnabled() {
294: return CONTINUOUS_LAYOUT_ENABLED.get(getMap());
295: }
296:
297: /**
298: * Enables/disables continuous layout.
299: *
300: * @param enabled if true continuous layout is enabled
301: * @return this
302: * @since IDW 1.4.0
303: */
304: public WindowBarProperties setContinuousLayoutEnabled(
305: boolean enabled) {
306: CONTINUOUS_LAYOUT_ENABLED.set(getMap(), enabled);
307: return this;
308: }
309: }
|