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 / CartographicSupportPage.java @ 40558
History | View | Annotate | Download (4.6 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
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 |
* as published by the Free Software Foundation; either version 3
|
9 |
* 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 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.gui.preferencespage; |
25 |
|
26 |
import javax.swing.ImageIcon; |
27 |
import javax.swing.JOptionPane; |
28 |
import javax.swing.JPanel; |
29 |
import javax.swing.JSeparator; |
30 |
|
31 |
import org.gvsig.andami.PluginServices; |
32 |
import org.gvsig.andami.PluginsLocator; |
33 |
import org.gvsig.andami.PluginsManager; |
34 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
35 |
import org.gvsig.andami.preferences.StoreException; |
36 |
import org.gvsig.app.ApplicationLocator; |
37 |
import org.gvsig.app.extension.BasicSymbologyExtension; |
38 |
import org.gvsig.app.gui.JComboBoxUnits; |
39 |
import org.gvsig.app.gui.styling.JComboBoxUnitsReferenceSystem; |
40 |
import org.gvsig.i18n.Messages; |
41 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit; |
42 |
import org.gvsig.tools.dynobject.DynObject; |
43 |
|
44 |
|
45 |
/**
|
46 |
*
|
47 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
48 |
*/
|
49 |
public class CartographicSupportPage extends AbstractPreferencePage { |
50 |
|
51 |
private static final String DefaultMeasureUnitKey = "default_measure_units"; |
52 |
private static final String DefaultUnitReferenceSystemKey = "default_measure_units_reference_system"; |
53 |
|
54 |
private JComboBoxUnits cmbUnits;
|
55 |
private JComboBoxUnitsReferenceSystem cmbReferenceSystem;
|
56 |
|
57 |
public CartographicSupportPage() {
|
58 |
super();
|
59 |
initialize(); |
60 |
} |
61 |
|
62 |
private void initialize() { |
63 |
addComponent(PluginServices.getText(this, "_Default_measure_units"), |
64 |
cmbUnits = new JComboBoxUnits(true)); |
65 |
addComponent(PluginServices.getText(this, "_Default_measure_units_reference_system"), |
66 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
67 |
addComponent(new JSeparator(JSeparator.HORIZONTAL)); |
68 |
} |
69 |
|
70 |
public void setChangesApplied() { |
71 |
setChanged(false);
|
72 |
} |
73 |
|
74 |
public String getID() { |
75 |
return getClass().getName();
|
76 |
} |
77 |
|
78 |
public ImageIcon getIcon() { |
79 |
// TODO Auto-generated method stub
|
80 |
return null; |
81 |
} |
82 |
|
83 |
public JPanel getPanel() { |
84 |
return this; |
85 |
} |
86 |
|
87 |
public String getTitle() { |
88 |
return Messages.getText("_Cartographic_support_panel_title"); |
89 |
} |
90 |
|
91 |
public void initializeValues() { |
92 |
|
93 |
DynObject props = this.getPluginProperties();
|
94 |
int val = 0; |
95 |
Object val_obj = null; |
96 |
|
97 |
val_obj = props.getDynValue(CartographicSupportPage.DefaultMeasureUnitKey); |
98 |
if (val_obj != null) { |
99 |
val = ((Integer) val_obj).intValue();
|
100 |
cmbUnits.setSelectedUnitIndex(val); |
101 |
} else {
|
102 |
ApplicationLocator.getManager().message( |
103 |
Messages.getText("_Persistence_error"),
|
104 |
JOptionPane.ERROR_MESSAGE);
|
105 |
} |
106 |
|
107 |
val_obj = props.getDynValue(CartographicSupportPage.DefaultUnitReferenceSystemKey); |
108 |
if (val_obj != null) { |
109 |
val = ((Integer) val_obj).intValue();
|
110 |
cmbReferenceSystem.setSelectedIndex(val); |
111 |
} else {
|
112 |
ApplicationLocator.getManager().message( |
113 |
Messages.getText("_Persistence_error"),
|
114 |
JOptionPane.ERROR_MESSAGE);
|
115 |
} |
116 |
} |
117 |
|
118 |
public void initializeDefaults() { |
119 |
cmbUnits.setSelectedUnitIndex(CartographicSupportToolkit.DefaultMeasureUnit); |
120 |
cmbReferenceSystem.setSelectedIndex(CartographicSupportToolkit.DefaultReferenceSystem); |
121 |
} |
122 |
|
123 |
public void storeValues() throws StoreException { |
124 |
|
125 |
DynObject props = this.getPluginProperties();
|
126 |
props.setDynValue(CartographicSupportPage.DefaultMeasureUnitKey, |
127 |
new Integer(cmbUnits.getSelectedUnitIndex())); |
128 |
props.setDynValue(CartographicSupportPage.DefaultUnitReferenceSystemKey, |
129 |
new Integer(cmbReferenceSystem.getSelectedIndex())); |
130 |
} |
131 |
|
132 |
public boolean isValueChanged() { |
133 |
return super.hasChanged(); |
134 |
} |
135 |
|
136 |
private DynObject getPluginProperties() {
|
137 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
138 |
return pluginsManager.getPlugin(BasicSymbologyExtension.class).getPluginProperties();
|
139 |
} |
140 |
|
141 |
} |