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: DBTablePropertySheet.java,v 1.1.2.1 2005/12/21 22:32:02 tomdz Exp $
024: */
025: public class DBTablePropertySheet extends javax.swing.JPanel implements
026: PropertySheetView {
027: org.apache.ojb.tools.mapping.reversedb.DBTable aTable;
028:
029: /** Creates new form DBCatalogPropertySheet */
030: public DBTablePropertySheet() {
031: initComponents();
032: }
033:
034: private void readValuesFromTable() {
035: this .cbEnabled.setSelected(aTable.isEnabled());
036: this .cbDisabledByParent.setSelected(!aTable.getDBSchema()
037: .isTreeEnabled());
038: this .tfTableName.setText(aTable.getTableName());
039: this .tfClassName.setText(aTable.getClassName());
040: this .tfPackageName.setText(aTable.getPackageName());
041: this .cbDynamicProxy.setSelected(aTable.hasDynamicProxy());
042: this .tfConversionStrategyClass.setText(aTable
043: .getConversionStrategyClass());
044: }
045:
046: /** This method is called from within the constructor to
047: * initialize the form.
048: * WARNING: Do NOT modify this code. The content of this method is
049: * always regenerated by the Form Editor.
050: */
051: private void initComponents()//GEN-BEGIN:initComponents
052: {
053: java.awt.GridBagConstraints gridBagConstraints;
054:
055: jPanel1 = new javax.swing.JPanel();
056: lblEnabled = new javax.swing.JLabel();
057: cbEnabled = new javax.swing.JCheckBox();
058: lblDisabledByParent = new javax.swing.JLabel();
059: cbDisabledByParent = new javax.swing.JCheckBox();
060: jLabel3 = new javax.swing.JLabel();
061: jLabel4 = new javax.swing.JLabel();
062: lblTableName = new javax.swing.JLabel();
063: tfTableName = new javax.swing.JTextField();
064: lblClassName = new javax.swing.JLabel();
065: tfClassName = new javax.swing.JTextField();
066: lblPackageName = new javax.swing.JLabel();
067: tfPackageName = new javax.swing.JTextField();
068: lblDynamicProxy = new javax.swing.JLabel();
069: cbDynamicProxy = new javax.swing.JCheckBox();
070: lblConversionStrategyClass = new javax.swing.JLabel();
071: tfConversionStrategyClass = new javax.swing.JTextField();
072:
073: setLayout(new java.awt.GridBagLayout());
074:
075: addComponentListener(new java.awt.event.ComponentAdapter() {
076: public void componentShown(java.awt.event.ComponentEvent evt) {
077: formComponentShown(evt);
078: }
079:
080: public void componentHidden(
081: java.awt.event.ComponentEvent evt) {
082: formComponentHidden(evt);
083: }
084: });
085:
086: addHierarchyListener(new java.awt.event.HierarchyListener() {
087: public void hierarchyChanged(
088: java.awt.event.HierarchyEvent evt) {
089: formHierarchyChanged(evt);
090: }
091: });
092:
093: jPanel1.setLayout(new java.awt.GridLayout(8, 2));
094:
095: lblEnabled.setDisplayedMnemonic('e');
096: lblEnabled.setText("enabled");
097: jPanel1.add(lblEnabled);
098:
099: cbEnabled.setMnemonic('e');
100: cbEnabled
101: .addActionListener(new java.awt.event.ActionListener() {
102: public void actionPerformed(
103: java.awt.event.ActionEvent evt) {
104: cbEnabledActionPerformed(evt);
105: }
106: });
107:
108: jPanel1.add(cbEnabled);
109:
110: lblDisabledByParent.setText("disabled by Parent:");
111: jPanel1.add(lblDisabledByParent);
112:
113: cbDisabledByParent.setEnabled(false);
114: jPanel1.add(cbDisabledByParent);
115:
116: jPanel1.add(jLabel3);
117:
118: jPanel1.add(jLabel4);
119:
120: lblTableName.setLabelFor(tfTableName);
121: lblTableName.setText("Table Name:");
122: jPanel1.add(lblTableName);
123:
124: tfTableName.setEditable(false);
125: tfTableName.setText("jTextField1");
126: tfTableName.setBorder(null);
127: tfTableName.setDisabledTextColor(new java.awt.Color(0, 51, 51));
128: tfTableName.setEnabled(false);
129: jPanel1.add(tfTableName);
130:
131: lblClassName.setDisplayedMnemonic('c');
132: lblClassName.setLabelFor(tfClassName);
133: lblClassName.setText("Class Name:");
134: jPanel1.add(lblClassName);
135:
136: tfClassName.setText("jTextField1");
137: tfClassName
138: .addActionListener(new java.awt.event.ActionListener() {
139: public void actionPerformed(
140: java.awt.event.ActionEvent evt) {
141: tfClassNameActionPerformed(evt);
142: }
143: });
144:
145: tfClassName.addFocusListener(new java.awt.event.FocusAdapter() {
146: public void focusLost(java.awt.event.FocusEvent evt) {
147: tfClassNameFocusLost(evt);
148: }
149: });
150:
151: tfClassName.addKeyListener(new java.awt.event.KeyAdapter() {
152: public void keyTyped(java.awt.event.KeyEvent evt) {
153: tfClassNameKeyTyped(evt);
154: }
155: });
156:
157: jPanel1.add(tfClassName);
158:
159: lblPackageName.setDisplayedMnemonic('p');
160: lblPackageName.setLabelFor(tfPackageName);
161: lblPackageName.setText("Package:");
162: jPanel1.add(lblPackageName);
163:
164: tfPackageName.setText("jTextField2");
165: tfPackageName
166: .addActionListener(new java.awt.event.ActionListener() {
167: public void actionPerformed(
168: java.awt.event.ActionEvent evt) {
169: tfPackageNameActionPerformed(evt);
170: }
171: });
172:
173: tfPackageName
174: .addFocusListener(new java.awt.event.FocusAdapter() {
175: public void focusLost(java.awt.event.FocusEvent evt) {
176: tfPackageNameFocusLost(evt);
177: }
178: });
179:
180: tfPackageName.addKeyListener(new java.awt.event.KeyAdapter() {
181: public void keyTyped(java.awt.event.KeyEvent evt) {
182: tfPackageNameKeyTyped(evt);
183: }
184: });
185:
186: jPanel1.add(tfPackageName);
187:
188: lblDynamicProxy.setDisplayedMnemonic('u');
189: lblDynamicProxy.setText("Use Dynamic Proxy:");
190: jPanel1.add(lblDynamicProxy);
191:
192: cbDynamicProxy.setMnemonic('u');
193: cbDynamicProxy
194: .addActionListener(new java.awt.event.ActionListener() {
195: public void actionPerformed(
196: java.awt.event.ActionEvent evt) {
197: cbDynamicProxyActionPerformed(evt);
198: }
199: });
200:
201: jPanel1.add(cbDynamicProxy);
202:
203: lblConversionStrategyClass.setDisplayedMnemonic('s');
204: lblConversionStrategyClass
205: .setLabelFor(tfConversionStrategyClass);
206: lblConversionStrategyClass
207: .setText("Conversion Strategy Class:");
208: jPanel1.add(lblConversionStrategyClass);
209:
210: tfConversionStrategyClass.setText("jTextField1");
211: tfConversionStrategyClass
212: .addActionListener(new java.awt.event.ActionListener() {
213: public void actionPerformed(
214: java.awt.event.ActionEvent evt) {
215: tfConversionStrategyClassActionPerformed(evt);
216: }
217: });
218:
219: tfConversionStrategyClass
220: .addFocusListener(new java.awt.event.FocusAdapter() {
221: public void focusLost(java.awt.event.FocusEvent evt) {
222: tfConversionStrategyClassFocusLost(evt);
223: }
224: });
225:
226: tfConversionStrategyClass
227: .addKeyListener(new java.awt.event.KeyAdapter() {
228: public void keyTyped(java.awt.event.KeyEvent evt) {
229: tfConversionStrategyClassKeyTyped(evt);
230: }
231: });
232:
233: jPanel1.add(tfConversionStrategyClass);
234:
235: gridBagConstraints = new java.awt.GridBagConstraints();
236: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
237: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
238: gridBagConstraints.weightx = 1.0;
239: gridBagConstraints.weighty = 1.0;
240: add(jPanel1, gridBagConstraints);
241:
242: }//GEN-END:initComponents
243:
244: private void tfConversionStrategyClassKeyTyped(
245: java.awt.event.KeyEvent evt)//GEN-FIRST:event_tfConversionStrategyClassKeyTyped
246: {//GEN-HEADEREND:event_tfConversionStrategyClassKeyTyped
247: // Revert on ESC
248: if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) {
249: this .tfConversionStrategyClass.setText(aTable
250: .getConversionStrategyClass());
251: }
252: }//GEN-LAST:event_tfConversionStrategyClassKeyTyped
253:
254: private void tfConversionStrategyClassFocusLost(
255: java.awt.event.FocusEvent evt)//GEN-FIRST:event_tfConversionStrategyClassFocusLost
256: {//GEN-HEADEREND:event_tfConversionStrategyClassFocusLost
257: // Commit on lost focus
258: aTable
259: .setConversionStrategyClass(this .tfConversionStrategyClass
260: .getText());
261: }//GEN-LAST:event_tfConversionStrategyClassFocusLost
262:
263: private void tfConversionStrategyClassActionPerformed(
264: java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfConversionStrategyClassActionPerformed
265: {//GEN-HEADEREND:event_tfConversionStrategyClassActionPerformed
266: // Commit on ENTER
267: aTable
268: .setConversionStrategyClass(this .tfConversionStrategyClass
269: .getText());
270: }//GEN-LAST:event_tfConversionStrategyClassActionPerformed
271:
272: private void tfPackageNameKeyTyped(java.awt.event.KeyEvent evt)//GEN-FIRST:event_tfPackageNameKeyTyped
273: {//GEN-HEADEREND:event_tfPackageNameKeyTyped
274: // Revert on ESC
275: if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) {
276: this .tfPackageName.setText(aTable.getPackageName());
277: }
278: }//GEN-LAST:event_tfPackageNameKeyTyped
279:
280: private void tfPackageNameFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_tfPackageNameFocusLost
281: {//GEN-HEADEREND:event_tfPackageNameFocusLost
282: // Commit on lost focus
283: aTable.setPackageName(tfPackageName.getText());
284: }//GEN-LAST:event_tfPackageNameFocusLost
285:
286: private void tfPackageNameActionPerformed(
287: java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfPackageNameActionPerformed
288: {//GEN-HEADEREND:event_tfPackageNameActionPerformed
289: // Commit on ENTER
290: aTable.setPackageName(tfPackageName.getText());
291: }//GEN-LAST:event_tfPackageNameActionPerformed
292:
293: private void tfClassNameKeyTyped(java.awt.event.KeyEvent evt)//GEN-FIRST:event_tfClassNameKeyTyped
294: {//GEN-HEADEREND:event_tfClassNameKeyTyped
295: // Revert on ESC
296: if (evt.getKeyChar() == KeyEvent.VK_ESCAPE) {
297: this .tfClassName.setText(aTable.getClassName());
298: }
299: }//GEN-LAST:event_tfClassNameKeyTyped
300:
301: private void tfClassNameFocusLost(java.awt.event.FocusEvent evt)//GEN-FIRST:event_tfClassNameFocusLost
302: {//GEN-HEADEREND:event_tfClassNameFocusLost
303: // Commit on lost focus
304: aTable.setClassName(tfClassName.getText());
305: }//GEN-LAST:event_tfClassNameFocusLost
306:
307: private void tfClassNameActionPerformed(
308: java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfClassNameActionPerformed
309: {//GEN-HEADEREND:event_tfClassNameActionPerformed
310: // Commit on ENTER
311: aTable.setClassName(tfClassName.getText());
312: }//GEN-LAST:event_tfClassNameActionPerformed
313:
314: private void cbDynamicProxyActionPerformed(
315: java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbDynamicProxyActionPerformed
316: {//GEN-HEADEREND:event_cbDynamicProxyActionPerformed
317: // Add your handling code here:
318: aTable.setDynamicProxy(this .cbDynamicProxy.isSelected());
319: }//GEN-LAST:event_cbDynamicProxyActionPerformed
320:
321: private void cbEnabledActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cbEnabledActionPerformed
322: {//GEN-HEADEREND:event_cbEnabledActionPerformed
323: // Add your handling code here:
324: this .aTable.setEnabled(this .cbEnabled.isSelected());
325: }//GEN-LAST:event_cbEnabledActionPerformed
326:
327: private void formHierarchyChanged(java.awt.event.HierarchyEvent evt)//GEN-FIRST:event_formHierarchyChanged
328: {//GEN-HEADEREND:event_formHierarchyChanged
329: // Add your handling code here:
330: readValuesFromTable();
331: }//GEN-LAST:event_formHierarchyChanged
332:
333: private void formComponentHidden(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentHidden
334: {//GEN-HEADEREND:event_formComponentHidden
335: // Add your handling code here:
336: }//GEN-LAST:event_formComponentHidden
337:
338: private void formComponentShown(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentShown
339: {//GEN-HEADEREND:event_formComponentShown
340: // Add your handling code here:
341: }//GEN-LAST:event_formComponentShown
342:
343: public void setModel(PropertySheetModel pm) {
344: if (pm instanceof org.apache.ojb.tools.mapping.reversedb.DBTable) {
345: this .aTable = (org.apache.ojb.tools.mapping.reversedb.DBTable) pm;
346: this .readValuesFromTable();
347: } else
348: throw new IllegalArgumentException();
349: }
350:
351: // Variables declaration - do not modify//GEN-BEGIN:variables
352: private javax.swing.JLabel lblConversionStrategyClass;
353: private javax.swing.JLabel jLabel4;
354: private javax.swing.JLabel lblClassName;
355: private javax.swing.JLabel lblTableName;
356: private javax.swing.JLabel jLabel3;
357: private javax.swing.JLabel lblEnabled;
358: private javax.swing.JCheckBox cbEnabled;
359: private javax.swing.JCheckBox cbDisabledByParent;
360: private javax.swing.JTextField tfConversionStrategyClass;
361: private javax.swing.JCheckBox cbDynamicProxy;
362: private javax.swing.JTextField tfTableName;
363: private javax.swing.JTextField tfPackageName;
364: private javax.swing.JLabel lblDisabledByParent;
365: private javax.swing.JTextField tfClassName;
366: private javax.swing.JLabel lblPackageName;
367: private javax.swing.JPanel jPanel1;
368: private javax.swing.JLabel lblDynamicProxy;
369: // End of variables declaration//GEN-END:variables
370:
371: }
372:
373: /***************************** Changelog *****************************
374: // $Log: DBTablePropertySheet.java,v $
375: // Revision 1.1.2.1 2005/12/21 22:32:02 tomdz
376: // Updated license
377: //
378: // Revision 1.1 2004/05/05 16:38:49 arminw
379: // fix fault
380: // wrong package structure used:
381: // org.apache.ojb.tools.reversdb
382: // org.apache.ojb.tools.reversdb2
383: //
384: // instead of
385: // org.apache.ojb.tools.mapping.reversdb
386: // org.apache.ojb.tools.mapping.reversdb2
387: //
388: // Revision 1.1 2004/05/04 13:44:59 arminw
389: // move reverseDB stuff
390: //
391: // Revision 1.9 2004/04/05 12:16:23 tomdz
392: // Fixed/updated license in files leftover from automatic license transition
393: //
394: // Revision 1.8 2004/04/04 23:53:42 brianm
395: // Fixed initial copyright dates to match cvs repository
396: //
397: // Revision 1.7 2004/03/11 18:16:22 brianm
398: // ASL 2.0
399: //
400: // Revision 1.6 2003/06/21 10:21:55 florianbruckner
401: // update netbeans 3.4 -> 3.5; XML and code genration changed a bit
402: //
403: // Revision 1.5 2003/06/07 10:11:50 brj
404: // some style fixes
405: //
406: // Revision 1.4 2003/02/21 12:48:07 florianbruckner
407: // corrected event handling of JInputField objects, value of field was
408: // not written back to the model object.
409: //
410: // Revision 1.3 2002/06/18 12:26:41 florianbruckner
411: // changes in Netbeans Form definitions after move to jakarta.
412: //
413: // Revision 1.2 2002/06/17 19:34:34 jvanzyl
414: // Correcting all the package references.
415: // PR:
416: // Obtained from:
417: // Submitted by:
418: // Reviewed by:
419: //
420: // Revision 1.1.1.1 2002/06/17 18:16:54 jvanzyl
421: // Initial OJB import
422: //
423: // Revision 1.2 2002/05/16 11:47:09 florianbruckner
424: // fix CR/LF issue, change license to ASL
425: //
426: // Revision 1.1 2002/04/18 11:44:16 mpoeschl
427: //
428: // move files to new location
429: //
430: // Revision 1.3 2002/04/07 09:05:17 thma
431: // *** empty log message ***
432: //
433: // Revision 1.2 2002/03/11 17:36:26 florianbruckner
434: // fix line break issue for these files that were previously checked in with -kb
435: //
436: // Revision 1.1 2002/03/04 17:19:32 thma
437: // initial checking for Florians Reverse engineering tool
438: //
439: // Revision 1.1.1.1 2002/02/20 13:35:25 Administrator
440: // initial import
441: //
442: /***************************** Changelog *****************************/
|