KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > graph > Participant


1 /* Participant.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.graph;
12
13 import org.enhydra.jawe.*;
14 import org.enhydra.jawe.xml.*;
15
16 import org.jgraph.graph.*;
17
18 import java.util.*;
19 import java.awt.*;
20 import javax.swing.*;
21
22 /**
23 * Used to define Participant object in process. Participant is a container
24 * for activities, subflows and other departmnet objects. Activities and
25 * subflow can be moved from one to the other Participant.
26 */

27 public class Participant extends DefaultGraphCell implements WorkflowElement {
28
29    /**
30    * Creates participant.
31    */

32    public Participant() {
33       this(null);
34    }
35
36    /**
37    * Creates Participant with given userObject.
38    */

39    public Participant(Object JavaDoc userObject) {
40       super(userObject);
41    }
42
43
44    /**
45    * Returns true if participant is a container for any other participant.
46    */

47    public boolean hasAnyParticipant () {
48       for (int i=0; i<getChildCount(); i++) {
49          if (getChildAt(i) instanceof Participant) {
50             return true;
51          }
52       }
53       return false;
54    }
55
56    /**
57    * Returns the number of participant's children participants (number of
58    * participants for which it is a container).
59    */

60    public int howManyChildParticipants () {
61       int cd=0;
62       for (int i=0; i<getChildCount(); i++) {
63          if (getChildAt(i) instanceof Participant) {
64             cd++;
65          }
66       }
67       return cd;
68    }
69
70    /**
71    * Returns participant's children participants (participants for which
72    * it is a container).
73    */

74    public Set getChildParticipants () {
75       Set childParticipants=new HashSet();
76       for (int i=0; i<getChildCount(); i++) {
77          Object JavaDoc child=getChildAt(i);
78          if (child instanceof Participant) {
79             childParticipants.add(child);
80          }
81       }
82       return childParticipants;
83    }
84
85    /**
86    * Returns true if participant is a container for any activity.
87    * <BR>NOTE: subflow is a kind of activity.
88    */

89    public boolean hasAnyActivity () {
90       for (int i=0; i<getChildCount(); i++) {
91          if (getChildAt(i) instanceof Activity) {
92             return true;
93          }
94       }
95       return false;
96    }
97
98    /**
99    * Returns the number of participant's children activities (number of
100    * activities for which it is a container).
101    * <BR>NOTE: subflow is a kind of activity.
102    */

103    public int howManyChildActivities () {
104       int ca=0;
105       for (int i=0; i<getChildCount(); i++) {
106          if (getChildAt(i) instanceof Activity) {
107             ca++;
108          }
109       }
110       return ca;
111    }
112
113    /**
114    * Returns participant's children activities (activities
115    * for which it is a container).
116    * <BR>NOTE: subflow is a kind of activity.
117    */

118    public Set getChildActivities () {
119       Set childActivities=new HashSet();
120       for (int i=0; i<getChildCount(); i++) {
121          Object JavaDoc child=getChildAt(i);
122          if (child instanceof Activity) {
123             childActivities.add(child);
124          }
125       }
126       return childActivities;
127    }
128
129    /**
130    * Shows a dialog for editing participant properties. This is a place
131    * where undoing of property changes is realized.
132    */

133    public void showPropertyDialog(Window parentWindow,AbstractGraph graph){
134       // set participant to be read-only if neccessary
135
org.enhydra.jawe.xml.elements.Participant p=
136             (org.enhydra.jawe.xml.elements.Participant)userObject;
137       if (p==org.enhydra.jawe.xml.elements.Participant.getFreeTextExpressionParticipant() ||
138           p.getCollection().getOwner() instanceof org.enhydra.jawe.xml.elements.Package) {
139          p.setReadOnly(true);
140       }
141       XMLElementDialog xmlED=((ProcessEditor)graph.getEditor()).
142          getElementEditingDialog();
143       if (xmlED.isShowing()) {
144          xmlED.switchPanel(getPropertyObject().getPanel(),
145             ResourceManager.getLanguageDependentString("DialogParticipantProperties")+
146             " - "+userObject.toString(),true);
147       } else {
148          xmlED.setTitle(ResourceManager.getLanguageDependentString("DialogParticipantProperties")+
149             " - "+userObject.toString());
150          xmlED.editXMLElement(getPropertyObject().getPanel(),true,false);
151       }
152
153    }
154
155    /**
156    * Gets a property object (DTDElement).
157    */

158    public XMLElement getPropertyObject () {
159       return (XMLElement)userObject;
160    }
161
162
163    /**
164    * Gets a participant property which name is given in parameter what.
165    */

166    public XMLElement get (String JavaDoc what) {
167       return ((XMLComplexElement)getPropertyObject()).get(what);
168    }
169
170    /**
171    * Sets a participant property which name is given in parameter what to a
172    * value given in a parameter value.
173    */

174    public void set (String JavaDoc what,Object JavaDoc value) {
175       ((XMLComplexElement)getPropertyObject()).set(what,value);
176    }
177
178    /**
179    * Gets a tooltip text for participant.
180    */

181    public String JavaDoc getTooltip () {
182       return ((org.enhydra.jawe.xml.elements.Participant)userObject).getTooltip();
183    }
184    /**
185    * Gets an participant name property.
186    */

187    public String JavaDoc toString () {
188       return userObject.toString();
189    }
190
191    /**
192    * Create a clone of the user object.
193    * @return Object a clone of this participant property object.
194    */

195    protected Object JavaDoc cloneUserObject() {
196       return null;
197    }
198
199 }
200
201 /* End of Participant.java */
202
Popular Tags