root / trunk / extensions / extRasterTools-SE / src / org / gvsig / raster / gui / preferences / panels / PreferenceTemporal.java @ 17491
History | View | Annotate | Download (4.6 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.gui.preferences.panels; |
20 |
|
21 |
import java.awt.Dimension; |
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
import java.awt.Insets; |
25 |
import java.awt.event.ActionEvent; |
26 |
import java.awt.event.ActionListener; |
27 |
import java.io.File; |
28 |
|
29 |
import javax.swing.BorderFactory; |
30 |
import javax.swing.JButton; |
31 |
import javax.swing.JLabel; |
32 |
import javax.swing.JTextField; |
33 |
|
34 |
import org.gvsig.fmap.raster.util.Configuration; |
35 |
import org.gvsig.gui.beans.swing.JFileChooser; |
36 |
import org.gvsig.raster.RasterLibrary; |
37 |
import org.gvsig.raster.util.PanelBase; |
38 |
|
39 |
import com.iver.andami.PluginServices; |
40 |
/**
|
41 |
*
|
42 |
* @version 12/12/2007
|
43 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
44 |
*/
|
45 |
public class PreferenceTemporal extends PanelBase implements ActionListener { |
46 |
private JLabel labelTemporales = null; |
47 |
private JButton buttonOpen = null; |
48 |
private JTextField textFieldDirectory = null; |
49 |
|
50 |
public PreferenceTemporal() {
|
51 |
initialize(); |
52 |
translate(); |
53 |
} |
54 |
|
55 |
private void translate() { |
56 |
getPanel().setBorder(BorderFactory.createTitledBorder(getText(this, "rutas"))); |
57 |
getLabelTemporales().setText(getText(this, "temporales") + ":"); |
58 |
getButtonOpen().setText(getText(this, "seleccionar_directorio")); |
59 |
} |
60 |
|
61 |
private void initialize() { |
62 |
GridBagConstraints gridBagConstraints;
|
63 |
|
64 |
getPanel().setLayout(new GridBagLayout()); |
65 |
|
66 |
gridBagConstraints = new GridBagConstraints(); |
67 |
gridBagConstraints.insets = new Insets(5, 5, 5, 2); |
68 |
getPanel().add(getLabelTemporales(), gridBagConstraints); |
69 |
|
70 |
gridBagConstraints = new GridBagConstraints(); |
71 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
72 |
gridBagConstraints.weightx = 1.0;
|
73 |
gridBagConstraints.insets = new Insets(5, 2, 5, 2); |
74 |
getPanel().add(getTextFieldDirectory(), gridBagConstraints); |
75 |
|
76 |
gridBagConstraints = new GridBagConstraints(); |
77 |
gridBagConstraints.insets = new Insets(5, 2, 5, 5); |
78 |
getPanel().add(getButtonOpen(), gridBagConstraints); |
79 |
} |
80 |
|
81 |
private JLabel getLabelTemporales() { |
82 |
if (labelTemporales == null) { |
83 |
labelTemporales = new JLabel(); |
84 |
} |
85 |
return labelTemporales;
|
86 |
} |
87 |
|
88 |
private JButton getButtonOpen() { |
89 |
if (buttonOpen == null) { |
90 |
buttonOpen = new JButton(); |
91 |
buttonOpen.addActionListener(this);
|
92 |
} |
93 |
return buttonOpen;
|
94 |
} |
95 |
|
96 |
private JTextField getTextFieldDirectory() { |
97 |
if (textFieldDirectory == null) { |
98 |
textFieldDirectory = new JTextField(); |
99 |
textFieldDirectory.setEditable(false);
|
100 |
textFieldDirectory.setPreferredSize(new Dimension(0, textFieldDirectory.getPreferredSize().height)); |
101 |
} |
102 |
return textFieldDirectory;
|
103 |
} |
104 |
|
105 |
|
106 |
public void initializeDefaults() { |
107 |
File file = new File((String) Configuration.getDefaultValue("path_temp_cache_directory")); |
108 |
if (!file.exists())
|
109 |
file.mkdir(); |
110 |
getTextFieldDirectory().setText(file.getAbsolutePath()); |
111 |
} |
112 |
|
113 |
public void initializeValues() { |
114 |
File file = new File(Configuration.getValue("path_temp_cache_directory", RasterLibrary.tempCacheDirectoryPath)); |
115 |
if (!file.exists())
|
116 |
file.mkdir(); |
117 |
getTextFieldDirectory().setText(file.getAbsolutePath()); |
118 |
} |
119 |
|
120 |
public void storeValues() { |
121 |
Configuration.setValue("path_temp_cache_directory", getTextFieldDirectory().getText()); |
122 |
} |
123 |
|
124 |
public void actionPerformed(ActionEvent e) { |
125 |
JFileChooser chooser = new JFileChooser(this.getClass().getName(), new File(getTextFieldDirectory().getText())); |
126 |
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
127 |
chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_directorio")); |
128 |
|
129 |
if (chooser.showOpenDialog(getPanel()) == JFileChooser.APPROVE_OPTION) |
130 |
getTextFieldDirectory().setText(chooser.getSelectedFile().getAbsolutePath()); |
131 |
|
132 |
JFileChooser.setLastPath(this.getClass().getName(), new File(getTextFieldDirectory().getText())); |
133 |
} |
134 |
} |