svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / preferencespage / CartographicSupportPage.java @ 39609
History | View | Annotate | Download (3.67 KB)
1 |
package org.gvsig.app.gui.preferencespage; |
---|---|
2 |
|
3 |
import javax.swing.ImageIcon; |
4 |
import javax.swing.JOptionPane; |
5 |
import javax.swing.JPanel; |
6 |
import javax.swing.JSeparator; |
7 |
|
8 |
import org.gvsig.andami.PluginServices; |
9 |
import org.gvsig.andami.PluginsLocator; |
10 |
import org.gvsig.andami.PluginsManager; |
11 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
12 |
import org.gvsig.andami.preferences.StoreException; |
13 |
import org.gvsig.app.ApplicationLocator; |
14 |
import org.gvsig.app.extension.BasicSymbologyExtension; |
15 |
import org.gvsig.app.gui.JComboBoxUnits; |
16 |
import org.gvsig.app.gui.styling.JComboBoxUnitsReferenceSystem; |
17 |
import org.gvsig.i18n.Messages; |
18 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.CartographicSupportToolkit; |
19 |
import org.gvsig.tools.dynobject.DynObject; |
20 |
|
21 |
|
22 |
/**
|
23 |
*
|
24 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
25 |
*/
|
26 |
public class CartographicSupportPage extends AbstractPreferencePage { |
27 |
|
28 |
private static final String DefaultMeasureUnitKey = "default_measure_units"; |
29 |
private static final String DefaultUnitReferenceSystemKey = "default_measure_units_reference_system"; |
30 |
|
31 |
private JComboBoxUnits cmbUnits;
|
32 |
private JComboBoxUnitsReferenceSystem cmbReferenceSystem;
|
33 |
|
34 |
public CartographicSupportPage() {
|
35 |
super();
|
36 |
initialize(); |
37 |
} |
38 |
|
39 |
private void initialize() { |
40 |
addComponent(PluginServices.getText(this, "_Default_measure_units"), |
41 |
cmbUnits = new JComboBoxUnits(true)); |
42 |
addComponent(PluginServices.getText(this, "_Default_measure_units_reference_system"), |
43 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem());
|
44 |
addComponent(new JSeparator(JSeparator.HORIZONTAL)); |
45 |
} |
46 |
|
47 |
public void setChangesApplied() { |
48 |
setChanged(false);
|
49 |
} |
50 |
|
51 |
public String getID() { |
52 |
return getClass().getName();
|
53 |
} |
54 |
|
55 |
public ImageIcon getIcon() { |
56 |
// TODO Auto-generated method stub
|
57 |
return null; |
58 |
} |
59 |
|
60 |
public JPanel getPanel() { |
61 |
return this; |
62 |
} |
63 |
|
64 |
public String getTitle() { |
65 |
return Messages.getText("_Cartographic_support_panel_title"); |
66 |
} |
67 |
|
68 |
public void initializeValues() { |
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 |
} |
93 |
} |
94 |
|
95 |
public void initializeDefaults() { |
96 |
cmbUnits.setSelectedUnitIndex(CartographicSupportToolkit.DefaultMeasureUnit); |
97 |
cmbReferenceSystem.setSelectedIndex(CartographicSupportToolkit.DefaultReferenceSystem); |
98 |
} |
99 |
|
100 |
public void storeValues() throws StoreException { |
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())); |
107 |
} |
108 |
|
109 |
public boolean isValueChanged() { |
110 |
return super.hasChanged(); |
111 |
} |
112 |
|
113 |
private DynObject getPluginProperties() {
|
114 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
115 |
return pluginsManager.getPlugin(BasicSymbologyExtension.class).getPluginProperties();
|
116 |
} |
117 |
|
118 |
} |