Statistics
| Revision:

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

History | View | Annotate | Download (5.42 KB)

1 7805 jaume
/* 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
/* CVS MESSAGES:
43
*
44
* $Id$
45
* $Log$
46 7811 jaume
* Revision 1.2  2006-10-03 11:12:41  jaume
47
* initialize values
48
*
49
* Revision 1.1  2006/10/03 10:33:34  jaume
50 7805 jaume
* *** empty log message ***
51
*
52
*
53
*/
54
package com.iver.cit.gvsig.gui.preferencespage;
55
56
import javax.swing.ImageIcon;
57
import javax.swing.JCheckBox;
58
import javax.swing.JPanel;
59
import javax.swing.JTextField;
60
61
import com.iver.andami.PluginServices;
62
import com.iver.andami.preferences.AbstractPreferencePage;
63
import com.iver.andami.preferences.StoreException;
64 7811 jaume
import com.iver.utiles.XMLEntity;
65 7805 jaume
66
public class LayoutPage extends AbstractPreferencePage{
67
68 7811 jaume
        private static final boolean FACTORY_DEFAULT_LAYOUT_ENABLE_RULES = false;
69
        private static final boolean FACTORY_DEFAULT_LAYOUT_GRID_SHOW = false;
70
        private static final double FACTORY_DEFAULT_VERTICAL_GAP = 0;
71
        private static final double FACTORY_DEFAULT_HORIZONTAL_GAP = 0;
72
        private static final boolean FACTORY_DEFAULT_LAYOUT_GRID_ENABLE = false;
73
        private static final String DEFAULT_LAYOUT_GRID_SHOW_KEY_NAME = null;
74
        private static final String DEFAULT_LAYOUT_GRID_ENABLE_KEY_NAME = null;
75
        private static final String DEFAULT_LAYOUT_ENABLE_RULES_KEY_NAME = null;
76
        private static final String DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME = null;
77
        private static final String DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME = null;
78 7805 jaume
        private String id;
79
        private ImageIcon icon;
80
        private JCheckBox chkGridEnabled;
81
        private JCheckBox chkEnableRules;
82
        private JCheckBox chkShowGrid;
83
        private JTextField txtVGap;
84
        private JTextField txtHGap;
85
86
        public LayoutPage() {
87
                super();
88
                id = this.getClass().getName();
89
                icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/mapas.png"));
90
91 7811 jaume
                // horizontal gap text field
92 7805 jaume
                addComponent(PluginServices.getText(this, "espaciado_horizontal"), txtHGap = new JTextField(5));
93 7811 jaume
94
                // vertical gap text field
95 7805 jaume
                addComponent(PluginServices.getText(this, "espaciado_vertical"), txtVGap = new JTextField(5));
96 7811 jaume
97
                // show/hide show check
98 7805 jaume
                addComponent(chkShowGrid = new JCheckBox(PluginServices.getText(this, "visualizar_cuadricula")));
99 7811 jaume
100
                // enable/disable grid
101 7805 jaume
                addComponent(chkGridEnabled = new JCheckBox(PluginServices.getText(this, "malla_activada")));
102 7811 jaume
103
                // enable/disable rules
104 7805 jaume
                addComponent(chkEnableRules = new JCheckBox(PluginServices.getText(this, "activar_regla")));
105
106
        }
107 7811 jaume
108 7805 jaume
        public void storeValues() throws StoreException {
109
                // TODO Auto-generated method stub
110
111
        }
112
113
        public String getID() {
114
                return id;
115
        }
116
117
        public String getTitle() {
118
                return PluginServices.getText(this, "Mapa");
119
        }
120
121
        public JPanel getPanel() {
122
                return this;
123
        }
124
125
        public void initializeValues() {
126 7811 jaume
                PluginServices ps = PluginServices.getPluginServices(this);
127
                XMLEntity xml = ps.getPersistentXML();
128 7805 jaume
129 7811 jaume
                // horizontal gap
130
                if (xml.contains(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME)) {
131
                        txtHGap.setText(String.valueOf(
132
                                xml.getDoubleProperty(DEFAULT_LAYOUT_GRID_HORIZONTAL_GAP_KEY_NAME)));
133
                } else {
134
                        txtHGap.setText(String.valueOf(FACTORY_DEFAULT_HORIZONTAL_GAP));
135
                }
136
137
                // vertical gap
138
                if (xml.contains(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME)) {
139
                        txtVGap.setText(String.valueOf(
140
                                xml.getDoubleProperty(DEFAULT_LAYOUT_GRID_VERTICAL_GAP_KEY_NAME)));
141
                } else {
142
                        txtVGap.setText(String.valueOf(FACTORY_DEFAULT_VERTICAL_GAP));
143
                }
144
145
                // show/hide grid check
146
                if (xml.contains(DEFAULT_LAYOUT_GRID_SHOW_KEY_NAME)) {
147
                        chkShowGrid.setSelected(
148
                                xml.getBooleanProperty(DEFAULT_LAYOUT_GRID_SHOW_KEY_NAME));
149
                } else {
150
                        chkShowGrid.setSelected(FACTORY_DEFAULT_LAYOUT_GRID_SHOW);
151
                }
152
153
                // enable/disable grid check
154
                if (xml.contains(DEFAULT_LAYOUT_GRID_ENABLE_KEY_NAME)) {
155
                        chkGridEnabled.setSelected(
156
                                xml.getBooleanProperty(DEFAULT_LAYOUT_GRID_ENABLE_KEY_NAME));
157
                } else {
158
                        chkGridEnabled.setSelected(FACTORY_DEFAULT_LAYOUT_GRID_ENABLE);
159
                }
160
161
                // enable/disable rules
162
                if (xml.contains(DEFAULT_LAYOUT_ENABLE_RULES_KEY_NAME)) {
163
                        chkGridEnabled.setSelected(
164
                                xml.getBooleanProperty(DEFAULT_LAYOUT_ENABLE_RULES_KEY_NAME));
165
                } else {
166
                        chkGridEnabled.setSelected(FACTORY_DEFAULT_LAYOUT_ENABLE_RULES);
167
                }
168
169 7805 jaume
        }
170
171
        public void initializeDefaults() {
172
                // TODO Auto-generated method stub
173
174
        }
175
176
        public ImageIcon getIcon() {
177
                return icon;
178
        }
179
180
        public boolean isValueChanged() {
181
                return super.hasChanged();
182
        }
183
184
        public void setChangesApplied() {
185
                setChanged(false);
186
        }
187
}