1 package org.enhydra.shark.corbaclient.workflowadmin.monitoring; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 import javax.swing.border.*; 7 import javax.swing.event.*; 8 9 import org.omg.WorkflowModel.*; 10 import org.enhydra.jawe.xml.elements.*; 11 import org.enhydra.shark.corbaclient.*; 12 import org.enhydra.shark.corbaclient.workflowadmin.monitoring.actions.*; 13 14 20 public class ManageActivities extends ActionPanel { 21 22 private static Dimension listFieldDimension=new Dimension(300,300); 23 24 private JList activities; 25 private JTextField activity=new JTextField(); 26 27 private java.util.List allActivities; 28 private WfProcess myProcess; 29 30 private ProcessMonitor processMonitor; 31 32 public ManageActivities (ProcessMonitor pm,WfProcess proc,java.util.List acts) { 33 super(); 34 this.processMonitor=pm; 35 this.myProcess=proc; 36 this.allActivities=acts; 37 super.init(); 38 super.initDialog(pm.getWorkflowAdmin().getFrame(), 39 ResourceManager.getLanguageDependentString("DialogManageActivities"), 40 false,false); 41 } 42 43 protected void createActions () { 44 defaultActions=new Action[] { 45 new SuspendActivity(this), 46 new ResumeActivity(this), 47 new TerminateActivity(this), 48 new AbortActivity(this), 49 new ManuallyStartActivity(this) 50 }; 51 } 52 53 56 protected Component createCenterComponent() { 57 activity.setEnabled(false); 58 59 JScrollPane scrollActivities=new JScrollPane(); 60 activities=new JList(allActivities.toArray()); 61 activities.addListSelectionListener(new ListSelectionListener() { 62 public void valueChanged(ListSelectionEvent e) { 63 if (e.getValueIsAdjusting()) { 64 return; 65 } 66 67 JList theList = (JList)e.getSource(); 68 if (theList.isSelectionEmpty()) { 69 activity.setText(""); 70 } else { 71 Activity act=(Activity)theList.getSelectedValue(); 72 WfActivity a=getLastActivityForDefinition(act,null,0); 73 try { 74 String state=a.state(); 75 String stateKey=ResourceManager.getLanguageDependentString(state+"Key"); 76 activity.setText(stateKey); 77 } catch (Exception ex) { 78 activity.setText(ResourceManager.getLanguageDependentString("NotOpenedKey")); 79 } 80 } 81 } 82 }); 83 84 activities.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 85 scrollActivities.setViewportView(activities); 86 scrollActivities.setPreferredSize(new Dimension(listFieldDimension)); 87 88 JPanel pm=new JPanel(); 89 Border emptyb=BorderFactory.createEmptyBorder(10,10,10,10); 90 Border inb=BorderFactory.createMatteBorder(1,1,1,1,Color.darkGray); 91 inb=BorderFactory.createTitledBorder(inb, 92 ResourceManager.getLanguageDependentString("SelectActivityKey")); 93 pm.setBorder(BorderFactory.createCompoundBorder(emptyb,inb)); 94 pm.setLayout(new BoxLayout(pm,BoxLayout.Y_AXIS)); 95 pm.add(scrollActivities); 96 pm.add(activity); 97 98 return pm; 99 } 100 101 111 public WfActivity getLastActivityForDefinition (Activity act,String state,int compareType) { 112 if (act==null) return null; 113 try { 114 WfActivityIterator wai=SharkClient.getCommonExpressionBuilder().getActivitiesForDefinitionAndState(myProcess.key(),act.getID(),state,compareType==0); 115 116 wai.goto_end(); 117 WfActivity lastActivityForDefinition=null; 118 while (true) { 120 lastActivityForDefinition=wai.get_previous_object(); 121 try { 122 String baId=SharkClient.getAdminMiscUtilities(). 123 getBlockActivityId(myProcess.key(),lastActivityForDefinition.key()); 124 if (baId==null || baId.length()==0) { 125 break; 126 } 127 } catch (Exception ex) { 128 break; 129 } 130 } 131 return lastActivityForDefinition; 132 } catch (Exception ex) { 133 return null; 134 } 135 } 136 137 public Activity getSelectedActivity () { 138 return (Activity)activities.getSelectedValue(); 139 } 140 141 public WfProcess getProcess () { 142 return myProcess; 143 } 144 145 public void updateListDisplay (Activity act) { 146 activities.getSelectionModel().clearSelection(); 147 activities.setSelectedValue(act,true); 148 } 149 150 public void updateProcessView () { 151 processMonitor.getProcessViewer().updateSelection(); 152 } 153 154 } 155 | Popular Tags |