KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > swingclient > workflowadmin > BlockActivityViewer


1 package org.enhydra.shark.swingclient.workflowadmin;
2
3 import java.awt.*;
4
5
6 import org.enhydra.shark.api.client.wfmodel.*;
7 import org.enhydra.jawe.*;
8 import org.enhydra.jawe.graph.BlockActivity;
9 import org.enhydra.jawe.xml.elements.*;
10 import org.enhydra.jawe.xml.elements.Activity;
11 import org.enhydra.shark.swingclient.*;
12
13 /**
14 * The panel that is used to display the BlockActivityGraph instances -
15 * the ActivitySets defined by the JaWE application.
16 */

17 //TODO: Fix to always show properly currently active activities (when there
18
// are two activities with the same definition Id, one in the block and the
19
// second in it's nested block, and the activity in nested block is active
20
// (and one in the block is not), the activity in the block is selected
21
public class BlockActivityViewer extends ProcessViewer {
22    private BlockActivity blockActivity;
23    private org.enhydra.jawe.xml.elements.Package pkg;
24    private WfProcessMgr wpm;
25    private WfProcess wpr;
26
27    private ActivitySet activitySet;
28
29    public BlockActivityViewer (Window parent,BlockActivity ba,
30          org.enhydra.jawe.xml.elements.Package pkg,
31          WfProcessMgr wpm,WfProcess wpr) {
32       super(parent);
33
34       this.blockActivity=ba;
35       this.pkg=pkg;
36       currentProcessMgr=wpm;
37       currentProcess=wpr;
38
39       WorkflowProcesses wps=(WorkflowProcesses)pkg.get("WorkflowProcesses");
40       String JavaDoc pdId="";
41       try {pdId=SharkAdmin.getAdminMiscUtilities().getProcessMgrProcDefId(wpm.name());}catch (Exception JavaDoc ex) {}
42       WorkflowProcess wp=wps.getWorkflowProcess(pdId);
43       String JavaDoc baId=blockActivity.getBlockID();
44       activitySet=((ActivitySets)wp.get("ActivitySets")).getActivitySet(baId);
45
46       try {
47          ProcessEditor pe=blockActivity.getImplementationEditor();
48          if (pe!=null) {
49             currentGraph=(ProcessGraph)pe.getGraph();
50          }
51          currentGraph.setEditable(false);
52          currentGraph.setMoveable(false);
53          ((ProcessEditor)currentGraph.getEditor()).setButtonsEnabled(false);
54          graphScrollPane.setViewportView(currentGraph);
55          updateSelection();
56       } catch (Exception JavaDoc ex) {
57          graphScrollPane.setViewportView(null);
58       }
59
60    }
61
62    /** Sets the dialog title. */
63    protected void setDialogTitle () {
64       myDialog.setTitle(blockActivity.toString());
65    }
66
67    public void displayProcess (
68       org.enhydra.jawe.xml.elements.Package pkg,
69       WfProcessMgr wpm,WfProcess wpr) {
70       updateSelection();
71       return;
72    }
73
74    /**
75    * Refreshes graph to select activities of current block activity insance that
76    * are currently in the open.running state.
77    */

78    public void updateSelection () {
79       if (currentGraph==null) return;
80       currentGraph.clearSelection();
81       if (currentProcess==null) return;
82
83       try {
84          WfActivityIterator wai=SharkClient.getCommonExpressionBuilder().getOpenActivities(currentProcess.key());
85          WfActivity[] allRunningActs=wai.get_next_n_sequence(0);
86          for (int i=0; i<allRunningActs.length; i++) {
87             Activities acts=(Activities)activitySet.get("Activities");
88             Activity act=acts.getActivity(
89                SharkClient.getAdminMiscUtilities().getActivityDefinitionId(currentProcess.key(),
90                   allRunningActs[i].key()));
91             try {
92                WorkflowManager wm=currentGraph.getWorkflowManager();
93                Object JavaDoc go=wm.getActivity(act.getID());
94                if (go!=null) {
95                   currentGraph.addSelectionCell(go);
96                }
97             } catch (Exception JavaDoc ex) {}
98          }
99          //System.out.println("Selection refreshed");
100
} catch (Exception JavaDoc ex) {
101          System.err.println("Problems while updating selection");
102       }
103    }
104
105 }
106
Popular Tags