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 import javax.swing.text.JTextComponent;
23
24 import com.eviware.soapui.support.UISupport;
25 import com.jgoodies.forms.builder.ButtonBarBuilder;
26
27 public class DirectoryFormComponent extends JPanel implements JFormComponent
28 {
29 private JTextField textField;
30
31 public DirectoryFormComponent( String tooltip )
32 {
33 ButtonBarBuilder builder = new ButtonBarBuilder( this );
34 textField = new JTextField( 30 );
35 textField.setToolTipText( tooltip );
36 builder.addGriddedGrowing( textField );
37 builder.addRelatedGap();
38 builder.addFixed( new JButton( new SelectDirectoryAction()) );
39 }
40
41 public void setValue(String value)
42 {
43 textField.setText( value );
44 }
45
46 public String getValue()
47 {
48 return textField.getText();
49 }
50
51 public class SelectDirectoryAction extends AbstractAction
52 {
53 public SelectDirectoryAction()
54 {
55 super( "Browse..." );
56 }
57
58 public void actionPerformed(ActionEvent e)
59 {
60 File currentDirectory = null;
61 if( textField.getText().length() > 0 )
62 currentDirectory = new File( textField.getText() );
63 File file = UISupport.getFileDialogs().openDirectory(this, "Select directory", currentDirectory);
64 if( file != null )
65 {
66 textField.setText( file.getAbsolutePath());
67 }
68 }
69 }
70
71 public JTextComponent getTextField()
72 {
73 return textField;
74 }
75 }