KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > wfxml > WfXMLControlPanel


1 /* XMLActualParametersListControlPanel.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11
12 package org.enhydra.jawe.wfxml;
13
14 import org.enhydra.jawe.xml.*;
15
16 import java.awt.Dimension JavaDoc;
17 import java.awt.event.ActionEvent JavaDoc;
18 import java.awt.event.ActionListener JavaDoc;
19 import java.net.URL JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Vector JavaDoc;
22 import javax.swing.Box JavaDoc;
23 import javax.swing.JComboBox JavaDoc;
24 import javax.swing.JOptionPane JavaDoc;
25 import javax.swing.JTable JavaDoc;
26 import javax.swing.table.DefaultTableModel JavaDoc;
27 import org.enhydra.jawe.*;
28 import org.enhydra.jawe.xml.*;
29 import org.enhydra.jawe.xml.panels.*;
30 import org.w3c.dom.Node JavaDoc;
31
32 /**
33  * Creates a control panel for table panel.
34  */

35 public class WfXMLControlPanel extends XMLControlPanel {
36    public WfXMLControlPanel (XMLCollection myOwner,
37                              final WfXMLPanel cont,
38                              String JavaDoc title,
39                              boolean isVertical,
40                              boolean hasBorder) {
41
42       super(myOwner,title,isVertical,hasBorder);
43
44       controlledPanel=cont.getControlledPanel();
45
46       String JavaDoc d=XMLUtil.getLanguageDependentString("DownloadKey");
47       String JavaDoc up=XMLUtil.getLanguageDependentString("UploadKey");
48       String JavaDoc u=XMLUtil.getLanguageDependentString("UpdateKey");
49
50       Dimension JavaDoc dim=getPreferredDimension(new String JavaDoc[]{d,u,up});
51
52       XMLButton buttonDownload=new XMLButton(d,"Download",dim);
53       XMLButton buttonUpload=new XMLButton(up,"Upload",dim);
54       XMLButton buttonUpdate=new XMLButton(u,"Update",dim);
55
56       add(Box.createHorizontalGlue());
57       add(buttonDownload);
58       add(Box.createRigidArea(new Dimension JavaDoc(10,0)));
59       add(buttonUpload);
60       add(Box.createRigidArea(new Dimension JavaDoc(10,0)));
61       add(buttonUpdate);
62       add(Box.createRigidArea(new Dimension JavaDoc(10,0)));
63       add(Box.createRigidArea(new Dimension JavaDoc(0,25)));
64
65       add(Box.createHorizontalGlue());
66
67
68       // action listener for downloading XPDL
69
buttonDownload.addActionListener(new ActionListener JavaDoc() {
70                public void actionPerformed(ActionEvent JavaDoc ae) {
71                   String JavaDoc selected=((XMLComplexElement)cont.getSelectedElement()).get("DefinitionKey").toString();
72                   if (selected!=null) {
73                      try {
74                         Node JavaDoc n=WfXMLConnector.wfxmlGetDefinition(new URL JavaDoc(selected));
75                         String JavaDoc pkgCnt=WfXMLConnector.node2String(n);
76                         String JavaDoc pkgId=XMLUtil.getID(n);
77
78                         JaWE.getInstance().openPackageFromStream(pkgId,pkgCnt);
79
80                         JaWE.getInstance().message(pkgId+" - "+ResourceManager.getLanguageDependentString("InformationWfXMLXPDLIsSucessfullyDownloaded"),JOptionPane.INFORMATION_MESSAGE);
81
82                      } catch (Exception JavaDoc ex) {
83                         ex.printStackTrace();
84                         JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileDownloadingXPDL")+" "+selected+" !",JOptionPane.ERROR_MESSAGE);
85                      }
86                   } else {
87                      cont.complainLoudly("WarningEmptySelectionToEditOrDelete");
88                   }
89                }
90             });
91
92       // action listener for uploading XPDL
93
buttonUpload.addActionListener(new ActionListener JavaDoc() {
94                public void actionPerformed(ActionEvent JavaDoc ae) {
95                   String JavaDoc pkgId=JaWE.getInstance().getRealXMLPackage().get("Id").toString();
96                   String JavaDoc selected=(String JavaDoc)cont.getSelectedItem();
97                   if (selected!=null && pkgId!=null && !pkgId.trim().equals("")) {
98                      try {
99                         String JavaDoc pkgContent=WfXMLConnector.xpdlToString();
100                         WfXMLConnector.wfxmlNewDefinition2(new URL JavaDoc(selected),pkgContent);
101                         JaWE.getInstance().message(pkgId+" - "+ResourceManager.getLanguageDependentString("InformationWfXMLXPDLIsSucessfullyUploaded"),JOptionPane.INFORMATION_MESSAGE);
102                      } catch (Exception JavaDoc ex) {
103                         ex.printStackTrace();
104                         JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileUploadingXPDL")+" "+selected+" !",JOptionPane.ERROR_MESSAGE);
105                         return;
106                      }
107                      try {
108                         DefInfos dis=(DefInfos)getOwner();
109                         List JavaDoc l=WfXMLConnector.wfxmlListDefinitions(new URL JavaDoc(selected),dis);
110                         cont.cleanTable();
111                         for (int i=0; i<l.size(); i++) {
112                            cont.addElement((XMLElement)l.get(i));
113                         }
114                      } catch (Exception JavaDoc ex) {
115                         ex.printStackTrace();
116                         JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileGettingDefinitionListForRegistry")+" "+selected+" !",JOptionPane.ERROR_MESSAGE);
117                      }
118
119                   } else {
120                      cont.complainLoudly("WarningEmptySelectionToEditOrDelete");
121                   }
122                }
123             });
124
125       // action listener for updating XPDL
126
buttonUpdate.addActionListener(new ActionListener JavaDoc() {
127                public void actionPerformed(ActionEvent JavaDoc ae) {
128                   String JavaDoc pkgId=JaWE.getInstance().getRealXMLPackage().get("Id").toString();
129                   if (cont.getSelectedElement()!=null && pkgId!=null && !pkgId.trim().equals("")) {
130                      String JavaDoc selected=((XMLComplexElement)cont.getSelectedElement()).get("DefinitionKey").toString();
131                      try {
132                         String JavaDoc pkgContent=WfXMLConnector.xpdlToString();
133                         WfXMLConnector.wfxmlSetDefinition2(new URL JavaDoc(selected),pkgContent);
134                         JaWE.getInstance().message(pkgId+" - "+ResourceManager.getLanguageDependentString("InformationWfXMLXPDLIsSucessfullyUpdated"),JOptionPane.INFORMATION_MESSAGE);
135                      } catch (Exception JavaDoc ex) {
136                         ex.printStackTrace();
137                         JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileUpdatingXPDL")+" "+selected+" !",JOptionPane.ERROR_MESSAGE);
138                         return;
139                      }
140                      try {
141                         selected=(String JavaDoc)cont.getSelectedItem();
142                         DefInfos dis=(DefInfos)getOwner();
143                         cont.cleanTable();
144                         List JavaDoc l=WfXMLConnector.wfxmlListDefinitions(new URL JavaDoc(selected),dis);
145                         for (int i=0; i<l.size(); i++) {
146                            cont.addElement((XMLElement)l.get(i));
147                         }
148                      } catch (Exception JavaDoc ex) {
149                         ex.printStackTrace();
150                         JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileGettingDefinitionListForRegistry")+" "+selected+" !",JOptionPane.ERROR_MESSAGE);
151                      }
152
153                   } else {
154                      cont.complainLoudly("WarningEmptySelectionToEditOrDelete");
155                   }
156                }
157             });
158    }
159
160
161 }
162
163
Popular Tags