KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corbaclient > workflowadmin > definition > actions > LoadPackage


1 package org.enhydra.shark.corbaclient.workflowadmin.definition.actions;
2
3 import org.omg.WfBase.*;
4 import org.enhydra.shark.corba.WorkflowService.*;
5 import java.awt.event.*;
6 import javax.swing.*;
7 import java.util.*;
8
9 import org.enhydra.jawe.JaWE;
10 import org.enhydra.shark.corbaclient.*;
11 import org.enhydra.shark.corbaclient.workflowadmin.*;
12 import org.enhydra.shark.corbaclient.workflowadmin.definition.*;
13
14 /**
15  * Displays the dialog for loading the packages into the engine.
16  *
17  * @author Sasa Bojanic
18  * @version 1.0
19  */

20 public class LoadPackage extends ActionBase {
21
22    public LoadPackage(PackageManagement pdm) {
23       super(pdm);
24    }
25
26    public void actionPerformed(ActionEvent e) {
27       PackageManagement pdm=(PackageManagement)actionPanel;
28       SharkAdmin workflowAdmin=pdm.getWorkflowAdmin();
29
30       // Filter the list of posible package files to display only the ones
31
// with the ids different then the ones of already loaded packages.
32
Collection existingIds=JaWE.getInstance().getXMLInterface().getAllPackageIds();
33       java.util.List JavaDoc allPackages=new ArrayList();
34       try {
35          NameValue[] allPkgs=SharkAdmin.getRepositoryManager().getPackagePathToIdMapping();
36
37          if (allPkgs!=null && allPkgs.length>0) {
38             for (int i=0; i<allPkgs.length; i++) {
39                if (!existingIds.contains(allPkgs[i].the_value.extract_wstring())) {
40                   allPackages.add(WorkflowUtilities.convertNameValueToNameValueString(allPkgs[i]));
41                }
42             }
43          }
44       } catch (Exception JavaDoc ex) {}
45
46       SelectPackage spd=new SelectPackage (this,pdm.getWindow(),allPackages);
47       spd.showDialog();
48    }
49
50    public void loadPackage (String JavaDoc packageName) {
51       PackageManagement pdm=(PackageManagement)actionPanel;
52       SplashScreen ss=pdm.getWorkflowAdmin().getSplashScreen();
53       ss.show("WaitImage",
54             pdm.getWorkflowAdmin().getFullUserName(),
55             ResourceManager.getLanguageDependentString("MessagePleaseWait"));
56       String JavaDoc errMsg=null;
57       String JavaDoc xpdlReport=null;
58       try {
59          SharkAdmin.getPackageAmin().openPkg(packageName);
60          pdm.getWorkflowAdmin().refresh(true);
61       } catch (PackageInvalid ipe) {
62          errMsg=ResourceManager.getLanguageDependentString("ErrorThePackageIsInvalid");
63          xpdlReport=ipe.XPDLValidationErrors;
64       } catch (ExternalPackageInvalid iepe) {
65          errMsg=ResourceManager.getLanguageDependentString("ErrorTheOneOfTheExternalPackagesIsInvalid");
66       } catch (Exception JavaDoc ex) {
67          errMsg=ResourceManager.getLanguageDependentString("ErrorThePackageCannotBeLoadedAtTheMoment");
68          //ex.printStackTrace();
69
}
70       ss.hide();
71       if (errMsg!=null) {
72          JOptionPane.showMessageDialog(pdm.getWindow(),errMsg,
73                SharkAdmin.getAppTitle(),JOptionPane.ERROR_MESSAGE);
74          pdm.getWorkflowAdmin().showXPDLErrorsReport(xpdlReport);
75       }
76
77    }
78
79 }
80
81
Popular Tags