KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* BlockActivity.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 import org.jgraph.graph.*;
16
17 import java.util.*;
18 import java.awt.*;
19 import javax.swing.*;
20
21
22 /**
23 * Used to define BlockActivity object in process and to modify it's
24 * properties.
25 */

26 public class BlockActivity extends Activity {
27
28    protected transient ProcessEditor pEditor;
29    /**
30    * Reference to block activity editor that will be created the first
31    * time showBlockActivity method is called.
32    */

33    protected transient BlockActivityEditor baEditor=null;
34
35    /**
36    * Creates block activity.
37    */

38    public BlockActivity(ProcessEditor pEd) {
39       this(null,pEd);
40    }
41
42    /**
43    * Creates block activity with given userObject.
44    */

45    public BlockActivity(Object JavaDoc userObject,ProcessEditor pEd) {
46       super(userObject);
47       this.pEditor=pEd;
48    }
49
50    public ProcessEditor getImplementationEditor () {
51       return baEditor;
52    }
53
54    public String JavaDoc getBlockID () {
55       String JavaDoc blockID=((org.enhydra.jawe.xml.elements.Activity)
56          userObject).getBlockActivity().get("BlockId").toString();
57       return blockID;
58    }
59
60    /**
61    * Shows a block activity editor with it's toolbar.
62    */

63    public void showBlockActivity (Window parentWindow) {
64       String JavaDoc baTitle="'"+toString()+"' - "+
65          ResourceManager.getLanguageDependentString("DialogBlockActivityDefinition");
66       if (baEditor == null) {
67          org.enhydra.jawe.xml.elements.WorkflowProcess wp=((org.enhydra.jawe.xml.elements.Activity)userObject).getOwnerProcess();
68          baEditor=new BlockActivityEditor(parentWindow,wp,this,pEditor);
69          baEditor.getStatusBar().updateMessage();
70          baEditor.showWindow(parentWindow,baTitle);
71       }
72       else {
73          // check xpdl object to prevent crashing if this is an invalid
74
// block activity without defined activity set
75
if (baEditor.getGraph().getXPDLObject()!=null) {
76             baEditor.getStatusBar().updateMessage();
77             baEditor.showWindow(parentWindow,baTitle);
78          }
79       }
80    }
81
82    public void createBlockActivityGraph (Window parentWindow) {
83       // create new editor
84
org.enhydra.jawe.xml.elements.WorkflowProcess wp=
85          ((org.enhydra.jawe.xml.elements.Activity)userObject).
86             getOwnerProcess();
87       baEditor=new BlockActivityEditor(parentWindow,wp,this,pEditor);
88
89       baEditor.getGraph().createWorkflowGraph(parentWindow);
90    }
91
92    public WorkflowManager getWorkflowManager () {
93       try {
94          return baEditor.getGraph().getWorkflowManager();
95       }
96       catch (Exception JavaDoc ex) {
97          return null;
98       }
99    }
100
101    public AbstractEditor getParentEditor () {
102       return pEditor;
103    }
104
105 }
106
Popular Tags