svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / preferencespage / DriverCSVPage.java @ 43983
History | View | Annotate | Download (3.28 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40558 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40558 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40558 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.app.gui.preferencespage; |
||
25 | |||
26 | import javax.swing.ImageIcon; |
||
27 | import javax.swing.JPanel; |
||
28 | import javax.swing.JTextField; |
||
29 | |||
30 | import org.gvsig.andami.PluginServices; |
||
31 | import org.gvsig.andami.preferences.AbstractPreferencePage; |
||
32 | import org.gvsig.andami.preferences.StoreException; |
||
33 | import org.gvsig.utils.XMLEntity; |
||
34 | |||
35 | /**
|
||
36 | * CSV Driver preference page where the user can establish default values for
|
||
37 | * <ol>
|
||
38 | * <li><b>separator</b></li>
|
||
39 | * </ol>
|
||
40 | * @author Vicente Caballero Navarro
|
||
41 | *
|
||
42 | */
|
||
43 | //TODO comentado para que compile
|
||
44 | public class DriverCSVPage extends AbstractPreferencePage{ |
||
45 | private static final String DEFAULT_SEPARATOR_CSV_DRIVER = "DefaultSeparatorCSVDriver"; |
||
46 | static String id = DriverCSVPage.class.getName();; |
||
47 | private ImageIcon icon; |
||
48 | private JTextField txtSeparator; |
||
49 | |||
50 | /**
|
||
51 | * Builds preference page where the user can establish default values for
|
||
52 | * <ol>
|
||
53 | * <li><b>separator</b></li>
|
||
54 | * </ol>
|
||
55 | */
|
||
56 | public DriverCSVPage() {
|
||
57 | super();
|
||
58 | icon=PluginServices.getIconTheme().get("mapa-icono");
|
||
59 | addComponent(PluginServices.getText(this, "separador"), txtSeparator = new JTextField(5)); |
||
60 | setParentID(DriversPages.class.getName()); |
||
61 | } |
||
62 | |||
63 | public void storeValues() throws StoreException { |
||
64 | String separator;
|
||
65 | separator = txtSeparator.getText(); |
||
66 | // DriverManager dm=LayerFactory.getDM();
|
||
67 | // CSVStringDriver cvsDriver=null;
|
||
68 | // try {
|
||
69 | // cvsDriver = (CSVStringDriver)dm.getDriver("csv string");
|
||
70 | // } catch (DriverLoadException e) {
|
||
71 | // throw new StoreException();
|
||
72 | // }
|
||
73 | // cvsDriver.setSeparator(separator);
|
||
74 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
75 | XMLEntity xml = ps.getPersistentXML(); |
||
76 | xml.putProperty(DEFAULT_SEPARATOR_CSV_DRIVER, separator); |
||
77 | } |
||
78 | |||
79 | public String getID() { |
||
80 | return id;
|
||
81 | } |
||
82 | |||
83 | public String getTitle() { |
||
84 | return PluginServices.getText(this, "CSVStringDriver"); |
||
85 | } |
||
86 | |||
87 | public JPanel getPanel() { |
||
88 | return this; |
||
89 | } |
||
90 | |||
91 | public void initializeValues() { |
||
92 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
93 | XMLEntity xml = ps.getPersistentXML(); |
||
94 | if (xml.contains(DEFAULT_SEPARATOR_CSV_DRIVER)) {
|
||
95 | txtSeparator.setText(xml.getStringProperty(DEFAULT_SEPARATOR_CSV_DRIVER)); |
||
96 | } |
||
97 | |||
98 | } |
||
99 | |||
100 | public void initializeDefaults() { |
||
101 | txtSeparator.setText(",");
|
||
102 | } |
||
103 | |||
104 | public ImageIcon getIcon() { |
||
105 | return icon;
|
||
106 | } |
||
107 | |||
108 | public boolean isValueChanged() { |
||
109 | return super.hasChanged(); |
||
110 | } |
||
111 | |||
112 | public void setChangesApplied() { |
||
113 | setChanged(false);
|
||
114 | } |
||
115 | } |