root / trunk / extensions / ext3Dgui / src / com / iver / ai2 / gvsig3dgui / preferences / View3DPreferences.java @ 15783
History | View | Annotate | Download (4.1 KB)
1 |
package com.iver.ai2.gvsig3dgui.preferences; |
---|---|
2 |
|
3 |
import java.awt.event.ActionEvent; |
4 |
import java.util.Enumeration; |
5 |
import java.util.prefs.Preferences; |
6 |
|
7 |
import javax.swing.AbstractAction; |
8 |
import javax.swing.Action; |
9 |
import javax.swing.ButtonGroup; |
10 |
import javax.swing.ImageIcon; |
11 |
import javax.swing.JLabel; |
12 |
import javax.swing.JPanel; |
13 |
import javax.swing.JRadioButton; |
14 |
|
15 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.andami.preferences.AbstractPreferencePage; |
19 |
import com.iver.andami.preferences.StoreException; |
20 |
|
21 |
public class View3DPreferences extends AbstractPreferencePage { |
22 |
|
23 |
private String id; |
24 |
private ImageIcon icon; |
25 |
private GridBagLayoutPanel panel;
|
26 |
private ButtonGroup radioButtonGroup; |
27 |
private boolean compatibilitySwing; |
28 |
private JRadioButton activeAWT; |
29 |
private JRadioButton activeGL; |
30 |
private static Preferences prefs = Preferences.userRoot().node( |
31 |
"gvsig.configuration.3D");
|
32 |
|
33 |
public View3DPreferences() {
|
34 |
super();
|
35 |
// TODO Auto-generated constructor stub
|
36 |
id = this.getClass().getName();
|
37 |
icon = PluginServices.getIconTheme().get("gnome-settings-theme");
|
38 |
} |
39 |
|
40 |
public void setChangesApplied() { |
41 |
// System.out.println("ESTOY LLAMANDO A setChangesApplied()");
|
42 |
if (compatibilitySwing)
|
43 |
activeAWT.setSelected(true);
|
44 |
else
|
45 |
activeGL.setSelected(true);
|
46 |
} |
47 |
|
48 |
public void storeValues() throws StoreException { |
49 |
// TODO Auto-generated method stub
|
50 |
// System.out.println("ESTOY LLAMANDO A storeValues()");
|
51 |
prefs.putBoolean("compatibilitySwing", compatibilitySwing);
|
52 |
} |
53 |
|
54 |
public String getID() { |
55 |
return id;
|
56 |
} |
57 |
|
58 |
public ImageIcon getIcon() { |
59 |
return icon;
|
60 |
} |
61 |
|
62 |
private ButtonGroup getRadioButonGroup() { |
63 |
|
64 |
if (radioButtonGroup == null) { |
65 |
|
66 |
// Create an action for each radio button
|
67 |
Action AWTaction = new AbstractAction("AWT") { |
68 |
|
69 |
// This method is called whenever the radio button is pressed,
|
70 |
// even if it is already selected; this method is not called
|
71 |
// if the radio button was selected programmatically
|
72 |
public void actionPerformed(ActionEvent evt) { |
73 |
// ACTION THAT ACTIVATE GL PANEL MODE
|
74 |
compatibilitySwing = true;
|
75 |
} |
76 |
}; |
77 |
|
78 |
Action GLaction = new AbstractAction("GL") { |
79 |
// See above
|
80 |
public void actionPerformed(ActionEvent evt) { |
81 |
// ACTION THAT ACTIVATE CANVAS MODE
|
82 |
compatibilitySwing = false;
|
83 |
} |
84 |
}; |
85 |
|
86 |
// Create the radio buttons using the actions
|
87 |
activeAWT = new JRadioButton(AWTaction); |
88 |
activeGL = new JRadioButton(GLaction); |
89 |
|
90 |
// Inicialize the button properties
|
91 |
activeAWT.setName("Si");
|
92 |
activeAWT.setLabel(PluginServices.getText(this, "AWT")); |
93 |
activeGL.setName("No");
|
94 |
activeGL.setLabel(PluginServices.getText(this, "GL")); |
95 |
|
96 |
if (compatibilitySwing)
|
97 |
activeAWT.setSelected(true);
|
98 |
else
|
99 |
activeGL.setSelected(true);
|
100 |
|
101 |
// Associate the two buttons with a button group
|
102 |
radioButtonGroup = new ButtonGroup(); |
103 |
radioButtonGroup.add(activeAWT); |
104 |
radioButtonGroup.add(activeGL); |
105 |
} |
106 |
|
107 |
return radioButtonGroup;
|
108 |
} |
109 |
|
110 |
public JPanel getPanel() { |
111 |
|
112 |
if (radioButtonGroup == null) { |
113 |
radioButtonGroup = getRadioButonGroup(); |
114 |
|
115 |
addComponent(new JLabel(PluginServices.getText(this, "Swing_Compability"))); |
116 |
for (Enumeration e = radioButtonGroup.getElements(); e |
117 |
.hasMoreElements();) { |
118 |
JRadioButton b = (JRadioButton) e.nextElement(); |
119 |
addComponent(b); |
120 |
} |
121 |
addComponent(new JLabel(PluginServices.getText(this, "Swing_Compability_Note"))); |
122 |
} |
123 |
return this; |
124 |
} |
125 |
|
126 |
public String getTitle() { |
127 |
// TODO Auto-generated method stub
|
128 |
return "3D"; |
129 |
} |
130 |
|
131 |
public void initializeDefaults() { |
132 |
// TODO Auto-generated method stub
|
133 |
// System.out.println("inicialize Defaults");
|
134 |
this.compatibilitySwing = true; |
135 |
|
136 |
} |
137 |
|
138 |
public void initializeValues() { |
139 |
// TODO Auto-generated method stub
|
140 |
// System.out.println("inicialize values");
|
141 |
compatibilitySwing = prefs.getBoolean("compatibilitySwing",
|
142 |
compatibilitySwing); |
143 |
|
144 |
} |
145 |
|
146 |
public boolean isValueChanged() { |
147 |
// TODO Auto-generated method stub
|
148 |
// System.out.println("is value changed");
|
149 |
return true; |
150 |
} |
151 |
|
152 |
} |