001: package net.suberic.util.swing;
002:
003: import net.suberic.util.*;
004: import java.util.*;
005: import javax.swing.*;
006: import javax.swing.plaf.metal.*;
007: import javax.swing.plaf.*;
008:
009: /**
010: *
011: */
012: public class ThemeWrapperItem implements Item, ValueChangeListener {
013:
014: private String itemId;
015: private String resourceString;
016:
017: private VariableBundle bundle = null;
018:
019: private WeakHashMap themeListenerList = new WeakHashMap();
020:
021: private MetalTheme mWrappedTheme = null;
022:
023: /**
024: * Creates a new ItemOcreanTheme from the given property.
025: */
026: public ThemeWrapperItem(VariableBundle sourceBundle,
027: String newResourceString, String newItemId) {
028: itemId = newItemId;
029: resourceString = newResourceString;
030:
031: bundle = sourceBundle;
032:
033: sourceBundle.addValueChangeListener(this , getItemProperty()
034: + ".*");
035: }
036:
037: /**
038: * Sets the wrapped theme.
039: */
040: public void setWrappedTheme(MetalTheme pWrappedTheme) {
041: mWrappedTheme = pWrappedTheme;
042: }
043:
044: /**
045: * Gets the wrapped theme.
046: */
047: public MetalTheme getWrappedTheme() {
048: return mWrappedTheme;
049: }
050:
051: /**
052: * The Item ID. For example, if you were to have a list of users, a
053: * given user's itemID may be "defaultUser".
054: */
055: public String getItemID() {
056: return itemId;
057: }
058:
059: /**
060: * The Item property. For example, if you were to have a list of users, a
061: * given user's itemProperty may be "Users.defaultUser".
062: */
063: public String getItemProperty() {
064: return resourceString + "." + itemId;
065: }
066:
067: /**
068: * Called when a ui value changes.
069: */
070: public void valueChanged(String changedValue) {
071: fireThemeChangedEvent();
072: }
073:
074: /**
075: * Adds a ThemeListener to the ListenerList.
076: */
077: public void addThemeListener(ThemeListener tl) {
078: if (!themeListenerList.containsKey(tl))
079: themeListenerList.put(tl, null);
080: }
081:
082: /**
083: * Removes a ThemeListener from the ListenerList.
084: */
085: public void removeThemeListener(ThemeListener tl) {
086: themeListenerList.remove(tl);
087: }
088:
089: /**
090: * Notifies all registered ThemeListeners that this Theme has changed.
091: */
092: public void fireThemeChangedEvent() {
093: // no-op. this theme doesn't change.
094: }
095:
096: public String getName() {
097: return getItemID();
098: }
099:
100: }
|