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: ViewTitleBarStateProperties.java,v 1.6 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.gui.util.ShapedPanelProperties;
027: import net.infonode.properties.propertymap.*;
028: import net.infonode.properties.types.*;
029: import net.infonode.util.Alignment;
030:
031: import javax.swing.*;
032:
033: /**
034: * Properties and property values for a view title bar state.
035: *
036: * @author johan
037: * @version $Revision: 1.6 $
038: * @since IDW 1.4.0
039: */
040: public class ViewTitleBarStateProperties extends PropertyMapContainer {
041: /**
042: * Property group containing all view title bar state properties.
043: */
044: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
045: "View Title Bar State Properties", "");
046:
047: /**
048: * Properties for the component
049: *
050: * @see #getComponentProperties
051: */
052: public static final PropertyMapProperty COMPONENT_PROPERTIES = new PropertyMapProperty(
053: PROPERTIES, "Component Properties",
054: "Properties for title bar.", ComponentProperties.PROPERTIES);
055:
056: /**
057: * Properties for the shaped panel
058: *
059: * @see #getShapedPanelProperties
060: */
061: public static final PropertyMapProperty SHAPED_PANEL_PROPERTIES = new PropertyMapProperty(
062: PROPERTIES, "Shaped Panel Properties",
063: "Properties for shaped title bar.",
064: ShapedPanelProperties.PROPERTIES);
065: /**
066: * The minimize button property values.
067: *
068: * @see #getMinimizeButtonProperties
069: */
070: public static final PropertyMapProperty MINIMIZE_BUTTON_PROPERTIES = new PropertyMapProperty(
071: PROPERTIES, "Minimize Button Properties",
072: "The minimize button property values.",
073: WindowTabButtonProperties.PROPERTIES);
074:
075: /**
076: * The minimize button property values.
077: *
078: * @see #getMinimizeButtonProperties
079: */
080: public static final PropertyMapProperty MAXIMIZE_BUTTON_PROPERTIES = new PropertyMapProperty(
081: PROPERTIES, "Maximize Button Properties",
082: "The maximizee button property values.",
083: WindowTabButtonProperties.PROPERTIES);
084: /**
085: * The restore button property values.
086: *
087: * @see #getRestoreButtonProperties
088: */
089: public static final PropertyMapProperty RESTORE_BUTTON_PROPERTIES = new PropertyMapProperty(
090: PROPERTIES, "Restore Button Properties",
091: "The restore button property values.",
092: WindowTabButtonProperties.PROPERTIES);
093:
094: /**
095: * The close button property values.
096: *
097: * @see #getCloseButtonProperties
098: */
099: public static final PropertyMapProperty CLOSE_BUTTON_PROPERTIES = new PropertyMapProperty(
100: PROPERTIES, "Close Button Properties",
101: "The close button property values.",
102: WindowTabButtonProperties.PROPERTIES);
103:
104: /**
105: * The undock button property values.
106: *
107: * @see #getUndockButtonProperties
108: */
109: public static final PropertyMapProperty UNDOCK_BUTTON_PROPERTIES = new PropertyMapProperty(
110: PROPERTIES, "Undock Button Properties",
111: "The undock button property values.",
112: WindowTabButtonProperties.PROPERTIES);
113:
114: /**
115: * The dock button property values.
116: *
117: * @see #getDockButtonProperties
118: */
119: public static final PropertyMapProperty DOCK_BUTTON_PROPERTIES = new PropertyMapProperty(
120: PROPERTIES, "Dock Button Properties",
121: "The dockbutton property values.",
122: WindowTabButtonProperties.PROPERTIES);
123:
124: /**
125: * The title bar title.
126: */
127: public static final StringProperty TITLE = new StringProperty(
128: PROPERTIES, "Title", "The title bar title.",
129: PropertyMapValueHandler.INSTANCE);
130:
131: /**
132: * Title visible property
133: *
134: * @see #setTitleVisible
135: * @see #getTitleVisible
136: */
137: public static final BooleanProperty TITLE_VISIBLE = new BooleanProperty(
138: PROPERTIES, "Title Visible",
139: "Controls if the title should be visible or not.",
140: PropertyMapValueHandler.INSTANCE);
141:
142: /**
143: * The title bar icon.
144: */
145: public static final IconProperty ICON = new IconProperty(
146: PROPERTIES, "Icon", "The title bar icon.",
147: PropertyMapValueHandler.INSTANCE);
148:
149: /**
150: * Icon visible property
151: *
152: * @see #setIconVisible
153: * @see #getIconVisible
154: */
155: public static final BooleanProperty ICON_VISIBLE = new BooleanProperty(
156: PROPERTIES, "Icon Visible",
157: "Controls if the icon should be visible or not.",
158: PropertyMapValueHandler.INSTANCE);
159: /**
160: * Icon text gap property
161: *
162: * @see #setIconTextGap
163: * @see #getIconTextGap
164: */
165: public static final IntegerProperty ICON_TEXT_GAP = IntegerProperty
166: .createPositive(PROPERTIES, "Icon Text Gap",
167: "Gap in pixels between the icon and the title", 2,
168: PropertyMapValueHandler.INSTANCE);
169:
170: /**
171: * Icon Text Horizontal alignment property
172: *
173: * @see #setIconTextHorizontalAlignment
174: * @see #getIconTextHorizontalAlignment
175: */
176: public static final AlignmentProperty ICON_TEXT_HORIZONTAL_ALIGNMENT = new AlignmentProperty(
177: PROPERTIES, "Icon Text Horizontal Alignment",
178: "Horizontal alignment for the icon and title text.",
179: PropertyMapValueHandler.INSTANCE, Alignment
180: .getHorizontalAlignments());
181:
182: /**
183: * Button spacing
184: *
185: * @see #setButtonSpacing
186: * @see #getButtonSpacing
187: */
188: public static final IntegerProperty BUTTON_SPACING = IntegerProperty
189: .createPositive(
190: PROPERTIES,
191: "Button Spacing",
192: "Spacing in pixels between the buttons on the title bar",
193: 2, PropertyMapValueHandler.INSTANCE);
194:
195: /**
196: * Creates an empty property object.
197: */
198: public ViewTitleBarStateProperties() {
199: super (PropertyMapFactory.create(PROPERTIES));
200: }
201:
202: /**
203: * Creates a property object containing the map.
204: *
205: * @param map the property map
206: */
207: public ViewTitleBarStateProperties(PropertyMap map) {
208: super (map);
209: }
210:
211: /**
212: * Creates a property object that inherit values from another property object.
213: *
214: * @param inheritFrom the object from which to inherit property values
215: */
216: public ViewTitleBarStateProperties(
217: ViewTitleBarStateProperties inheritFrom) {
218: super (PropertyMapFactory.create(inheritFrom.getMap()));
219: }
220:
221: /**
222: * Adds a super object from which property values are inherited.
223: *
224: * @param properties the object from which to inherit property values
225: * @return this
226: */
227: public ViewTitleBarStateProperties addSuperObject(
228: ViewTitleBarStateProperties properties) {
229: getMap().addSuperMap(properties.getMap());
230:
231: return this ;
232: }
233:
234: /**
235: * Removes a super object.
236: *
237: * @param superObject the super object to remove
238: * @return this
239: */
240: public ViewTitleBarStateProperties removeSuperObject(
241: ViewTitleBarStateProperties super Object) {
242: getMap().removeSuperMap(super Object.getMap());
243: return this ;
244: }
245:
246: /**
247: * Gets the component properties
248: *
249: * @return component properties
250: */
251: public ComponentProperties getComponentProperties() {
252: return new ComponentProperties(COMPONENT_PROPERTIES
253: .get(getMap()));
254: }
255:
256: /**
257: * Gets the shaped panel properties
258: *
259: * @return shaped panel properties
260: */
261: public ShapedPanelProperties getShapedPanelProperties() {
262: return new ShapedPanelProperties(SHAPED_PANEL_PROPERTIES
263: .get(getMap()));
264: }
265:
266: /**
267: * Returns the minimize button property values.
268: *
269: * @return the minimize button property values
270: */
271: public WindowTabButtonProperties getMinimizeButtonProperties() {
272: return new WindowTabButtonProperties(MINIMIZE_BUTTON_PROPERTIES
273: .get(getMap()));
274: }
275:
276: /**
277: * Returns the maximize button property values.
278: *
279: * @return the maximize button property values
280: */
281: public WindowTabButtonProperties getMaximizeButtonProperties() {
282: return new WindowTabButtonProperties(MAXIMIZE_BUTTON_PROPERTIES
283: .get(getMap()));
284: }
285:
286: /**
287: * Returns the restore button property values.
288: *
289: * @return the restore button property values
290: */
291: public WindowTabButtonProperties getRestoreButtonProperties() {
292: return new WindowTabButtonProperties(RESTORE_BUTTON_PROPERTIES
293: .get(getMap()));
294: }
295:
296: /**
297: * Returns the close button property values.
298: *
299: * @return the close button property values
300: */
301: public WindowTabButtonProperties getCloseButtonProperties() {
302: return new WindowTabButtonProperties(CLOSE_BUTTON_PROPERTIES
303: .get(getMap()));
304: }
305:
306: /**
307: * Returns the undock button property values.
308: *
309: * @return the undock button property values
310: */
311: public WindowTabButtonProperties getUndockButtonProperties() {
312: return new WindowTabButtonProperties(UNDOCK_BUTTON_PROPERTIES
313: .get(getMap()));
314: }
315:
316: /**
317: * Returns the dock button property values.
318: *
319: * @return the dock button property values
320: */
321: public WindowTabButtonProperties getDockButtonProperties() {
322: return new WindowTabButtonProperties(DOCK_BUTTON_PROPERTIES
323: .get(getMap()));
324: }
325:
326: /**
327: * Sets the spacing between the buttons on the title bar
328: *
329: * @param spacing spacing in pixels
330: * @return this
331: */
332: public ViewTitleBarStateProperties setButtonSpacing(int spacing) {
333: BUTTON_SPACING.set(getMap(), spacing);
334: return this ;
335: }
336:
337: /**
338: * Returns the spacing between the buttons on the title bar
339: *
340: * @return spacing in pixels
341: */
342: public int getButtonSpacing() {
343: return BUTTON_SPACING.get(getMap());
344: }
345:
346: /**
347: * Sets the title.
348: *
349: * @param title the title
350: * @return this
351: */
352: public ViewTitleBarStateProperties setTitle(String title) {
353: TITLE.set(getMap(), title);
354:
355: return this ;
356: }
357:
358: /**
359: * Returns the view title.
360: *
361: * @return the view title
362: */
363: public String getTitle() {
364: return TITLE.get(getMap());
365: }
366:
367: /**
368: * Sets if the title should be visible or not
369: *
370: * @param visible True for visible, otherwise false
371: * @return this
372: */
373: public ViewTitleBarStateProperties setTitleVisible(boolean visible) {
374: TITLE_VISIBLE.set(getMap(), visible);
375: return this ;
376: }
377:
378: /**
379: * Returns if the title should be visible or not
380: *
381: * @return True if visible, otherwise false
382: */
383: public boolean getTitleVisible() {
384: return TITLE_VISIBLE.get(getMap());
385: }
386:
387: /**
388: * Sets the icon.
389: *
390: * @param icon the icon
391: * @return this
392: */
393: public ViewTitleBarStateProperties setIcon(Icon icon) {
394: ICON.set(getMap(), icon);
395:
396: return this ;
397: }
398:
399: /**
400: * Returns the view icon.
401: *
402: * @return the view icon
403: */
404: public Icon getIcon() {
405: return ICON.get(getMap());
406: }
407:
408: /**
409: * Sets if the icon should be visible or not
410: *
411: * @param visible True for visible, otherwise false
412: * @return this
413: */
414: public ViewTitleBarStateProperties setIconVisible(boolean visible) {
415: ICON_VISIBLE.set(getMap(), visible);
416: return this ;
417: }
418:
419: /**
420: * Returns if the icon should be visible or not
421: *
422: * @return True if visible, otherwise false
423: */
424: public boolean getIconVisible() {
425: return ICON_VISIBLE.get(getMap());
426: }
427:
428: /**
429: * Sets the gap between the icon and the title in the title bar
430: *
431: * @param gap gap in pixels
432: * @return this
433: */
434: public ViewTitleBarStateProperties setIconTextGap(int gap) {
435: ICON_TEXT_GAP.set(getMap(), gap);
436: return this ;
437: }
438:
439: /**
440: * Returns the gap between the icon and the title in the title bar
441: *
442: * @return gap in pixels
443: */
444: public int getIconTextGap() {
445: return ICON_TEXT_GAP.get(getMap());
446: }
447:
448: /**
449: * Sets the text's and icon's horizontal alignment
450: *
451: * @param alignment text and icon alignment
452: * @return this
453: */
454: public ViewTitleBarStateProperties setIconTextHorizontalAlignment(
455: Alignment alignment) {
456: ICON_TEXT_HORIZONTAL_ALIGNMENT.set(getMap(), alignment);
457: return this ;
458: }
459:
460: /**
461: * Gets the text's and icon's horizontal alignment
462: *
463: * @return text and icon alignment
464: */
465: public Alignment getIconTextHorizontalAlignment() {
466: return ICON_TEXT_HORIZONTAL_ALIGNMENT.get(getMap());
467: }
468: }
|