1 10 11 12 package org.enhydra.jawe.wfxml; 13 14 import org.enhydra.jawe.xml.*; 15 16 import java.awt.Dimension ; 17 import java.awt.event.ActionEvent ; 18 import java.awt.event.ActionListener ; 19 import java.net.URL ; 20 import java.util.List ; 21 import java.util.Vector ; 22 import javax.swing.Box ; 23 import javax.swing.JComboBox ; 24 import javax.swing.JOptionPane ; 25 import javax.swing.JTable ; 26 import javax.swing.table.DefaultTableModel ; 27 import org.enhydra.jawe.*; 28 import org.enhydra.jawe.xml.*; 29 import org.enhydra.jawe.xml.panels.*; 30 import org.w3c.dom.Node ; 31 32 35 public class WfXMLControlPanel extends XMLControlPanel { 36 public WfXMLControlPanel (XMLCollection myOwner, 37 final WfXMLPanel cont, 38 String title, 39 boolean isVertical, 40 boolean hasBorder) { 41 42 super(myOwner,title,isVertical,hasBorder); 43 44 controlledPanel=cont.getControlledPanel(); 45 46 String d=XMLUtil.getLanguageDependentString("DownloadKey"); 47 String up=XMLUtil.getLanguageDependentString("UploadKey"); 48 String u=XMLUtil.getLanguageDependentString("UpdateKey"); 49 50 Dimension dim=getPreferredDimension(new String []{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 (10,0))); 59 add(buttonUpload); 60 add(Box.createRigidArea(new Dimension (10,0))); 61 add(buttonUpdate); 62 add(Box.createRigidArea(new Dimension (10,0))); 63 add(Box.createRigidArea(new Dimension (0,25))); 64 65 add(Box.createHorizontalGlue()); 66 67 68 buttonDownload.addActionListener(new ActionListener () { 70 public void actionPerformed(ActionEvent ae) { 71 String selected=((XMLComplexElement)cont.getSelectedElement()).get("DefinitionKey").toString(); 72 if (selected!=null) { 73 try { 74 Node n=WfXMLConnector.wfxmlGetDefinition(new URL (selected)); 75 String pkgCnt=WfXMLConnector.node2String(n); 76 String 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 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 buttonUpload.addActionListener(new ActionListener () { 94 public void actionPerformed(ActionEvent ae) { 95 String pkgId=JaWE.getInstance().getRealXMLPackage().get("Id").toString(); 96 String selected=(String )cont.getSelectedItem(); 97 if (selected!=null && pkgId!=null && !pkgId.trim().equals("")) { 98 try { 99 String pkgContent=WfXMLConnector.xpdlToString(); 100 WfXMLConnector.wfxmlNewDefinition2(new URL (selected),pkgContent); 101 JaWE.getInstance().message(pkgId+" - "+ResourceManager.getLanguageDependentString("InformationWfXMLXPDLIsSucessfullyUploaded"),JOptionPane.INFORMATION_MESSAGE); 102 } catch (Exception 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 l=WfXMLConnector.wfxmlListDefinitions(new URL (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 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 buttonUpdate.addActionListener(new ActionListener () { 127 public void actionPerformed(ActionEvent ae) { 128 String pkgId=JaWE.getInstance().getRealXMLPackage().get("Id").toString(); 129 if (cont.getSelectedElement()!=null && pkgId!=null && !pkgId.trim().equals("")) { 130 String selected=((XMLComplexElement)cont.getSelectedElement()).get("DefinitionKey").toString(); 131 try { 132 String pkgContent=WfXMLConnector.xpdlToString(); 133 WfXMLConnector.wfxmlSetDefinition2(new URL (selected),pkgContent); 134 JaWE.getInstance().message(pkgId+" - "+ResourceManager.getLanguageDependentString("InformationWfXMLXPDLIsSucessfullyUpdated"),JOptionPane.INFORMATION_MESSAGE); 135 } catch (Exception ex) { 136 ex.printStackTrace(); 137 JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileUpdatingXPDL")+" "+selected+" !",JOptionPane.ERROR_MESSAGE); 138 return; 139 } 140 try { 141 selected=(String )cont.getSelectedItem(); 142 DefInfos dis=(DefInfos)getOwner(); 143 cont.cleanTable(); 144 List l=WfXMLConnector.wfxmlListDefinitions(new URL (selected),dis); 145 for (int i=0; i<l.size(); i++) { 146 cont.addElement((XMLElement)l.get(i)); 147 } 148 } catch (Exception 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 |