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 @ 43256
History | View | Annotate | Download (4.29 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
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 | 40435 | jjdelcerro | 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 | 41304 | nbrodin | } |
102 | |||
103 | 40435 | jjdelcerro | val_obj = props.getDynValue(CartographicSupportPage.DefaultUnitReferenceSystemKey); |
104 | if (val_obj != null) { |
||
105 | val = ((Integer) val_obj).intValue();
|
||
106 | cmbReferenceSystem.setSelectedIndex(val); |
||
107 | } |
||
108 | } |
||
109 | |||
110 | public void initializeDefaults() { |
||
111 | cmbUnits.setSelectedUnitIndex(CartographicSupportToolkit.DefaultMeasureUnit); |
||
112 | cmbReferenceSystem.setSelectedIndex(CartographicSupportToolkit.DefaultReferenceSystem); |
||
113 | } |
||
114 | |||
115 | public void storeValues() throws StoreException { |
||
116 | |||
117 | DynObject props = this.getPluginProperties();
|
||
118 | props.setDynValue(CartographicSupportPage.DefaultMeasureUnitKey, |
||
119 | new Integer(cmbUnits.getSelectedUnitIndex())); |
||
120 | props.setDynValue(CartographicSupportPage.DefaultUnitReferenceSystemKey, |
||
121 | new Integer(cmbReferenceSystem.getSelectedIndex())); |
||
122 | } |
||
123 | |||
124 | public boolean isValueChanged() { |
||
125 | return super.hasChanged(); |
||
126 | } |
||
127 | |||
128 | private DynObject getPluginProperties() {
|
||
129 | PluginsManager pluginsManager = PluginsLocator.getManager(); |
||
130 | return pluginsManager.getPlugin(BasicSymbologyExtension.class).getPluginProperties();
|
||
131 | } |
||
132 | |||
133 | } |