KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > swingclient > workflowadmin > monitoring > actions > DeleteSelectedProcesses


1 package org.enhydra.shark.swingclient.workflowadmin.monitoring.actions;
2
3 import java.awt.event.ActionEvent JavaDoc;
4 import javax.swing.JOptionPane JavaDoc;
5 import org.enhydra.shark.api.client.wfservice.AdminMisc;
6 import org.enhydra.shark.api.client.wfmodel.WfProcess;
7 import org.enhydra.shark.api.client.wfmodel.WfProcessMgr;
8 import org.enhydra.shark.swingclient.ActionBase;
9 import org.enhydra.shark.swingclient.ResourceManager;
10 import org.enhydra.shark.swingclient.SharkClient;
11 import org.enhydra.shark.swingclient.workflowadmin.SharkAdmin;
12 import org.enhydra.shark.swingclient.workflowadmin.monitoring.ProcessMonitor;
13
14 /**
15  * Deletes selected processes from DB if they are finished.
16  *
17  * @author Sasa Bojanic
18  */

19 public class DeleteSelectedProcesses extends ActionBase {
20
21    public DeleteSelectedProcesses (ProcessMonitor pm) {
22       super(pm);
23    }
24
25    public void actionPerformed(ActionEvent JavaDoc e) {
26       ProcessMonitor pm=(ProcessMonitor)actionPanel;
27       SharkAdmin workflowAdmin=pm.getWorkflowAdmin();
28
29       String JavaDoc pkgId=null;
30       String JavaDoc pDefId=null;
31
32       Object JavaDoc userObject=pm.getSelectedUserObject();
33
34
35       try {
36          if (userObject instanceof org.enhydra.jawe.xml.elements.Package) {
37             org.enhydra.jawe.xml.elements.Package pkg=
38                (org.enhydra.jawe.xml.elements.Package)userObject;
39             pkgId=pkg.get("Id").toString();
40          }
41          if (userObject instanceof WfProcessMgr) {
42             AdminMisc am=workflowAdmin.getAdminMiscUtilities();
43             pkgId=am.getProcessMgrPkgId(((WfProcessMgr)userObject).name());
44             pDefId=am.getProcessMgrProcDefId(((WfProcessMgr)userObject).name());
45          }
46          if (pkgId!=null && pDefId!=null) {
47             workflowAdmin.getExecAmin().deleteClosedProcesses(pkgId,pDefId);
48          } else if (pkgId!=null) {
49             workflowAdmin.getExecAmin().deleteClosedProcesses(pkgId);
50          } else {
51             WfProcess proc=pm.getProcessViewer().getCurrentProcess();
52             workflowAdmin.getExecAmin().deleteClosedProcess(proc.key());
53          }
54          workflowAdmin.getEngineTreeModel().clear();
55          workflowAdmin.refresh(true);
56       } catch (Exception JavaDoc ex){
57          JOptionPane.showMessageDialog(pm.getWindow(),
58                                        ResourceManager.getLanguageDependentString(
59                                           "MessageProcessCannotBeDeleted"),
60                                        SharkClient.getAppTitle(),JOptionPane.WARNING_MESSAGE);
61
62          ex.printStackTrace();
63       }
64    }
65 }
66
Popular Tags