01: package desktop;
02:
03: import org.wings.SURLIcon;
04:
05: import java.util.HashMap;
06: import java.util.Map;
07:
08: public class ToolRegistry {
09:
10: private static ToolRegistry ref = null;
11: private Map<String, DesktopTool> registeredTools = new HashMap<String, DesktopTool>();
12:
13: private ToolRegistry() {
14: EditorTool ed = new EditorTool();
15: ed.setText("Add new Editor");
16: ed.setIcon(new SURLIcon("../icons/penguin.png"));
17: registerTool("EditorTool", ed);
18:
19: FileOpenerTool op = new FileOpenerTool();
20: op.setText("Open File in Editor");
21: op.setIcon(new SURLIcon("../icons/penguin.png"));
22: registerTool("FileOpenerTool", op);
23:
24: NewsFeedTool news = new NewsFeedTool();
25: news.setText("New Newsfeed");
26: registerTool("NewsfeedTool", news);
27: }
28:
29: public static ToolRegistry getToolRegistry() {
30: if (ref == null)
31: ref = new ToolRegistry();
32:
33: return ref;
34: }
35:
36: public Map<String, DesktopTool> getRegisteredTools() {
37: return registeredTools;
38: }
39:
40: public void registerTool(String toolName, DesktopTool tool) {
41: registeredTools.put(toolName, tool);
42: }
43: }
|