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