01: package org.enhydra.jawe;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05: import java.util.Observer;
06:
07: import org.enhydra.shark.xpdl.XMLElementChangeInfo;
08:
09: /**
10: * Structure representing info for the change of some XPDL Element.
11: *
12: * @author Sasa Bojanic
13: */
14: public class XPDLElementChangeInfo extends XMLElementChangeInfo {
15: public static final int SELECTED = 8;
16: public static final int REFERENCES = 9;
17: public static final int VALIDATION_ERRORS = 10;
18: public static final int UNDOABLE_ACTION_STARTED = 13;
19: public static final int ADJUST_UNDOABLE_ACTION = 14;
20: public static final int UNDOABLE_ACTION_ENDED = 15;
21: public static final int UNDO = 16;
22: public static final int REDO = 17;
23: public static final int COPY = 18;
24: public static final int CUT = 19;
25: public static final int SEARCH_RESULT = 20;
26:
27: private static Map actionToNameMap = new HashMap();
28: static {
29: actionToNameMap
30: .put(new Integer(XPDLElementChangeInfo.SELECTED),
31: "SELECTED");
32: actionToNameMap.put(new Integer(
33: XPDLElementChangeInfo.REFERENCES), "REFERENCES");
34: actionToNameMap.put(new Integer(
35: XPDLElementChangeInfo.VALIDATION_ERRORS),
36: "VALIDATION_ERRORS");
37: actionToNameMap.put(new Integer(
38: XPDLElementChangeInfo.UNDOABLE_ACTION_STARTED),
39: "UNDOABLE_ACTION_STARTED");
40: actionToNameMap.put(new Integer(
41: XPDLElementChangeInfo.ADJUST_UNDOABLE_ACTION),
42: "ADJUST_UNDOABLE_ACTION");
43: actionToNameMap.put(new Integer(
44: XPDLElementChangeInfo.UNDOABLE_ACTION_ENDED),
45: "UNDOABLE_ACTION_ENDED");
46: actionToNameMap.put(new Integer(XPDLElementChangeInfo.UNDO),
47: "UNDO");
48: actionToNameMap.put(new Integer(XPDLElementChangeInfo.REDO),
49: "REDO");
50: actionToNameMap.put(new Integer(XPDLElementChangeInfo.COPY),
51: "COPY");
52: actionToNameMap.put(new Integer(XPDLElementChangeInfo.CUT),
53: "CUT");
54: }
55:
56: protected Observer source;
57:
58: public XPDLElementChangeInfo() {
59: }
60:
61: public XPDLElementChangeInfo(Observer source,
62: XMLElementChangeInfo info) {
63: this .setAction(info.getAction());
64: this .setChangedElement(info.getChangedElement());
65: this .setChangedSubElements(info.getChangedSubElements());
66: this .setNewValue(info.getNewValue());
67: this .setOldValue(info.getOldValue());
68: this .setSource(source);
69: }
70:
71: public void setSource(Observer source) {
72: this .source = source;
73: }
74:
75: public Observer getSource() {
76: return source;
77: }
78:
79: public String getActionName() {
80: String ret = super .getActionName();
81: if (ret == null) {
82: ret = (String) actionToNameMap.get(new Integer(action));
83: }
84: return ret;
85: }
86:
87: public String toString() {
88:
89: String ret = "Source="
90: + (source != null ? source.getClass().getName() : "")
91: + ", " + " oldVal = " + getOldValue() + ", "
92: + " newVal = " + getNewValue() + ", "
93: + super.toString();
94: return ret;
95: }
96:
97: }
|