KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > elements > ActivitySet


1 /* ActivitySet.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.xml.elements;
12
13
14 import org.enhydra.jawe.xml.*;
15 import org.enhydra.jawe.xml.panels.*;
16
17 import java.util.*;
18 import javax.swing.tree.*;
19 import java.awt.*;
20
21 import org.w3c.dom.*;
22
23 /**
24 * Represents a WfMC DTD element that has the similar name.
25 */

26 public class ActivitySet extends XMLCollectionElement {
27    private Activities refActivities;
28    private Transitions refTransitions;
29
30    /** Container for activity set. */
31    private transient WorkflowProcess myWorkflow=null;
32
33   /**
34    * Creates a new instance of the class.
35    *
36    * @param ass activity sets
37    * @param myWorkflow WorkflowProcess class that holds ActivitySet class.
38    */

39    public ActivitySet (ActivitySets ass,WorkflowProcess myWorkflow) {
40       super (ass);
41       // the ID is controled other way
42
ass.decrementID();
43
44       this.myWorkflow=myWorkflow;
45
46       refActivities=new Activities(this);
47       refTransitions=new Transitions(this);
48
49       fillStructure();
50    }
51
52    /**
53    * Defines the super-class method. Read the explanation for
54    * this method within XMLComplexElement class.
55    */

56    protected void fillStructure () {
57       super.fillStructure();
58       attrId.setReadOnly(true);
59       complexStructure.add(refActivities);
60       complexStructure.add(refTransitions);
61    }
62
63    /** Sets proper ID prefix for all Id generators (XMLCollection class instances). */
64    public void setIDPrefixForCollections () {
65       String JavaDoc colPref=getID()+this.ID_DELIMITER;
66       refActivities.setIDPrefix(colPref+"Act");
67       refTransitions.setIDPrefix(colPref+"Tra");
68    }
69
70    /**
71    * Returns a workflow process that contains the set.
72    *
73    * @return The workflow process that ownes the set.
74    */

75    public WorkflowProcess getOwnerProcess () {
76       return myWorkflow;
77    }
78
79    /**
80    * Called by Package object after importing of XML file to set the proper
81    * Participant objects for performer of activity, according on it's
82    * ID read from XML, to set proper reference to workflow process for
83    * activities of Subflow type, and to set proper user defined activity
84    * properties.
85    */

86    protected void afterImporting () {
87       refActivities.afterImporting();
88       refTransitions.afterImporting();
89       refActivities.fillOutgoingTransitions();
90    }
91
92    /**
93    * Prepares the tabbed panel to show editable fields of Activity.
94    * Panel consists of six tabs that logically comprises the
95    * Activity elements to be edited.
96    *
97    * @return XMLPanel to be shown.
98    */

99    public XMLPanel getPanel () {
100       return new XMLGroupPanel(this,
101          new XMLElement[] {
102             attrId,
103             refActivities,
104             refTransitions
105          },toLabel());
106    }
107
108    /**
109    * Returns <tt>true</tt> if specified workflow process isn't referenced from
110    * any activity of subflow type.
111    */

112    protected boolean canRemoveWorkflow (WorkflowProcess toRemove) {
113       return refActivities.canRemoveWorkflow(toRemove);
114    }
115
116    /**
117    * Returns <tt>true</tt> if specified participant isn't referenced to
118    * be a performer of activity.
119    */

120    protected boolean canRemoveParticipant (Participant toRemove) {
121       return refActivities.canRemoveParticipant(toRemove);
122    }
123
124    /**
125    * Returns <tt>true</tt> if specified application isn't used anywhere.
126    */

127    protected boolean canRemoveApplication (Application toRemove) {
128       return refActivities.canRemoveApplication(toRemove);
129    }
130
131    /**
132    * Returns <tt>true</tt> if specified data field isn't used anywhere.
133    */

134    protected boolean canRemoveDataFieldOrFormalParameter (XMLCollectionElement toRemove) {
135       boolean cr=refActivities.canRemoveDataFieldOrFormalParameter(toRemove);
136       if (cr==false) {
137          return false;
138       }
139       return refTransitions.canRemoveDataFieldOrFormalParameter(toRemove);
140    }
141
142    /**
143    * Returns <tt>true</tt> if specified data field or formal parameter is
144    * used in transition condition expression of any transition within
145    * activity set's transitions.
146    */

147    protected boolean isDataFieldOrFormalParameterUsedWithinTransitionConditions (XMLCollectionElement toRemove) {
148       return !refTransitions.canRemoveDataFieldOrFormalParameter(toRemove);
149    }
150
151    public String JavaDoc toString () {
152       return attrId.toString();
153    }
154
155    /**
156    * Overrides super-class method to realize this class specific
157    * writting to XML file.
158    *
159    * @return The string for a WfMC DTD WorkflowProcess element tag.
160    */

161    public void toXML (Node parent) throws DOMException {
162       if (parent.getOwnerDocument()!=null) {
163          super.toXML(parent);
164       // this happens when user wants to view XPDL presentation of the graph
165
} else {
166          Node node = ((Document) parent).createElement(name);
167          super.toXML(node);
168          parent.appendChild(node);
169       }
170    }
171
172    public void fromXML(Node node) {
173       processAttributes(node);
174       setIDPrefixForCollections();
175       processElements(node);
176
177       ((ActivitySets)myCollection).updateID(getID());
178    }
179
180 }
181
Popular Tags