View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2007, Ontotext Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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  * $Log$
133  * Revision 1.2  2007/09/17 13:10:23  alex_simov
134  * bpmo properties update
135  *
136  * Revision 1.1  2007/09/15 16:37:56  alex_simov
137  * bpmo properties update
138  *
139  */