Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / preferencespage / DriverCSVPage.java @ 9634

History | View | Annotate | Download (3.62 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

    
42
package com.iver.cit.gvsig.gui.preferencespage;
43

    
44
import javax.swing.ImageIcon;
45
import javax.swing.JPanel;
46
import javax.swing.JTextField;
47

    
48
import com.hardcode.driverManager.Driver;
49
import com.hardcode.driverManager.DriverManager;
50
import com.hardcode.gdbms.driver.csvstring.CSVStringDriver;
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.preferences.AbstractPreferencePage;
53
import com.iver.andami.preferences.StoreException;
54
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
55
import com.iver.utiles.XMLEntity;
56
/**
57
 * CSV Driver preference page where the user can establish default values for
58
 * <ol>
59
 *  <li><b>separator</b></li>
60
 * </ol>
61
 * @author Vicente Caballero Navarro
62
 *
63
 */
64
public class DriverCSVPage extends AbstractPreferencePage{
65
        private static final String DEFAULT_SEPARATOR_CSV_DRIVER = "DefaultSeparatorCSVDriver";
66
        static String id = DriverCSVPage.class.getName();;
67
        private ImageIcon icon;
68
        private JTextField txtSeparator;
69

    
70
        /**
71
         * Builds preference page where the user can establish default values for
72
         * <ol>
73
         *  <li><b>separator</b></li>
74
         * </ol>
75
         */
76
        public DriverCSVPage() {
77
                super();
78
                icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/mapas.png"));
79
                addComponent(PluginServices.getText(this, "separador"), txtSeparator = new JTextField(5));
80
                setParentID(DriversPages.class.getName());
81
        }
82

    
83
        public void storeValues() throws StoreException {
84
                String separator;
85
                separator = txtSeparator.getText();
86
                DriverManager dm=LayerFactory.getDM();
87
                CSVStringDriver cvsDriver=(CSVStringDriver)dm.getDriver("csv string");
88
                cvsDriver.setSeparator(separator);
89
                PluginServices ps = PluginServices.getPluginServices(this);
90
                XMLEntity xml = ps.getPersistentXML();
91
                xml.putProperty(DEFAULT_SEPARATOR_CSV_DRIVER, separator);
92
        }
93

    
94
        public String getID() {
95
                return id;
96
        }
97

    
98
        public String getTitle() {
99
                return PluginServices.getText(this, "CSVStringDriver");
100
        }
101

    
102
        public JPanel getPanel() {
103
                return this;
104
        }
105

    
106
        public void initializeValues() {
107
                PluginServices ps = PluginServices.getPluginServices(this);
108
                XMLEntity xml = ps.getPersistentXML();
109
                if (xml.contains(DEFAULT_SEPARATOR_CSV_DRIVER)) {
110
                        txtSeparator.setText(xml.getStringProperty(DEFAULT_SEPARATOR_CSV_DRIVER));
111
                }
112

    
113
        }
114

    
115
        public void initializeDefaults() {
116
                txtSeparator.setText(",");
117
        }
118

    
119
        public ImageIcon getIcon() {
120
                return icon;
121
        }
122

    
123
        public boolean isValueChanged() {
124
                return super.hasChanged();
125
        }
126

    
127
        public void setChangesApplied() {
128
                setChanged(false);
129
        }
130
}