Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.i18n.app / org.gvsig.i18n.app.mainplugin / src / main / java / org / gvsig / i18n / extension / preferences / I18nPreferencePage.java @ 40557

History | View | Annotate | Download (19.7 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2008 {DiSiD Technologies}  {New extension for installation and update of text translations}
27
 */
28
package org.gvsig.i18n.extension.preferences;
29

    
30
import java.awt.Color;
31
import java.awt.Component;
32
import java.awt.Dimension;
33
import java.awt.Font;
34
import java.awt.GridBagConstraints;
35
import java.awt.GridBagLayout;
36
import java.awt.Insets;
37
import java.awt.event.ActionEvent;
38
import java.awt.event.ActionListener;
39
import java.io.File;
40
import java.util.ArrayList;
41
import java.util.HashSet;
42
import java.util.List;
43
import java.util.Locale;
44
import java.util.Set;
45

    
46
import javax.swing.Box;
47
import javax.swing.BoxLayout;
48
import javax.swing.ImageIcon;
49
import javax.swing.JFileChooser;
50
import javax.swing.JLabel;
51
import javax.swing.JOptionPane;
52
import javax.swing.JPanel;
53
import javax.swing.JScrollPane;
54
import javax.swing.JTable;
55
import javax.swing.JTextArea;
56
import javax.swing.ListSelectionModel;
57
import javax.swing.filechooser.FileFilter;
58
import javax.swing.table.TableColumn;
59

    
60
import org.gvsig.andami.PluginServices;
61
import org.gvsig.andami.preferences.AbstractPreferencePage;
62
import org.gvsig.andami.preferences.StoreException;
63
import org.gvsig.gui.beans.swing.JButton;
64
import org.gvsig.i18n.I18nException;
65
import org.gvsig.i18n.I18nManager;
66
import org.gvsig.i18n.Messages;
67
import org.gvsig.i18n.extension.preferences.table.LocaleTableModel;
68
import org.gvsig.i18n.extension.preferences.table.RadioButtonCellEditor;
69
import org.gvsig.i18n.extension.preferences.table.RadioButtonCellRenderer;
70
import org.gvsig.i18n.impl.I18nManagerImpl;
71

    
72

    
73
/**
74
 * Prefence page to manage gvSIG locales.
75
 * 
76
 * @author <a href="mailto:dcervera@disid.com">David Cervera</a>
77
 */
78
public class I18nPreferencePage extends AbstractPreferencePage implements
79
        ActionListener {
80

    
81
    private static final long serialVersionUID = 7164183052397200888L;
82

    
83
    private static final String COMMAND_UNINSTALL = "UNINSTALL";
84

    
85
    private static final String COMMAND_EXPORT = "EXPORT";
86

    
87
    private static final String COMMAND_EXPORT_NEW = "EXPORT_NEW";
88

    
89
    private static final String COMMAND_INSTALL = "INSTALL";
90

    
91
    private static final String EXPORT_JAR_FILE_EXTENSION = ".jar";
92

    
93
    private static final String EXPORT_ZIP_FILE_EXTENSION = ".zip";
94

    
95
    private ImageIcon icon;
96

    
97
    private I18nManager manager = I18nManagerImpl.getInstance();
98

    
99
    private JTable localesTable;
100

    
101
    private LocaleTableModel tableModel;
102

    
103
    private JFileChooser fileChooser;
104

    
105
    /**
106
     * Creates a new I18n preferences page.
107
     */
108
    public I18nPreferencePage() {
109
                setParentID("org.gvsig.coreplugin.preferences.general.GeneralPage");
110
                
111
        icon = PluginServices.getIconTheme().get("i18n-preferences");
112
        
113
        // GridBagConstants.HORIZONTAL
114
        Insets zero_ins = new Insets(0, 0, 0, 0);
115
        Font hints_fnt = new JLabel().getFont();
116

    
117
        addComponent(getLocalesPanel(),
118
            GridBagConstraints.HORIZONTAL, zero_ins);
119
        
120
        addComponent(Box.createRigidArea(new Dimension(0, 5)),
121
            GridBagConstraints.HORIZONTAL, zero_ins);
122
        
123
        addComponent(getActiveLocaleLabel(
124
            this.getBackground(), hints_fnt.deriveFont(Font.BOLD)),
125
            GridBagConstraints.HORIZONTAL, zero_ins);
126
        
127
        addComponent(Box.createRigidArea(new Dimension(0, 5)),
128
            GridBagConstraints.HORIZONTAL, zero_ins);
129
        
130
        addComponent(getButtonsPanel(),
131
            GridBagConstraints.HORIZONTAL, zero_ins);
132
        
133
        addComponent(Box.createRigidArea(new Dimension(0, 5)),
134
            GridBagConstraints.HORIZONTAL, zero_ins);
135
        
136
        addComponent(getCollaborationLabel(
137
            this.getBackground(), hints_fnt),
138
            GridBagConstraints.HORIZONTAL, zero_ins);
139

    
140
        /*
141
        add(getLocalesPanel());
142
        add(Box.createRigidArea(new Dimension(0, 5)));
143
        add(getActiveLocaleLabel());
144
        add(Box.createRigidArea(new Dimension(0, 5)));
145
        add(getButtonsPanel());
146
        add(Box.createRigidArea(new Dimension(0, 5)));
147
        add(getCollaborationLabel());
148
        */
149
    }
150

    
151
    public String getID() {
152
                return getClass().getName();
153
    }
154

    
155
    public String getTitle() {
156
        return Messages.getText("idioma");
157
    }
158

    
159
    public ImageIcon getIcon() {
160
        return icon;
161
    }
162

    
163
    public JPanel getPanel() {
164
        return this;
165
    }
166

    
167
    public void setChangesApplied() {
168
        tableModel.setChangesApplied();
169
    }
170

    
171
    public boolean isValueChanged() {
172
        return tableModel.isValueChanged();
173
    }
174

    
175
    public void storeValues() throws StoreException {
176
        tableModel.saveSelectedLocale();
177
    }
178

    
179
    public void initializeDefaults() {
180
        tableModel.selectDefaultLocale();
181
    }
182

    
183
    public void initializeValues() {
184
        tableModel.selectPreviousLocale();
185
    }
186

    
187
    public void actionPerformed(ActionEvent event) {
188
        if (COMMAND_INSTALL.equals(event.getActionCommand())) {
189
            installLocale();
190
        }
191
        else if (COMMAND_EXPORT.equals(event.getActionCommand())) {
192
            exportLocaleForUpdate();
193
        }
194
        else if (COMMAND_EXPORT_NEW.equals(event.getActionCommand())) {
195
            exportLocaleForTranslation();
196
        }
197
        else if (COMMAND_UNINSTALL.equals(event.getActionCommand())) {
198
            uninstallSelectedLocale();
199
        }
200
    }
201

    
202
    /**
203
     * Installs a new Locale translation or updates an already existing one.
204
     */
205
    private void installLocale() {
206
        JFileChooser fileChooser = getJarFileChooser();
207

    
208
        int returnVal = fileChooser.showOpenDialog(this);
209

    
210
        if (returnVal == JFileChooser.APPROVE_OPTION) {
211
            File importFile = fileChooser.getSelectedFile();
212
            try {
213
                Locale[] installedLocales = manager.installLocales(importFile);
214
                if (installedLocales == null || installedLocales.length == 0) {
215
                    JOptionPane
216
                            .showMessageDialog(
217
                                    this,
218
                                    Messages
219
                                            .getText("I18nPreferencePage.idiomas_no_encontrados_para_instalar"),
220
                                    Messages
221
                                            .getText("I18nPreferencePage.error_instalar_idiomas"),
222
                                    JOptionPane.ERROR_MESSAGE);
223
                }
224
                else {
225
                    StringBuffer msg = new StringBuffer(Messages
226
                            .getText("I18nPreferencePage.idiomas_instalados"));
227

    
228
                    for (int i = 0; i < installedLocales.length; i++) {
229
                        msg.append(manager.getDisplayName(installedLocales[i]));
230
                        if (i < installedLocales.length - 1) {
231
                            msg.append(", ");
232
                        }
233
                    }
234
                    tableModel.reloadLocales();
235
                    JOptionPane
236
                            .showMessageDialog(
237
                                    this,
238
                                    msg.toString(),
239
                                    Messages
240
                                            .getText("I18nPreferencePage.instalar_idiomas"),
241
                                    JOptionPane.INFORMATION_MESSAGE);
242
                }
243
            } catch (I18nException ex) {
244
                ex.showError();
245
            }
246
        }
247
    }
248

    
249
    /**
250
     * Updates the translation of a locale
251
     */
252
    private void exportLocaleForUpdate() {
253
        Locale[] locales = getSelectedLocales();
254

    
255
        if (locales == null) {
256
            JOptionPane.showMessageDialog(this, Messages
257
                    .getText("I18nPreferencePage.seleccione_idioma"), Messages
258
                    .getText("I18nPreferencePage.error_actualizar_idioma"),
259
                    JOptionPane.ERROR_MESSAGE);
260
        }
261
        else {
262
            // Select the reference language
263
            LocaleItem[] items = getLocaleItemsForSelection(manager
264
                    .getInstalledLocales(), locales);
265
            LocaleItem selected = null;
266
            if (items != null && items.length > 0) {
267
                // Select by default the current locale, or the first one
268
                // if the current locale is one of the ones to be updated
269
                for (int i = 0; i < locales.length && selected == null; i++) {
270
                    if (locales[i].equals(manager.getCurrentLocale())) {
271
                        selected = items[0];
272
                    }
273
                }
274
                if (selected == null) {
275
                    selected = new LocaleItem(manager.getCurrentLocale(),
276
                            manager);
277
                }
278
                selected = (LocaleItem) JOptionPane
279
                        .showInputDialog(
280
                                this,
281
                                Messages
282
                                        .getText("I18nPreferencePage.seleccione_idioma_referencia"),
283
                                Messages
284
                                        .getText("I18nPreferencePage.exportar_idioma"),
285
                                JOptionPane.QUESTION_MESSAGE, null, items,
286
                                selected);
287

    
288
                if (selected == null) {
289
                    return;
290
                }
291
            }
292
            // Select the file to export to
293
            JFileChooser fileChooser = getJarFileChooser();
294
            fileChooser.setSelectedFile(new File(
295
                    getLocaleJarFileName(locales[0])));
296

    
297
            if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
298
                File saveFile = fileChooser.getSelectedFile();
299
                try {
300
                    Locale fileNameLocale = selected == null ? manager
301
                            .getCurrentLocale() : selected.getLocale();
302
                    manager.exportLocalesForUpdate(locales, fileNameLocale,
303
                            saveFile);
304
                    
305
                    JOptionPane
306
                            .showMessageDialog(
307
                                    this,
308
                                    Messages
309
                                            .getText("I18nPreferencePage.exportado_textos_idioma")
310
                                            + " "
311
                                            + saveFile,
312
                                    Messages
313
                                            .getText("I18nPreferencePage.exportar_idioma"),
314
                                    JOptionPane.INFORMATION_MESSAGE);
315
                } catch (I18nException ex) {
316
                    ex.showError();
317
                }
318
            }
319
        }
320
    }
321

    
322
    /**
323
     * Prepares a locale for translation.
324
     */
325
    private void exportLocaleForTranslation() {
326
        // Get the selected locale as the ones for reference
327
        Locale[] refLocales = getSelectedLocales();
328

    
329
        if (refLocales == null) {
330
            JOptionPane
331
                    .showMessageDialog(
332
                            this,
333
                            Messages
334
                                    .getText("I18nPreferencePage.seleccione_idioma_actualizar"),
335
                            Messages
336
                                    .getText("I18nPreferencePage.error_actualizar_idioma"),
337
                            JOptionPane.ERROR_MESSAGE);
338
        }
339
        else {
340

    
341
            // Select the locale to translate
342
            LocaleItem[] items = getLocaleItemsForSelection(Locale
343
                    .getAvailableLocales(), manager.getInstalledLocales());
344
            LocaleItem selected = (LocaleItem) JOptionPane
345
                    .showInputDialog(
346
                            this,
347
                            Messages
348
                                    .getText("I18nPreferencePage.seleccione_idioma_traducir"),
349
                            Messages
350
                                    .getText("I18nPreferencePage.exportar_idioma"),
351
                            JOptionPane.QUESTION_MESSAGE, null, items, items[0]);
352

    
353
            if (selected == null) {
354
                return;
355
            }
356

    
357
            // Select the file to export to
358
            JFileChooser fileChooser = getJarFileChooser();
359
            fileChooser.setSelectedFile(new File(getLocaleJarFileName(selected
360
                    .getLocale())));
361

    
362
            if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
363
                File saveFile = fileChooser.getSelectedFile();
364
                try {
365
                    manager.exportLocaleForTranslation(selected.getLocale(),
366
                            refLocales, saveFile);
367

    
368
                    JOptionPane
369
                            .showMessageDialog(
370
                                    this,
371
                                    Messages
372
                                            .getText("I18nPreferencePage.idioma_preparado_traducir")
373
                                            + manager.getDisplayName(selected
374
                                                    .getLocale())
375
                                            + Messages
376
                                                    .getText("I18nPreferencePage.en_archivo")
377
                                            + saveFile,
378
                                    Messages
379
                                            .getText("I18nPreferencePage.exportar_idioma"),
380
                                    JOptionPane.INFORMATION_MESSAGE);
381
                } catch (I18nException ex) {
382
                    ex.showError();
383
                }
384
            }
385
        }
386

    
387
    }
388

    
389
    private LocaleItem[] getLocaleItemsForSelection(Locale[] locales,
390
            Locale[] exceptions) {
391
        List items = new ArrayList();
392
        Set exceptionsSet = new HashSet(exceptions.length);
393
        for (int i = 0; i < exceptions.length; i++) {
394
            exceptionsSet.add(exceptions[i]);
395
        }
396

    
397
        int j = 0;
398
        for (int i = 0; i < locales.length; i++) {
399
            // Only add locales not included in the exceptions list
400
            if (!exceptionsSet.contains(locales[i])) {
401
                items.add(new LocaleItem(locales[i], manager));
402
                j++;
403
            }
404
        }
405
        return (LocaleItem[]) items.toArray(new LocaleItem[items.size()]);
406
    }
407

    
408
    /**
409
     * Returns a name for the jar file to export a locale.
410
     */
411
    private String getLocaleJarFileName(Locale locale) {
412
        return manager.getDisplayName(locale, I18nManager.ENGLISH).replace(' ',
413
                '_').concat(EXPORT_ZIP_FILE_EXTENSION);
414
    }
415

    
416
    /**
417
     * Creates a new JFileChooser to import or export a locale jar file.
418
     */
419
    private JFileChooser getJarFileChooser() {
420
        if (fileChooser == null) {
421
            fileChooser = new JFileChooser();
422
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
423
            fileChooser.setMultiSelectionEnabled(false);
424
            fileChooser.setFileFilter(new FileFilter() {
425

    
426
                public boolean accept(File file) {
427
                    return (file.isDirectory()
428
                            || file.getName().endsWith(
429
                                    EXPORT_JAR_FILE_EXTENSION) || file
430
                            .getName().endsWith(EXPORT_ZIP_FILE_EXTENSION));
431
                }
432

    
433
                public String getDescription() {
434
                    return Messages.getText("I18nPreferencePage.archivos_jar");
435
                }
436

    
437
            });
438
        }
439
        return fileChooser;
440
    }
441

    
442
    /**
443
     * Removes some installed locales from gvSIG.
444
     */
445
    private void uninstallSelectedLocale() {
446
        Locale[] locales = getSelectedLocales();
447

    
448
        if (locales == null) {
449
            JOptionPane
450
                    .showMessageDialog(
451
                            this,
452
                            Messages
453
                                    .getText("I18nPreferencePage.seleccione_idioma_desinstalar"),
454
                            Messages
455
                                    .getText("I18nPreferencePage.error_desinstalar_idioma"),
456
                            JOptionPane.ERROR_MESSAGE);
457
            return;
458
        }
459
        
460
        for (int i = 0; i < locales.length; i++) {
461

    
462
            if (locales[i].equals(manager.getCurrentLocale())) {
463
                JOptionPane
464
                        .showMessageDialog(
465
                                this,
466
                                Messages
467
                                        .getText("I18nPreferencePage.idioma_actual_no_puede_desinstalar"),
468
                                Messages
469
                                        .getText("I18nPreferencePage.error_desinstalar_idioma"),
470
                                JOptionPane.ERROR_MESSAGE);
471
            } else {
472
                int option = JOptionPane
473
                        .showConfirmDialog(
474
                                this,
475
                                Messages
476
                                        .getText("I18nPreferencePage.seguro_desea_desinstalar_idioma")
477
                                        + " "
478
                                        + manager.getDisplayName(locales[i])
479
                                        + "?",
480
                                Messages
481
                                        .getText("I18nPreferencePage.confirmar_desinstalar_idioma"),
482
                                JOptionPane.YES_NO_OPTION);
483
                if (option == JOptionPane.YES_OPTION) {
484
                    try {
485
                        tableModel.removeLocale(locales[i]);
486
                    } catch (I18nException ex) {
487
                        ex.showError();
488
                    }
489
                }
490
            }
491
        }
492
    }
493

    
494
    /**
495
     * Returns the Locales selected in the table of available locales.
496
     */
497
    private Locale[] getSelectedLocales() {
498
        int[] rowIndexes = localesTable.getSelectedRows();
499
        if (rowIndexes != null && rowIndexes.length > 0) {
500
            Locale[] locales = new Locale[rowIndexes.length];
501
            for (int i = 0; i < locales.length; i++) {
502
                locales[i] = tableModel.getLocale(rowIndexes[i]);
503
            }
504
            return locales;
505
        }
506
        else {
507
            return null;
508
        }
509
    }
510

    
511
    /**
512
     * Creates the Panel with the table of Locales.
513
     */
514
    private Component getLocalesPanel() {
515
        tableModel = new LocaleTableModel(manager);
516
        localesTable = new JTable(tableModel);
517

    
518
        TableColumn activeColumn = localesTable.getColumnModel().getColumn(
519
                LocaleTableModel.COLUMN_ACTIVE);
520
        activeColumn.setCellEditor(new RadioButtonCellEditor());
521
        activeColumn.setCellRenderer(new RadioButtonCellRenderer());
522

    
523
        localesTable
524
                .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
525
        localesTable.getSelectionModel().setSelectionInterval(0, 0);
526
        JScrollPane scrollPane = new JScrollPane(localesTable);
527

    
528
        // Container panel
529
        JPanel localesPanel = new JPanel();
530
        localesPanel.setLayout(new BoxLayout(localesPanel, BoxLayout.Y_AXIS));
531
        localesPanel.add(scrollPane);
532
        localesPanel.setAlignmentX(CENTER_ALIGNMENT);
533
        localesPanel.setPreferredSize(new Dimension(236, 200));
534
        localesPanel.setMaximumSize(new Dimension(500, 230));
535

    
536
        return localesPanel;
537
    }
538

    
539
    /**
540
     * Creates the panel with the buttons to perform the related actions.
541
     */
542
    private Component getButtonsPanel() {
543
        JPanel buttonPanel = new JPanel(new GridBagLayout());
544
        GridBagConstraints constraints = new GridBagConstraints();
545
        constraints.fill = GridBagConstraints.NONE;
546
        constraints.anchor = GridBagConstraints.LINE_START;
547
        Insets btInsets = new Insets(2, 0, 2, 4);
548
        Insets lbInsets = new Insets(2, 2, 2, 0);
549

    
550
        /* ROW 0 */
551
        constraints.gridy = 0;
552

    
553
        constraints.gridx = 0;
554
        constraints.insets = btInsets;
555
        JButton newLocaleButton = new JButton(Messages
556
                .getText("I18nPreferencePage.Instalar"));
557
        newLocaleButton.setActionCommand(COMMAND_INSTALL);
558
        newLocaleButton.addActionListener(this);
559
        newLocaleButton.setToolTipText(Messages
560
                .getText("I18nPreferencePage.Instalar_idioma_tooltip"));
561
        buttonPanel.add(newLocaleButton, constraints);
562

    
563
        constraints.gridx = 1;
564
        constraints.insets = lbInsets;
565
        buttonPanel.add(new JLabel(Messages
566
                .getText("I18nPreferencePage.Instalar_idioma_tooltip")),
567
                constraints);
568

    
569
        /* ROW 1 */
570
        constraints.gridy = 1;
571

    
572
        constraints.gridx = 0;
573
        constraints.insets = btInsets;
574
        JButton removeLocaleButton = new JButton(Messages
575
                .getText("I18nPreferencePage.Desinstalar"));
576
        removeLocaleButton.setActionCommand(COMMAND_UNINSTALL);
577
        removeLocaleButton.addActionListener(this);
578
        removeLocaleButton.setToolTipText(Messages
579
                .getText("I18nPreferencePage.Desinstalar_idioma_tooltip"));
580
        buttonPanel.add(removeLocaleButton, constraints);
581

    
582
        constraints.gridx = 1;
583
        constraints.insets = lbInsets;
584
        buttonPanel.add(new JLabel(Messages
585
                .getText("I18nPreferencePage.Desinstalar_idioma_tooltip")),
586
                constraints);
587

    
588
        /* ROW 2 */
589
        constraints.gridy = 2;
590

    
591
        constraints.gridx = 0;
592
        constraints.insets = btInsets;
593
        JButton exportLocaleButton = new JButton(Messages
594
                .getText("I18nPreferencePage.exportar_actualizar"));
595
        exportLocaleButton.setActionCommand(COMMAND_EXPORT);
596
        exportLocaleButton.addActionListener(this);
597
        exportLocaleButton.setToolTipText(Messages
598
                .getText("I18nPreferencePage.exportar_actualizar_tooltip"));
599
        buttonPanel.add(exportLocaleButton, constraints);
600

    
601
        constraints.gridx = 1;
602
        constraints.insets = lbInsets;
603
        buttonPanel.add(new JLabel(Messages
604
                .getText("I18nPreferencePage.exportar_actualizar_tooltip")),
605
                constraints);
606

    
607
        /* ROW 3 */
608
        constraints.gridy = 3;
609

    
610
        constraints.gridx = 0;
611
        constraints.insets = btInsets;
612
        JButton exportNewLocaleButton = new JButton(Messages
613
                .getText("I18nPreferencePage.exportar_traducir"));
614
        exportNewLocaleButton.setActionCommand(COMMAND_EXPORT_NEW);
615
        exportNewLocaleButton.addActionListener(this);
616
        exportNewLocaleButton.setToolTipText(Messages
617
                .getText("I18nPreferencePage.exportar_traducir_tooltip"));
618
        buttonPanel.add(exportNewLocaleButton, constraints);
619

    
620
        constraints.gridx = 1;
621
        constraints.insets = lbInsets;
622
        buttonPanel.add(new JLabel(Messages
623
                .getText("I18nPreferencePage.exportar_traducir_tooltip")),
624
                constraints);
625

    
626
        buttonPanel.setAlignmentX(CENTER_ALIGNMENT);
627
        return buttonPanel;
628
    }
629

    
630
    /**
631
     * Creates the JLabel to show information about the preference page.
632
     */
633
    private Component getActiveLocaleLabel(Color bg, Font fnt) {
634
        JTextArea textArea = new JTextArea(Messages
635
                .getText("I18nPreferencePage.ayuda"));
636
        textArea.setEditable(false);
637
        textArea.setAutoscrolls(true);
638
        textArea.setLineWrap(true);
639
        textArea.setWrapStyleWord(true);
640
        textArea.setFont(fnt);
641
    textArea.setBackground(bg);
642
        return textArea;
643
    }
644

    
645
    /**
646
     * Creates the JLabel to show information about gvSIG translation
647
     * collaboration.
648
     */
649
    private Component getCollaborationLabel(Color bg, Font fnt) {
650
        JTextArea textArea = new JTextArea(Messages
651
                .getText("I18nPreferencePage.colaboracion"));
652
        textArea.setEditable(false);
653
        textArea.setAutoscrolls(true);
654
        textArea.setLineWrap(true);
655
        textArea.setWrapStyleWord(true);
656
        textArea.setFont(fnt);
657
        textArea.setBackground(bg);
658
        return textArea;
659
    }
660

    
661
    private class LocaleItem {
662
        private final Locale locale;
663
        private final I18nManager manager;
664

    
665
        public LocaleItem(Locale locale, I18nManager manager) {
666
            this.locale = locale;
667
            this.manager = manager;
668
        }
669

    
670
        public Locale getLocale() {
671
            return locale;
672
        }
673

    
674
        public String toString() {
675
            return manager.getDisplayName(locale);
676
        }
677

    
678
        public boolean equals(Object obj) {
679
            if (obj == null || !(obj instanceof LocaleItem)) {
680
                return false;
681
            }
682

    
683
            LocaleItem item = (LocaleItem) obj;
684
            return locale.equals(item.getLocale());
685
        }
686
    }
687
}