1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.mindcrimeilab.xsanalyzer.actions;
19
20 import java.util.HashMap;
21 import java.util.Map;
22
23 import org.apache.xerces.xs.XSObject;
24 import org.springframework.binding.value.ValueModel;
25 import org.springframework.richclient.command.ActionCommand;
26
27 import de.mindcrimeilab.util.Accessor;
28
29
30
31
32
33
34
35
36
37 public abstract class AbstractXSObjectCommand extends ActionCommand {
38
39 private ValueModel valueModel;
40
41 private Accessor accessor;
42
43
44
45
46 public AbstractXSObjectCommand(String commandId, ValueModel valueModel, Accessor accessor) {
47 super(commandId);
48 this.valueModel = valueModel;
49 this.accessor = accessor;
50 }
51
52
53
54
55 public Accessor<XSObject, ? super Object> getAccessor() {
56 return accessor;
57 }
58
59
60
61
62
63 public void setAccessor(Accessor accessor) {
64 this.accessor = accessor;
65 }
66
67
68
69
70 public ValueModel getValueModel() {
71 return valueModel;
72 }
73
74
75
76
77
78 public void setValueModel(ValueModel valueModel) {
79 this.valueModel = valueModel;
80 }
81
82 protected abstract void executeWrappedExecutor(Map<String, XSObject> parameter);
83
84 @Override
85 protected void doExecuteCommand() {
86 Map<String, XSObject> parameter = new HashMap<String, XSObject>();
87 final Object object = ((Object[]) valueModel.getValue())[0];
88 final XSObject target;
89 if (null != accessor) {
90 target = (XSObject) accessor.getValue(object);
91 }
92 else {
93 target = (XSObject) object;
94 }
95
96 assert target instanceof XSObject;
97
98 parameter.put(TypeHierarchyExecutor.TARGET_OBJECT, target);
99 logger.debug("Getting value from ValueModel [" + valueModel.getValue() + "]");
100 executeWrappedExecutor(parameter);
101 }
102
103 }