001: /*
002: * Copyright 2006 Ethan Nicholas. All rights reserved.
003: * Use is subject to license terms.
004: */
005: package jaxx.runtime.swing;
006:
007: import java.awt.*;
008: import java.beans.*;
009: import javax.swing.*;
010: import javax.swing.event.*;
011:
012: public class TabInfo {
013: public static String BACKGROUND_PROPERTY = "background";
014: public static String DISABLED_ICON_PROPERTY = "disabledIcon";
015: public static String DISPLAYED_MNEMONIC_INDEX_PROPERTY = "displayedMnemonicIndex";
016: public static String ENABLED_PROPERTY = "enabled";
017: public static String FOREGROUND_PROPERTY = "foreground";
018: public static String ICON_PROPERTY = "icon";
019: public static String MNEMONIC_PROPERTY = "mnemonic";
020: public static String TITLE_PROPERTY = "title";
021: public static String TOOL_TIP_TEXT_PROPERTY = "toolTipText";
022:
023: private String id;
024: private Color background;
025: private Icon disabledIcon;
026: private int displayedMnemonicIndex = -1;
027: private boolean enabled = true;
028: private Color foreground;
029: private Icon icon;
030: private int mnemonic = -1;
031: private String title;
032: private String toolTipText;
033:
034: private PropertyChangeSupport propertyChangeSupport;
035:
036: public TabInfo() {
037: }
038:
039: public TabInfo(String id) {
040: this .id = id;
041: }
042:
043: public String getId() {
044: return id;
045: }
046:
047: public Color getBackground() {
048: return background;
049: }
050:
051: public void setBackground(Color background) {
052: Color oldValue = this .background;
053: this .background = background;
054: firePropertyChange(BACKGROUND_PROPERTY, oldValue, background);
055: }
056:
057: public Icon getDisabledIcon() {
058: return disabledIcon;
059: }
060:
061: public void setDisabledIcon(Icon disabledIcon) {
062: Icon oldValue = this .disabledIcon;
063: this .disabledIcon = disabledIcon;
064: firePropertyChange(DISABLED_ICON_PROPERTY, oldValue,
065: disabledIcon);
066: }
067:
068: public int getDisplayedMnemonicIndex() {
069: return displayedMnemonicIndex;
070: }
071:
072: public void setDisplayedMnemonicIndex(int displayedMnemonicIndex) {
073: int oldValue = this .displayedMnemonicIndex;
074: this .displayedMnemonicIndex = displayedMnemonicIndex;
075: firePropertyChange(DISPLAYED_MNEMONIC_INDEX_PROPERTY,
076: new Integer(oldValue), new Integer(
077: displayedMnemonicIndex));
078: }
079:
080: public boolean isEnabled() {
081: return enabled;
082: }
083:
084: public void setEnabled(boolean enabled) {
085: boolean oldValue = this .enabled;
086: this .enabled = enabled;
087: firePropertyChange(ENABLED_PROPERTY, new Boolean(oldValue),
088: new Boolean(enabled));
089: }
090:
091: public Color getForeground() {
092: return foreground;
093: }
094:
095: public void setForeground(Color foreground) {
096: Color oldValue = this .foreground;
097: this .foreground = foreground;
098: firePropertyChange(FOREGROUND_PROPERTY, oldValue, foreground);
099: }
100:
101: public Icon getIcon() {
102: return icon;
103: }
104:
105: public void setIcon(Icon icon) {
106: Icon oldValue = this .icon;
107: this .icon = icon;
108: firePropertyChange(ICON_PROPERTY, oldValue, icon);
109: }
110:
111: public int getMnemonic() {
112: return mnemonic;
113: }
114:
115: public void setMnemonic(int mnemonic) {
116: int oldValue = this .mnemonic;
117: this .mnemonic = mnemonic;
118: firePropertyChange(MNEMONIC_PROPERTY, new Integer(oldValue),
119: new Integer(mnemonic));
120: }
121:
122: public String getTitle() {
123: return title;
124: }
125:
126: public void setTitle(String title) {
127: String oldValue = this .title;
128: this .title = title;
129: firePropertyChange(TITLE_PROPERTY, oldValue, title);
130: }
131:
132: public String getToolTipText() {
133: return toolTipText;
134: }
135:
136: public void setToolTipText(String toolTipText) {
137: String oldValue = this .toolTipText;
138: this .toolTipText = toolTipText;
139: firePropertyChange(TOOL_TIP_TEXT_PROPERTY, oldValue,
140: toolTipText);
141: }
142:
143: private PropertyChangeSupport getPropertyChangeSupport() {
144: if (propertyChangeSupport == null)
145: propertyChangeSupport = new SwingPropertyChangeSupport(this );
146: return propertyChangeSupport;
147: }
148:
149: public void addPropertyChangeListener(
150: PropertyChangeListener listener) {
151: getPropertyChangeSupport().addPropertyChangeListener(listener);
152: }
153:
154: public void addPropertyChangeListener(String property,
155: PropertyChangeListener listener) {
156: getPropertyChangeSupport().addPropertyChangeListener(property,
157: listener);
158: }
159:
160: public void removePropertyChangeListener(
161: PropertyChangeListener listener) {
162: getPropertyChangeSupport().removePropertyChangeListener(
163: listener);
164: }
165:
166: public void removePropertyChangeListener(String property,
167: PropertyChangeListener listener) {
168: getPropertyChangeSupport().removePropertyChangeListener(
169: property, listener);
170: }
171:
172: protected void firePropertyChange(String propertyName,
173: Object oldValue, Object newValue) {
174: if (propertyChangeSupport != null)
175: getPropertyChangeSupport().firePropertyChange(propertyName,
176: oldValue, newValue);
177: }
178: }
|