Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / preferencespage / DriverCSVPage.java @ 10626

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

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

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

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

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

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

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

    
112
        }
113

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

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

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

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