KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corbaclient > workflowadmin > definition > PackageManagement


1 package org.enhydra.shark.corbaclient.workflowadmin.definition;
2
3 import java.awt.*;
4 import java.util.*;
5
6 import javax.swing.*;
7
8 import org.enhydra.jawe.xml.elements.*;
9 import org.enhydra.shark.corbaclient.*;
10 import org.enhydra.shark.corbaclient.workflowadmin.*;
11 import org.enhydra.shark.corbaclient.workflowadmin.definition.actions.*;
12 import org.enhydra.jawe.JaWE;
13
14 /**
15  * Implements the user interface and program logic to import
16  * packages to and remove packages from engine.
17  *
18  * @author Sasa Bojanic
19  * @version 1.0
20  */

21 public class PackageManagement extends ActionPanel {
22    private SharkAdmin workflowAdmin;
23
24    TablePanel openedPackagesTablePanel;
25
26    public PackageManagement (SharkAdmin wa) {
27       super();
28       this.workflowAdmin=wa;
29       super.init();
30    }
31
32    protected void createActions () {
33       defaultActions=new Action[] {
34          new LoadPackage(this),
35             new UnloadPackages(this),
36             new UnloadPackage(this),
37             new UpdatePackage(this),
38             new SynchronizePackageCache(this)
39       };
40       //defaultActions[2].setEnabled(false);
41
}
42
43    protected Component createCenterComponent() {
44       Vector columnNames=new Vector();
45       columnNames.add(ResourceManager.getLanguageDependentString("IdKey"));
46       columnNames.add(ResourceManager.getLanguageDependentString("VersionKey"));
47       columnNames.add(ResourceManager.getLanguageDependentString("NameKey"));
48       columnNames.add(ResourceManager.getLanguageDependentString("NoOfProcessDefinitionsKey"));
49
50       openedPackagesTablePanel=new TablePanel(columnNames, true);
51       return openedPackagesTablePanel;
52    }
53
54    public SharkAdmin getWorkflowAdmin () {
55       return workflowAdmin;
56    }
57
58    public void clear () {
59
60    }
61
62    public synchronized void refresh (boolean mandatoryRefreshing) {
63       if (isShowing() || mandatoryRefreshing) {
64          openedPackagesTablePanel.removeAll();
65          insertPackages(JaWE.getInstance().getXMLInterface().getAllPackages());
66       }
67    }
68
69    public String JavaDoc getSelectedPackageId () {
70       return (String JavaDoc)openedPackagesTablePanel.getColumnValueOfSelectedRow(0);
71    }
72
73    public String JavaDoc getSelectedPackageVersion () {
74       return (String JavaDoc)openedPackagesTablePanel.getColumnValueOfSelectedRow(1);
75    }
76
77    private void insertPackages (Collection packages) {
78       Iterator it=packages.iterator();
79       while (it.hasNext()) {
80          org.enhydra.jawe.xml.elements.Package pkg=
81             (org.enhydra.jawe.xml.elements.Package)
82             it.next();
83          String JavaDoc pkgId=pkg.get("Id").toString();
84          try {
85             String JavaDoc[] vers=SharkAdmin.getPackageAmin().getPackageVersions(pkgId);
86             String JavaDoc curVer=SharkAdmin.getPackageAmin().getCurrentPackageVersion(pkgId);
87             if (vers==null) continue;
88             for (int i=0; i<vers.length; i++) {
89                Vector row=new Vector();
90                row.add(pkgId);
91                row.add(vers[i]);
92                if (vers[i].equals(curVer)) {
93                   row.add(pkg.get("Name").toString());
94                   WorkflowProcesses wps=(WorkflowProcesses)pkg.get("WorkflowProcesses");
95                   row.add(new Integer JavaDoc(wps.size()));
96                } else {
97                   row.add("???");
98                   row.add(new Integer JavaDoc(-1));
99                }
100                openedPackagesTablePanel.addElement(row);
101             }
102          } catch (Exception JavaDoc ex) {
103             ex.printStackTrace();
104          }
105       }
106    }
107
108 }
109
Popular Tags