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: WindowTabButtonProperties.java,v 1.16 2005/02/16 11:28:14 jesper Exp $
023: package net.infonode.docking.properties;
024:
025: import net.infonode.docking.action.DockingWindowAction;
026: import net.infonode.docking.action.DockingWindowActionProperty;
027: import net.infonode.gui.button.ButtonFactory;
028: import net.infonode.properties.propertymap.*;
029: import net.infonode.properties.types.BooleanProperty;
030: import net.infonode.properties.types.ButtonFactoryProperty;
031: import net.infonode.properties.types.IconProperty;
032: import net.infonode.properties.types.StringProperty;
033:
034: import javax.swing.*;
035:
036: /**
037: * Properties and property values for a button in a window tab.
038: *
039: * @author $Author: jesper $
040: * @version $Revision: 1.16 $
041: */
042: public class WindowTabButtonProperties extends PropertyMapContainer {
043: /**
044: * Property group containing all window tab button properties.
045: */
046: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
047: "Window Tab Button Properties", "");
048:
049: /**
050: * True if the button is visible.
051: */
052: public static final BooleanProperty VISIBLE = new BooleanProperty(
053: PROPERTIES, "Visible", "True if the button is visible.",
054: PropertyMapValueHandler.INSTANCE);
055:
056: /**
057: * The button icon.
058: */
059: public static final IconProperty ICON = new IconProperty(
060: PROPERTIES, "Icon", "The button icon.",
061: PropertyMapValueHandler.INSTANCE);
062:
063: /**
064: * The button tool tip text.
065: *
066: * @since IDW 1.1.0
067: */
068: public static final StringProperty TOOL_TIP_TEXT = new StringProperty(
069: PROPERTIES, "Tool Tip Text", "The button tool tip text.",
070: PropertyMapValueHandler.INSTANCE);
071:
072: /**
073: * The {@link DockingWindowAction} that is performed when the button is clicked.
074: *
075: * @since IDW 1.3.0
076: */
077: public static final DockingWindowActionProperty ACTION = new DockingWindowActionProperty(
078: PROPERTIES, "Action",
079: "The action that is performed when the button is clicked.",
080: PropertyMapValueHandler.INSTANCE);
081:
082: /**
083: * The button factory.
084: * This factory is used to create the button when it's first needed. Modifying this property will NOT cause already
085: * created buttons to be replaced. The created button will be set to non-focusable and will be assigned the icon from
086: * {@link #ICON} and the tool tip from {@link #TOOL_TIP_TEXT}. An action listener is also added to the button.
087: *
088: * @since IDW 1.1.0
089: */
090: public static final ButtonFactoryProperty FACTORY = new ButtonFactoryProperty(
091: PROPERTIES,
092: "Factory",
093: "The button factory. This factory is used to create the button when it's first needed. "
094: + "Modifying this property will NOT cause already created buttons to be replaced. The "
095: + "created button will be set to non-focusable and will be assigned the icon from the '"
096: + ICON.getName()
097: + "' property and the tool tip from the '"
098: + TOOL_TIP_TEXT.getName()
099: + "' "
100: + "property. An action listener that performs the action in set in the '"
101: + ACTION.getName()
102: + "' property is added to the button.",
103: PropertyMapValueHandler.INSTANCE);
104:
105: /**
106: * Creates an empty property object.
107: */
108: public WindowTabButtonProperties() {
109: super (PROPERTIES);
110: }
111:
112: /**
113: * Creates a property object containing the map.
114: *
115: * @param map the property map
116: */
117: public WindowTabButtonProperties(PropertyMap map) {
118: super (map);
119: }
120:
121: /**
122: * Creates a property object that inherit values from another property object.
123: *
124: * @param inheritFrom the object from which to inherit property values
125: */
126: public WindowTabButtonProperties(
127: WindowTabButtonProperties inheritFrom) {
128: super (PropertyMapFactory.create(inheritFrom.getMap()));
129: }
130:
131: /**
132: * Adds a super object from which property values are inherited.
133: *
134: * @param properties the object from which to inherit property values
135: * @return this
136: */
137: public WindowTabButtonProperties addSuperObject(
138: WindowTabButtonProperties properties) {
139: getMap().addSuperMap(properties.getMap());
140: return this ;
141: }
142:
143: /**
144: * Removes the last added super object.
145: *
146: * @return this
147: * @since IDW 1.1.0
148: * @deprecated Use {@link #removeSuperObject(WindowTabButtonProperties)} instead.
149: */
150: public WindowTabButtonProperties removeSuperObject() {
151: getMap().removeSuperMap();
152: return this ;
153: }
154:
155: /**
156: * Removes a super object.
157: *
158: * @param superObject the super object to remove
159: * @return this
160: * @since IDW 1.3.0
161: */
162: public WindowTabButtonProperties removeSuperObject(
163: WindowTabButtonProperties super Object) {
164: getMap().removeSuperMap(super Object.getMap());
165: return this ;
166: }
167:
168: /**
169: * Set to true if this button should be visible.
170: *
171: * @param visible true if this button should be visible
172: * @return this
173: */
174: public WindowTabButtonProperties setVisible(boolean visible) {
175: VISIBLE.set(getMap(), visible);
176: return this ;
177: }
178:
179: /**
180: * Returns true if this button is visible.
181: *
182: * @return true if this button is visible
183: */
184: public boolean isVisible() {
185: return VISIBLE.get(getMap());
186: }
187:
188: /**
189: * Sets the button icon.
190: *
191: * @param icon the button icon
192: * @return this
193: */
194: public WindowTabButtonProperties setIcon(Icon icon) {
195: ICON.set(getMap(), icon);
196: return this ;
197: }
198:
199: /**
200: * Returns the button icon.
201: *
202: * @return the button icon
203: */
204: public Icon getIcon() {
205: return ICON.get(getMap());
206: }
207:
208: /**
209: * Returns the button tool tip text.
210: *
211: * @return the button tool tip text
212: * @since IDW 1.1.0
213: */
214: public String getToolTipText() {
215: return TOOL_TIP_TEXT.get(getMap());
216: }
217:
218: /**
219: * Sets the button tool tip text.
220: *
221: * @param text the button tool tip text
222: * @return this
223: * @since IDW 1.1.0
224: */
225: public WindowTabButtonProperties setToolTipText(String text) {
226: TOOL_TIP_TEXT.set(getMap(), text);
227: return this ;
228: }
229:
230: /**
231: * Gets the button factory.
232: * This factory is used to create the button when it's first needed. Modifying this property will NOT cause already
233: * created buttons to be replaced. The created button will be set to non-focusable and will be assigned the icon from
234: * {@link #ICON} and the tool tip from {@link #TOOL_TIP_TEXT}. An action listener is also added to the button.
235: *
236: * @return the button factory
237: * @since IDW 1.1.0
238: */
239: public ButtonFactory getFactory() {
240: return FACTORY.get(getMap());
241: }
242:
243: /**
244: * Sets the button factory.
245: * This factory is used to create the button when it's first needed. Modifying this property will NOT cause already
246: * created buttons to be replaced. The created button will be set to non-focusable and will be assigned the icon from
247: * {@link #ICON} and the tool tip from {@link #TOOL_TIP_TEXT}. An action listener is also added to the button.
248: *
249: * @param factory the button factory
250: * @return this
251: * @since IDW 1.1.0
252: */
253: public WindowTabButtonProperties setFactory(ButtonFactory factory) {
254: FACTORY.set(getMap(), factory);
255: return this ;
256: }
257:
258: /**
259: * Gets the {@link DockingWindowAction} that is performed when the button is clicked.
260: *
261: * @return the {@link DockingWindowAction} that is performed when the button is clicked
262: * @since IDW 1.3.0
263: */
264: public DockingWindowAction getAction() {
265: return ACTION.get(getMap());
266: }
267:
268: /**
269: * Sets the {@link DockingWindowAction} that will be performed when the button is clicked.
270: *
271: * @param action the {@link DockingWindowAction} that is performed when the button is clicked
272: * @return this
273: * @since IDW 1.3.0
274: */
275: public WindowTabButtonProperties setAction(
276: DockingWindowAction action) {
277: ACTION.set(getMap(), action);
278: return this ;
279: }
280:
281: /**
282: * Sets the action is performed when the button is clicked.
283: * Also sets the icon and tooltip text of the button using the values from
284: * {@link DockingWindowAction}.
285: *
286: * @param action the action that is performed when the button is clicked
287: * @return this
288: * @since IDW 1.3.0
289: */
290: public WindowTabButtonProperties setTo(DockingWindowAction action) {
291: setAction(action);
292: setIcon(action.getIcon());
293: setToolTipText(action.getName());
294: return this;
295: }
296:
297: }
|