01: package org.enhydra.jawe.base.panel;
02:
03: import java.util.ArrayList;
04:
05: import org.enhydra.shark.utilities.SequencedHashMap;
06: import org.enhydra.shark.xpdl.XMLComplexChoice;
07: import org.enhydra.shark.xpdl.XMLElement;
08: import org.enhydra.shark.xpdl.XPDLConstants;
09: import org.enhydra.shark.xpdl.elements.Activity;
10: import org.enhydra.shark.xpdl.elements.ActivityTypes;
11:
12: /**
13: * Helper element for displaying choices of other elements.
14: *
15: * @author Sasa Bojanic
16: */
17: public class ActivityTypesChoiceElement extends XMLComplexChoice {
18:
19: protected ActivityTypes controlled;
20:
21: public ActivityTypesChoiceElement(ActivityTypes controlled) {
22: super (null, controlled.toName(), true);
23: this .controlled = controlled;
24: int type = ((Activity) controlled.getParent())
25: .getActivityType();
26: SequencedHashMap chsMap = new SequencedHashMap();
27: chsMap.put(new Integer(XPDLConstants.ACTIVITY_TYPE_BLOCK),
28: controlled.getBlockActivity());
29: chsMap.put(new Integer(XPDLConstants.ACTIVITY_TYPE_NO),
30: controlled.getImplementation().getImplementationTypes()
31: .getNo());
32: chsMap.put(new Integer(XPDLConstants.ACTIVITY_TYPE_ROUTE),
33: controlled.getRoute());
34: chsMap.put(new Integer(XPDLConstants.ACTIVITY_TYPE_SUBFLOW),
35: controlled.getImplementation().getImplementationTypes()
36: .getSubFlow());
37: chsMap.put(new Integer(XPDLConstants.ACTIVITY_TYPE_TOOL),
38: controlled.getImplementation().getImplementationTypes()
39: .getTools());
40: choosen = (XMLElement) chsMap.get(new Integer(type));
41: this .choices = new ArrayList(chsMap.values());
42: }
43:
44: public void setChoosen(XMLElement ch) {
45: super .setChoosen(ch);
46: if (ch.getParent() == controlled) {
47: controlled.setChoosen(ch);
48: } else {
49: controlled.setImplementation();
50: controlled.getImplementation().getImplementationTypes()
51: .setChoosen(ch);
52: }
53: }
54:
55: protected void fillChoices() {
56: }
57:
58: public void setReadOnly(boolean readOnly) {
59: this .isReadOnly = readOnly;
60: }
61:
62: public String toName() {
63: return controlled.toName();
64: }
65:
66: public XMLElement getControlledElement() {
67: return controlled;
68: }
69: }
|