01: package org.osbl.client.wings.action;
02:
03: import org.wings.SIcon;
04: import org.wings.SComponent;
05: import org.osbl.client.wings.shell.Client;
06:
07: import javax.swing.*;
08: import java.util.Map;
09: import java.awt.event.ActionEvent;
10: import java.lang.reflect.Constructor;
11:
12: /**
13: * @author hengels
14: * @version $Revision: 1.2 $
15: */
16: @Deprecated
17: public class ShowToolAction extends NavigationAction {
18: protected String className;
19: private Map paramMap;
20:
21: public ShowToolAction(String className, String command, SIcon icon) {
22: this (className, command);
23: putValue(Action.SMALL_ICON, icon);
24: }
25:
26: public ShowToolAction(String className, String command) {
27: this .className = className;
28: putValue(Action.ACTION_COMMAND_KEY, command);
29: putValue(Action.SHORT_DESCRIPTION, command);
30: }
31:
32: public ShowToolAction(String className, String command, Map paramMap) {
33: this (className, command);
34: this .paramMap = paramMap;
35: }
36:
37: public Map getParamMap() {
38: return paramMap;
39: }
40:
41: public void setParamMap(Map paramMap) {
42: this .paramMap = paramMap;
43: }
44:
45: public void actionPerformed(ActionEvent event) {
46: Client.getInstance().show("main",
47: (SComponent) createComponentInstance(paramMap));
48: }
49:
50: protected Object createComponentInstance(Map map) {
51: try {
52: ClassLoader classLoader = Thread.currentThread()
53: .getContextClassLoader();
54: Class cl = classLoader.loadClass(className);
55: if (map != null) {
56: Constructor ctor = cl.getConstructor(Map.class);
57: return ctor.newInstance(map);
58: } else
59: return cl.newInstance();
60: } catch (Exception e) {
61: e.printStackTrace();
62: throw new RuntimeException(e);
63: }
64: }
65:
66: public void navigate(Object object) {
67: actionPerformed(new ActionEvent(this , -1, toString()));
68: }
69:
70: public void navigate(Map<String, String> query) {
71: actionPerformed(new ActionEvent(this , -1, toString()));
72: }
73: }
|