KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* Responsibles.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
20 /**
21 * Represents a WfMC DTD element that has the similar name.
22 * This class is a collection of class <b>Responsible</b> instances.
23 *
24 * @see XML
25 */

26 public class Responsibles extends XMLCollection {
27    /**
28    * Creates a new instance of the class.
29    *
30    * @param packageOrWProcess The class instance which member
31    * is this class instance. Can be
32    * Package or WorkflowProcess
33    */

34    public Responsibles (XMLComplexElement packageOrWProcess) {
35       super(packageOrWProcess);
36    }
37
38    /**
39    * Returns <tt>true</tt> if specified participant isn't referenced to
40    * be a responsible for some process or package.
41    */

42    protected boolean canRemoveParticipant (Participant toRemove) {
43       Responsible r;
44       Iterator it=refCollectionElements.iterator();
45       while (it.hasNext()) {
46          r=(Responsible)it.next();
47          if (r.toValue()==toRemove) {
48             return false;
49          }
50       }
51       return true;
52    }
53
54    /**
55    * Generates a new element of the class which instances
56    * are members of collection of this class.
57    *
58    * return The generated instance of class that makes collection.
59    */

60    public XMLElement generateNewElement() {
61       Responsible r=new Responsible(myOwner);
62       r.setRequired(true);
63       return r;
64    }
65
66    /**
67    * Creates panel which allows user to manipulate with instances
68    * of classes that makes a collection that this class represents.
69    * The panel consists of two sections: XMLListPanel - shows
70    * collections' elements, and XMLListControlPanel - display buttons
71    * for manipulating with that elements.
72    * <p>NOTE: The order of creation is relevant, first, the controlled
73    * panel must be created, and then the control panel
74    *
75    * @return DTDPanel to be shown
76    */

77    public XMLPanel getPanel () {
78       controlledPanel=new XMLListPanel(this,"",false,true,false);
79       controlPanel=new XMLListControlPanel(this,"",true,false,true);
80       return new XMLGroupPanel(this,new XMLPanel[]{
81          controlledPanel,controlPanel},toLabel(),XMLPanel.BOX_LAYOUT,
82          false,true);
83    }
84
85    /**
86    * Called by Package object after importing of XML file to set the proper
87    * Participant objects for Responsibles of Package or WorkflowProcess,
88    * depending on that who owns Responsibles. Participants are set
89    * according to it's ID's read from XML.
90    */

91    protected void afterImporting () {
92       Participants ps=(Participants)myOwner.get("Participants");
93       Iterator it=refCollectionElements.iterator();
94       while (it.hasNext()) {
95          Responsible r=(Responsible)it.next();
96          r.setValue(ps.getParticipant(r.toValue().toString()));
97       }
98    }
99
100    /**
101    * Used to create exact copy of instance of this class.
102    * The newly created instance will have all the properties
103    * same as the copied one.
104    *
105    * @return The newly created instance of this class.
106    */

107    public Object JavaDoc clone () {
108       Responsibles r=(Responsibles)super.clone();
109       return r;
110    }
111
112 }
113
Popular Tags