1 19 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui; 20 21 import java.awt.event.ItemListener ; 22 import org.netbeans.modules.j2ee.websphere6.dd.beans.*; 23 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject; 24 import org.netbeans.modules.j2ee.websphere6.dd.loaders.webbnd.WSWebBndDataObject; 25 import org.netbeans.modules.xml.multiview.*; 26 import org.netbeans.modules.xml.multiview.ui.*; 27 import org.netbeans.modules.xml.multiview.Error; 28 32 public class WSReferenceBindingsPanel extends SectionInnerPanel implements java.awt.event.ItemListener { 33 CommonRef reference; 34 WSMultiViewDataObject dObj; 35 38 public WSReferenceBindingsPanel(SectionView view, WSMultiViewDataObject dObj, CommonRef reference) { 39 super(view); 40 this.dObj=dObj; 41 this.reference=reference; 42 initComponents(); 43 referenceField.setText(reference.getXmiId()); 44 jndiNameField.setText(reference.getJndiName()); 45 hrefField.setText(reference.getHref()); 46 addModifier(hrefField); 47 addModifier(jndiNameField); 48 addModifier(referenceField); 49 getSectionView().getErrorPanel().clearError(); 50 typeComboBox.setModel(new javax.swing.DefaultComboBoxModel (DDXmiConstants.BINDING_EJB_REF_TYPES)); 51 typeComboBox.setSelectedItem(reference.getXmiType()); 52 typeComboBox.addItemListener(this); 53 } 54 55 public void setValue(javax.swing.JComponent source, Object value) { 56 if (source==referenceField) { 57 reference.setXmiId((String )value); 58 } else if(source==jndiNameField) { 59 reference.setJndiName((String )value); 60 } else if(source==hrefField) { 61 reference.setHref((String )value); 62 } 63 } 64 65 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 66 if (comp==referenceField) { 67 String val = (String )value; 68 if (val.length()==0) { 69 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "id", comp)); 70 return; 71 } 72 getSectionView().getErrorPanel().clearError(); 73 } 74 if(comp==jndiNameField) { 75 String val = (String )value; 76 if (val.length()==0) { 77 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "jndi", comp)); 78 return; 79 } 80 getSectionView().getErrorPanel().clearError(); 81 } 82 if(comp==hrefField) { 83 String val = (String )value; 84 if (val.length()==0) { 85 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "webhref", comp)); 86 return; 87 } 88 getSectionView().getErrorPanel().clearError(); 89 } 90 } 91 92 public void rollbackValue(javax.swing.text.JTextComponent source) { 93 if (referenceField==source) { 94 referenceField.setText(reference.getXmiId()); 95 } 96 if (jndiNameField==source) { 97 jndiNameField.setText(reference.getJndiName()); 98 } 99 if (hrefField==source) { 100 hrefField.setText(reference.getHref()); 101 } 102 } 103 public void linkButtonPressed(Object ddBean, String ddProperty) { 104 } 105 106 public void itemStateChanged(java.awt.event.ItemEvent evt) { 107 dObj.setChangedFromUI(true); 108 if(evt.getSource()==typeComboBox) { 109 reference.setXmiType((String )typeComboBox.getSelectedItem()); 110 } 111 dObj.modelUpdatedFromUI(); 112 dObj.setChangedFromUI(false); 114 } 115 116 public javax.swing.JComponent getErrorComponent(String errorId) { 117 if ("id".equals(errorId)) return referenceField; 118 if ("jndi".equals(errorId)) return jndiNameField; 119 if ("webhref".equals(errorId)) return hrefField; 120 return null; 121 } 122 123 125 protected void startUIChange() { 126 dObj.setChangedFromUI(true); 127 } 128 129 131 protected void endUIChange() { 132 dObj.modelUpdatedFromUI(); 133 dObj.setChangedFromUI(false); 134 } 135 140 private void initComponents() { 142 jLabel1 = new javax.swing.JLabel (); 143 jLabel2 = new javax.swing.JLabel (); 144 jLabel3 = new javax.swing.JLabel (); 145 referenceField = new javax.swing.JTextField (); 146 jndiNameField = new javax.swing.JTextField (); 147 hrefField = new javax.swing.JTextField (); 148 typeComboBox = new javax.swing.JComboBox (); 149 jLabel4 = new javax.swing.JLabel (); 150 151 jLabel1.setText("Name:"); 152 153 jLabel2.setText("JNDI Name:"); 154 155 jLabel3.setText("Name in Web.xml :"); 156 157 jLabel4.setText("Type"); 158 159 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 160 this.setLayout(layout); 161 layout.setHorizontalGroup( 162 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 163 .add(layout.createSequentialGroup() 164 .addContainerGap() 165 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 166 .add(jLabel1) 167 .add(jLabel2) 168 .add(jLabel3) 169 .add(jLabel4)) 170 .add(16, 16, 16) 171 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 172 .add(referenceField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE) 173 .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE) 174 .add(jndiNameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE) 175 .add(typeComboBox, 0, 338, Short.MAX_VALUE)) 176 .addContainerGap()) 177 ); 178 layout.setVerticalGroup( 179 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 180 .add(layout.createSequentialGroup() 181 .addContainerGap() 182 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 183 .add(jLabel1) 184 .add(referenceField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 185 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 186 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 187 .add(jLabel2) 188 .add(jndiNameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 189 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 190 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 191 .add(jLabel3) 192 .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 193 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 194 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 195 .add(typeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 196 .add(jLabel4)) 197 .addContainerGap()) 198 ); 199 } 201 202 private javax.swing.JTextField hrefField; 204 private javax.swing.JLabel jLabel1; 205 private javax.swing.JLabel jLabel2; 206 private javax.swing.JLabel jLabel3; 207 private javax.swing.JLabel jLabel4; 208 private javax.swing.JTextField jndiNameField; 209 private javax.swing.JTextField referenceField; 210 private javax.swing.JComboBox typeComboBox; 211 213 } 214 | Popular Tags |