01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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 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: private JTextField textField;
28:
29: public FileFormComponent(String tooltip) {
30: ButtonBarBuilder builder = new ButtonBarBuilder(this );
31: textField = new JTextField(30);
32: textField.setToolTipText(tooltip);
33: builder.addGriddedGrowing(textField);
34: builder.addRelatedGap();
35: builder.addFixed(new JButton(new SelectDirectoryAction()));
36: }
37:
38: public void setValue(String value) {
39: textField.setText(value);
40: }
41:
42: public JTextField getTextField() {
43: return textField;
44: }
45:
46: public String getValue() {
47: return textField.getText();
48: }
49:
50: public class SelectDirectoryAction extends AbstractAction {
51: public SelectDirectoryAction() {
52: super ("Browse...");
53: }
54:
55: public void actionPerformed(ActionEvent e) {
56: File file = UISupport.getFileDialogs().open(this ,
57: "Select file", null, null, null);
58: if (file != null) {
59: textField.setText(file.getAbsolutePath());
60: }
61: }
62: }
63: }
|