1 10 11 12 package org.enhydra.jawe.wfxml; 13 14 import javax.swing.*; 15 import java.awt.Dimension ; 16 import org.enhydra.jawe.xml.*; 17 import org.enhydra.jawe.xml.elements.*; 18 import org.enhydra.jawe.xml.panels.*; 19 import org.enhydra.jawe.xml.panels.*; 20 import org.enhydra.jawe.xml.panels.XMLTableControlPanel; 21 import org.enhydra.jawe.xml.panels.XMLTablePanel; 22 import org.enhydra.jawe.xml.*; 23 24 import java.awt.Dimension ; 25 import java.awt.event.ActionEvent ; 26 import java.awt.event.ActionListener ; 27 import java.net.URL ; 28 import java.util.List ; 29 import java.util.Vector ; 30 import javax.swing.Box ; 31 import javax.swing.JComboBox ; 32 import javax.swing.JOptionPane ; 33 import javax.swing.JTable ; 34 import javax.swing.table.DefaultTableModel ; 35 import org.enhydra.jawe.*; 36 import org.enhydra.jawe.xml.*; 37 import org.enhydra.jawe.xml.panels.*; 38 import org.w3c.dom.Node ; 39 40 41 44 public class WfXMLPanel extends XMLPanel { 45 46 XMLTablePanel lstPanel; 47 WfXMLComboPanel cboPanel; 48 49 public WfXMLPanel (XMLCollection myOwner) { 50 51 super(myOwner,1,"",XMLPanel.BOX_LAYOUT,true,false); 52 53 cboPanel=new WfXMLComboPanel(myOwner); 54 55 lstPanel=new XMLTablePanel (myOwner,myOwner.toLabel(),false,true,false,false,false); 56 57 add(cboPanel); 58 add(Box.createRigidArea(new Dimension (0,10))); 59 add(lstPanel); 60 61 setPreferredSize(new Dimension (850,500)); 62 63 XMLButton buttonConnect=cboPanel.getConnectButton(); 64 final JComboBox jcb=cboPanel.getComboBox(); 65 buttonConnect.addActionListener(new ActionListener (){ 67 public void actionPerformed(ActionEvent ae){ 68 String selected=(String )jcb.getSelectedItem(); 69 DefInfos dis=(DefInfos)getOwner(); 70 if (selected!=null) { 71 try { 72 List l=WfXMLConnector.wfxmlListDefinitions(new URL (selected),dis); 73 cleanTable(); 74 for (int i=0; i<l.size(); i++) { 75 addElement((XMLElement)l.get(i)); 76 } 77 JaWE.getInstance().message(ResourceManager.getLanguageDependentString("InformationWfXMLSuccessfullyConnectedToRegistryService")+" "+selected,JOptionPane.INFORMATION_MESSAGE); 78 } catch (Exception ex) { 79 ex.printStackTrace(); 80 JaWE.getInstance().message(ResourceManager.getLanguageDependentString("ErrorWfXMLProblemsWhileGettingDefinitionListForRegistry")+" "+selected+" !",JOptionPane.ERROR_MESSAGE); 81 } 82 } else { 83 complainLoudly("WarningEmptySelectionToEditOrDelete"); 84 } 85 } 86 }); 87 88 89 90 } 91 92 public XMLPanel getControlledPanel () { 93 return lstPanel; 94 } 95 96 public WfXMLComboPanel getComboPanel () { 97 return cboPanel; 98 } 99 100 103 public void complainLoudly(String message) { 104 JOptionPane.showMessageDialog(getDialog(), 105 XMLUtil.getLanguageDependentString(message), 106 XMLUtil.getLanguageDependentString("Title"), 107 JOptionPane.WARNING_MESSAGE); 108 } 109 110 public void cleanTable () { 111 ((XMLCollection)getOwner()).clear(); 112 JTable t=lstPanel.getTable(); 113 DefaultTableModel dtm=(DefaultTableModel )t.getModel(); 114 int rc=dtm.getRowCount(); 115 for (int i=rc-1; i>=0; i--) { 116 dtm.removeRow(i); 117 } 118 } 119 120 public void addElement(XMLElement e) { 121 XMLCollection owncol=(XMLCollection)getOwner(); 122 int rowpos=owncol.size(); 123 owncol.add(e); 124 JTable t=lstPanel.getTable(); 125 DefaultTableModel dtm=(DefaultTableModel )t.getModel(); 126 Vector v=null; 127 if (e instanceof XMLComplexElement) { 128 v=new Vector (((XMLComplexElement)e).toComplexTypeValues()); 129 } else { 130 v=new Vector (); 131 v.add(e.toString()); 132 } 133 134 v.add(0,e); 136 dtm.insertRow(rowpos,v); 137 try { 139 t.setRowSelectionInterval(rowpos,rowpos); 141 } catch (Exception ex) {} 142 t.requestFocus(); 143 } 144 145 public XMLElement getSelectedElement() { 146 return lstPanel.getSelectedElement(); 147 } 148 149 150 public Object getSelectedItem () { 151 Object si=cboPanel.getComboBox().getSelectedItem(); 152 System.out.println("Si="+si); 153 return si; 154 } 155 156 } 157 158 | Popular Tags |