001: package org.apache.ojb.tools.mapping.reversedb.gui;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import java.awt.event.KeyEvent;
019:
020: import org.apache.ojb.tools.mapping.reversedb.Utilities;
021:
022: /**
023: *
024: * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
025: * @version $Id: DBColumnPropertySheet.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
026: */
027: public class DBColumnPropertySheet extends javax.swing.JPanel implements
028: PropertySheetView {
029: org.apache.ojb.tools.mapping.reversedb.DBColumn aColumn;
030:
031: /** Creates new form DBCatalogPropertySheet */
032: public DBColumnPropertySheet() {
033: initComponents();
034: }
035:
036: private void readValuesFromColumn() {
037: this .tfColumnName.setText(aColumn.getColumnName());
038: this .cbEnabled.setSelected(aColumn.isEnabled());
039: this .cbDisabledByParent.setSelected(!aColumn.getDBTable()
040: .isTreeEnabled());
041: this .cmbSQLType
042: .setSelectedItem(org.apache.ojb.tools.mapping.reversedb.Utilities.hmJDBCTypeToName
043: .get(new Integer(aColumn.getColumnType())));
044: this .tfSQLTypeName.setText(aColumn.getColumnTypeName());
045: this .tfJavaFieldName.setText(aColumn.getJavaFieldName());
046: this .cmbJavaType.setSelectedItem(aColumn.getJavaFieldType());
047: }
048:
049: /** This method is called from within the constructor to
050: * initialize the form.
051: * WARNING: Do NOT modify this code. The content of this method is
052: * always regenerated by the Form Editor.
053: */
054: private void initComponents()//GEN-BEGIN:initComponents
055: {
056: java.awt.GridBagConstraints gridBagConstraints;
057:
058: jPanel1 = new javax.swing.JPanel();
059: lblEnabled = new javax.swing.JLabel();
060: cbEnabled = new javax.swing.JCheckBox();
061: lblDisabledByParent = new javax.swing.JLabel();
062: cbDisabledByParent = new javax.swing.JCheckBox();
063: jLabel4 = new javax.swing.JLabel();
064: jLabel3 = new javax.swing.JLabel();
065: lblColumnName = new javax.swing.JLabel();
066: tfColumnName = new javax.swing.JTextField();
067: lblJavaFieldName = new javax.swing.JLabel();
068: tfJavaFieldName = new javax.swing.JTextField();
069: lblSQLTypeName = new javax.swing.JLabel();
070: tfSQLTypeName = new javax.swing.JTextField();
071: lblSQLType = new javax.swing.JLabel();
072: cmbSQLType = new javax.swing.JComboBox();
073: lblJavaType = new javax.swing.JLabel();
074: cmbJavaType = new javax.swing.JComboBox();
075:
076: setLayout(new java.awt.GridBagLayout());
077:
078: addComponentListener(new java.awt.event.ComponentAdapter() {
079: public void componentShown(java.awt.event.ComponentEvent evt) {
080: formComponentShown(evt);
081: }
082:
083: public void componentHidden(
084: java.awt.event.ComponentEvent evt) {
085: formComponentHidden(evt);
086: }
087: });
088:
089: addHierarchyListener(new java.awt.event.HierarchyListener() {
090: public void hierarchyChanged(
091: java.awt.event.HierarchyEvent evt) {
092: formHierarchyChanged(evt);
093: }
094: });
095:
096: jPanel1.setLayout(new java.awt.GridLayout(8, 2));
097:
098: lblEnabled.setDisplayedMnemonic('e');
099: lblEnabled.setText("enabled:");
100: jPanel1.add(lblEnabled);
101:
102: cbEnabled.setMnemonic('e');
103: cbEnabled
104: .addActionListener(new java.awt.event.ActionListener() {
105: public void actionPerformed(
106: java.awt.event.ActionEvent evt) {
107: cbEnabledActionPerformed(evt);
108: }
109: });
110:
111: jPanel1.add(cbEnabled);
112:
113: lblDisabledByParent.setText("disabled by Parent:");
114: jPanel1.add(lblDisabledByParent);
115:
116: cbDisabledByParent.setMnemonic('d');
117: cbDisabledByParent.setEnabled(false);
118: jPanel1.add(cbDisabledByParent);
119:
120: jPanel1.add(jLabel4);
121:
122: jPanel1.add(jLabel3);
123:
124: lblColumnName.setLabelFor(tfColumnName);
125: lblColumnName.setText("Column Name:");
126: jPanel1.add(lblColumnName);
127:
128: tfColumnName.setEditable(false);
129: tfColumnName.setText("jTextField1");
130: tfColumnName.setBorder(null);
131: tfColumnName
132: .setDisabledTextColor((java.awt.Color) javax.swing.UIManager
133: .getDefaults().get("windowText"));
134: tfColumnName.setEnabled(false);
135: jPanel1.add(tfColumnName);
136:
137: lblJavaFieldName.setLabelFor(tfColumnName);
138: lblJavaFieldName.setText("Java Field Name:");
139: jPanel1.add(lblJavaFieldName);
140:
141: tfJavaFieldName.setText("jTextField1");
142: tfJavaFieldName
143: .addActionListener(new java.awt.event.ActionListener() {
144: public void actionPerformed(
145: java.awt.event.ActionEvent evt) {
146: tfJavaFieldNameActionPerformed(evt);
147: }
148: });
149:
150: tfJavaFieldName
151: .addFocusListener(new java.awt.event.FocusAdapter() {
152: public void focusLost(java.awt.event.FocusEvent evt) {
153: tfJavaFieldNameFocusLost(evt);
154: }
155: });
156:
157: tfJavaFieldName.addKeyListener(new java.awt.event.KeyAdapter() {
158: public void keyTyped(java.awt.event.KeyEvent evt) {
159: tfJavaFieldNameKeyTyped(evt);
160: }
161: });
162:
163: jPanel1.add(tfJavaFieldName);
164:
165: lblSQLTypeName.setLabelFor(tfColumnName);
166: lblSQLTypeName.setText("SQL Type Name:");
167: jPanel1.add(lblSQLTypeName);
168:
169: tfSQLTypeName.setEditable(false);
170: tfSQLTypeName.setText("jTextField1");
171: tfSQLTypeName.setBorder(null);
172: tfSQLTypeName
173: .setDisabledTextColor((java.awt.Color) javax.swing.UIManager
174: .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(
182: Utilities.vJDBCTypeNames));
183: cmbSQLType
184: .addActionListener(new java.awt.event.ActionListener() {
185: public void actionPerformed(
186: java.awt.event.ActionEvent evt) {
187: cmbSQLTypeActionPerformed(evt);
188: }
189: });
190:
191: jPanel1.add(cmbSQLType);
192:
193: lblJavaType.setText("Java Type:");
194: jPanel1.add(lblJavaType);
195:
196: cmbJavaType.setEditable(true);
197: cmbJavaType
198: .setModel(new org.apache.ojb.tools.swing.SortingComboBoxModel(
199: Utilities.vJavaTypes)
200: /*new javax.swing.DefaultComboBoxModel(at.citec.ojb.schemegenerator.Utilities.vJavaTypes)*/);
201: cmbJavaType
202: .addActionListener(new java.awt.event.ActionListener() {
203: public void actionPerformed(
204: java.awt.event.ActionEvent evt) {
205: cmbJavaTypeActionPerformed(evt);
206: }
207: });
208:
209: jPanel1.add(cmbJavaType);
210:
211: gridBagConstraints = new java.awt.GridBagConstraints();
212: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
213: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
214: gridBagConstraints.weightx = 1.0;
215: gridBagConstraints.weighty = 1.0;
216: add(jPanel1, gridBagConstraints);
217:
218: }//GEN-END:initComponents
219:
220: private void tfJavaFieldNameKeyTyped(java.awt.event.KeyEvent evt)//GEN-FIRST:event_tfJavaFieldNameKeyTyped
221: {//GEN-HEADEREND:event_tfJavaFieldNameKeyTyped
222: // Revert to original value if ESC is pressed.
223: if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) {
224: this .tfJavaFieldName.setText(aColumn.getJavaFieldName());
225: }
226: }//GEN-LAST:event_tfJavaFieldNameKeyTyped
227:
228: private void tfJavaFieldNameFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_tfJavaFieldNameFocusLost
229: {//GEN-HEADEREND:event_tfJavaFieldNameFocusLost
230: // Commit the new value to the column if the focus is lost
231: aColumn.setJavaFieldName(tfJavaFieldName.getText());
232: }//GEN-LAST:event_tfJavaFieldNameFocusLost
233:
234: private void tfJavaFieldNameActionPerformed(
235: java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfJavaFieldNameActionPerformed
236: {//GEN-HEADEREND:event_tfJavaFieldNameActionPerformed
237: // Commit value to column object if ENTER is pressed
238: aColumn.setJavaFieldName(tfJavaFieldName.getText());
239: }//GEN-LAST:event_tfJavaFieldNameActionPerformed
240:
241: private void cmbJavaTypeActionPerformed(
242: java.awt.event.ActionEvent evt)//GEN-FIRST:event_cmbJavaTypeActionPerformed
243: {//GEN-HEADEREND:event_cmbJavaTypeActionPerformed
244: // Add your handling code here:
245: aColumn.setJavaFieldType(cmbJavaType.getSelectedItem()
246: .toString());
247: if (cmbJavaType.getModel() instanceof org.apache.ojb.tools.swing.SortingComboBoxModel) {
248: org.apache.ojb.tools.swing.SortingComboBoxModel cmbModel = (org.apache.ojb.tools.swing.SortingComboBoxModel) this .cmbJavaType
249: .getModel();
250: if (cmbModel.getIndexOf(cmbJavaType.getSelectedItem()) == -1)
251: cmbJavaType.addItem(cmbJavaType.getSelectedItem());
252: } else if (cmbJavaType.getModel() instanceof javax.swing.DefaultComboBoxModel) {
253: javax.swing.DefaultComboBoxModel cmbModel = (javax.swing.DefaultComboBoxModel) this .cmbJavaType
254: .getModel();
255: if (cmbModel.getIndexOf(cmbJavaType.getSelectedItem()) == -1)
256: cmbJavaType.addItem(cmbJavaType.getSelectedItem());
257: }
258: }//GEN-LAST:event_cmbJavaTypeActionPerformed
259:
260: private void cbEnabledActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbEnabledActionPerformed
261: {//GEN-HEADEREND:event_cbEnabledActionPerformed
262: // Add your handling code here:
263: this .aColumn.setEnabled(this .cbEnabled.isSelected());
264: }//GEN-LAST:event_cbEnabledActionPerformed
265:
266: private void cmbSQLTypeActionPerformed(
267: java.awt.event.ActionEvent evt)//GEN-FIRST:event_cmbSQLTypeActionPerformed
268: {//GEN-HEADEREND:event_cmbSQLTypeActionPerformed
269: // Add your handling code here:
270: // System.out.println(this.jComboBox1.getSelectedItem());
271: aColumn.setColumnType(this .cmbSQLType.getSelectedItem()
272: .toString());
273: }//GEN-LAST:event_cmbSQLTypeActionPerformed
274:
275: private void formHierarchyChanged(java.awt.event.HierarchyEvent evt)//GEN-FIRST:event_formHierarchyChanged
276: {//GEN-HEADEREND:event_formHierarchyChanged
277: // Add your handling code here:
278: readValuesFromColumn();
279: }//GEN-LAST:event_formHierarchyChanged
280:
281: private void formComponentHidden(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentHidden
282: {//GEN-HEADEREND:event_formComponentHidden
283: // Add your handling code here:
284: }//GEN-LAST:event_formComponentHidden
285:
286: private void formComponentShown(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentShown
287: {//GEN-HEADEREND:event_formComponentShown
288: // Add your handling code here:
289: }//GEN-LAST:event_formComponentShown
290:
291: public void setModel(PropertySheetModel pm) {
292: if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBColumn) {
293: this .aColumn = (org.apache.ojb.tools.mapping.reversedb.DBColumn) pm;
294: this .readValuesFromColumn();
295: } else
296: throw new IllegalArgumentException();
297: }
298:
299: // Variables declaration - do not modify//GEN-BEGIN:variables
300: 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: // End of variables declaration//GEN-END:variables
318:
319: }
320:
321: /***************************** Changelog *****************************
322: // $Log: DBColumnPropertySheet.java,v $
323: // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
324: // Updated license
325: //
326: // Revision 1.1 2004/05/05 16:38:49 arminw
327: // fix fault
328: // wrong package structure used:
329: // org.apache.ojb.tools.reversdb
330: // org.apache.ojb.tools.reversdb2
331: //
332: // instead of
333: // org.apache.ojb.tools.mapping.reversdb
334: // org.apache.ojb.tools.mapping.reversdb2
335: //
336: // Revision 1.1 2004/05/04 13:44:59 arminw
337: // move reverseDB stuff
338: //
339: // Revision 1.9 2004/04/05 12:16:23 tomdz
340: // Fixed/updated license in files leftover from automatic license transition
341: //
342: // Revision 1.8 2004/04/04 23:53:42 brianm
343: // Fixed initial copyright dates to match cvs repository
344: //
345: // Revision 1.7 2004/03/11 18:16:22 brianm
346: // ASL 2.0
347: //
348: // Revision 1.6 2003/06/21 10:21:55 florianbruckner
349: // update netbeans 3.4 -> 3.5; XML and code genration changed a bit
350: //
351: // Revision 1.5 2003/06/07 10:11:50 brj
352: // some style fixes
353: //
354: // Revision 1.4 2003/02/21 12:47:03 florianbruckner
355: // corrected event handling of JInputField objects, value of field was
356: // not written back to the model object.
357: //
358: // Revision 1.3 2002/06/18 12:26:41 florianbruckner
359: // changes in Netbeans Form definitions after move to jakarta.
360: //
361: // Revision 1.2 2002/06/17 19:34:34 jvanzyl
362: // Correcting all the package references.
363: // PR:
364: // Obtained from:
365: // Submitted by:
366: // Reviewed by:
367: //
368: // Revision 1.1.1.1 2002/06/17 18:16:52 jvanzyl
369: // Initial OJB import
370: //
371: // Revision 1.2 2002/05/16 11:47:09 florianbruckner
372: // fix CR/LF issue, change license to ASL
373: //
374: // Revision 1.1 2002/04/18 11:44:16 mpoeschl
375: //
376: // move files to new location
377: //
378: // Revision 1.4 2002/04/07 09:05:17 thma
379: // *** empty log message ***
380: //
381: // Revision 1.3 2002/03/11 18:40:26 florianbruckner
382: // modify .form files so the use the correct package name
383: //
384: // Revision 1.2 2002/03/11 17:36:26 florianbruckner
385: // fix line break issue for these files that were previously checked in with -kb
386: //
387: // Revision 1.1 2002/03/04 17:19:32 thma
388: // initial checking for Florians Reverse engineering tool
389: //
390: // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
391: // initial import
392: //
393: /***************************** Changelog *****************************/
|