svn-gvsig-desktop / trunk / extensions / extNormalization / src / org / gvsig / normalization / preferences / PreferencesNormPanel.java @ 22677
History | View | Annotate | Download (4.89 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Prodevelop S.L. main developer
|
26 |
*/
|
27 |
package org.gvsig.normalization.preferences; |
28 |
|
29 |
import java.awt.Component; |
30 |
import java.awt.Dimension; |
31 |
import java.io.File; |
32 |
|
33 |
import javax.swing.BorderFactory; |
34 |
import javax.swing.JButton; |
35 |
import javax.swing.JFileChooser; |
36 |
import javax.swing.JLabel; |
37 |
import javax.swing.JPanel; |
38 |
import javax.swing.JTextField; |
39 |
import javax.swing.border.TitledBorder; |
40 |
|
41 |
import org.apache.log4j.Logger; |
42 |
|
43 |
import com.iver.andami.PluginServices; |
44 |
|
45 |
/**
|
46 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
47 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
48 |
*/
|
49 |
public class PreferencesNormPanel extends JPanel { |
50 |
|
51 |
/**
|
52 |
*
|
53 |
*/
|
54 |
private static final long serialVersionUID = 1L; |
55 |
/**
|
56 |
*
|
57 |
*/
|
58 |
|
59 |
private JButton jButAdd; |
60 |
private JLabel jLabFile; |
61 |
private JTextField jTextPath; |
62 |
|
63 |
private static final Logger log = Logger |
64 |
.getLogger(PreferencesNormPanel.class); |
65 |
private String folder = ""; |
66 |
|
67 |
/**
|
68 |
* Builder
|
69 |
* @param fol
|
70 |
*/
|
71 |
public PreferencesNormPanel(String fol) { |
72 |
initComponents(); |
73 |
updateLabels(); |
74 |
folder = fol; |
75 |
setFolderPattern(folder); |
76 |
} |
77 |
|
78 |
private void initComponents() { |
79 |
java.awt.GridBagConstraints gridBagConstraints; |
80 |
|
81 |
jLabFile = new javax.swing.JLabel();
|
82 |
jTextPath = new javax.swing.JTextField();
|
83 |
jButAdd = new javax.swing.JButton();
|
84 |
|
85 |
setLayout(new java.awt.GridBagLayout());
|
86 |
setBorder(javax.swing.BorderFactory.createTitledBorder("folder path of normalization patterns"));
|
87 |
setMinimumSize(new Dimension(500, 100)); |
88 |
|
89 |
jLabFile.setText("path pattern folder");
|
90 |
jLabFile.setMinimumSize(new java.awt.Dimension(200, 20)); |
91 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
92 |
gridBagConstraints.gridx = 0;
|
93 |
gridBagConstraints.gridy = 0;
|
94 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
95 |
gridBagConstraints.weightx = 1.0;
|
96 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
97 |
add(jLabFile, gridBagConstraints); |
98 |
jTextPath.setMinimumSize(new java.awt.Dimension(200, 20)); |
99 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
100 |
gridBagConstraints.gridx = 0;
|
101 |
gridBagConstraints.gridy = 1;
|
102 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
103 |
gridBagConstraints.weightx = 1.0;
|
104 |
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5); |
105 |
add(jTextPath, gridBagConstraints); |
106 |
|
107 |
jButAdd.setText("Change");
|
108 |
jButAdd.addActionListener(new java.awt.event.ActionListener() {
|
109 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
110 |
evtChangeFile(evt); |
111 |
} |
112 |
}); |
113 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
114 |
gridBagConstraints.gridx = 1;
|
115 |
gridBagConstraints.gridy = 1;
|
116 |
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 5); |
117 |
add(jButAdd, gridBagConstraints); |
118 |
} |
119 |
|
120 |
private void evtChangeFile(java.awt.event.ActionEvent evt) { |
121 |
File fol = loadFolder();
|
122 |
if (folder != null) { |
123 |
folder = fol.getAbsolutePath(); |
124 |
setFolderPattern(folder); |
125 |
} else {
|
126 |
log.debug("Folder null");
|
127 |
} |
128 |
} |
129 |
|
130 |
private void updateLabels() { |
131 |
|
132 |
jLabFile.setText(PluginServices.getText(this, "pref_path_folder")); |
133 |
jButAdd.setText(PluginServices.getText(this, "pref_change_folder")); |
134 |
|
135 |
//TODO
|
136 |
this.setBorder(BorderFactory.createTitledBorder(PluginServices |
137 |
.getText(this,"pref_title_folder"))); |
138 |
} |
139 |
|
140 |
public void setFolderPattern(String file) { |
141 |
jTextPath.setText(file); |
142 |
} |
143 |
|
144 |
public String getFolderPattern() { |
145 |
|
146 |
return jTextPath.getText().trim();
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* This method loads a folder where you save the Normalization pattern
|
151 |
*
|
152 |
* @return File folder
|
153 |
*/
|
154 |
private File loadFolder() { |
155 |
|
156 |
File thefolder = null; |
157 |
|
158 |
JFileChooser jfc = new JFileChooser(); |
159 |
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
160 |
jfc.setDialogTitle(PluginServices.getText(this, "pref_dialog_forder")); |
161 |
|
162 |
int returnval = jfc.showOpenDialog((Component) PluginServices |
163 |
.getMainFrame()); |
164 |
|
165 |
if (returnval == JFileChooser.APPROVE_OPTION) { |
166 |
thefolder = jfc.getSelectedFile(); |
167 |
log.debug("Open folder: " + thefolder.toString());
|
168 |
} else {
|
169 |
return null; |
170 |
} |
171 |
|
172 |
return thefolder;
|
173 |
} |
174 |
|
175 |
} |