View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
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  }