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: ViewProperties.java,v 1.21 2005/12/04 13:46:04 jesper Exp $
023: package net.infonode.docking.properties;
024:
025: import net.infonode.properties.propertymap.*;
026: import net.infonode.properties.types.BooleanProperty;
027: import net.infonode.properties.types.IconProperty;
028: import net.infonode.properties.types.StringProperty;
029:
030: import javax.swing.*;
031:
032: /**
033: * Properties and property values for views.
034: *
035: * @author $Author: jesper $
036: * @version $Revision: 1.21 $
037: */
038: public class ViewProperties extends PropertyMapContainer {
039: /**
040: * Property group containing all view properties.
041: */
042: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
043: "View Properties", "");
044:
045: /**
046: * Properties for the view title bar
047: *
048: * @see #getViewTitleBarProperties
049: * @since IDW 1.4.0
050: */
051: public static final PropertyMapProperty VIEW_TITLE_BAR_PROPERTIES = new PropertyMapProperty(
052: PROPERTIES, "View Title Bar Properties",
053: "Properties for view's title bar.",
054: ViewTitleBarProperties.PROPERTIES);
055:
056: /**
057: * If true the view will always be placed in a TabWindow so that it's title is shown.
058: */
059: public static final BooleanProperty ALWAYS_SHOW_TITLE = new BooleanProperty(
060: PROPERTIES,
061: "Always Show Title",
062: "If true the view will always be placed in a TabWindow so that it's title is shown.",
063: PropertyMapValueHandler.INSTANCE);
064:
065: /**
066: * The view title.
067: */
068: public static final StringProperty TITLE = new StringProperty(
069: PROPERTIES, "Title", "The view title.",
070: PropertyMapValueHandler.INSTANCE);
071:
072: /**
073: * The view icon.
074: */
075: public static final IconProperty ICON = new IconProperty(
076: PROPERTIES, "Icon", "The view icon.",
077: PropertyMapValueHandler.INSTANCE);
078:
079: static {
080: new ViewProperties(PROPERTIES.getDefaultMap())
081: .setAlwaysShowTitle(true);
082: }
083:
084: /**
085: * Creates an empty property object.
086: */
087: public ViewProperties() {
088: super (PropertyMapFactory.create(PROPERTIES));
089: }
090:
091: /**
092: * Creates a property object containing the map.
093: *
094: * @param map the property map
095: */
096: public ViewProperties(PropertyMap map) {
097: super (map);
098: }
099:
100: /**
101: * Creates a property object that inherit values from another property object.
102: *
103: * @param inheritFrom the object from which to inherit property values
104: */
105: public ViewProperties(ViewProperties inheritFrom) {
106: super (PropertyMapFactory.create(inheritFrom.getMap()));
107: }
108:
109: /**
110: * Adds a super object from which property values are inherited.
111: *
112: * @param properties the object from which to inherit property values
113: * @return this
114: */
115: public ViewProperties addSuperObject(ViewProperties properties) {
116: getMap().addSuperMap(properties.getMap());
117:
118: return this ;
119: }
120:
121: /**
122: * Removes the last added super object.
123: *
124: * @return this
125: * @since IDW 1.1.0
126: * @deprecated Use {@link #removeSuperObject(ViewProperties)} instead.
127: */
128: public ViewProperties removeSuperObject() {
129: getMap().removeSuperMap();
130: return this ;
131: }
132:
133: /**
134: * Removes a super object.
135: *
136: * @param superObject the super object to remove
137: * @return this
138: * @since IDW 1.3.0
139: */
140: public ViewProperties removeSuperObject(ViewProperties super Object) {
141: getMap().removeSuperMap(super Object.getMap());
142: return this ;
143: }
144:
145: /**
146: * Returns the property values for the title bar in the view
147: *
148: * @return the property values for the title bar in the view
149: * @since IDW 1.4.0
150: */
151: public ViewTitleBarProperties getViewTitleBarProperties() {
152: return new ViewTitleBarProperties(VIEW_TITLE_BAR_PROPERTIES
153: .get(getMap()));
154: }
155:
156: /**
157: * Returns true if the view shows it's title even though it's not in a tabbed panel with other windows.
158: *
159: * @return true if the view shows it's title even though it's not in a tabbed panel with other windows
160: */
161: public boolean getAlwaysShowTitle() {
162: return ALWAYS_SHOW_TITLE.get(getMap());
163: }
164:
165: /**
166: * Set to true the view should always be placed in a TabWindow so that it's title is shown.
167: *
168: * @param showTitle true the view should always be placed in a TabWindow so that it's title is shown
169: * @return this
170: */
171: public ViewProperties setAlwaysShowTitle(boolean showTitle) {
172: ALWAYS_SHOW_TITLE.set(getMap(), showTitle);
173:
174: return this ;
175: }
176:
177: /**
178: * Sets the view title.
179: *
180: * @param title the view title
181: * @return this
182: */
183: public ViewProperties setTitle(String title) {
184: TITLE.set(getMap(), title);
185:
186: return this ;
187: }
188:
189: /**
190: * Sets the view icon.
191: *
192: * @param icon the view icon
193: * @return this
194: */
195: public ViewProperties setIcon(Icon icon) {
196: ICON.set(getMap(), icon);
197:
198: return this ;
199: }
200:
201: /**
202: * Returns the view title.
203: *
204: * @return the view title
205: */
206: public String getTitle() {
207: return TITLE.get(getMap());
208: }
209:
210: /**
211: * Returns the view icon.
212: *
213: * @return the view icon
214: */
215: public Icon getIcon() {
216: return ICON.get(getMap());
217: }
218: }
|