root / tags / v2_0_0_Build_2059 / extensions / extI18n / src / main / java / org / gvsig / i18n / extension / preferences / I18nPreferencePage.java @ 39301
History | View | Annotate | Download (19.6 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 {DiSiD Technologies} {New extension for installation and update of text translations}
|
26 |
*/
|
27 |
package org.gvsig.i18n.extension.preferences; |
28 |
|
29 |
import java.awt.Color; |
30 |
import java.awt.Component; |
31 |
import java.awt.Dimension; |
32 |
import java.awt.Font; |
33 |
import java.awt.GridBagConstraints; |
34 |
import java.awt.GridBagLayout; |
35 |
import java.awt.Insets; |
36 |
import java.awt.event.ActionEvent; |
37 |
import java.awt.event.ActionListener; |
38 |
import java.io.File; |
39 |
import java.util.ArrayList; |
40 |
import java.util.HashSet; |
41 |
import java.util.List; |
42 |
import java.util.Locale; |
43 |
import java.util.Set; |
44 |
|
45 |
import javax.swing.Box; |
46 |
import javax.swing.BoxLayout; |
47 |
import javax.swing.ImageIcon; |
48 |
import javax.swing.JFileChooser; |
49 |
import javax.swing.JLabel; |
50 |
import javax.swing.JOptionPane; |
51 |
import javax.swing.JPanel; |
52 |
import javax.swing.JScrollPane; |
53 |
import javax.swing.JTable; |
54 |
import javax.swing.JTextArea; |
55 |
import javax.swing.ListSelectionModel; |
56 |
import javax.swing.filechooser.FileFilter; |
57 |
import javax.swing.table.TableColumn; |
58 |
|
59 |
import org.gvsig.andami.PluginServices; |
60 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
61 |
import org.gvsig.andami.preferences.StoreException; |
62 |
import org.gvsig.gui.beans.swing.JButton; |
63 |
import org.gvsig.i18n.I18nException; |
64 |
import org.gvsig.i18n.I18nManager; |
65 |
import org.gvsig.i18n.Messages; |
66 |
import org.gvsig.i18n.extension.preferences.table.LocaleTableModel; |
67 |
import org.gvsig.i18n.extension.preferences.table.RadioButtonCellEditor; |
68 |
import org.gvsig.i18n.extension.preferences.table.RadioButtonCellRenderer; |
69 |
import org.gvsig.i18n.impl.I18nManagerImpl; |
70 |
|
71 |
|
72 |
/**
|
73 |
* Prefence page to manage gvSIG locales.
|
74 |
*
|
75 |
* @author <a href="mailto:dcervera@disid.com">David Cervera</a>
|
76 |
*/
|
77 |
public class I18nPreferencePage extends AbstractPreferencePage implements |
78 |
ActionListener {
|
79 |
|
80 |
private static final long serialVersionUID = 7164183052397200888L; |
81 |
|
82 |
private static final String COMMAND_UNINSTALL = "UNINSTALL"; |
83 |
|
84 |
private static final String COMMAND_EXPORT = "EXPORT"; |
85 |
|
86 |
private static final String COMMAND_EXPORT_NEW = "EXPORT_NEW"; |
87 |
|
88 |
private static final String COMMAND_INSTALL = "INSTALL"; |
89 |
|
90 |
private static final String EXPORT_JAR_FILE_EXTENSION = ".jar"; |
91 |
|
92 |
private static final String EXPORT_ZIP_FILE_EXTENSION = ".zip"; |
93 |
|
94 |
private ImageIcon icon; |
95 |
|
96 |
private I18nManager manager = I18nManagerImpl.getInstance();
|
97 |
|
98 |
private JTable localesTable; |
99 |
|
100 |
private LocaleTableModel tableModel;
|
101 |
|
102 |
private JFileChooser fileChooser; |
103 |
|
104 |
/**
|
105 |
* Creates a new I18n preferences page.
|
106 |
*/
|
107 |
public I18nPreferencePage() {
|
108 |
setParentID("org.gvsig.coreplugin.preferences.general.GeneralPage");
|
109 |
|
110 |
icon = PluginServices.getIconTheme().get("i18n-preferences");
|
111 |
|
112 |
// GridBagConstants.HORIZONTAL
|
113 |
Insets zero_ins = new Insets(0, 0, 0, 0); |
114 |
Font hints_fnt = new JLabel().getFont(); |
115 |
|
116 |
addComponent(getLocalesPanel(), |
117 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
118 |
|
119 |
addComponent(Box.createRigidArea(new Dimension(0, 5)), |
120 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
121 |
|
122 |
addComponent(getActiveLocaleLabel( |
123 |
this.getBackground(), hints_fnt.deriveFont(Font.BOLD)), |
124 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
125 |
|
126 |
addComponent(Box.createRigidArea(new Dimension(0, 5)), |
127 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
128 |
|
129 |
addComponent(getButtonsPanel(), |
130 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
131 |
|
132 |
addComponent(Box.createRigidArea(new Dimension(0, 5)), |
133 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
134 |
|
135 |
addComponent(getCollaborationLabel( |
136 |
this.getBackground(), hints_fnt),
|
137 |
GridBagConstraints.HORIZONTAL, zero_ins);
|
138 |
|
139 |
/*
|
140 |
add(getLocalesPanel());
|
141 |
add(Box.createRigidArea(new Dimension(0, 5)));
|
142 |
add(getActiveLocaleLabel());
|
143 |
add(Box.createRigidArea(new Dimension(0, 5)));
|
144 |
add(getButtonsPanel());
|
145 |
add(Box.createRigidArea(new Dimension(0, 5)));
|
146 |
add(getCollaborationLabel());
|
147 |
*/
|
148 |
} |
149 |
|
150 |
public String getID() { |
151 |
return getClass().getName();
|
152 |
} |
153 |
|
154 |
public String getTitle() { |
155 |
return Messages.getText("idioma"); |
156 |
} |
157 |
|
158 |
public ImageIcon getIcon() { |
159 |
return icon;
|
160 |
} |
161 |
|
162 |
public JPanel getPanel() { |
163 |
return this; |
164 |
} |
165 |
|
166 |
public void setChangesApplied() { |
167 |
tableModel.setChangesApplied(); |
168 |
} |
169 |
|
170 |
public boolean isValueChanged() { |
171 |
return tableModel.isValueChanged();
|
172 |
} |
173 |
|
174 |
public void storeValues() throws StoreException { |
175 |
tableModel.saveSelectedLocale(); |
176 |
} |
177 |
|
178 |
public void initializeDefaults() { |
179 |
tableModel.selectDefaultLocale(); |
180 |
} |
181 |
|
182 |
public void initializeValues() { |
183 |
tableModel.selectPreviousLocale(); |
184 |
} |
185 |
|
186 |
public void actionPerformed(ActionEvent event) { |
187 |
if (COMMAND_INSTALL.equals(event.getActionCommand())) {
|
188 |
installLocale(); |
189 |
} |
190 |
else if (COMMAND_EXPORT.equals(event.getActionCommand())) { |
191 |
exportLocaleForUpdate(); |
192 |
} |
193 |
else if (COMMAND_EXPORT_NEW.equals(event.getActionCommand())) { |
194 |
exportLocaleForTranslation(); |
195 |
} |
196 |
else if (COMMAND_UNINSTALL.equals(event.getActionCommand())) { |
197 |
uninstallSelectedLocale(); |
198 |
} |
199 |
} |
200 |
|
201 |
/**
|
202 |
* Installs a new Locale translation or updates an already existing one.
|
203 |
*/
|
204 |
private void installLocale() { |
205 |
JFileChooser fileChooser = getJarFileChooser();
|
206 |
|
207 |
int returnVal = fileChooser.showOpenDialog(this); |
208 |
|
209 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
210 |
File importFile = fileChooser.getSelectedFile();
|
211 |
try {
|
212 |
Locale[] installedLocales = manager.installLocales(importFile); |
213 |
if (installedLocales == null || installedLocales.length == 0) { |
214 |
JOptionPane
|
215 |
.showMessageDialog( |
216 |
this,
|
217 |
Messages |
218 |
.getText("I18nPreferencePage.idiomas_no_encontrados_para_instalar"),
|
219 |
Messages |
220 |
.getText("I18nPreferencePage.error_instalar_idiomas"),
|
221 |
JOptionPane.ERROR_MESSAGE);
|
222 |
} |
223 |
else {
|
224 |
StringBuffer msg = new StringBuffer(Messages |
225 |
.getText("I18nPreferencePage.idiomas_instalados"));
|
226 |
|
227 |
for (int i = 0; i < installedLocales.length; i++) { |
228 |
msg.append(manager.getDisplayName(installedLocales[i])); |
229 |
if (i < installedLocales.length - 1) { |
230 |
msg.append(", ");
|
231 |
} |
232 |
} |
233 |
tableModel.reloadLocales(); |
234 |
JOptionPane
|
235 |
.showMessageDialog( |
236 |
this,
|
237 |
msg.toString(), |
238 |
Messages |
239 |
.getText("I18nPreferencePage.instalar_idiomas"),
|
240 |
JOptionPane.INFORMATION_MESSAGE);
|
241 |
} |
242 |
} catch (I18nException ex) {
|
243 |
ex.showError(); |
244 |
} |
245 |
} |
246 |
} |
247 |
|
248 |
/**
|
249 |
* Updates the translation of a locale
|
250 |
*/
|
251 |
private void exportLocaleForUpdate() { |
252 |
Locale[] locales = getSelectedLocales(); |
253 |
|
254 |
if (locales == null) { |
255 |
JOptionPane.showMessageDialog(this, Messages |
256 |
.getText("I18nPreferencePage.seleccione_idioma"), Messages
|
257 |
.getText("I18nPreferencePage.error_actualizar_idioma"),
|
258 |
JOptionPane.ERROR_MESSAGE);
|
259 |
} |
260 |
else {
|
261 |
// Select the reference language
|
262 |
LocaleItem[] items = getLocaleItemsForSelection(manager
|
263 |
.getInstalledLocales(), locales); |
264 |
LocaleItem selected = null;
|
265 |
if (items != null && items.length > 0) { |
266 |
// Select by default the current locale, or the first one
|
267 |
// if the current locale is one of the ones to be updated
|
268 |
for (int i = 0; i < locales.length && selected == null; i++) { |
269 |
if (locales[i].equals(manager.getCurrentLocale())) {
|
270 |
selected = items[0];
|
271 |
} |
272 |
} |
273 |
if (selected == null) { |
274 |
selected = new LocaleItem(manager.getCurrentLocale(),
|
275 |
manager); |
276 |
} |
277 |
selected = (LocaleItem) JOptionPane
|
278 |
.showInputDialog( |
279 |
this,
|
280 |
Messages |
281 |
.getText("I18nPreferencePage.seleccione_idioma_referencia"),
|
282 |
Messages |
283 |
.getText("I18nPreferencePage.exportar_idioma"),
|
284 |
JOptionPane.QUESTION_MESSAGE, null, items, |
285 |
selected); |
286 |
|
287 |
if (selected == null) { |
288 |
return;
|
289 |
} |
290 |
} |
291 |
// Select the file to export to
|
292 |
JFileChooser fileChooser = getJarFileChooser();
|
293 |
fileChooser.setSelectedFile(new File( |
294 |
getLocaleJarFileName(locales[0])));
|
295 |
|
296 |
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { |
297 |
File saveFile = fileChooser.getSelectedFile();
|
298 |
try {
|
299 |
Locale fileNameLocale = selected == null ? manager |
300 |
.getCurrentLocale() : selected.getLocale(); |
301 |
manager.exportLocalesForUpdate(locales, fileNameLocale, |
302 |
saveFile); |
303 |
|
304 |
JOptionPane
|
305 |
.showMessageDialog( |
306 |
this,
|
307 |
Messages |
308 |
.getText("I18nPreferencePage.exportado_textos_idioma")
|
309 |
+ " "
|
310 |
+ saveFile, |
311 |
Messages |
312 |
.getText("I18nPreferencePage.exportar_idioma"),
|
313 |
JOptionPane.INFORMATION_MESSAGE);
|
314 |
} catch (I18nException ex) {
|
315 |
ex.showError(); |
316 |
} |
317 |
} |
318 |
} |
319 |
} |
320 |
|
321 |
/**
|
322 |
* Prepares a locale for translation.
|
323 |
*/
|
324 |
private void exportLocaleForTranslation() { |
325 |
// Get the selected locale as the ones for reference
|
326 |
Locale[] refLocales = getSelectedLocales(); |
327 |
|
328 |
if (refLocales == null) { |
329 |
JOptionPane
|
330 |
.showMessageDialog( |
331 |
this,
|
332 |
Messages |
333 |
.getText("I18nPreferencePage.seleccione_idioma_actualizar"),
|
334 |
Messages |
335 |
.getText("I18nPreferencePage.error_actualizar_idioma"),
|
336 |
JOptionPane.ERROR_MESSAGE);
|
337 |
} |
338 |
else {
|
339 |
|
340 |
// Select the locale to translate
|
341 |
LocaleItem[] items = getLocaleItemsForSelection(Locale |
342 |
.getAvailableLocales(), manager.getInstalledLocales()); |
343 |
LocaleItem selected = (LocaleItem) JOptionPane
|
344 |
.showInputDialog( |
345 |
this,
|
346 |
Messages |
347 |
.getText("I18nPreferencePage.seleccione_idioma_traducir"),
|
348 |
Messages |
349 |
.getText("I18nPreferencePage.exportar_idioma"),
|
350 |
JOptionPane.QUESTION_MESSAGE, null, items, items[0]); |
351 |
|
352 |
if (selected == null) { |
353 |
return;
|
354 |
} |
355 |
|
356 |
// Select the file to export to
|
357 |
JFileChooser fileChooser = getJarFileChooser();
|
358 |
fileChooser.setSelectedFile(new File(getLocaleJarFileName(selected |
359 |
.getLocale()))); |
360 |
|
361 |
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { |
362 |
File saveFile = fileChooser.getSelectedFile();
|
363 |
try {
|
364 |
manager.exportLocaleForTranslation(selected.getLocale(), |
365 |
refLocales, saveFile); |
366 |
|
367 |
JOptionPane
|
368 |
.showMessageDialog( |
369 |
this,
|
370 |
Messages |
371 |
.getText("I18nPreferencePage.idioma_preparado_traducir")
|
372 |
+ manager.getDisplayName(selected |
373 |
.getLocale()) |
374 |
+ Messages |
375 |
.getText("I18nPreferencePage.en_archivo")
|
376 |
+ saveFile, |
377 |
Messages |
378 |
.getText("I18nPreferencePage.exportar_idioma"),
|
379 |
JOptionPane.INFORMATION_MESSAGE);
|
380 |
} catch (I18nException ex) {
|
381 |
ex.showError(); |
382 |
} |
383 |
} |
384 |
} |
385 |
|
386 |
} |
387 |
|
388 |
private LocaleItem[] getLocaleItemsForSelection(Locale[] locales, |
389 |
Locale[] exceptions) { |
390 |
List items = new ArrayList(); |
391 |
Set exceptionsSet = new HashSet(exceptions.length); |
392 |
for (int i = 0; i < exceptions.length; i++) { |
393 |
exceptionsSet.add(exceptions[i]); |
394 |
} |
395 |
|
396 |
int j = 0; |
397 |
for (int i = 0; i < locales.length; i++) { |
398 |
// Only add locales not included in the exceptions list
|
399 |
if (!exceptionsSet.contains(locales[i])) {
|
400 |
items.add(new LocaleItem(locales[i], manager));
|
401 |
j++; |
402 |
} |
403 |
} |
404 |
return (LocaleItem[]) items.toArray(new LocaleItem[items.size()]); |
405 |
} |
406 |
|
407 |
/**
|
408 |
* Returns a name for the jar file to export a locale.
|
409 |
*/
|
410 |
private String getLocaleJarFileName(Locale locale) { |
411 |
return manager.getDisplayName(locale, I18nManager.ENGLISH).replace(' ', |
412 |
'_').concat(EXPORT_ZIP_FILE_EXTENSION);
|
413 |
} |
414 |
|
415 |
/**
|
416 |
* Creates a new JFileChooser to import or export a locale jar file.
|
417 |
*/
|
418 |
private JFileChooser getJarFileChooser() { |
419 |
if (fileChooser == null) { |
420 |
fileChooser = new JFileChooser(); |
421 |
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
422 |
fileChooser.setMultiSelectionEnabled(false);
|
423 |
fileChooser.setFileFilter(new FileFilter() { |
424 |
|
425 |
public boolean accept(File file) { |
426 |
return (file.isDirectory()
|
427 |
|| file.getName().endsWith( |
428 |
EXPORT_JAR_FILE_EXTENSION) || file |
429 |
.getName().endsWith(EXPORT_ZIP_FILE_EXTENSION)); |
430 |
} |
431 |
|
432 |
public String getDescription() { |
433 |
return Messages.getText("I18nPreferencePage.archivos_jar"); |
434 |
} |
435 |
|
436 |
}); |
437 |
} |
438 |
return fileChooser;
|
439 |
} |
440 |
|
441 |
/**
|
442 |
* Removes some installed locales from gvSIG.
|
443 |
*/
|
444 |
private void uninstallSelectedLocale() { |
445 |
Locale[] locales = getSelectedLocales(); |
446 |
|
447 |
if (locales == null) { |
448 |
JOptionPane
|
449 |
.showMessageDialog( |
450 |
this,
|
451 |
Messages |
452 |
.getText("I18nPreferencePage.seleccione_idioma_desinstalar"),
|
453 |
Messages |
454 |
.getText("I18nPreferencePage.error_desinstalar_idioma"),
|
455 |
JOptionPane.ERROR_MESSAGE);
|
456 |
return;
|
457 |
} |
458 |
|
459 |
for (int i = 0; i < locales.length; i++) { |
460 |
|
461 |
if (locales[i].equals(manager.getCurrentLocale())) {
|
462 |
JOptionPane
|
463 |
.showMessageDialog( |
464 |
this,
|
465 |
Messages |
466 |
.getText("I18nPreferencePage.idioma_actual_no_puede_desinstalar"),
|
467 |
Messages |
468 |
.getText("I18nPreferencePage.error_desinstalar_idioma"),
|
469 |
JOptionPane.ERROR_MESSAGE);
|
470 |
} else {
|
471 |
int option = JOptionPane |
472 |
.showConfirmDialog( |
473 |
this,
|
474 |
Messages |
475 |
.getText("I18nPreferencePage.seguro_desea_desinstalar_idioma")
|
476 |
+ " "
|
477 |
+ manager.getDisplayName(locales[i]) |
478 |
+ "?",
|
479 |
Messages |
480 |
.getText("I18nPreferencePage.confirmar_desinstalar_idioma"),
|
481 |
JOptionPane.YES_NO_OPTION);
|
482 |
if (option == JOptionPane.YES_OPTION) { |
483 |
try {
|
484 |
tableModel.removeLocale(locales[i]); |
485 |
} catch (I18nException ex) {
|
486 |
ex.showError(); |
487 |
} |
488 |
} |
489 |
} |
490 |
} |
491 |
} |
492 |
|
493 |
/**
|
494 |
* Returns the Locales selected in the table of available locales.
|
495 |
*/
|
496 |
private Locale[] getSelectedLocales() { |
497 |
int[] rowIndexes = localesTable.getSelectedRows(); |
498 |
if (rowIndexes != null && rowIndexes.length > 0) { |
499 |
Locale[] locales = new Locale[rowIndexes.length]; |
500 |
for (int i = 0; i < locales.length; i++) { |
501 |
locales[i] = tableModel.getLocale(rowIndexes[i]); |
502 |
} |
503 |
return locales;
|
504 |
} |
505 |
else {
|
506 |
return null; |
507 |
} |
508 |
} |
509 |
|
510 |
/**
|
511 |
* Creates the Panel with the table of Locales.
|
512 |
*/
|
513 |
private Component getLocalesPanel() { |
514 |
tableModel = new LocaleTableModel(manager);
|
515 |
localesTable = new JTable(tableModel); |
516 |
|
517 |
TableColumn activeColumn = localesTable.getColumnModel().getColumn(
|
518 |
LocaleTableModel.COLUMN_ACTIVE); |
519 |
activeColumn.setCellEditor(new RadioButtonCellEditor());
|
520 |
activeColumn.setCellRenderer(new RadioButtonCellRenderer());
|
521 |
|
522 |
localesTable |
523 |
.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
524 |
localesTable.getSelectionModel().setSelectionInterval(0, 0); |
525 |
JScrollPane scrollPane = new JScrollPane(localesTable); |
526 |
|
527 |
// Container panel
|
528 |
JPanel localesPanel = new JPanel(); |
529 |
localesPanel.setLayout(new BoxLayout(localesPanel, BoxLayout.Y_AXIS)); |
530 |
localesPanel.add(scrollPane); |
531 |
localesPanel.setAlignmentX(CENTER_ALIGNMENT); |
532 |
localesPanel.setPreferredSize(new Dimension(236, 200)); |
533 |
localesPanel.setMaximumSize(new Dimension(500, 230)); |
534 |
|
535 |
return localesPanel;
|
536 |
} |
537 |
|
538 |
/**
|
539 |
* Creates the panel with the buttons to perform the related actions.
|
540 |
*/
|
541 |
private Component getButtonsPanel() { |
542 |
JPanel buttonPanel = new JPanel(new GridBagLayout()); |
543 |
GridBagConstraints constraints = new GridBagConstraints(); |
544 |
constraints.fill = GridBagConstraints.NONE;
|
545 |
constraints.anchor = GridBagConstraints.LINE_START;
|
546 |
Insets btInsets = new Insets(2, 0, 2, 4); |
547 |
Insets lbInsets = new Insets(2, 2, 2, 0); |
548 |
|
549 |
/* ROW 0 */
|
550 |
constraints.gridy = 0;
|
551 |
|
552 |
constraints.gridx = 0;
|
553 |
constraints.insets = btInsets; |
554 |
JButton newLocaleButton = new JButton(Messages |
555 |
.getText("I18nPreferencePage.Instalar"));
|
556 |
newLocaleButton.setActionCommand(COMMAND_INSTALL); |
557 |
newLocaleButton.addActionListener(this);
|
558 |
newLocaleButton.setToolTipText(Messages |
559 |
.getText("I18nPreferencePage.Instalar_idioma_tooltip"));
|
560 |
buttonPanel.add(newLocaleButton, constraints); |
561 |
|
562 |
constraints.gridx = 1;
|
563 |
constraints.insets = lbInsets; |
564 |
buttonPanel.add(new JLabel(Messages |
565 |
.getText("I18nPreferencePage.Instalar_idioma_tooltip")),
|
566 |
constraints); |
567 |
|
568 |
/* ROW 1 */
|
569 |
constraints.gridy = 1;
|
570 |
|
571 |
constraints.gridx = 0;
|
572 |
constraints.insets = btInsets; |
573 |
JButton removeLocaleButton = new JButton(Messages |
574 |
.getText("I18nPreferencePage.Desinstalar"));
|
575 |
removeLocaleButton.setActionCommand(COMMAND_UNINSTALL); |
576 |
removeLocaleButton.addActionListener(this);
|
577 |
removeLocaleButton.setToolTipText(Messages |
578 |
.getText("I18nPreferencePage.Desinstalar_idioma_tooltip"));
|
579 |
buttonPanel.add(removeLocaleButton, constraints); |
580 |
|
581 |
constraints.gridx = 1;
|
582 |
constraints.insets = lbInsets; |
583 |
buttonPanel.add(new JLabel(Messages |
584 |
.getText("I18nPreferencePage.Desinstalar_idioma_tooltip")),
|
585 |
constraints); |
586 |
|
587 |
/* ROW 2 */
|
588 |
constraints.gridy = 2;
|
589 |
|
590 |
constraints.gridx = 0;
|
591 |
constraints.insets = btInsets; |
592 |
JButton exportLocaleButton = new JButton(Messages |
593 |
.getText("I18nPreferencePage.exportar_actualizar"));
|
594 |
exportLocaleButton.setActionCommand(COMMAND_EXPORT); |
595 |
exportLocaleButton.addActionListener(this);
|
596 |
exportLocaleButton.setToolTipText(Messages |
597 |
.getText("I18nPreferencePage.exportar_actualizar_tooltip"));
|
598 |
buttonPanel.add(exportLocaleButton, constraints); |
599 |
|
600 |
constraints.gridx = 1;
|
601 |
constraints.insets = lbInsets; |
602 |
buttonPanel.add(new JLabel(Messages |
603 |
.getText("I18nPreferencePage.exportar_actualizar_tooltip")),
|
604 |
constraints); |
605 |
|
606 |
/* ROW 3 */
|
607 |
constraints.gridy = 3;
|
608 |
|
609 |
constraints.gridx = 0;
|
610 |
constraints.insets = btInsets; |
611 |
JButton exportNewLocaleButton = new JButton(Messages |
612 |
.getText("I18nPreferencePage.exportar_traducir"));
|
613 |
exportNewLocaleButton.setActionCommand(COMMAND_EXPORT_NEW); |
614 |
exportNewLocaleButton.addActionListener(this);
|
615 |
exportNewLocaleButton.setToolTipText(Messages |
616 |
.getText("I18nPreferencePage.exportar_traducir_tooltip"));
|
617 |
buttonPanel.add(exportNewLocaleButton, constraints); |
618 |
|
619 |
constraints.gridx = 1;
|
620 |
constraints.insets = lbInsets; |
621 |
buttonPanel.add(new JLabel(Messages |
622 |
.getText("I18nPreferencePage.exportar_traducir_tooltip")),
|
623 |
constraints); |
624 |
|
625 |
buttonPanel.setAlignmentX(CENTER_ALIGNMENT); |
626 |
return buttonPanel;
|
627 |
} |
628 |
|
629 |
/**
|
630 |
* Creates the JLabel to show information about the preference page.
|
631 |
*/
|
632 |
private Component getActiveLocaleLabel(Color bg, Font fnt) { |
633 |
JTextArea textArea = new JTextArea(Messages |
634 |
.getText("I18nPreferencePage.ayuda"));
|
635 |
textArea.setEditable(false);
|
636 |
textArea.setAutoscrolls(true);
|
637 |
textArea.setLineWrap(true);
|
638 |
textArea.setWrapStyleWord(true);
|
639 |
textArea.setFont(fnt); |
640 |
textArea.setBackground(bg); |
641 |
return textArea;
|
642 |
} |
643 |
|
644 |
/**
|
645 |
* Creates the JLabel to show information about gvSIG translation
|
646 |
* collaboration.
|
647 |
*/
|
648 |
private Component getCollaborationLabel(Color bg, Font fnt) { |
649 |
JTextArea textArea = new JTextArea(Messages |
650 |
.getText("I18nPreferencePage.colaboracion"));
|
651 |
textArea.setEditable(false);
|
652 |
textArea.setAutoscrolls(true);
|
653 |
textArea.setLineWrap(true);
|
654 |
textArea.setWrapStyleWord(true);
|
655 |
textArea.setFont(fnt); |
656 |
textArea.setBackground(bg); |
657 |
return textArea;
|
658 |
} |
659 |
|
660 |
private class LocaleItem { |
661 |
private final Locale locale; |
662 |
private final I18nManager manager; |
663 |
|
664 |
public LocaleItem(Locale locale, I18nManager manager) { |
665 |
this.locale = locale;
|
666 |
this.manager = manager;
|
667 |
} |
668 |
|
669 |
public Locale getLocale() { |
670 |
return locale;
|
671 |
} |
672 |
|
673 |
public String toString() { |
674 |
return manager.getDisplayName(locale);
|
675 |
} |
676 |
|
677 |
public boolean equals(Object obj) { |
678 |
if (obj == null || !(obj instanceof LocaleItem)) { |
679 |
return false; |
680 |
} |
681 |
|
682 |
LocaleItem item = (LocaleItem) obj; |
683 |
return locale.equals(item.getLocale());
|
684 |
} |
685 |
} |
686 |
} |