001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package data;
043:
044: /**
045: * Test form for all beans binding tests
046: *
047: * @author Jiri Vagner
048: */
049: public class ConvertorAndValidatorTest extends javax.swing.JFrame {
050:
051: /** Creates new form ConvertorAndValidatorTest */
052: public ConvertorAndValidatorTest() {
053: initComponents();
054:
055: bindingGroup.addBindingListener(new SystemOutBindingListener());
056:
057: jButton1.addActionListener(new java.awt.event.ActionListener() {
058: public void actionPerformed(java.awt.event.ActionEvent evt) {
059: jButton1ActionPerformed(evt);
060: }
061: });
062:
063: jButton2.addActionListener(new java.awt.event.ActionListener() {
064: public void actionPerformed(java.awt.event.ActionEvent evt) {
065: jButton2ActionPerformed(evt);
066: }
067: });
068:
069: jButton3.addActionListener(new java.awt.event.ActionListener() {
070: public void actionPerformed(java.awt.event.ActionEvent evt) {
071: jButton3ActionPerformed(evt);
072: }
073: });
074:
075: jButton4.addActionListener(new java.awt.event.ActionListener() {
076: public void actionPerformed(java.awt.event.ActionEvent evt) {
077: jButton4ActionPerformed(evt);
078: }
079: });
080:
081: jButton5.addActionListener(new java.awt.event.ActionListener() {
082: public void actionPerformed(java.awt.event.ActionEvent evt) {
083: jButton5ActionPerformed(evt);
084: }
085: });
086:
087: jButton6.addActionListener(new java.awt.event.ActionListener() {
088: public void actionPerformed(java.awt.event.ActionEvent evt) {
089: jButton6ActionPerformed(evt);
090: }
091: });
092:
093: }
094:
095: /** This method is called from within the constructor to
096: * initialize the form.
097: * WARNING: Do NOT modify this code. The content of this method is
098: * always regenerated by the Form Editor.
099: */
100: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
101: private void initComponents() {
102: bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
103:
104: bool2FaceConverter = new data.Bool2FaceConverter();
105: loginLengthValidator = new data.LoginLengthValidator();
106: jLabel1 = new javax.swing.JLabel();
107: jLabel2 = new javax.swing.JLabel();
108: jButton1 = new javax.swing.JButton();
109: jButton2 = new javax.swing.JButton();
110: jLabel3 = new javax.swing.JLabel();
111: jLabel4 = new javax.swing.JLabel();
112: jButton3 = new javax.swing.JButton();
113: jButton4 = new javax.swing.JButton();
114: jButton5 = new javax.swing.JButton();
115: jButton6 = new javax.swing.JButton();
116: jLabel5 = new javax.swing.JLabel();
117: jLabel6 = new javax.swing.JLabel();
118: jLabel7 = new javax.swing.JLabel();
119: jLabel8 = new javax.swing.JLabel();
120: jCheckBox1 = new javax.swing.JCheckBox();
121: jLabel9 = new javax.swing.JLabel();
122: jCheckBox2 = new javax.swing.JCheckBox();
123: jLabel10 = new javax.swing.JLabel();
124: jLabel11 = new javax.swing.JLabel();
125: jLabel12 = new javax.swing.JLabel();
126: jButton7 = new javax.swing.JButton();
127: jButton8 = new javax.swing.JButton();
128:
129: setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
130:
131: jLabel1.setText("jLabel1");
132:
133: org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings
134: .createAutoBinding(
135: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_ONCE,
136: jLabel1, org.jdesktop.beansbinding.ELProperty
137: .create("${text}"), jLabel2,
138: org.jdesktop.beansbinding.BeanProperty
139: .create("text"));
140: bindingGroup.addBinding(binding);
141:
142: jButton1.setText("Modify jLabel1 Text");
143:
144: jButton2.setText("Modify jLabel2 Text");
145:
146: jLabel3.setText("jLabel3");
147:
148: binding = org.jdesktop.beansbinding.Bindings
149: .createAutoBinding(
150: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ,
151: jLabel3, org.jdesktop.beansbinding.ELProperty
152: .create("${text}"), jLabel4,
153: org.jdesktop.beansbinding.BeanProperty
154: .create("text"));
155: bindingGroup.addBinding(binding);
156:
157: jButton3.setText("Modify jLabel3 Text");
158:
159: jButton4.setText("Modify jLabel4 Text");
160:
161: jButton5.setText("Modify jLabel5 Text");
162:
163: jButton6.setText("Modify jLabel6 Text");
164:
165: jLabel5.setText("jLabel5");
166:
167: binding = org.jdesktop.beansbinding.Bindings
168: .createAutoBinding(
169: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
170: jLabel5, org.jdesktop.beansbinding.ELProperty
171: .create("${text}"), jLabel6,
172: org.jdesktop.beansbinding.BeanProperty
173: .create("text"));
174: bindingGroup.addBinding(binding);
175:
176: jLabel7.setBackground(new java.awt.Color(238, 239, 231));
177: jLabel7.setBorder(javax.swing.BorderFactory
178: .createEtchedBorder());
179:
180: binding = org.jdesktop.beansbinding.Bindings
181: .createAutoBinding(
182: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
183: this , org.jdesktop.beansbinding.ELProperty
184: .create("${iconImage}"), jLabel7,
185: org.jdesktop.beansbinding.BeanProperty
186: .create("text"));
187: binding.setSourceNullValue("null foo msg");
188: binding.setSourceUnreadableValue("incomplete foo msg");
189: bindingGroup.addBinding(binding);
190:
191: jLabel8.setBorder(javax.swing.BorderFactory
192: .createEtchedBorder());
193:
194: binding = org.jdesktop.beansbinding.Bindings
195: .createAutoBinding(
196: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
197: this ,
198: org.jdesktop.beansbinding.ELProperty
199: .create("${iconImage.graphics.font.fontName}"),
200: jLabel8, org.jdesktop.beansbinding.BeanProperty
201: .create("text"));
202: bindingGroup.addBinding(binding);
203:
204: jCheckBox1.setText("jCheckBox1");
205:
206: binding = org.jdesktop.beansbinding.Bindings
207: .createAutoBinding(
208: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
209: jCheckBox1,
210: org.jdesktop.beansbinding.ELProperty
211: .create("${selected}"), jLabel9,
212: org.jdesktop.beansbinding.BeanProperty
213: .create("text"));
214: bindingGroup.addBinding(binding);
215:
216: jCheckBox2.setSelected(true);
217: jCheckBox2.setText("jCheckBox2");
218:
219: binding = org.jdesktop.beansbinding.Bindings
220: .createAutoBinding(
221: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
222: jCheckBox2,
223: org.jdesktop.beansbinding.ELProperty
224: .create("${selected}"), jLabel10,
225: org.jdesktop.beansbinding.BeanProperty
226: .create("text"));
227: bindingGroup.addBinding(binding);
228:
229: jLabel11.setText("1");
230:
231: binding = org.jdesktop.beansbinding.Bindings
232: .createAutoBinding(
233: org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE,
234: jLabel11, org.jdesktop.beansbinding.ELProperty
235: .create("${text}"), jLabel12,
236: org.jdesktop.beansbinding.BeanProperty
237: .create("text"));
238: bindingGroup.addBinding(binding);
239:
240: jButton7.setText("+");
241: jButton7.addActionListener(new java.awt.event.ActionListener() {
242: public void actionPerformed(java.awt.event.ActionEvent evt) {
243: jButton7ActionPerformed(evt);
244: }
245: });
246:
247: jButton8.setText("+");
248:
249: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
250: getContentPane());
251: getContentPane().setLayout(layout);
252: layout
253: .setHorizontalGroup(layout
254: .createParallelGroup(
255: org.jdesktop.layout.GroupLayout.LEADING)
256: .add(
257: layout
258: .createSequentialGroup()
259: .addContainerGap()
260: .add(
261: layout
262: .createParallelGroup(
263: org.jdesktop.layout.GroupLayout.TRAILING)
264: .add(
265: org.jdesktop.layout.GroupLayout.LEADING,
266: jLabel8,
267: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
268: 267,
269: Short.MAX_VALUE)
270: .add(
271: org.jdesktop.layout.GroupLayout.LEADING,
272: layout
273: .createParallelGroup(
274: org.jdesktop.layout.GroupLayout.LEADING,
275: false)
276: .add(
277: layout
278: .createSequentialGroup()
279: .add(
280: jButton2)
281: .addPreferredGap(
282: org.jdesktop.layout.LayoutStyle.RELATED)
283: .add(
284: jLabel2))
285: .add(
286: layout
287: .createParallelGroup(
288: org.jdesktop.layout.GroupLayout.TRAILING)
289: .add(
290: org.jdesktop.layout.GroupLayout.LEADING,
291: layout
292: .createSequentialGroup()
293: .add(
294: jButton3)
295: .addPreferredGap(
296: org.jdesktop.layout.LayoutStyle.RELATED)
297: .add(
298: jLabel3))
299: .add(
300: layout
301: .createSequentialGroup()
302: .add(
303: jButton4)
304: .addPreferredGap(
305: org.jdesktop.layout.LayoutStyle.RELATED)
306: .add(
307: jLabel4)))
308: .add(
309: layout
310: .createSequentialGroup()
311: .add(
312: jButton1)
313: .addPreferredGap(
314: org.jdesktop.layout.LayoutStyle.RELATED)
315: .add(
316: jLabel1))
317: .add(
318: layout
319: .createSequentialGroup()
320: .add(
321: jButton5)
322: .addPreferredGap(
323: org.jdesktop.layout.LayoutStyle.RELATED)
324: .add(
325: jLabel5))
326: .add(
327: layout
328: .createSequentialGroup()
329: .add(
330: jButton6)
331: .addPreferredGap(
332: org.jdesktop.layout.LayoutStyle.RELATED)
333: .add(
334: jLabel6))
335: .add(
336: jLabel7,
337: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
338: 267,
339: Short.MAX_VALUE)))
340: .addPreferredGap(
341: org.jdesktop.layout.LayoutStyle.RELATED)
342: .add(
343: layout
344: .createParallelGroup(
345: org.jdesktop.layout.GroupLayout.LEADING)
346: .add(jCheckBox1)
347: .add(jLabel10)
348: .add(jLabel9)
349: .add(jCheckBox2)
350: .add(jLabel12)
351: .add(jLabel11))
352: .addPreferredGap(
353: org.jdesktop.layout.LayoutStyle.RELATED)
354: .add(
355: layout
356: .createParallelGroup(
357: org.jdesktop.layout.GroupLayout.LEADING,
358: false)
359: .add(
360: jButton8,
361: 0,
362: 0,
363: Short.MAX_VALUE)
364: .add(
365: jButton7,
366: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
367: 63,
368: Short.MAX_VALUE))
369: .add(67, 67, 67)));
370:
371: layout.linkSize(new java.awt.Component[] { jButton1, jButton2,
372: jButton3, jButton4, jButton5, jButton6 },
373: org.jdesktop.layout.GroupLayout.HORIZONTAL);
374:
375: layout
376: .setVerticalGroup(layout
377: .createParallelGroup(
378: org.jdesktop.layout.GroupLayout.LEADING)
379: .add(
380: layout
381: .createSequentialGroup()
382: .addContainerGap()
383: .add(
384: layout
385: .createParallelGroup(
386: org.jdesktop.layout.GroupLayout.LEADING)
387: .add(
388: layout
389: .createSequentialGroup()
390: .add(
391: layout
392: .createParallelGroup(
393: org.jdesktop.layout.GroupLayout.BASELINE)
394: .add(
395: jButton1,
396: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
397: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
398: Short.MAX_VALUE)
399: .add(
400: jLabel1))
401: .addPreferredGap(
402: org.jdesktop.layout.LayoutStyle.RELATED)
403: .add(
404: layout
405: .createParallelGroup(
406: org.jdesktop.layout.GroupLayout.BASELINE)
407: .add(
408: jButton2)
409: .add(
410: jLabel2))
411: .add(
412: 18,
413: 18,
414: 18)
415: .add(
416: layout
417: .createParallelGroup(
418: org.jdesktop.layout.GroupLayout.BASELINE)
419: .add(
420: jButton3)
421: .add(
422: jLabel3))
423: .addPreferredGap(
424: org.jdesktop.layout.LayoutStyle.RELATED)
425: .add(
426: layout
427: .createParallelGroup(
428: org.jdesktop.layout.GroupLayout.BASELINE)
429: .add(
430: jButton4)
431: .add(
432: jLabel4))
433: .add(
434: 18,
435: 18,
436: 18)
437: .add(
438: layout
439: .createParallelGroup(
440: org.jdesktop.layout.GroupLayout.BASELINE)
441: .add(
442: jButton5)
443: .add(
444: jLabel5))
445: .addPreferredGap(
446: org.jdesktop.layout.LayoutStyle.RELATED)
447: .add(
448: layout
449: .createParallelGroup(
450: org.jdesktop.layout.GroupLayout.BASELINE)
451: .add(
452: jButton6)
453: .add(
454: jLabel6))
455: .add(
456: 18,
457: 18,
458: 18)
459: .add(
460: jLabel7,
461: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
462: 27,
463: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
464: .addPreferredGap(
465: org.jdesktop.layout.LayoutStyle.RELATED)
466: .add(
467: jLabel8,
468: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
469: 27,
470: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
471: .add(
472: layout
473: .createSequentialGroup()
474: .add(
475: jCheckBox1)
476: .addPreferredGap(
477: org.jdesktop.layout.LayoutStyle.RELATED)
478: .add(
479: jLabel9)
480: .addPreferredGap(
481: org.jdesktop.layout.LayoutStyle.RELATED)
482: .add(
483: layout
484: .createParallelGroup(
485: org.jdesktop.layout.GroupLayout.LEADING)
486: .add(
487: layout
488: .createSequentialGroup()
489: .add(
490: 90,
491: 90,
492: 90)
493: .add(
494: layout
495: .createParallelGroup(
496: org.jdesktop.layout.GroupLayout.BASELINE)
497: .add(
498: jLabel11)
499: .add(
500: jButton8)))
501: .add(
502: layout
503: .createSequentialGroup()
504: .addPreferredGap(
505: org.jdesktop.layout.LayoutStyle.RELATED)
506: .add(
507: jCheckBox2)
508: .addPreferredGap(
509: org.jdesktop.layout.LayoutStyle.RELATED)
510: .add(
511: jLabel10)))
512: .addPreferredGap(
513: org.jdesktop.layout.LayoutStyle.RELATED)
514: .add(
515: layout
516: .createParallelGroup(
517: org.jdesktop.layout.GroupLayout.BASELINE)
518: .add(
519: jLabel12)
520: .add(
521: jButton7))))
522: .addContainerGap()));
523:
524: bindingGroup.bind();
525:
526: pack();
527: }// </editor-fold>//GEN-END:initComponents
528:
529: private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
530: jLabel12.setText(jLabel12.getText() + "+"); // NOI18N
531: }//GEN-LAST:event_jButton7ActionPerformed
532:
533: private void modifyLabelText(javax.swing.JLabel label) {
534: label.setText(label.getText() + "mod"); // NOI18N
535: }
536:
537: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
538: modifyLabelText(jLabel1);
539: }
540:
541: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
542: modifyLabelText(jLabel2);
543: }
544:
545: private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
546: modifyLabelText(jLabel3);
547: }
548:
549: private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
550: modifyLabelText(jLabel4);
551: }
552:
553: private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
554: modifyLabelText(jLabel5);
555: }
556:
557: private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
558: modifyLabelText(jLabel6);
559: }
560:
561: /**
562: * @param args the command line arguments
563: */
564: public static void main(String args[]) {
565: java.awt.EventQueue.invokeLater(new Runnable() {
566: public void run() {
567: new ConvertorAndValidatorTest().setVisible(true);
568: }
569: });
570: }
571:
572: // Variables declaration - do not modify//GEN-BEGIN:variables
573: private data.Bool2FaceConverter bool2FaceConverter;
574: private javax.swing.JButton jButton1;
575: private javax.swing.JButton jButton2;
576: private javax.swing.JButton jButton3;
577: private javax.swing.JButton jButton4;
578: private javax.swing.JButton jButton5;
579: private javax.swing.JButton jButton6;
580: private javax.swing.JButton jButton7;
581: private javax.swing.JButton jButton8;
582: private javax.swing.JCheckBox jCheckBox1;
583: private javax.swing.JCheckBox jCheckBox2;
584: private javax.swing.JLabel jLabel1;
585: private javax.swing.JLabel jLabel10;
586: private javax.swing.JLabel jLabel11;
587: private javax.swing.JLabel jLabel12;
588: private javax.swing.JLabel jLabel2;
589: private javax.swing.JLabel jLabel3;
590: private javax.swing.JLabel jLabel4;
591: private javax.swing.JLabel jLabel5;
592: private javax.swing.JLabel jLabel6;
593: private javax.swing.JLabel jLabel7;
594: private javax.swing.JLabel jLabel8;
595: private javax.swing.JLabel jLabel9;
596: private data.LoginLengthValidator loginLengthValidator;
597: private org.jdesktop.beansbinding.BindingGroup bindingGroup;
598: // End of variables declaration//GEN-END:variables
599:
600: }
|