KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ActualParameters.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 import org.enhydra.jawe.xml.*;
14 import org.enhydra.jawe.xml.panels.*;
15 import org.enhydra.jawe.xml.elements.specialpanels.*;
16
17 import java.util.*;
18
19 /**
20  * Represents a WfMC DTD element that has the similar name.
21  * This class is a collection of class <b>ActualParameter</b> instances.
22  *
23  * @see XML
24  */

25 public class ActualParameters extends XMLCollection {
26    /** Used to get data fields defined within workflow process */
27    private transient WorkflowProcess myWorkflow=null;
28
29    private transient XMLComplexElement myToolOrSubflow=null;
30    /**
31     * Creates a new instance of the class.
32     *
33     * @param wp The workflow process which defines DataField
34     * elements to use as a actual parameters.
35     */

36    public ActualParameters (WorkflowProcess wp,XMLComplexElement toolOrSbflw) {
37       super(toolOrSbflw);
38       myWorkflow=wp;
39       myToolOrSubflow=toolOrSbflw;
40    }
41
42    /**
43     * Generates a new element of the class which instances
44     * are members of collection of this class.
45     *
46     * return The generated instance of class that makes collection.
47     */

48    public XMLElement generateNewElement() {
49       ActualParameter ap=new ActualParameter(myWorkflow);
50       ap.setRequired(true);
51       return ap;
52    }
53
54    /**
55     * Creates panel which allows user to manipulate with instances
56     * of classes that makes a collection that this class represents.
57     * The panel consists of two sections: XMLListPanel - shows
58     * collections' elements, and XMLListControlPanel - display buttons
59     * for manipulating with that elements.
60     * <p>NOTE: The order of creation is relevant, first, the controlled
61     * panel must be created, and then the control panel
62     *
63     * @return DTDPanel to be shown
64     */

65    public XMLPanel getPanel () {
66       /*controlledPanel=new XMLListPanel(this,"",false,true,false);
67        //controlPanel=new XMLListControlPanel(this,"",true,false,true);
68        controlPanel=new XMLActualParametersListControlPanel(this,"",true,false);*/

69       //controlPanel=new XMLListControlPanel(this,"",true,false,true);
70
XMLComplexChoice sel=null;
71       if (myToolOrSubflow instanceof Tool) {
72          sel=(XMLComplexChoice)myToolOrSubflow.get("Application");
73       } else {
74          sel=(XMLComplexChoice)myToolOrSubflow.get("WorkflowProcess");
75       }
76       Object JavaDoc selO=sel.getChoosen();
77
78       FormalParameters fps=null;
79
80       if (selO instanceof XMLCollectionElement) {
81          XMLCollectionElement selectedAppOrWp=(XMLCollectionElement)sel.getChoosen();
82
83          if (selectedAppOrWp!=null) {
84             fps=(FormalParameters)selectedAppOrWp.get("FormalParameters");
85             if (fps==null) { // 'selected' is instance of Application
86
Object JavaDoc tmp=selectedAppOrWp.get("Choice");
87                tmp=((XMLChoice)tmp).getChoosen();
88                if (tmp instanceof FormalParameters) {
89                   fps=(FormalParameters)tmp;
90                }
91             }
92          }
93       }
94       //controlledPanel=new XMLActualParametersTablePanel(this,"",false,true,true,fps);
95
XMLActualParametersPanel app=new XMLActualParametersPanel(this,fps);
96       controlledPanel=app.getControlledPanel();
97       //controlPanel=new XMLTableControlPanel(this,"",true,false);
98
controlPanel=new XMLActualParametersTableControlPanel(this,"",true,false);
99       //controlledPanel=mp.getAPPanel();
100
//controlPanel=new XMLTableControlPanel(this,"",true,false);
101
//controlledPanel=new XMLActualParametersListPanel(this,"",false,true,true,fpTypes);
102
//controlPanel=new XMLActualParametersListControlPanel(this,"",true,false);
103

104       return new XMLGroupPanel(this,new XMLPanel[]{
105                app,controlPanel},"",XMLPanel.BOX_LAYOUT,
106                                false,false);
107    }
108
109    /**
110     * Overrides the super class method to return the label for
111     * ActualParameter - thus means that it returns the string
112     * that is defined in property file for ActualParameterKey.
113     *
114     * @return The word for ActualParameter in currently used language.
115     */

116    public Object JavaDoc toValue () {
117       return toLabel();
118    }
119
120    /**
121     * Used to create exact copy of instance of this class.
122     * The newly created instance will have all the properties
123     * same as the copied one.
124     *
125     * @return The newly created instance of this class.
126     */

127    public Object JavaDoc clone () {
128       ActualParameters ap=(ActualParameters)super.clone();
129       ap.myWorkflow=this.myWorkflow;
130       ap.myToolOrSubflow=this.myToolOrSubflow;
131       return ap;
132    }
133
134    // Used when Tool element is cloned
135
protected void setToolOrSubflow (XMLComplexElement tOrSbflw) {
136       this.myToolOrSubflow=tOrSbflw;
137    }
138 }
139
Popular Tags