1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.components;
14
15 import javax.swing.ComboBoxModel;
16 import javax.swing.JCheckBox;
17 import javax.swing.JComboBox;
18 import javax.swing.JComponent;
19 import javax.swing.JPasswordField;
20 import javax.swing.JTextArea;
21 import javax.swing.JTextField;
22
23 import com.jgoodies.binding.PresentationModel;
24 import com.jgoodies.binding.adapter.Bindings;
25 import com.jgoodies.binding.list.SelectionInList;
26
27 public class SimpleBindingForm extends SimpleForm
28 {
29 private final PresentationModel<?> pm;
30
31 public SimpleBindingForm( PresentationModel<?> pm )
32 {
33 this.pm = pm;
34 }
35
36 public JTextField appendTextField( String propertyName, String label, String tooltip )
37 {
38 JTextField textField = super.appendTextField( label, tooltip );
39 Bindings.bind( textField, pm.getModel( propertyName ) );
40 return textField;
41 }
42
43 public JTextArea appendTextArea( String propertyName, String label, String tooltip )
44 {
45 JTextArea textArea = super.appendTextArea( label, tooltip );
46 Bindings.bind( textArea, pm.getModel( propertyName ) );
47 return textArea;
48 }
49
50 public JPasswordField appendPasswordField( String propertyName, String label, String tooltip )
51 {
52 JPasswordField textField = super.appendPasswordField( label, tooltip );
53 Bindings.bind( textField, pm.getModel( propertyName ) );
54 return textField;
55 }
56
57 public JCheckBox appendCheckBox( String propertyName, String label, String tooltip )
58 {
59 JCheckBox checkBox = super.appendCheckBox( label, tooltip, false );
60 Bindings.bind( checkBox, pm.getModel( propertyName ) );
61 return checkBox;
62 }
63
64 public void appendComponent( String propertyName, String label, JComponent component )
65 {
66 super.append( label, component );
67 Bindings.bind( component, propertyName, pm.getModel( propertyName ) );
68 }
69
70 public JComboBox appendComboBox( String propertyName, String label, Object[] values, String tooltip )
71 {
72 JComboBox comboBox = super.appendComboBox( label, values, tooltip );
73 Bindings.bind( comboBox, new SelectionInList<Object>( values, pm.getModel( propertyName ) ) );
74 return comboBox;
75 }
76
77 public JComboBox appendComboBox( String propertyName, String label, ComboBoxModel model, String tooltip )
78 {
79 JComboBox comboBox = super.appendComboBox( label, model, tooltip );
80 Bindings.bind( comboBox, new SelectionInList<Object>( model, pm.getModel( propertyName ) ) );
81 return comboBox;
82 }
83
84 }