001: package org.apache.ojb.tools.mapping.reversedb.gui;
002:
003: import java.awt.event.KeyEvent;
004:
005: /* Copyright 2002-2005 The Apache Software Foundation
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: */
019:
020: /**
021: *
022: * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a>
023: * @version $Id: DBFKRelationPropertySheet.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
024: */
025: public class DBFKRelationPropertySheet extends javax.swing.JPanel
026: implements PropertySheetView {
027: org.apache.ojb.tools.mapping.reversedb.DBFKRelation aRelation;
028:
029: /** Creates new form DBCatalogPropertySheet */
030: public DBFKRelationPropertySheet() {
031: initComponents();
032: }
033:
034: private void readValuesFromReference() {
035: if (aRelation.getPKTable() != null)
036: this .tfPKTableName.setText(aRelation.getPKTable()
037: .getTableName());
038: if (aRelation.getFKTable() != null)
039: this .tfFKTableName.setText(aRelation.getFKTable()
040: .getTableName());
041: if (aRelation.isPkTableParent()) {
042: this .tfReferenceType.setText("Collection");
043: this .tfJavaFieldType.setEditable(true);
044: this .tfJavaFieldType.setText(aRelation.getFieldType());
045: if (aRelation.getFKTable() != null)
046: this .cbDisabledByParent.setSelected(!aRelation
047: .getPKTable().isTreeEnabled());
048: } else {
049: this .tfReferenceType.setText("Reference");
050: this .tfJavaFieldType.setEditable(false);
051: if (aRelation.getPKTable() != null) {
052: this .tfJavaFieldType.setText(aRelation.getPKTable()
053: .getClassName());
054: this .cbDisabledByParent.setSelected(!aRelation
055: .getFKTable().isTreeEnabled());
056: }
057: }
058: this .cbEnabled.setSelected(aRelation.isEnabled());
059:
060: this .cbAutoDelete.setSelected(aRelation.getAutoDelete());
061: this .cbAutoRetrieve.setSelected(aRelation.getAutoRetrieve());
062: this .cbAutoUpdate.setSelected(aRelation.getAutoUpdate());
063:
064: this .tfJavaFieldName.setText(aRelation.getFieldName());
065: }
066:
067: /** This method is called from within the constructor to
068: * initialize the form.
069: * WARNING: Do NOT modify this code. The content of this method is
070: * always regenerated by the Form Editor.
071: */
072: private void initComponents()//GEN-BEGIN:initComponents
073: {
074: java.awt.GridBagConstraints gridBagConstraints;
075:
076: jPanel1 = new javax.swing.JPanel();
077: lblEnabled = new javax.swing.JLabel();
078: cbEnabled = new javax.swing.JCheckBox();
079: lblDisabledByParent = new javax.swing.JLabel();
080: cbDisabledByParent = new javax.swing.JCheckBox();
081: jLabel4 = new javax.swing.JLabel();
082: jLabel3 = new javax.swing.JLabel();
083: lblPKTableName = new javax.swing.JLabel();
084: tfPKTableName = new javax.swing.JTextField();
085: lblFKTableName = new javax.swing.JLabel();
086: tfFKTableName = new javax.swing.JTextField();
087: lblReferenceType = new javax.swing.JLabel();
088: tfReferenceType = new javax.swing.JTextField();
089: jLabel5 = new javax.swing.JLabel();
090: jLabel6 = new javax.swing.JLabel();
091: lblAutoRetrieve = new javax.swing.JLabel();
092: cbAutoRetrieve = new javax.swing.JCheckBox();
093: lblAutoUpdate = new javax.swing.JLabel();
094: cbAutoUpdate = new javax.swing.JCheckBox();
095: lblAutoDelete = new javax.swing.JLabel();
096: cbAutoDelete = new javax.swing.JCheckBox();
097: jLabel10 = new javax.swing.JLabel();
098: jLabel11 = new javax.swing.JLabel();
099: lblJavaFieldName = new javax.swing.JLabel();
100: tfJavaFieldName = new javax.swing.JTextField();
101: lblJavaFieldType = new javax.swing.JLabel();
102: tfJavaFieldType = new javax.swing.JTextField();
103:
104: setLayout(new java.awt.GridBagLayout());
105:
106: addComponentListener(new java.awt.event.ComponentAdapter() {
107: public void componentShown(java.awt.event.ComponentEvent evt) {
108: formComponentShown(evt);
109: }
110:
111: public void componentHidden(
112: java.awt.event.ComponentEvent evt) {
113: formComponentHidden(evt);
114: }
115: });
116:
117: addHierarchyListener(new java.awt.event.HierarchyListener() {
118: public void hierarchyChanged(
119: java.awt.event.HierarchyEvent evt) {
120: formHierarchyChanged(evt);
121: }
122: });
123:
124: jPanel1.setLayout(new java.awt.GridLayout(15, 2));
125:
126: lblEnabled.setDisplayedMnemonic('e');
127: lblEnabled.setText("enabled:");
128: jPanel1.add(lblEnabled);
129:
130: cbEnabled.setMnemonic('e');
131: cbEnabled
132: .addActionListener(new java.awt.event.ActionListener() {
133: public void actionPerformed(
134: java.awt.event.ActionEvent evt) {
135: cbEnabledActionPerformed(evt);
136: }
137: });
138:
139: jPanel1.add(cbEnabled);
140:
141: lblDisabledByParent.setText("disabled by parent:");
142: jPanel1.add(lblDisabledByParent);
143:
144: cbDisabledByParent.setEnabled(false);
145: jPanel1.add(cbDisabledByParent);
146:
147: jPanel1.add(jLabel4);
148:
149: jPanel1.add(jLabel3);
150:
151: lblPKTableName.setLabelFor(tfPKTableName);
152: lblPKTableName.setText("Primary Key Table:");
153: jPanel1.add(lblPKTableName);
154:
155: tfPKTableName.setEditable(false);
156: tfPKTableName.setText("jTextField1");
157: tfPKTableName.setBorder(null);
158: tfPKTableName
159: .setDisabledTextColor((java.awt.Color) javax.swing.UIManager
160: .getDefaults().get("TextField.foreground"));
161: tfPKTableName.setEnabled(false);
162: jPanel1.add(tfPKTableName);
163:
164: lblFKTableName.setLabelFor(tfFKTableName);
165: lblFKTableName.setText("Foreign Key Table:");
166: jPanel1.add(lblFKTableName);
167:
168: tfFKTableName.setEditable(false);
169: tfFKTableName.setText("jTextField1");
170: tfFKTableName.setBorder(null);
171: tfFKTableName
172: .setDisabledTextColor((java.awt.Color) javax.swing.UIManager
173: .getDefaults().get("TextField.foreground"));
174: tfFKTableName.setEnabled(false);
175: jPanel1.add(tfFKTableName);
176:
177: lblReferenceType.setLabelFor(tfReferenceType);
178: lblReferenceType.setText("Type:");
179: jPanel1.add(lblReferenceType);
180:
181: tfReferenceType.setEditable(false);
182: tfReferenceType.setText("jTextField1");
183: tfReferenceType.setBorder(null);
184: tfReferenceType
185: .setDisabledTextColor((java.awt.Color) javax.swing.UIManager
186: .getDefaults().get("TextField.foreground"));
187: tfReferenceType.setEnabled(false);
188: jPanel1.add(tfReferenceType);
189:
190: jPanel1.add(jLabel5);
191:
192: jPanel1.add(jLabel6);
193:
194: lblAutoRetrieve.setDisplayedMnemonic('r');
195: lblAutoRetrieve.setText("Auto retrieve:");
196: jPanel1.add(lblAutoRetrieve);
197:
198: cbAutoRetrieve.setMnemonic('r');
199: cbAutoRetrieve
200: .addActionListener(new java.awt.event.ActionListener() {
201: public void actionPerformed(
202: java.awt.event.ActionEvent evt) {
203: cbAutoRetrieveActionPerformed(evt);
204: }
205: });
206:
207: jPanel1.add(cbAutoRetrieve);
208:
209: lblAutoUpdate.setDisplayedMnemonic('u');
210: lblAutoUpdate.setText("Auto update:");
211: jPanel1.add(lblAutoUpdate);
212:
213: cbAutoUpdate.setMnemonic('u');
214: cbAutoUpdate
215: .addActionListener(new java.awt.event.ActionListener() {
216: public void actionPerformed(
217: java.awt.event.ActionEvent evt) {
218: cbAutoUpdateActionPerformed(evt);
219: }
220: });
221:
222: jPanel1.add(cbAutoUpdate);
223:
224: lblAutoDelete.setDisplayedMnemonic('d');
225: lblAutoDelete.setText("Auto delete:");
226: jPanel1.add(lblAutoDelete);
227:
228: cbAutoDelete.setMnemonic('d');
229: cbAutoDelete
230: .addActionListener(new java.awt.event.ActionListener() {
231: public void actionPerformed(
232: java.awt.event.ActionEvent evt) {
233: cbAutoDeleteActionPerformed(evt);
234: }
235: });
236:
237: jPanel1.add(cbAutoDelete);
238:
239: jPanel1.add(jLabel10);
240:
241: jPanel1.add(jLabel11);
242:
243: lblJavaFieldName.setDisplayedMnemonic('n');
244: lblJavaFieldName.setLabelFor(tfJavaFieldName);
245: lblJavaFieldName.setText("Java Field Name:");
246: jPanel1.add(lblJavaFieldName);
247:
248: tfJavaFieldName.setText("jTextField1");
249: tfJavaFieldName
250: .addActionListener(new java.awt.event.ActionListener() {
251: public void actionPerformed(
252: java.awt.event.ActionEvent evt) {
253: tfJavaFieldNameActionPerformed(evt);
254: }
255: });
256:
257: tfJavaFieldName
258: .addFocusListener(new java.awt.event.FocusAdapter() {
259: public void focusLost(java.awt.event.FocusEvent evt) {
260: tfJavaFieldNameFocusLost(evt);
261: }
262: });
263:
264: tfJavaFieldName.addKeyListener(new java.awt.event.KeyAdapter() {
265: public void keyTyped(java.awt.event.KeyEvent evt) {
266: tfJavaFieldNameKeyTyped(evt);
267: }
268: });
269:
270: jPanel1.add(tfJavaFieldName);
271:
272: lblJavaFieldType.setDisplayedMnemonic('t');
273: lblJavaFieldType.setLabelFor(tfJavaFieldType);
274: lblJavaFieldType.setText("Java Field Type:");
275: jPanel1.add(lblJavaFieldType);
276:
277: tfJavaFieldType.setText("jTextField2");
278: tfJavaFieldType
279: .addActionListener(new java.awt.event.ActionListener() {
280: public void actionPerformed(
281: java.awt.event.ActionEvent evt) {
282: tfJavaFieldTypeActionPerformed(evt);
283: }
284: });
285:
286: tfJavaFieldType
287: .addFocusListener(new java.awt.event.FocusAdapter() {
288: public void focusLost(java.awt.event.FocusEvent evt) {
289: tfJavaFieldTypeFocusLost(evt);
290: }
291: });
292:
293: tfJavaFieldType.addKeyListener(new java.awt.event.KeyAdapter() {
294: public void keyTyped(java.awt.event.KeyEvent evt) {
295: tfJavaFieldTypeKeyTyped(evt);
296: }
297: });
298:
299: jPanel1.add(tfJavaFieldType);
300:
301: gridBagConstraints = new java.awt.GridBagConstraints();
302: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
303: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
304: gridBagConstraints.weightx = 1.0;
305: gridBagConstraints.weighty = 1.0;
306: add(jPanel1, gridBagConstraints);
307:
308: }//GEN-END:initComponents
309:
310: private void tfJavaFieldTypeKeyTyped(java.awt.event.KeyEvent evt)//GEN-FIRST:event_tfJavaFieldTypeKeyTyped
311: {//GEN-HEADEREND:event_tfJavaFieldTypeKeyTyped
312: // Revert on ESC
313: if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) {
314: this .tfJavaFieldType.setText(aRelation.getFieldType());
315: }
316: }//GEN-LAST:event_tfJavaFieldTypeKeyTyped
317:
318: private void tfJavaFieldTypeFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_tfJavaFieldTypeFocusLost
319: {//GEN-HEADEREND:event_tfJavaFieldTypeFocusLost
320: // Commit on lost focus
321: this .aRelation.setFieldType(tfJavaFieldType.getText());
322: }//GEN-LAST:event_tfJavaFieldTypeFocusLost
323:
324: private void tfJavaFieldTypeActionPerformed(
325: java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfJavaFieldTypeActionPerformed
326: {//GEN-HEADEREND:event_tfJavaFieldTypeActionPerformed
327: // Commit on ENTER
328: this .aRelation.setFieldType(tfJavaFieldType.getText());
329: }//GEN-LAST:event_tfJavaFieldTypeActionPerformed
330:
331: private void tfJavaFieldNameKeyTyped(java.awt.event.KeyEvent evt)//GEN-FIRST:event_tfJavaFieldNameKeyTyped
332: {//GEN-HEADEREND:event_tfJavaFieldNameKeyTyped
333: // Revert to original value if ESC is typed
334: if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) {
335: this .tfJavaFieldName.setText(aRelation.getFieldName());
336: }
337: }//GEN-LAST:event_tfJavaFieldNameKeyTyped
338:
339: private void tfJavaFieldNameFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_tfJavaFieldNameFocusLost
340: {//GEN-HEADEREND:event_tfJavaFieldNameFocusLost
341: // Commit value if focus is lost
342: aRelation.setFieldName(tfJavaFieldName.getText());
343: }//GEN-LAST:event_tfJavaFieldNameFocusLost
344:
345: private void tfJavaFieldNameActionPerformed(
346: java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfJavaFieldNameActionPerformed
347: {//GEN-HEADEREND:event_tfJavaFieldNameActionPerformed
348: // Commit value if ENTER is typed
349: aRelation.setFieldName(tfJavaFieldName.getText());
350: }//GEN-LAST:event_tfJavaFieldNameActionPerformed
351:
352: private void cbAutoDeleteActionPerformed(
353: java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbAutoDeleteActionPerformed
354: {//GEN-HEADEREND:event_cbAutoDeleteActionPerformed
355: // Add your handling code here:
356: this .aRelation.setAutoDelete(this .cbAutoDelete.isSelected());
357: }//GEN-LAST:event_cbAutoDeleteActionPerformed
358:
359: private void cbAutoUpdateActionPerformed(
360: java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbAutoUpdateActionPerformed
361: {//GEN-HEADEREND:event_cbAutoUpdateActionPerformed
362: // Add your handling code here:
363: this .aRelation.setAutoUpdate(this .cbAutoUpdate.isSelected());
364: }//GEN-LAST:event_cbAutoUpdateActionPerformed
365:
366: private void cbAutoRetrieveActionPerformed(
367: java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbAutoRetrieveActionPerformed
368: {//GEN-HEADEREND:event_cbAutoRetrieveActionPerformed
369: // Add your handling code here:
370: aRelation.setAutoRetrieve(cbAutoRetrieve.isSelected());
371: }//GEN-LAST:event_cbAutoRetrieveActionPerformed
372:
373: private void cbEnabledActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbEnabledActionPerformed
374: {//GEN-HEADEREND:event_cbEnabledActionPerformed
375: // Add your handling code here:
376: aRelation.setEnabled(this .cbEnabled.isSelected());
377: }//GEN-LAST:event_cbEnabledActionPerformed
378:
379: private void formHierarchyChanged(java.awt.event.HierarchyEvent evt)//GEN-FIRST:event_formHierarchyChanged
380: {//GEN-HEADEREND:event_formHierarchyChanged
381: // Add your handling code here:
382: readValuesFromReference();
383: }//GEN-LAST:event_formHierarchyChanged
384:
385: private void formComponentHidden(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentHidden
386: {//GEN-HEADEREND:event_formComponentHidden
387: // Add your handling code here:
388: }//GEN-LAST:event_formComponentHidden
389:
390: private void formComponentShown(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentShown
391: {//GEN-HEADEREND:event_formComponentShown
392: // Add your handling code here:
393: }//GEN-LAST:event_formComponentShown
394:
395: public void setModel(PropertySheetModel pm) {
396: if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBFKRelation) {
397: this .aRelation = (org.apache.ojb.tools.mapping.reversedb.DBFKRelation) pm;
398: this .readValuesFromReference();
399: } else
400: throw new IllegalArgumentException();
401: }
402:
403: // Variables declaration - do not modify//GEN-BEGIN:variables
404: private javax.swing.JLabel jLabel4;
405: private javax.swing.JLabel lblAutoUpdate;
406: private javax.swing.JLabel jLabel3;
407: private javax.swing.JCheckBox cbAutoRetrieve;
408: private javax.swing.JLabel lblEnabled;
409: private javax.swing.JCheckBox cbEnabled;
410: private javax.swing.JTextField tfJavaFieldName;
411: private javax.swing.JLabel lblAutoRetrieve;
412: private javax.swing.JCheckBox cbAutoUpdate;
413: private javax.swing.JCheckBox cbDisabledByParent;
414: private javax.swing.JLabel lblJavaFieldType;
415: private javax.swing.JTextField tfReferenceType;
416: private javax.swing.JLabel lblPKTableName;
417: private javax.swing.JLabel lblFKTableName;
418: private javax.swing.JLabel jLabel11;
419: private javax.swing.JTextField tfJavaFieldType;
420: private javax.swing.JTextField tfPKTableName;
421: private javax.swing.JLabel lblDisabledByParent;
422: private javax.swing.JLabel lblReferenceType;
423: private javax.swing.JPanel jPanel1;
424: private javax.swing.JCheckBox cbAutoDelete;
425: private javax.swing.JLabel lblAutoDelete;
426: private javax.swing.JLabel lblJavaFieldName;
427: private javax.swing.JLabel jLabel6;
428: private javax.swing.JTextField tfFKTableName;
429: private javax.swing.JLabel jLabel10;
430: private javax.swing.JLabel jLabel5;
431: // End of variables declaration//GEN-END:variables
432:
433: }
434:
435: /***************************** Changelog *****************************
436: // $Log: DBFKRelationPropertySheet.java,v $
437: // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
438: // Updated license
439: //
440: // Revision 1.1 2004/05/05 16:38:49 arminw
441: // fix fault
442: // wrong package structure used:
443: // org.apache.ojb.tools.reversdb
444: // org.apache.ojb.tools.reversdb2
445: //
446: // instead of
447: // org.apache.ojb.tools.mapping.reversdb
448: // org.apache.ojb.tools.mapping.reversdb2
449: //
450: // Revision 1.1 2004/05/04 13:44:59 arminw
451: // move reverseDB stuff
452: //
453: // Revision 1.9 2004/04/05 12:16:23 tomdz
454: // Fixed/updated license in files leftover from automatic license transition
455: //
456: // Revision 1.8 2004/04/04 23:53:42 brianm
457: // Fixed initial copyright dates to match cvs repository
458: //
459: // Revision 1.7 2004/03/11 18:16:22 brianm
460: // ASL 2.0
461: //
462: // Revision 1.6 2003/12/12 16:37:16 brj
463: // removed unnecessary casts, semicolons etc.
464: //
465: // Revision 1.5 2003/06/21 10:21:55 florianbruckner
466: // update netbeans 3.4 -> 3.5; XML and code genration changed a bit
467: //
468: // Revision 1.4 2003/02/21 12:47:53 florianbruckner
469: // corrected event handling of JInputField objects, value of field was
470: // not written back to the model object.
471: //
472: // Revision 1.3 2002/06/18 12:26:41 florianbruckner
473: // changes in Netbeans Form definitions after move to jakarta.
474: //
475: // Revision 1.2 2002/06/17 19:34:34 jvanzyl
476: // Correcting all the package references.
477: // PR:
478: // Obtained from:
479: // Submitted by:
480: // Reviewed by:
481: //
482: // Revision 1.1.1.1 2002/06/17 18:16:52 jvanzyl
483: // Initial OJB import
484: //
485: // Revision 1.2 2002/05/16 11:47:09 florianbruckner
486: // fix CR/LF issue, change license to ASL
487: //
488: // Revision 1.1 2002/04/18 11:44:16 mpoeschl
489: //
490: // move files to new location
491: //
492: // Revision 1.3 2002/04/07 09:05:17 thma
493: // *** empty log message ***
494: //
495: // Revision 1.2 2002/03/11 17:36:26 florianbruckner
496: // fix line break issue for these files that were previously checked in with -kb
497: //
498: // Revision 1.1 2002/03/04 17:19:32 thma
499: // initial checking for Florians Reverse engineering tool
500: //
501: // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
502: // initial import
503: //
504: /***************************** Changelog *****************************/
|