KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* Subflow.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.xml.*;
14 import org.enhydra.jawe.xml.elements.*;
15
16 import org.jgraph.graph.*;
17
18 import java.util.*;
19 import java.awt.*;
20 import javax.swing.*;
21 import org.enhydra.jawe.*;
22
23 /*
24  import javax.swing.undo.*;
25  import javax.swing.event.*;
26  */

27
28 /**
29  * Used to define Subflow object in the graph and to modify it's
30  * properties.
31  */

32 public class Subflow extends Activity {
33
34    /**
35     * Creates subflow
36     */

37    public Subflow() {
38       this(null);
39    }
40
41    /**
42     * Creates subflow with given userObject.
43     */

44    public Subflow(Object JavaDoc userObject) {
45       super(userObject);
46    }
47
48    /**
49     * Shows referenced process, if no process is referenced, the new
50     * process is created and shown.
51     *
52     * @param parentWindow The parent window of one beeing shown when
53     * this method is executed.
54     * @param pkg The package within the subflow activity is defined.
55     */

56    public void showSubflow (Window parentWindow,org.enhydra.jawe.xml.elements.Package pkg) {
57       WorkflowProcess wp=getReferencedWorkflowProcess(pkg);
58       if (wp!=null) {
59          wp=JaWE.getInstance().showProcess(parentWindow,wp,wp.getID());
60          getXMLSubflow().set("WorkflowProcess",wp);
61       }
62    }
63
64    public WorkflowProcess getReferencedWorkflowProcess (org.enhydra.jawe.xml.elements.Package pkg) {
65       String JavaDoc ID=getProcessID();
66       return pkg.getWorkflowProcess(ID);
67    }
68
69    /**
70     * Returns ID of referenced process. If there is no referenced
71     * process (the new process is to be created when editing subflow
72     * activity), generates an ID for new process and returns it.
73     */

74    private String JavaDoc getProcessID () {
75       SubFlow s=getXMLSubflow();
76       XMLComplexChoice wp=(XMLComplexChoice)s.get("WorkflowProcess");
77
78       Object JavaDoc choosenWorkflow=wp.getChoosen();
79       String JavaDoc subflowID;
80
81       if (choosenWorkflow!=null &&
82           choosenWorkflow instanceof WorkflowProcess) {
83          subflowID=((WorkflowProcess)choosenWorkflow).getID();
84       } else {
85          subflowID=choosenWorkflow.toString();
86       }
87       return subflowID;
88    }
89
90    /**
91     * Returns a logical (XML) element describing a reference to
92     * the process.
93     */

94    private SubFlow getXMLSubflow () {
95       return ((org.enhydra.jawe.xml.elements.Activity)
96                  userObject).getSubflow();
97    }
98
99 }
100
Popular Tags