View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.x.impl.swing;
14  
15  import com.eviware.soapui.support.components.StringListFormComponent;
16  import com.eviware.x.form.XFormOptionsField;
17  import com.eviware.x.form.XFormTextField;
18  
19  public class JStringListFormField extends AbstractSwingXFormField<StringListFormComponent> implements XFormTextField,
20  		XFormOptionsField
21  {
22  	public JStringListFormField( String tooltip )
23  	{
24  		this( tooltip, null );
25  	}
26  
27  	public JStringListFormField( String tooltip, String defaultValue )
28  	{
29  		super( new StringListFormComponent( tooltip, false, defaultValue ) );
30  	}
31  
32  	public void setValue( String value )
33  	{
34  		getComponent().setValue( value );
35  	}
36  
37  	public String getValue()
38  	{
39  		return getComponent().getValue();
40  	}
41  
42  	public void setWidth( int columns )
43  	{
44  	}
45  
46  	@Override
47  	public void addItem( Object value )
48  	{
49  		getComponent().addItem( String.valueOf( value ) );
50  	}
51  
52  	@Override
53  	public String[] getOptions()
54  	{
55  		return getComponent().getData();
56  	}
57  
58  	@Override
59  	public int[] getSelectedIndexes()
60  	{
61  		return new int[0];
62  	}
63  
64  	@Override
65  	public Object[] getSelectedOptions()
66  	{
67  		return new Object[0];
68  	}
69  
70  	@Override
71  	public void setOptions( Object[] values )
72  	{
73  		String[] data = new String[values.length];
74  		for( int c = 0; c < values.length; c++ )
75  			data[c] = String.valueOf( values[c] );
76  
77  		getComponent().setData( data );
78  	}
79  
80  	@Override
81  	public void setSelectedOptions( Object[] options )
82  	{
83  	}
84  }