Revision 39609 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/gui/preferencespage/CartographicSupportPage.java
CartographicSupportPage.java | ||
---|---|---|
1 | 1 |
package org.gvsig.app.gui.preferencespage; |
2 | 2 |
|
3 | 3 |
import javax.swing.ImageIcon; |
4 |
import javax.swing.JOptionPane; |
|
4 | 5 |
import javax.swing.JPanel; |
5 | 6 |
import javax.swing.JSeparator; |
6 | 7 |
|
7 | 8 |
import org.gvsig.andami.PluginServices; |
9 |
import org.gvsig.andami.PluginsLocator; |
|
10 |
import org.gvsig.andami.PluginsManager; |
|
8 | 11 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
9 | 12 |
import org.gvsig.andami.preferences.StoreException; |
13 |
import org.gvsig.app.ApplicationLocator; |
|
14 |
import org.gvsig.app.extension.BasicSymbologyExtension; |
|
10 | 15 |
import org.gvsig.app.gui.JComboBoxUnits; |
11 | 16 |
import org.gvsig.app.gui.styling.JComboBoxUnitsReferenceSystem; |
12 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
|
|
17 |
import org.gvsig.i18n.Messages;
|
|
13 | 18 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit; |
14 |
import org.gvsig.utils.XMLEntity;
|
|
19 |
import org.gvsig.tools.dynobject.DynObject;
|
|
15 | 20 |
|
16 | 21 |
|
17 | 22 |
/** |
... | ... | |
19 | 24 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
20 | 25 |
*/ |
21 | 26 |
public class CartographicSupportPage extends AbstractPreferencePage { |
22 |
private static final String DefaultMeasureUnitKey = "DefaultMeasureUnitKey"; |
|
23 |
private static final String DefaultUnitReferenceSystemKey = "DefaultUnitReferenceSystemKey"; |
|
27 |
|
|
28 |
private static final String DefaultMeasureUnitKey = "default_measure_units"; |
|
29 |
private static final String DefaultUnitReferenceSystemKey = "default_measure_units_reference_system"; |
|
30 |
|
|
24 | 31 |
private JComboBoxUnits cmbUnits; |
25 | 32 |
private JComboBoxUnitsReferenceSystem cmbReferenceSystem; |
26 | 33 |
|
... | ... | |
30 | 37 |
} |
31 | 38 |
|
32 | 39 |
private void initialize() { |
33 |
addComponent(PluginServices.getText(this, "default_measure_units"),
|
|
40 |
addComponent(PluginServices.getText(this, "_Default_measure_units"),
|
|
34 | 41 |
cmbUnits = new JComboBoxUnits(true)); |
35 |
addComponent(PluginServices.getText(this, "default_measure_units_reference_system"),
|
|
42 |
addComponent(PluginServices.getText(this, "_Default_measure_units_reference_system"),
|
|
36 | 43 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem()); |
37 | 44 |
addComponent(new JSeparator(JSeparator.HORIZONTAL)); |
38 | 45 |
} |
39 | 46 |
|
40 |
// pending of a proposed refactor, don't erase |
|
41 |
// @Override |
|
42 |
// public void persistPreferences() throws StoreException { |
|
43 |
// PluginServices ps = PluginServices.getPluginServices(this); |
|
44 |
// XMLEntity xml = ps.getPersistentXML(); |
|
45 |
// xml.putProperty(DefaultMeasureUnitKey, cmbUnits.getSelectedUnitIndex()); |
|
46 |
// xml.putProperty(DefaultUnitReferenceSystemKey, cmbReferenceSystem.getSelectedIndex()); |
|
47 |
// } |
|
48 |
|
|
49 |
@Override |
|
50 | 47 |
public void setChangesApplied() { |
51 | 48 |
setChanged(false); |
52 | 49 |
} |
53 | 50 |
|
54 |
public void applyValuesFromPersistence() throws StoreException { |
|
55 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
56 |
XMLEntity xml = ps.getPersistentXML(); |
|
57 |
if (xml.contains(DefaultMeasureUnitKey)) |
|
58 |
CartographicSupportToolkit.DefaultMeasureUnit = xml.getIntProperty(DefaultMeasureUnitKey); |
|
59 |
if (xml.contains(DefaultUnitReferenceSystemKey)) |
|
60 |
CartographicSupportToolkit.DefaultReferenceSystem = xml.getIntProperty(DefaultUnitReferenceSystemKey); |
|
61 |
} |
|
62 |
|
|
63 | 51 |
public String getID() { |
64 | 52 |
return getClass().getName(); |
65 | 53 |
} |
... | ... | |
74 | 62 |
} |
75 | 63 |
|
76 | 64 |
public String getTitle() { |
77 |
return PluginServices.getText(this, "cartographic_support");
|
|
65 |
return Messages.getText("_Cartographic_support_panel_title");
|
|
78 | 66 |
} |
79 | 67 |
|
80 |
// pending of a refactoring do not delete (swap commented lines) |
|
81 |
// public void initializeComponents() { |
|
82 | 68 |
public void initializeValues() { |
83 |
cmbUnits.setSelectedUnitIndex(CartographicSupportToolkit.DefaultMeasureUnit); |
|
84 |
cmbReferenceSystem.setSelectedIndex(CartographicSupportToolkit.DefaultReferenceSystem); |
|
69 |
|
|
70 |
DynObject props = this.getPluginProperties(); |
|
71 |
int val = 0; |
|
72 |
Object val_obj = null; |
|
73 |
|
|
74 |
val_obj = props.getDynValue(CartographicSupportPage.DefaultMeasureUnitKey); |
|
75 |
if (val_obj != null) { |
|
76 |
val = ((Integer) val_obj).intValue(); |
|
77 |
cmbUnits.setSelectedUnitIndex(val); |
|
78 |
} else { |
|
79 |
ApplicationLocator.getManager().message( |
|
80 |
Messages.getText("_Persistence_error"), |
|
81 |
JOptionPane.ERROR_MESSAGE); |
|
82 |
} |
|
83 |
|
|
84 |
val_obj = props.getDynValue(CartographicSupportPage.DefaultUnitReferenceSystemKey); |
|
85 |
if (val_obj != null) { |
|
86 |
val = ((Integer) val_obj).intValue(); |
|
87 |
cmbReferenceSystem.setSelectedIndex(val); |
|
88 |
} else { |
|
89 |
ApplicationLocator.getManager().message( |
|
90 |
Messages.getText("_Persistence_error"), |
|
91 |
JOptionPane.ERROR_MESSAGE); |
|
92 |
} |
|
85 | 93 |
} |
86 | 94 |
|
87 | 95 |
public void initializeDefaults() { |
88 |
CartographicSupportToolkit.DefaultMeasureUnit = -1; // pixel |
|
89 |
CartographicSupportToolkit.DefaultReferenceSystem = CartographicSupport.WORLD; |
|
90 |
initializeValues(); |
|
91 |
// pending of a refactoring do not delete (swap commented lines) |
|
92 |
// initializeComponents(); |
|
96 |
cmbUnits.setSelectedUnitIndex(CartographicSupportToolkit.DefaultMeasureUnit); |
|
97 |
cmbReferenceSystem.setSelectedIndex(CartographicSupportToolkit.DefaultReferenceSystem); |
|
93 | 98 |
} |
94 | 99 |
|
95 |
// pending of a refactoring, following method would be removed |
|
96 |
@Override |
|
97 | 100 |
public void storeValues() throws StoreException { |
98 |
// TODO Auto-generated method stub |
|
99 |
|
|
101 |
|
|
102 |
DynObject props = this.getPluginProperties(); |
|
103 |
props.setDynValue(CartographicSupportPage.DefaultMeasureUnitKey, |
|
104 |
new Integer(cmbUnits.getSelectedUnitIndex())); |
|
105 |
props.setDynValue(CartographicSupportPage.DefaultUnitReferenceSystemKey, |
|
106 |
new Integer(cmbReferenceSystem.getSelectedIndex())); |
|
100 | 107 |
} |
101 | 108 |
|
102 | 109 |
public boolean isValueChanged() { |
103 | 110 |
return super.hasChanged(); |
104 | 111 |
} |
112 |
|
|
113 |
private DynObject getPluginProperties() { |
|
114 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
|
115 |
return pluginsManager.getPlugin(BasicSymbologyExtension.class).getPluginProperties(); |
|
116 |
} |
|
105 | 117 |
|
106 | 118 |
} |
Also available in: Unified diff