01: package net.refractions.udig.project.ui.tool;
02:
03: import java.util.HashMap;
04: import java.util.HashSet;
05: import java.util.Map;
06: import java.util.Set;
07:
08: /**
09: * Abstract class for action tools.
10: *
11: *
12: * @author Vitalus
13: * @since UDIG 1.1
14: *
15: */
16: public abstract class AbstractActionTool implements ActionTool {
17:
18: /**
19: * Tool context.
20: */
21: protected IToolContext context;
22:
23: private Map<String, Object> properties = new HashMap<String, Object>(
24: 5);
25:
26: /**
27: *
28: * Tool's lifecycle listeners.
29: */
30: private Set<ToolLifecycleListener> listeners = new HashSet<ToolLifecycleListener>();
31:
32: private boolean enabled = true;
33:
34: public AbstractActionTool() {
35: }
36:
37: /**
38: * @see net.refractions.udig.project.ui.tool.Tool#setContext(net.refractions.udig.project.ui.tool.ToolContext)
39: */
40: public void setContext(IToolContext toolContext) {
41: this .context = toolContext;
42: }
43:
44: /**
45: * @see net.refractions.udig.project.ui.tool.Tool#getContext()
46: */
47: public IToolContext getContext() {
48: return context;
49: }
50:
51: /**
52: * @see net.refractions.udig.project.ui.tool.Tool#getProperty()
53: */
54: public Object getProperty(String key) {
55: return properties.get(key);
56:
57: }
58:
59: /**
60: * @see net.refractions.udig.project.ui.tool.Tool#setProperty()
61: */
62: public void setProperty(String key, Object value) {
63: properties.put(key, value);
64: }
65:
66: public boolean isEnabled() {
67: return enabled;
68: }
69:
70: public void setEnabled(boolean enabled) {
71: this .enabled = enabled;
72:
73: }
74:
75: public void addListener(ToolLifecycleListener listener) {
76: listeners.add(listener);
77:
78: }
79:
80: public void removeListener(ToolLifecycleListener listener) {
81: listeners.remove(listener);
82:
83: }
84:
85: }
|