Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.ui / src / main / java / org / gvsig / gui / beans / wizard / panel / SelectFileOptionPanel.java @ 40561

History | View | Annotate | Download (3.18 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2010 {Prodevelop}   {Task}
27
 */
28

    
29
package org.gvsig.gui.beans.wizard.panel;
30

    
31
import java.awt.BorderLayout;
32
import java.awt.GridBagConstraints;
33
import java.awt.GridBagLayout;
34
import java.io.File;
35

    
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38
import javax.swing.JTextField;
39
import javax.swing.event.DocumentEvent;
40
import javax.swing.event.DocumentListener;
41

    
42
import org.gvsig.gui.beans.openfile.FileTextField;
43

    
44
/**
45
 * <p>
46
 * This panel implements a panel to select a file that can be added to a wizard.
47
 * </p>
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
49
 */
50
public class SelectFileOptionPanel extends JPanel implements DocumentListener{
51
        private JLabel fileLabel;
52
        private FileTextField fileTextField;
53
        private javax.swing.JPanel northPanel;
54

    
55
        public SelectFileOptionPanel(String fileText) {
56
                super();                
57
                initComponents();
58
                if (fileText != null){
59
                    fileLabel.setText(fileText + ":");
60
                }
61
                initListeners();
62
        }
63
        
64
    private void initListeners() {        
65
                Object obj = fileTextField.getComponent(0);
66
                if ((obj != null) && (obj instanceof JTextField)) {
67
                        ((JTextField)obj).getDocument().addDocumentListener(this);        
68
                }
69
        }
70

    
71
        private void initComponents() {
72
                java.awt.GridBagConstraints gridBagConstraints;
73

    
74
                northPanel = new JPanel();
75
                fileLabel = new JLabel();
76
                fileTextField = new FileTextField();
77

    
78
                setLayout(new BorderLayout());
79

    
80
                northPanel.setLayout(new GridBagLayout());
81

    
82
                northPanel.add(fileLabel, new GridBagConstraints());
83

    
84
                gridBagConstraints = new GridBagConstraints();
85
                gridBagConstraints.gridx = 1;
86
                gridBagConstraints.gridy = 0;
87
                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
88
                gridBagConstraints.weightx = 1.0;
89
                northPanel.add(fileTextField, gridBagConstraints);
90

    
91
                add(northPanel, BorderLayout.NORTH);
92
        }
93

    
94
        public File getSelectedFile(){
95
                return fileTextField.getSelectedFile();
96
        }
97

    
98
        public String getSelectedFileName(){
99
                return fileTextField.getSelectedFile().getAbsolutePath();
100
        }
101

    
102
        protected void checkNextButtonEnabled(){
103

    
104
        }
105

    
106
        public void changedUpdate(DocumentEvent e) {
107
                checkNextButtonEnabled();                
108
        }
109

    
110
        public void insertUpdate(DocumentEvent e) {
111
                checkNextButtonEnabled();                        
112
        }
113

    
114
        public void removeUpdate(DocumentEvent e) {
115
                checkNextButtonEnabled();                        
116
        }   
117
}
118