1   package org.wcb.gui.forms.wizard;
2   
3   import org.wcb.gui.component.JXTitlePanel;
4   import org.wcb.gui.dialog.file.ImportFileDialog;
5   import org.jdesktop.swingx.border.DropShadowBorder;
6   
7   import javax.swing.border.Border;
8   import javax.swing.border.CompoundBorder;
9   import javax.swing.*;
10  import java.awt.event.ActionListener;
11  import java.awt.event.ActionEvent;
12  import java.awt.*;
13  import java.io.File;
14  
15  /**
16   * <small>
17   * <p/>
18   * Copyright (C)  2006  wbogaardt.
19   * This library is free software; you can redistribute it and/or
20   * modify it under the terms of the GNU Lesser General Public
21   * License as published by the Free Software Foundation; either
22   * version 2.1 of the License, or (at your option) any later version.
23   * <p/>
24   * This library is distributed in the hope that it will be useful,
25   * but WITHOUT ANY WARRANTY; without even the implied warranty of
26   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27   * Lesser General Public License for more details.
28   * <p/>
29   * You should have received a copy of the GNU Lesser General Public
30   * License along with this library; if not, write to the Free Software
31   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
32   * <p/>
33   * $File:  $ <br>
34   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Oct 26, 2006 2:43:12 PM $ <br>
35   * </small>
36   *
37   * @author wbogaardt
38   *        Page 1 file to import data from.
39   */
40  
41  public class Step1ofImportWizard extends JXTitlePanel implements ActionListener {
42  
43      public Step1ofImportWizard() {
44          super("Step 1 - Import from File", new Color(0x3779ff));
45          Border shadow = new DropShadowBorder(Color.BLACK, 2, 5, .3f, 15, true, true, true, true);
46          setBorder(new CompoundBorder(shadow, getBorder()));
47          initComponents();
48      }
49  
50      /** This method is called from within the constructor to
51       * initialize the form.
52       * WARNING: Do NOT modify this code. The content of this method is
53       * always regenerated by the Form Editor.
54       */
55      private void initComponents() {
56          fileName = new JTextField(System.getProperty("user.home") + File.separator);
57          fileLocationButton = new JButton("..");
58          fileLocationButton.addActionListener(this);
59  
60          setLayout(new GridBagLayout());
61  
62          GridBagConstraints gridBagConstraints = new GridBagConstraints();
63          gridBagConstraints.anchor = GridBagConstraints.WEST;
64          gridBagConstraints.gridwidth = 3;
65          gridBagConstraints.insets = new Insets(0,0,5,0);
66          add(new JLabel("The following data file is being selected for import:"), gridBagConstraints);
67  
68  
69          gridBagConstraints = new GridBagConstraints();
70          gridBagConstraints.anchor = GridBagConstraints.WEST;
71          gridBagConstraints.gridx = 0;
72          gridBagConstraints.gridy = 1;
73          gridBagConstraints.insets = new Insets(0,0,0,5);
74          add(new JLabel("File Name:"), gridBagConstraints);
75  
76          gridBagConstraints = new GridBagConstraints();
77          gridBagConstraints.gridx = 1;
78          gridBagConstraints.gridy = 1;
79          gridBagConstraints.anchor = GridBagConstraints.WEST;
80          add(fileName, gridBagConstraints);
81  
82          gridBagConstraints = new GridBagConstraints();
83          gridBagConstraints.gridx = 2;
84          gridBagConstraints.gridy = 1;
85          gridBagConstraints.anchor = GridBagConstraints.WEST;
86          add(fileLocationButton, gridBagConstraints);
87      }
88  
89      public String getFilePathName() {
90          return fileName.getText();
91      }
92  
93      public void actionPerformed(ActionEvent evt) {
94          ImportFileDialog importDialog = new ImportFileDialog();
95          String filePath = importDialog.getFilePath();
96          if(filePath != null) {
97              fileName.setText(filePath);
98          }
99      }
100 
101     // Variables declaration - do not modify
102     private JTextField fileName;
103     private JButton fileLocationButton;
104     // End of variables declaration
105 
106 }