01: package com.opensymphony.workflow.designer;
02:
03: import java.util.Map;
04:
05: import org.jgraph.graph.AttributeMap;
06: import org.jgraph.graph.GraphConstants;
07: import com.opensymphony.workflow.loader.StepDescriptor;
08: import com.opensymphony.workflow.loader.ResultDescriptor;
09: import com.opensymphony.workflow.loader.ActionDescriptor;
10:
11: /**
12: * @author hani Date: Dec 30, 2004 Time: 2:50:15 PM
13: */
14: public class WorkflowAttributeMap extends AttributeMap {
15: public WorkflowAttributeMap(Map map) {
16: super (map);
17: }
18:
19: public Object valueChanged(Object newValue) {
20: Object userObject = get(GraphConstants.VALUE);
21: if (userObject instanceof StepDescriptor) {
22: StepDescriptor descriptor = (StepDescriptor) userObject;
23: //StepDescriptor user = (StepDescriptor)((StepDescriptor)userObject).clone();
24: descriptor.setName(newValue.toString());
25: return descriptor;
26: } else if (userObject instanceof ResultDescriptor) {
27: ResultDescriptor result = (ResultDescriptor) userObject;
28: String name = result.getDisplayName();
29: boolean hasNickname = (name != null);
30: if (hasNickname)
31: hasNickname &= (name.length() > 0);
32: if ((!hasNickname)
33: && (result.getParent() instanceof ActionDescriptor)) {
34: if (((ActionDescriptor) result.getParent())
35: .getConditionalResults() != null) {
36: if (((ActionDescriptor) result.getParent())
37: .getConditionalResults().isEmpty()) {
38: ((ActionDescriptor) result.getParent())
39: .setName(newValue.toString());
40: return result;
41: }
42: }
43: }
44: result.setDisplayName(newValue.toString());
45: return result;
46: } else if (userObject instanceof ActionDescriptor) {
47: ActionDescriptor descriptor = (ActionDescriptor) userObject;
48: //StepDescriptor user = (StepDescriptor)((StepDescriptor)userObject).clone();
49: descriptor.setName(newValue.toString());
50: return descriptor;
51: }
52:
53: return super.valueChanged(newValue);
54: }
55:
56: }
|