1 package org.apache.ojb.tools.mapping.reversedb.gui; 2 3 17 18 import java.awt.event.KeyEvent ; 19 20 import org.apache.ojb.tools.mapping.reversedb.Utilities; 21 22 27 public class DBColumnPropertySheet extends javax.swing.JPanel 28 implements PropertySheetView 29 { 30 org.apache.ojb.tools.mapping.reversedb.DBColumn aColumn; 31 32 public DBColumnPropertySheet () 33 { 34 initComponents (); 35 } 36 37 private void readValuesFromColumn() 38 { 39 this.tfColumnName.setText(aColumn.getColumnName()); 40 this.cbEnabled.setSelected(aColumn.isEnabled()); 41 this.cbDisabledByParent.setSelected(!aColumn.getDBTable().isTreeEnabled()); 42 this.cmbSQLType.setSelectedItem(org.apache.ojb.tools.mapping.reversedb.Utilities.hmJDBCTypeToName.get(new Integer (aColumn.getColumnType()))); 43 this.tfSQLTypeName.setText(aColumn.getColumnTypeName ()); 44 this.tfJavaFieldName.setText(aColumn.getJavaFieldName()); 45 this.cmbJavaType.setSelectedItem(aColumn.getJavaFieldType()); 46 } 47 48 53 private void initComponents() { 55 java.awt.GridBagConstraints gridBagConstraints; 56 57 jPanel1 = new javax.swing.JPanel (); 58 lblEnabled = new javax.swing.JLabel (); 59 cbEnabled = new javax.swing.JCheckBox (); 60 lblDisabledByParent = new javax.swing.JLabel (); 61 cbDisabledByParent = new javax.swing.JCheckBox (); 62 jLabel4 = new javax.swing.JLabel (); 63 jLabel3 = new javax.swing.JLabel (); 64 lblColumnName = new javax.swing.JLabel (); 65 tfColumnName = new javax.swing.JTextField (); 66 lblJavaFieldName = new javax.swing.JLabel (); 67 tfJavaFieldName = new javax.swing.JTextField (); 68 lblSQLTypeName = new javax.swing.JLabel (); 69 tfSQLTypeName = new javax.swing.JTextField (); 70 lblSQLType = new javax.swing.JLabel (); 71 cmbSQLType = new javax.swing.JComboBox (); 72 lblJavaType = new javax.swing.JLabel (); 73 cmbJavaType = new javax.swing.JComboBox (); 74 75 setLayout(new java.awt.GridBagLayout ()); 76 77 addComponentListener(new java.awt.event.ComponentAdapter () 78 { 79 public void componentShown(java.awt.event.ComponentEvent evt) 80 { 81 formComponentShown(evt); 82 } 83 public void componentHidden(java.awt.event.ComponentEvent evt) 84 { 85 formComponentHidden(evt); 86 } 87 }); 88 89 addHierarchyListener(new java.awt.event.HierarchyListener () 90 { 91 public void hierarchyChanged(java.awt.event.HierarchyEvent evt) 92 { 93 formHierarchyChanged(evt); 94 } 95 }); 96 97 jPanel1.setLayout(new java.awt.GridLayout (8, 2)); 98 99 lblEnabled.setDisplayedMnemonic('e'); 100 lblEnabled.setText("enabled:"); 101 jPanel1.add(lblEnabled); 102 103 cbEnabled.setMnemonic('e'); 104 cbEnabled.addActionListener(new java.awt.event.ActionListener () 105 { 106 public void actionPerformed(java.awt.event.ActionEvent evt) 107 { 108 cbEnabledActionPerformed(evt); 109 } 110 }); 111 112 jPanel1.add(cbEnabled); 113 114 lblDisabledByParent.setText("disabled by Parent:"); 115 jPanel1.add(lblDisabledByParent); 116 117 cbDisabledByParent.setMnemonic('d'); 118 cbDisabledByParent.setEnabled(false); 119 jPanel1.add(cbDisabledByParent); 120 121 jPanel1.add(jLabel4); 122 123 jPanel1.add(jLabel3); 124 125 lblColumnName.setLabelFor(tfColumnName); 126 lblColumnName.setText("Column Name:"); 127 jPanel1.add(lblColumnName); 128 129 tfColumnName.setEditable(false); 130 tfColumnName.setText("jTextField1"); 131 tfColumnName.setBorder(null); 132 tfColumnName.setDisabledTextColor((java.awt.Color ) javax.swing.UIManager.getDefaults().get("windowText")); 133 tfColumnName.setEnabled(false); 134 jPanel1.add(tfColumnName); 135 136 lblJavaFieldName.setLabelFor(tfColumnName); 137 lblJavaFieldName.setText("Java Field Name:"); 138 jPanel1.add(lblJavaFieldName); 139 140 tfJavaFieldName.setText("jTextField1"); 141 tfJavaFieldName.addActionListener(new java.awt.event.ActionListener () 142 { 143 public void actionPerformed(java.awt.event.ActionEvent evt) 144 { 145 tfJavaFieldNameActionPerformed(evt); 146 } 147 }); 148 149 tfJavaFieldName.addFocusListener(new java.awt.event.FocusAdapter () 150 { 151 public void focusLost(java.awt.event.FocusEvent evt) 152 { 153 tfJavaFieldNameFocusLost(evt); 154 } 155 }); 156 157 tfJavaFieldName.addKeyListener(new java.awt.event.KeyAdapter () 158 { 159 public void keyTyped(java.awt.event.KeyEvent evt) 160 { 161 tfJavaFieldNameKeyTyped(evt); 162 } 163 }); 164 165 jPanel1.add(tfJavaFieldName); 166 167 lblSQLTypeName.setLabelFor(tfColumnName); 168 lblSQLTypeName.setText("SQL Type Name:"); 169 jPanel1.add(lblSQLTypeName); 170 171 tfSQLTypeName.setEditable(false); 172 tfSQLTypeName.setText("jTextField1"); 173 tfSQLTypeName.setBorder(null); 174 tfSQLTypeName.setDisabledTextColor((java.awt.Color ) javax.swing.UIManager.getDefaults().get("windowText")); 175 tfSQLTypeName.setEnabled(false); 176 jPanel1.add(tfSQLTypeName); 177 178 lblSQLType.setText("Java SQL Type:"); 179 jPanel1.add(lblSQLType); 180 181 cmbSQLType.setModel(new javax.swing.DefaultComboBoxModel (Utilities.vJDBCTypeNames)); 182 cmbSQLType.addActionListener(new java.awt.event.ActionListener () 183 { 184 public void actionPerformed(java.awt.event.ActionEvent evt) 185 { 186 cmbSQLTypeActionPerformed(evt); 187 } 188 }); 189 190 jPanel1.add(cmbSQLType); 191 192 lblJavaType.setText("Java Type:"); 193 jPanel1.add(lblJavaType); 194 195 cmbJavaType.setEditable(true); 196 cmbJavaType.setModel( new org.apache.ojb.tools.swing.SortingComboBoxModel(Utilities.vJavaTypes) 197 ); 198 cmbJavaType.addActionListener(new java.awt.event.ActionListener () 199 { 200 public void actionPerformed(java.awt.event.ActionEvent evt) 201 { 202 cmbJavaTypeActionPerformed(evt); 203 } 204 }); 205 206 jPanel1.add(cmbJavaType); 207 208 gridBagConstraints = new java.awt.GridBagConstraints (); 209 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 210 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 211 gridBagConstraints.weightx = 1.0; 212 gridBagConstraints.weighty = 1.0; 213 add(jPanel1, gridBagConstraints); 214 215 } 217 private void tfJavaFieldNameKeyTyped(java.awt.event.KeyEvent evt) { if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) 221 { 222 this.tfJavaFieldName.setText(aColumn.getJavaFieldName()); 223 } 224 } 226 private void tfJavaFieldNameFocusLost(java.awt.event.FocusEvent evt) { aColumn.setJavaFieldName(tfJavaFieldName.getText()); 230 } 232 private void tfJavaFieldNameActionPerformed(java.awt.event.ActionEvent evt) { aColumn.setJavaFieldName(tfJavaFieldName.getText()); 236 } 238 private void cmbJavaTypeActionPerformed (java.awt.event.ActionEvent evt) { aColumn.setJavaFieldType(cmbJavaType.getSelectedItem().toString()); 242 if (cmbJavaType.getModel() instanceof org.apache.ojb.tools.swing.SortingComboBoxModel) 243 { 244 org.apache.ojb.tools.swing.SortingComboBoxModel cmbModel = 245 (org.apache.ojb.tools.swing.SortingComboBoxModel)this.cmbJavaType.getModel(); 246 if (cmbModel.getIndexOf(cmbJavaType.getSelectedItem()) == -1 ) 247 cmbJavaType.addItem(cmbJavaType.getSelectedItem()); 248 } 249 else if (cmbJavaType.getModel() instanceof javax.swing.DefaultComboBoxModel ) 250 { 251 javax.swing.DefaultComboBoxModel cmbModel = 252 (javax.swing.DefaultComboBoxModel )this.cmbJavaType.getModel(); 253 if (cmbModel.getIndexOf(cmbJavaType.getSelectedItem()) == -1 ) 254 cmbJavaType.addItem(cmbJavaType.getSelectedItem()); 255 } 256 } 258 private void cbEnabledActionPerformed (java.awt.event.ActionEvent evt) { this.aColumn.setEnabled(this.cbEnabled.isSelected()); 262 } 264 private void cmbSQLTypeActionPerformed (java.awt.event.ActionEvent evt) { aColumn.setColumnType(this.cmbSQLType.getSelectedItem().toString()); 269 } 271 private void formHierarchyChanged (java.awt.event.HierarchyEvent evt) { readValuesFromColumn(); 275 } 277 private void formComponentHidden (java.awt.event.ComponentEvent evt) { } 282 private void formComponentShown (java.awt.event.ComponentEvent evt) { } 287 public void setModel (PropertySheetModel pm) 288 { 289 if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBColumn) 290 { 291 this.aColumn = (org.apache.ojb.tools.mapping.reversedb.DBColumn)pm; 292 this.readValuesFromColumn(); 293 } 294 else 295 throw new IllegalArgumentException (); 296 } 297 298 299 private javax.swing.JLabel jLabel4; 301 private javax.swing.JLabel lblSQLTypeName; 302 private javax.swing.JLabel jLabel3; 303 private javax.swing.JComboBox cmbSQLType; 304 private javax.swing.JLabel lblJavaType; 305 private javax.swing.JLabel lblEnabled; 306 private javax.swing.JCheckBox cbEnabled; 307 private javax.swing.JTextField tfJavaFieldName; 308 private javax.swing.JCheckBox cbDisabledByParent; 309 private javax.swing.JTextField tfColumnName; 310 private javax.swing.JLabel lblDisabledByParent; 311 private javax.swing.JLabel lblColumnName; 312 private javax.swing.JComboBox cmbJavaType; 313 private javax.swing.JPanel jPanel1; 314 private javax.swing.JLabel lblJavaFieldName; 315 private javax.swing.JLabel lblSQLType; 316 private javax.swing.JTextField tfSQLTypeName; 317 319 } 320 321 322 395 | Popular Tags |