svn-gvsig-desktop / tags / v1_0_2_Build_910 / libraries / libCorePlugin / src / com / iver / core / preferences / general / LanguagePage.java @ 11275
History | View | Annotate | Download (7.38 KB)
1 | 6102 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
||
4 | *
|
||
5 | * This program is free software; you can redistribute it and/or
|
||
6 | * modify it under the terms of the GNU General Public License
|
||
7 | * as published by the Free Software Foundation; either version 2
|
||
8 | * of the License, or (at your option) any later version.
|
||
9 | *
|
||
10 | * This program is distributed in the hope that it will be useful,
|
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | * GNU General Public License for more details.
|
||
14 | *
|
||
15 | * You should have received a copy of the GNU General Public License
|
||
16 | * along with this program; if not, write to the Free Software
|
||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
18 | *
|
||
19 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | 5792 | caballero | package com.iver.core.preferences.general; |
42 | |||
43 | import java.awt.BorderLayout; |
||
44 | 6805 | jaume | import java.awt.event.ActionEvent; |
45 | import java.awt.event.ActionListener; |
||
46 | 5792 | caballero | import java.util.Locale; |
47 | |||
48 | import javax.swing.DefaultComboBoxModel; |
||
49 | import javax.swing.ImageIcon; |
||
50 | import javax.swing.JComboBox; |
||
51 | 9384 | jmvivo | import javax.swing.JLabel; |
52 | 5792 | caballero | import javax.swing.JPanel; |
53 | |||
54 | import com.iver.andami.Launcher; |
||
55 | import com.iver.andami.PluginServices; |
||
56 | import com.iver.andami.preferences.AbstractPreferencePage; |
||
57 | |||
58 | public class LanguagePage extends AbstractPreferencePage { |
||
59 | 8765 | jjdelcerro | private static LanguageItem DEFAULT_LANGUAGE; |
60 | 5792 | caballero | private ImageIcon icon; |
61 | 5804 | fjp | |
62 | 5792 | caballero | private String id; |
63 | 5804 | fjp | |
64 | 5792 | caballero | private JPanel pN = null; |
65 | 5804 | fjp | |
66 | 5792 | caballero | private JPanel pC = null; |
67 | 5804 | fjp | |
68 | 9384 | jmvivo | private JPanel pS = null; |
69 | |||
70 | 5792 | caballero | private JPanel jPanel = null; |
71 | 5804 | fjp | |
72 | 5792 | caballero | private JComboBox cmbIdioma = null; |
73 | 9384 | jmvivo | |
74 | private JLabel label = null; |
||
75 | 5804 | fjp | |
76 | 6575 | jaume | private int langIndex; |
77 | 6805 | jaume | private boolean changed = false; |
78 | 6575 | jaume | |
79 | 5792 | caballero | public LanguagePage() {
|
80 | super();
|
||
81 | initialize(); |
||
82 | id = this.getClass().getName();
|
||
83 | 5804 | fjp | setParentID(GeneralPage.class.getName()); |
84 | 5792 | caballero | } |
85 | |||
86 | private void initialize() { |
||
87 | 5804 | fjp | icon = new ImageIcon(this.getClass().getClassLoader().getResource( |
88 | "images/babel.png"));
|
||
89 | this.setLayout(new BorderLayout()); |
||
90 | this.setSize(new java.awt.Dimension(386, 177)); |
||
91 | this.add(getPN(), java.awt.BorderLayout.NORTH);
|
||
92 | this.add(getPC(), java.awt.BorderLayout.CENTER);
|
||
93 | 9384 | jmvivo | this.add(getPS(), java.awt.BorderLayout.SOUTH);
|
94 | 6575 | jaume | langIndex = getJComboBox().getSelectedIndex(); |
95 | 5792 | caballero | } |
96 | |||
97 | public String getID() { |
||
98 | return id;
|
||
99 | } |
||
100 | |||
101 | public String getTitle() { |
||
102 | return PluginServices.getText(this, "idioma"); |
||
103 | } |
||
104 | |||
105 | public JPanel getPanel() { |
||
106 | return this; |
||
107 | } |
||
108 | |||
109 | 5804 | fjp | public void initializeValues() { |
110 | 5792 | caballero | } |
111 | |||
112 | private class LanguageItem { |
||
113 | public Locale locale; |
||
114 | 5804 | fjp | |
115 | 5792 | caballero | public String description; |
116 | |||
117 | 5804 | fjp | public LanguageItem(Locale loc, String str) { |
118 | 5792 | caballero | locale = loc; |
119 | description = str; |
||
120 | } |
||
121 | |||
122 | 5804 | fjp | public String toString() { |
123 | 5792 | caballero | return description;
|
124 | } |
||
125 | } |
||
126 | 5804 | fjp | |
127 | 6662 | caballero | public void storeValues() { |
128 | 5804 | fjp | // Se escribe el idioma
|
129 | 5792 | caballero | LanguageItem sel = (LanguageItem) cmbIdioma.getSelectedItem(); |
130 | Launcher.getAndamiConfig().setLocaleLanguage(sel.locale.getLanguage()); |
||
131 | Launcher.getAndamiConfig().setLocaleCountry(sel.locale.getCountry()); |
||
132 | Launcher.getAndamiConfig().setLocaleVariant(sel.locale.getVariant()); |
||
133 | 6575 | jaume | langIndex = getJComboBox().getSelectedIndex(); |
134 | 6810 | jaume | |
135 | 5792 | caballero | } |
136 | |||
137 | public void initializeDefaults() { |
||
138 | 8765 | jjdelcerro | getJComboBox().setSelectedItem(DEFAULT_LANGUAGE); |
139 | 5792 | caballero | } |
140 | |||
141 | public ImageIcon getIcon() { |
||
142 | return icon;
|
||
143 | } |
||
144 | |||
145 | /**
|
||
146 | * This method initializes pN
|
||
147 | 6102 | jaume | *
|
148 | 5792 | caballero | * @return javax.swing.JPanel
|
149 | */
|
||
150 | private JPanel getPN() { |
||
151 | if (pN == null) { |
||
152 | pN = new JPanel(); |
||
153 | } |
||
154 | return pN;
|
||
155 | } |
||
156 | |||
157 | /**
|
||
158 | * This method initializes pC
|
||
159 | 6102 | jaume | *
|
160 | 5792 | caballero | * @return javax.swing.JPanel
|
161 | */
|
||
162 | private JPanel getPC() { |
||
163 | if (pC == null) { |
||
164 | pC = new JPanel(); |
||
165 | pC.add(getJPanel(), null);
|
||
166 | } |
||
167 | return pC;
|
||
168 | } |
||
169 | |||
170 | /**
|
||
171 | 9384 | jmvivo | * This method initializes pS
|
172 | *
|
||
173 | * @return javax.swing.JPanel
|
||
174 | */
|
||
175 | private JPanel getPS() { |
||
176 | if (pS == null) { |
||
177 | pS = new JPanel(); |
||
178 | pS.add(getLabel(),BorderLayout.SOUTH);
|
||
179 | } |
||
180 | return pS;
|
||
181 | } |
||
182 | |||
183 | |||
184 | /**
|
||
185 | 5792 | caballero | * This method initializes jPanel
|
186 | 6102 | jaume | *
|
187 | 5792 | caballero | * @return javax.swing.JPanel
|
188 | */
|
||
189 | private JPanel getJPanel() { |
||
190 | if (jPanel == null) { |
||
191 | jPanel = new JPanel(); |
||
192 | 5804 | fjp | jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
|
193 | 8765 | jjdelcerro | PluginServices.getText(this,"idioma"), |
194 | 5804 | fjp | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
195 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
196 | null));
|
||
197 | 9384 | jmvivo | jPanel.add(getJComboBox(), BorderLayout.NORTH);
|
198 | |||
199 | 5792 | caballero | } |
200 | return jPanel;
|
||
201 | } |
||
202 | /**
|
||
203 | 9384 | jmvivo | * This method initializes Label
|
204 | *
|
||
205 | * @return javax.swing.JComboBox
|
||
206 | */
|
||
207 | private JLabel getLabel() { |
||
208 | if (label == null){ |
||
209 | label = new JLabel(PluginServices.getText(null,"Los_cambios_efectuados_sobre_estos_valores_se_aplicaran_al_reiniciar_la_aplicacion")); |
||
210 | } |
||
211 | return label;
|
||
212 | } |
||
213 | /**
|
||
214 | 5792 | caballero | * This method initializes jComboBox
|
215 | 6102 | jaume | *
|
216 | 5792 | caballero | * @return javax.swing.JComboBox
|
217 | */
|
||
218 | private JComboBox getJComboBox() { |
||
219 | if (cmbIdioma == null) { |
||
220 | cmbIdioma = new JComboBox(); |
||
221 | 5804 | fjp | cmbIdioma.setPreferredSize(new java.awt.Dimension(195, 20)); |
222 | 5792 | caballero | |
223 | Locale esp = new Locale("es"); |
||
224 | Locale eng = new Locale("en"); |
||
225 | Locale fra = new Locale("fr"); |
||
226 | Locale ita = new Locale("it"); |
||
227 | Locale val = new Locale("ca"); |
||
228 | 5804 | fjp | Locale cs = new Locale("cs"); // Checo |
229 | Locale eu = new Locale("eu"); // euskera |
||
230 | Locale brasil = new Locale("pt", "BR"); |
||
231 | Locale de = new Locale("de"); // Alem?n |
||
232 | Locale gl = new Locale("gl", "GL"); // Griego |
||
233 | 8765 | jjdelcerro | Locale zh = new Locale("zh", "ZH"); // Chino |
234 | 10500 | jmvivo | Locale ro = new Locale("ro"); // Rumano |
235 | 10702 | jmvivo | Locale pl = new Locale("pl"); // Polaco |
236 | 5792 | caballero | |
237 | 8765 | jjdelcerro | // Default language
|
238 | |||
239 | 5792 | caballero | // Parche para valenciano/catal?n valenci?/catal?
|
240 | String strValenciano = PluginServices.getText(this, "__catalan"); |
||
241 | 5804 | fjp | // Parche para euskera
|
242 | 5792 | caballero | |
243 | 5804 | fjp | Locale localeActual = Locale.getDefault(); // Se configura en la |
244 | // clase Launcher
|
||
245 | String strEuskera;
|
||
246 | if (eu.getDisplayLanguage().compareTo("vascuence") == 0) |
||
247 | strEuskera = "Euskera";
|
||
248 | else
|
||
249 | strEuskera = eu.getDisplayLanguage(); |
||
250 | 5792 | caballero | |
251 | 8765 | jjdelcerro | // English as default language
|
252 | DEFAULT_LANGUAGE = new LanguageItem(eng, eng.getDisplayLanguage());
|
||
253 | |||
254 | 5804 | fjp | LanguageItem[] lenguajes = new LanguageItem[] { |
255 | 5792 | caballero | new LanguageItem(esp, esp.getDisplayLanguage()),
|
256 | 8765 | jjdelcerro | DEFAULT_LANGUAGE, |
257 | 5792 | caballero | new LanguageItem(fra, fra.getDisplayLanguage()),
|
258 | new LanguageItem(ita, ita.getDisplayLanguage()),
|
||
259 | 5804 | fjp | new LanguageItem(val, strValenciano),
|
260 | new LanguageItem(cs, cs.getDisplayLanguage()),
|
||
261 | new LanguageItem(eu, strEuskera),
|
||
262 | new LanguageItem(brasil, brasil.getDisplayLanguage()),
|
||
263 | 5792 | caballero | new LanguageItem(de, de.getDisplayLanguage()),
|
264 | 8765 | jjdelcerro | new LanguageItem(gl, gl.getDisplayLanguage()),
|
265 | 10500 | jmvivo | new LanguageItem(zh, zh.getDisplayLanguage()),
|
266 | 10702 | jmvivo | new LanguageItem(ro, ro.getDisplayLanguage()),
|
267 | new LanguageItem(pl, pl.getDisplayLanguage())};
|
||
268 | 5792 | caballero | |
269 | DefaultComboBoxModel model = new DefaultComboBoxModel(lenguajes); |
||
270 | |||
271 | for (int i = 0; i < lenguajes.length; i++) { |
||
272 | 5804 | fjp | if (lenguajes[i].locale.equals(Locale.getDefault())) { |
273 | 5792 | caballero | model.setSelectedItem(lenguajes[i]); |
274 | } |
||
275 | } |
||
276 | |||
277 | cmbIdioma.setModel(model); |
||
278 | 6805 | jaume | cmbIdioma.addActionListener(new ActionListener() { |
279 | public void actionPerformed(ActionEvent e) { |
||
280 | changed = true;
|
||
281 | } |
||
282 | }); |
||
283 | 5792 | caballero | } |
284 | return cmbIdioma;
|
||
285 | } |
||
286 | 6805 | jaume | |
287 | public boolean isValueChanged() { |
||
288 | return changed;
|
||
289 | } |
||
290 | 6810 | jaume | |
291 | public void setChangesApplied() { |
||
292 | changed = false;
|
||
293 | |||
294 | } |
||
295 | 5804 | fjp | } // @jve:decl-index=0:visual-constraint="10,10" |