01: package org.osbl.client.wings.shell;
02:
03: import java.beans.PropertyChangeListener;
04: import java.beans.PropertyChangeSupport;
05: import java.util.*;
06:
07: /**
08: * @author hengels
09: * @version $Revision$
10: */
11: public abstract class AbstractTool implements Tool {
12: Map values = new HashMap();
13: boolean enabled = true;
14: PropertyChangeSupport changeSupport = new PropertyChangeSupport(
15: this );
16:
17: public Object getValue(String key) {
18: return values.get(key);
19: }
20:
21: public void putValue(String key, Object value) {
22: Object oldValue = values.put(key, value);
23: changeSupport.firePropertyChange(key, oldValue, value);
24: }
25:
26: public boolean isEnabled() {
27: return enabled;
28: }
29:
30: public void setEnabled(boolean enabled) {
31: boolean oldEnabled = this .enabled;
32: this .enabled = enabled;
33: changeSupport
34: .firePropertyChange("enabled", oldEnabled, enabled);
35: }
36:
37: public void addPropertyChangeListener(
38: PropertyChangeListener listener) {
39: changeSupport.addPropertyChangeListener(listener);
40: }
41:
42: public void removePropertyChangeListener(
43: PropertyChangeListener listener) {
44: changeSupport.removePropertyChangeListener(listener);
45: }
46:
47: public boolean equals(Object o) {
48: if (this == o)
49: return true;
50: if (o == null || getClass() != o.getClass())
51: return false;
52:
53: final AbstractTool that = (AbstractTool) o;
54:
55: if (values.get(KEY) != null ? !values.get(KEY).equals(
56: that.values.get(KEY)) : that.values.get(KEY) != null)
57: return false;
58:
59: return true;
60: }
61:
62: public int hashCode() {
63: return (values.get(KEY) != null ? values.get(KEY).hashCode()
64: : 0);
65: }
66:
67: public String toString() {
68: return (String) values.get(NAME);
69: }
70: }
|