KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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