1
2
3
4
5
6
7
8
9
10
11
12
13 package com/eviware/soapui/support/components/package-summary.html">> com.eviware.soapui.support.components;
14
15 import java.awt.event.ActionEvent;
16 import java.io.File;
17
18 import javax.swing.AbstractAction;
19 import javax.swing.JButton;
20 import javax.swing.JPanel;
21 import javax.swing.JTextField;
22
23 import com.eviware.soapui.support.UISupport;
24 import com.jgoodies.forms.builder.ButtonBarBuilder;
25
26 public class FileFormComponent extends JPanel implements JFormComponent
27 {
28 private JTextField textField;
29
30 public FileFormComponent( String tooltip )
31 {
32 ButtonBarBuilder builder = new ButtonBarBuilder( this );
33 textField = new JTextField( 30 );
34 textField.setToolTipText( tooltip );
35 builder.addGriddedGrowing( textField );
36 builder.addRelatedGap();
37 builder.addFixed( new JButton( new SelectDirectoryAction()) );
38 }
39
40 public void setValue(String value)
41 {
42 textField.setText( value );
43 }
44
45 public JTextField getTextField()
46 {
47 return textField;
48 }
49
50 public String getValue()
51 {
52 return textField.getText();
53 }
54
55 public class SelectDirectoryAction extends AbstractAction
56 {
57 public SelectDirectoryAction()
58 {
59 super( "Browse..." );
60 }
61
62 public void actionPerformed(ActionEvent e)
63 {
64 File file = UISupport.getFileDialogs().open(this, "Select file", null, null );
65 if( file != null )
66 {
67 textField.setText( file.getAbsolutePath());
68 }
69 }
70 }
71 }