1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 /***
19 * <p>Title: WSMO Studio</p>
20 * <p>Description: Semantic Web Service Editor</p>
21 * <p>Copyright: Copyright (c) 2004-2007</p>
22 * <p>Company: Ontotext Lab. / SIRMA </p>
23 */
24
25 package org.wsmostudio.bpmo.model;
26
27 import java.util.LinkedList;
28 import java.util.List;
29
30 import org.eclipse.swt.graphics.Image;
31
32 public class WorkflowProperty {
33
34 public static final String[] defaultValueRemovePolicies = new String[] { "Remove" };
35 public static final String[] defaultValueEditPolicies = new String[] { "Edit" };
36 public static final String[] defaultValueEditOrRemovePolicies = new String[] { "Edit", "Remove" };
37
38 String id;
39 Image icon;
40 String[] actions;
41 String[] valueEditPolicies;
42 List<Object> values;
43 boolean isCardinalityOne;
44
45 public WorkflowProperty(String propName, Image image, String[] actions, boolean isMultiValued, String[] valueEditPolicies) {
46 this.id = propName;
47 this.icon = image;
48 this.actions = actions;
49 isCardinalityOne = !isMultiValued;
50 this.values = new LinkedList<Object>();
51 if (valueEditPolicies != null) {
52 this.valueEditPolicies = valueEditPolicies;
53 }
54 else {
55 this.valueEditPolicies = defaultValueRemovePolicies;
56 }
57 }
58
59 public WorkflowProperty(String propName, Image image, String[] actions, boolean isMultiValued) {
60 this(propName, image, actions, isMultiValued, null);
61 }
62
63 public String[] getActions() {
64 return this.actions;
65 }
66
67 public String[] getValueEditPolicies() {
68 return getValueEditPolicies(null);
69 }
70
71 public String[] getValueEditPolicies(Object value) {
72 return this.valueEditPolicies;
73 }
74
75 public void addValue(Object val) {
76 if (this.values == null) {
77 this.values = new LinkedList<Object>();
78 }
79 if (isCardinalityOne) {
80 values.clear();
81 }
82 if (val == null) {
83 return;
84 }
85 this.values.add(val);
86 }
87
88 public List<Object> listValues() {
89 return this.values;
90 }
91
92 public Object getSingleValue() {
93 if (this.values.size() == 0) {
94 return null;
95 }
96 return this.values.get(0);
97 }
98
99 public void removeValue(Object val) {
100 if (this.values == null) {
101 return;
102 }
103 if (val == null) {
104 return;
105 }
106 this.values.remove(val);
107 }
108
109 public boolean allowsMultiValue() {
110 return isCardinalityOne == false;
111 }
112
113 public Image getIcon() {
114 return this.icon;
115 }
116
117 public String toString() {
118 return this.id;
119 }
120
121 public void clearAll() {
122 if (this.values == null) {
123 return;
124 }
125 this.values.clear();
126 }
127
128 }
129
130
131
132
133
134
135
136
137
138
139