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.JTextField;
21
22 import com.jgoodies.binding.PresentationModel;
23 import com.jgoodies.binding.adapter.Bindings;
24 import com.jgoodies.binding.list.SelectionInList;
25
26 public class SimpleBindingForm extends SimpleForm
27 {
28 private final PresentationModel<?> pm;
29
30 public SimpleBindingForm( PresentationModel<?> pm )
31 {
32 this.pm = pm;
33 }
34
35 public JTextField appendTextField( String propertyName, String label, String tooltip )
36 {
37 JTextField textField = super.appendTextField( label, tooltip );
38 Bindings.bind( textField, pm.getModel( propertyName ));
39 return textField;
40 }
41
42 public JPasswordField appendPasswordField( String propertyName, String label, String tooltip )
43 {
44 JPasswordField textField = super.appendPasswordField( label, tooltip );
45 Bindings.bind( textField, pm.getModel( propertyName ));
46 return textField;
47 }
48
49 public JCheckBox appendCheckBox( String propertyName, String label, String tooltip )
50 {
51 JCheckBox checkBox = super.appendCheckBox( label, tooltip, false );
52 Bindings.bind( checkBox, pm.getModel( propertyName ) );
53 return checkBox;
54 }
55
56 public void appendComponent( String propertyName, String label, JComponent component)
57 {
58 super.append( label, component );
59 Bindings.bind( component, propertyName, pm.getModel(propertyName) );
60 }
61
62
63 public JComboBox appendComboBox( String propertyName, String label, Object[] values, String tooltip )
64 {
65 JComboBox comboBox = super.appendComboBox( label, values, tooltip );
66 Bindings.bind( comboBox, new SelectionInList<Object>( values, pm.getModel( propertyName )) );
67 return comboBox;
68 }
69
70 public JComboBox appendComboBox( String propertyName, String label, ComboBoxModel model, String tooltip )
71 {
72 JComboBox comboBox = super.appendComboBox( label, model, tooltip );
73 Bindings.bind( comboBox, new SelectionInList<Object>( model, pm.getModel( propertyName )) );
74 return comboBox;
75 }
76 }