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.JTextField;
19
20 import com.jgoodies.binding.PresentationModel;
21 import com.jgoodies.binding.adapter.Bindings;
22 import com.jgoodies.binding.list.SelectionInList;
23
24 public class SimpleBindingForm extends SimpleForm
25 {
26 private final PresentationModel pm;
27
28 public SimpleBindingForm( PresentationModel pm )
29 {
30 this.pm = pm;
31 }
32
33 public JTextField appendTextField( String propertyName, String label, String tooltip )
34 {
35 JTextField textField = super.appendTextField( label, tooltip );
36 Bindings.bind( textField, pm.getModel( propertyName ));
37 return textField;
38 }
39
40 public JCheckBox appendCheckBox( String propertyName, String label, String tooltip )
41 {
42 JCheckBox checkBox = super.appendCheckBox( label, tooltip, false );
43 Bindings.bind( checkBox, pm.getModel( propertyName ) );
44 return checkBox;
45 }
46
47 public JComboBox appendComboBox( String propertyName, String label, Object[] values, String tooltip )
48 {
49 JComboBox comboBox = super.appendComboBox( label, values, tooltip );
50 Bindings.bind( comboBox, new SelectionInList<Object>( values, pm.getModel( propertyName )) );
51 return comboBox;
52 }
53
54 public JComboBox appendComboBox( String propertyName, String label, ComboBoxModel model, String tooltip )
55 {
56 JComboBox comboBox = super.appendComboBox( label, model, tooltip );
57 Bindings.bind( comboBox, new SelectionInList<Object>( model, pm.getModel( propertyName )) );
58 return comboBox;
59 }
60 }