Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libCorePlugin / src / com / iver / core / configExtensions / ConfigPlugins.java @ 28494

History | View | Annotate | Download (21.3 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
package com.iver.core.configExtensions;
42

    
43
import java.awt.BorderLayout;
44
import java.awt.Component;
45
import java.io.File;
46
import java.io.FileReader;
47
import java.io.FileWriter;
48
import java.io.IOException;
49
import java.util.ArrayList;
50
import java.util.HashMap;
51
import java.util.Iterator;
52
import java.util.Locale;
53

    
54
import javax.swing.BoxLayout;
55
import javax.swing.DefaultComboBoxModel;
56
import javax.swing.JButton;
57
import javax.swing.JCheckBox;
58
import javax.swing.JComboBox;
59
import javax.swing.JDialog;
60
import javax.swing.JFileChooser;
61
import javax.swing.JLabel;
62
import javax.swing.JPanel;
63
import javax.swing.JScrollPane;
64
import javax.swing.JSplitPane;
65
import javax.swing.JTabbedPane;
66
import javax.swing.JTextArea;
67
import javax.swing.JTextField;
68
import javax.swing.JTree;
69
import javax.swing.tree.DefaultMutableTreeNode;
70

    
71
import org.exolab.castor.xml.MarshalException;
72
import org.exolab.castor.xml.ValidationException;
73

    
74
import com.iver.andami.Launcher;
75
import com.iver.andami.PluginServices;
76
import com.iver.andami.plugins.config.generate.Extension;
77
import com.iver.andami.plugins.config.generate.Extensions;
78
import com.iver.andami.plugins.config.generate.PluginConfig;
79
import com.iver.andami.ui.mdiManager.IWindow;
80
import com.iver.andami.ui.mdiManager.WindowInfo;
81
import com.iver.utiles.GenericFileFilter;
82
/**
83
 * Di?logo de Configuraci?n de ANDAMI.
84
 *
85
 * @author Vicente Caballero Navarro
86
 * @deprecated
87
 */
88
public class ConfigPlugins extends JPanel implements IWindow {
89
        private JTree jTree = null;
90
        private JPanel jPanel = null; //  @jve:decl-index=0:visual-constraint="113,10"
91
        private JPanel jPanel1 = null;
92
        private JSplitPane jSplitPane = null;
93
        private JCheckBox chbActivar = null;
94
        private JTextField jTextField = null;
95
        private JPanel pGeneral = null;
96
        private JButton jButton = null;
97
        private JPanel pOpciones = null;
98
        private JTabbedPane jTabbedPane1 = null;
99
        private JPanel pDescripcion = null;
100
        private JPanel pDirectorio = null;
101
        private JPanel jPanel2 = null;
102
        private JScrollPane jScrollPane1 = null;
103
        private WindowInfo m_viewinfo = null;
104
        private JPanel pBotones = null;
105
        private JButton bAceptar = null;
106
        private JButton bCancelar = null;
107
        private HashMap listExt = new HashMap();
108
        private HashMap listPlugins = new HashMap();
109
        private JTextArea taDescripcion = null;
110
        private JScrollPane jScrollPane = null;
111
        private Extension ext = null;
112
        private JTextField jTextField1 = null;
113
        private JLabel jLabel = null;
114
        private JPanel jPanel3 = null;
115

    
116
        private JPanel jPanel4 = null;
117
        private JLabel jLabel1 = null;
118
        private JComboBox cmbIdioma = null;
119
        /**
120
         * This is the default constructor
121
         */
122
        public ConfigPlugins() {
123
                super();
124
                initialize();
125
        }
126

    
127
        /**
128
         * A?ade los nodes al arbol que representa a todos los plugins y extesiones que hay.
129
         *
130
         * @param top
131
         */
132
        private void addNodes(DefaultMutableTreeNode top) {
133
                DefaultMutableTreeNode nameExtension = null;
134
                DefaultMutableTreeNode namePlugin = null;
135
                HashMap pc = Launcher.getPluginConfig();
136
                ArrayList array = new ArrayList();
137
                Iterator iter = pc.values().iterator();
138

    
139
                while (iter.hasNext()) {
140
                        array.add(((PluginConfig) iter.next()).getExtensions());
141
                }
142

    
143
                Extensions[] exts = (Extensions[]) array.toArray(new Extensions[0]);
144

    
145
                for (int i = 0; i < exts.length; i++) {
146
                        if (exts[i].getSkinExtension() != null) {
147
                        }
148

    
149
                        for (int j = 0; j < exts[i].getExtensionCount(); j++) {
150
                                Extension ext = exts[i].getExtension(j);
151
                                String pn = null;
152
                                String sExt = ext.getClassName().toString();
153
                                pn = sExt.substring(0, sExt.lastIndexOf("."));
154
                                namePlugin = new DefaultMutableTreeNode(pn);
155

    
156
                                if (!listPlugins.containsKey(namePlugin.getUserObject()
157
                                                                                                                   .toString())) {
158
                                        listPlugins.put(namePlugin.getUserObject().toString(),
159
                                                namePlugin);
160
                                        top.add(namePlugin);
161
                                        nameExtension = new DefaultMutableTreeNode(sExt.substring(sExt.lastIndexOf(
162
                                                                        ".") + 1, sExt.length())); //replaceFirst(namePlugin.getUserObject().toString()+".",""));
163
                                        listExt.put(sExt, ext);
164
                                        namePlugin.add(nameExtension);
165
                                } else {
166
                                        nameExtension = new DefaultMutableTreeNode(sExt.substring(sExt.lastIndexOf(
167
                                                                        ".") + 1, sExt.length())); //sExt.replaceFirst(namePlugin.getUserObject().toString()+".",""));
168
                                        listExt.put(sExt, ext);
169
                                        ((DefaultMutableTreeNode) listPlugins.get(namePlugin.getUserObject()
170
                                                                                                                                                .toString())).add(nameExtension);
171
                                }
172
                        }
173
                }
174
        }
175

    
176
        /**
177
         * This method initializes jTree
178
         *
179
         * @return javax.swing.JTree
180
         */
181
        private JTree getJTree() {
182
                if (jTree == null) {
183
                        DefaultMutableTreeNode root = new DefaultMutableTreeNode("ANDAMI");
184
                        addNodes(root);
185
                        jTree = new JTree(root);
186

    
187
                        jTree.setName("ANDAMI");
188
                        jTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
189
                                        public void valueChanged(
190
                                                javax.swing.event.TreeSelectionEvent e) {
191
                                                if (e.getPath().getParentPath() != null) {
192
                                                        ext = (Extension) listExt.get(e.getPath()
193
                                                                                                                   .getParentPath()
194
                                                                                                                   .getLastPathComponent()
195
                                                                                                                   .toString() + "." +
196
                                                                        e.getPath().getLastPathComponent().toString());
197

    
198
                                                        if (ext == null) {
199
                                                                getChbActivar().setVisible(false);
200
                                                                getTaDescripcion().setText("Plugin : " +
201
                                                                        e.getNewLeadSelectionPath().toString());
202
                                                        } else {
203
                                                                try {
204
                                                                        getChbActivar().setSelected((Launcher.getExtension(
205
                                                                                        ext.getClassName())).getActive());
206
                                                                        getChbActivar().setVisible(true);
207
                                                                        getTaDescripcion().setText((Launcher.getExtension(
208
                                                                                        ext.getClassName())).getDescription());
209
                                                                        getJTextField1().setText(String.valueOf(
210
                                                                                        ext.getPriority()));
211
                                                                } catch (NullPointerException npe) {
212
                                                                        getChbActivar().setVisible(false);
213
                                                                        getTaDescripcion().setText("Plugin : " +
214
                                                                                e.getNewLeadSelectionPath().toString());
215
                                                                }
216
                                                        }
217
                                                }
218
                                        }
219
                                });
220
                }
221

    
222
                return jTree;
223
        }
224

    
225
        /**
226
         * This method initializes jPanel
227
         *
228
         * @return javax.swing.JPanel
229
         */
230
        private JPanel getJPanel() {
231
                if (jPanel == null) {
232
                        jPanel = new JPanel();
233
                        jPanel.setLayout(new BorderLayout());
234
                        jPanel.setName("jPanel");
235
                        jPanel.setPreferredSize(new java.awt.Dimension(150, 150));
236
                        jPanel.setSize(435, 299);
237
                        jPanel.add(getJSplitPane(), java.awt.BorderLayout.CENTER);
238
                        jPanel.add(getPBotones(), java.awt.BorderLayout.SOUTH);
239
                }
240

    
241
                return jPanel;
242
        }
243

    
244
        /**
245
         * This method initializes jPanel1
246
         *
247
         * @return javax.swing.JPanel
248
         */
249
        private JPanel getJPanel1() {
250
                if (jPanel1 == null) {
251
                        jPanel1 = new JPanel();
252
                        jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS));
253
                        jPanel1.setName("jPanel1");
254
                        jPanel1.setPreferredSize(new java.awt.Dimension(200, 100));
255
                        jPanel1.add(getJTabbedPane1(), null);
256
                }
257

    
258
                return jPanel1;
259
        }
260

    
261
        /**
262
         * This method initializes jSplitPane
263
         *
264
         * @return javax.swing.JSplitPane
265
         */
266
        private JSplitPane getJSplitPane() {
267
                if (jSplitPane == null) {
268
                        jSplitPane = new JSplitPane();
269
                        jSplitPane.setRightComponent(getJPanel1());
270
                        jSplitPane.setLeftComponent(getJPanel2());
271
                }
272

    
273
                return jSplitPane;
274
        }
275

    
276
        /**
277
         * This method initializes chbActivar
278
         *
279
         * @return javax.swing.JCheckBox
280
         */
281
        private JCheckBox getChbActivar() {
282
                if (chbActivar == null) {
283
                        chbActivar = new JCheckBox();
284
                        chbActivar.setSelected(true);
285
                        chbActivar.setVisible(false);
286
                        chbActivar.setText(PluginServices.getText(this, "extension_activada"));
287
                        chbActivar.addActionListener(new java.awt.event.ActionListener() {
288
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
289
                                                ext.setActive(chbActivar.isSelected());
290
                                        }
291
                                });
292
                }
293

    
294
                return chbActivar;
295
        }
296

    
297
        /**
298
         * This method initializes jTextField
299
         *
300
         * @return javax.swing.JTextField
301
         */
302
        private JTextField getJTextField() {
303
                if (jTextField == null) {
304
                        jTextField = new JTextField();
305
                        jTextField.setPreferredSize(new java.awt.Dimension(200, 20));
306
                        jTextField.setText(Launcher.getAndamiConfig().getPluginsDirectory());
307
                }
308

    
309
                return jTextField;
310
        }
311

    
312
        /**
313
         * This method initializes pGeneral
314
         *
315
         * @return javax.swing.JPanel
316
         */
317
        private JPanel getPGeneral() {
318
                if (pGeneral == null) {
319
                        pGeneral = new JPanel();
320
                        pGeneral.add(getPDirectorio(), null);
321
                        pGeneral.add(getJPanel4(), null);
322
                }
323

    
324
                return pGeneral;
325
        }
326

    
327
        /**
328
         * This method initializes jButton
329
         *
330
         * @return javax.swing.JButton
331
         */
332
        private JButton getJButton() {
333
                if (jButton == null) {
334
                        jButton = new JButton();
335
                        jButton.setText(PluginServices.getText(this, "examinar"));
336
                        jButton.addActionListener(new java.awt.event.ActionListener() {
337
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
338
                                                JFileChooser jfc = new JFileChooser();
339
                                                jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
340
                                                jfc.addChoosableFileFilter(new GenericFileFilter("",
341
                                                                PluginServices.getText(this,
342
                                                                        "directorio_extensiones")));
343

    
344
                                                if (jfc.showOpenDialog(
345
                                                                        (Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
346
                                                        getJTextField().setText(jfc.getSelectedFile()
347
                                                                                                           .getAbsolutePath());
348
                                                }
349
                                        }
350
                                });
351
                }
352

    
353
                return jButton;
354
        }
355

    
356
        /**
357
         * This method initializes pOpciones
358
         *
359
         * @return javax.swing.JPanel
360
         */
361
        private JPanel getPOpciones() {
362
                if (pOpciones == null) {
363
                        jLabel = new JLabel();
364
                        pOpciones = new JPanel();
365
                        pOpciones.setLayout(new BorderLayout());
366
                        jLabel.setText(PluginServices.getText(this, "prioridad"));
367
                        pOpciones.add(getChbActivar(), java.awt.BorderLayout.NORTH);
368
                        pOpciones.add(getPDescripcion(), java.awt.BorderLayout.CENTER);
369
                        pOpciones.add(getJPanel3(), java.awt.BorderLayout.SOUTH);
370
                }
371

    
372
                return pOpciones;
373
        }
374

    
375
        /**
376
         * This method initializes jTabbedPane1
377
         *
378
         * @return javax.swing.JTabbedPane
379
         */
380
        private JTabbedPane getJTabbedPane1() {
381
                if (jTabbedPane1 == null) {
382
                        jTabbedPane1 = new JTabbedPane();
383
                        jTabbedPane1.addTab(PluginServices.getText(this, "opciones"), null,
384
                                getPOpciones(), null);
385
                        jTabbedPane1.addTab(PluginServices.getText(this, "general"), null,
386
                                getPGeneral(), null);
387
                }
388

    
389
                return jTabbedPane1;
390
        }
391

    
392
        /**
393
         * This method initializes pDescripcion
394
         *
395
         * @return javax.swing.JPanel
396
         */
397
        private JPanel getPDescripcion() {
398
                if (pDescripcion == null) {
399
                        pDescripcion = new JPanel();
400
                        pDescripcion.setLayout(new BorderLayout());
401
                        pDescripcion.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
402
                        pDescripcion.setBorder(javax.swing.BorderFactory.createTitledBorder(
403
                                        null, PluginServices.getText(this, "descripcion"),
404
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
405
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
406
                }
407

    
408
                return pDescripcion;
409
        }
410

    
411
        /**
412
         * This method initializes pDirectorio
413
         *
414
         * @return javax.swing.JPanel
415
         */
416
        private JPanel getPDirectorio() {
417
                if (pDirectorio == null) {
418
                        pDirectorio = new JPanel();
419
                        pDirectorio.setBorder(javax.swing.BorderFactory.createTitledBorder(
420
                                        null, PluginServices.getText(this, "directorio"),
421
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
422
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
423
                        pDirectorio.add(getJTextField(), null);
424
                        pDirectorio.add(getJButton(), null);
425
                }
426

    
427
                return pDirectorio;
428
        }
429

    
430
        /**
431
         * This method initializes jPanel2
432
         *
433
         * @return javax.swing.JPanel
434
         */
435
        private JPanel getJPanel2() {
436
                if (jPanel2 == null) {
437
                        jPanel2 = new JPanel();
438
                        jPanel2.setLayout(new BorderLayout());
439
                        jPanel2.setPreferredSize(new java.awt.Dimension(120, 200));
440
                        jPanel2.add(getJScrollPane1(), java.awt.BorderLayout.CENTER);
441
                }
442

    
443
                return jPanel2;
444
        }
445

    
446
        /**
447
         * This method initializes jScrollPane1
448
         *
449
         * @return javax.swing.JScrollPane
450
         */
451
        private JScrollPane getJScrollPane1() {
452
                if (jScrollPane1 == null) {
453
                        jScrollPane1 = new JScrollPane();
454
                        jScrollPane1.setViewportView(getJTree());
455
                }
456

    
457
                return jScrollPane1;
458
        }
459

    
460
        /**
461
         * This method initializes pBotones
462
         *
463
         * @return javax.swing.JPanel
464
         */
465
        private JPanel getPBotones() {
466
                if (pBotones == null) {
467
                        pBotones = new JPanel();
468
                        pBotones.add(getBAceptar(), null);
469
                        pBotones.add(getBCancelar(), null);
470
                }
471

    
472
                return pBotones;
473
        }
474

    
475
        /**
476
         * This method initializes bAceptar
477
         *
478
         * @return javax.swing.JButton
479
         */
480
        private JButton getBAceptar() {
481
                if (bAceptar == null) {
482
                        bAceptar = new JButton();
483
                        bAceptar.setText(PluginServices.getText(this, "aceptar"));
484
                        bAceptar.addActionListener(new java.awt.event.ActionListener() {
485
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
486
                                                //Se escribe el config de los plugins
487
                                                marshalPlugins();
488

    
489
                                                //Se escribe el directorio de los plugins
490
                                                Launcher.getAndamiConfig().setPluginsDirectory(getJTextField().getText());
491

    
492
                                                //Se escribe el idioma
493
                                                LanguageItem sel = (LanguageItem) cmbIdioma.getSelectedItem();
494
                                                Launcher.getAndamiConfig().setLocaleLanguage(sel.locale.getLanguage());
495
                                                Launcher.getAndamiConfig().setLocaleCountry(sel.locale.getCountry());
496
                                                Launcher.getAndamiConfig().setLocaleVariant(sel.locale.getVariant());
497

    
498
                                                PluginServices.getMDIManager().closeWindow(ConfigPlugins.this);
499
                                        }
500
                                });
501
                }
502

    
503
                return bAceptar;
504
        }
505

    
506
        /**
507
         * This method initializes bCancelar
508
         *
509
         * @return javax.swing.JButton
510
         */
511
        private JButton getBCancelar() {
512
                if (bCancelar == null) {
513
                        bCancelar = new JButton();
514
                        bCancelar.setText(PluginServices.getText(this, "cancelar"));
515
                        bCancelar.addActionListener(new java.awt.event.ActionListener() {
516
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
517
                                                unmarshalPlugins();
518
                                                PluginServices.getMDIManager().closeWindow(ConfigPlugins.this);
519
                                        }
520
                                });
521
                }
522

    
523
                return bCancelar;
524
        }
525

    
526
        /**
527
         * This method initializes jTextArea1
528
         *
529
         * @return javax.swing.JTextArea
530
         */
531
        private JTextArea getTaDescripcion() {
532
                if (taDescripcion == null) {
533
                        taDescripcion = new JTextArea();
534
                        taDescripcion.setPreferredSize(new java.awt.Dimension(200, 100));
535
                        taDescripcion.setText("");
536
                        taDescripcion.setEditable(false);
537
                        taDescripcion.setEnabled(false);
538
                        taDescripcion.setLineWrap(true);
539
                }
540

    
541
                return taDescripcion;
542
        }
543

    
544
        /**
545
         * This method initializes jScrollPane
546
         *
547
         * @return javax.swing.JScrollPane
548
         */
549
        private JScrollPane getJScrollPane() {
550
                if (jScrollPane == null) {
551
                        jScrollPane = new JScrollPane();
552
                        jScrollPane.setViewportView(getTaDescripcion());
553
                        jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
554
                        jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
555
                }
556

    
557
                return jScrollPane;
558
        }
559

    
560
        /**
561
         * This method initializes jTextField1
562
         *
563
         * @return javax.swing.JTextField
564
         */
565
        private JTextField getJTextField1() {
566
                if (jTextField1 == null) {
567
                        jTextField1 = new JTextField();
568
                        jTextField1.setPreferredSize(new java.awt.Dimension(20, 20));
569

    
570
                        jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
571
                                        public void keyTyped(java.awt.event.KeyEvent e) {
572
                                                ext.setPriority(Integer.parseInt(jTextField1.getText()));
573
                                        }
574
                                });
575
                }
576

    
577
                return jTextField1;
578
        }
579

    
580
        /**
581
         * This method initializes jPanel3
582
         *
583
         * @return javax.swing.JPanel
584
         */
585
        private JPanel getJPanel3() {
586
                if (jPanel3 == null) {
587
                        jPanel3 = new JPanel();
588
                        jPanel3.add(getJTextField1(), null);
589
                        jPanel3.add(jLabel, null);
590
                }
591

    
592
                return jPanel3;
593
        }
594

    
595
        /**
596
         * This method initializes jPanel4
597
         *
598
         * @return javax.swing.JPanel
599
         */
600
        private JPanel getJPanel4() {
601
                if (jPanel4 == null) {
602
                        jLabel1 = new JLabel();
603
                        jPanel4 = new JPanel();
604
                        jLabel1.setText("Idioma:");
605
                        jPanel4.add(jLabel1, null);
606
                        jPanel4.add(getCmbIdioma(), null);
607
                }
608
                return jPanel4;
609
        }
610
        /**
611
         * This method initializes cmbIdioma
612
         *
613
         * @return javax.swing.JComboBox
614
         */
615
        private JComboBox getCmbIdioma() {
616
                if (cmbIdioma == null) {
617
                        cmbIdioma = new JComboBox();
618
                        cmbIdioma.setPreferredSize(new java.awt.Dimension(195,20));
619

    
620
                        Locale esp = new Locale("es");
621
                        Locale eng = new Locale("en");
622
                        Locale fra = new Locale("fr");
623
                        Locale ita = new Locale("it");
624
                        Locale val = new Locale("ca");
625
            Locale cs = new Locale("cs"); // Checo
626
            Locale eu = new Locale("eu"); // euskera
627
            Locale brasil = new Locale("pt", "BR");
628
            Locale de = new Locale("de"); // Alem?n
629
            Locale gr = new Locale("el", "GR"); // Griego
630
            Locale gl = new Locale("gl", "GL"); // Griego
631

    
632
                        // Parche para valenciano/catal?n valenci?/catal?
633
                        String strValenciano = PluginServices.getText(this, "__valenciano");
634
            // Parche para euskera
635

    
636
            Locale localeActual = Locale.getDefault(); // Se configura en la clase Launcher
637
            String strEuskera;
638
            if (eu.getDisplayLanguage().compareTo("vascuence") == 0) {
639
                                strEuskera = "Euskera";
640
                        } else {
641
                                strEuskera = eu.getDisplayLanguage();
642
                        }
643

    
644

    
645
                        LanguageItem[] lenguajes = new LanguageItem[]{
646
                                        new LanguageItem(esp, esp.getDisplayLanguage()),
647
                                        new LanguageItem(eng, eng.getDisplayLanguage()),
648
                                        new LanguageItem(fra, fra.getDisplayLanguage()),
649
                                        new LanguageItem(ita, ita.getDisplayLanguage()),
650
                    new LanguageItem(val, strValenciano),
651
                    new LanguageItem(cs, cs.getDisplayLanguage()),
652
                    new LanguageItem(eu, strEuskera),
653
                    new LanguageItem(brasil, brasil.getDisplayLanguage()),
654
                                        new LanguageItem(de, de.getDisplayLanguage()),
655
                                        new LanguageItem(gr, gr.getDisplayLanguage()),
656
                                        new LanguageItem(gl, gl.getDisplayLanguage())};
657

    
658
                        DefaultComboBoxModel model = new DefaultComboBoxModel(lenguajes);
659

    
660
                        for (int i = 0; i < lenguajes.length; i++) {
661
                                if (lenguajes[i].locale.equals(Locale.getDefault())){
662
                                        model.setSelectedItem(lenguajes[i]);
663
                                }
664
                        }
665

    
666
                        cmbIdioma.setModel(model);
667
                }
668
                return cmbIdioma;
669
        }
670

    
671
        private class LanguageItem {
672
                public Locale locale;
673
                public String description;
674

    
675
                public LanguageItem(Locale loc, String str){
676
                        locale = loc;
677
                        description = str;
678
                }
679

    
680
                public String toString(){
681
                        return description;
682
                }
683
        }
684
           /**
685
         * DOCUMENT ME!
686
         *
687
         * @param args DOCUMENT ME!
688
         */
689
        public static void main(String[] args) {
690
                ConfigPlugins cp = new ConfigPlugins();
691
                cp.setVisible(true);
692

    
693
                JDialog dialog = new JDialog();
694
                dialog.getContentPane().add(cp);
695
                dialog.setSize(400, 300);
696
                dialog.show(true);
697
        }
698

    
699
        /**
700
         * This method initializes this
701
         */
702
        private void initialize() {
703
                this.setLayout(new BorderLayout());
704
                this.setSize(443, 299);
705
                this.setLocation(1, 1);
706
                this.add(getJPanel(), java.awt.BorderLayout.CENTER);
707
        }
708

    
709
        /**
710
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
711
         */
712
        public WindowInfo getWindowInfo() {
713
                if (m_viewinfo == null) {
714
                        m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
715
                        m_viewinfo.setTitle(PluginServices.getText(this, "configurar_ANDAMI"));
716
                }
717

    
718
                return m_viewinfo;
719
        }
720

    
721
        /**
722
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
723
         */
724
        public void viewActivated() {
725
        }
726

    
727
        /**
728
         * Escribe sobre el config.xml, la nueva configuraci?n.
729
         */
730
        public void marshalPlugins() {
731
                HashMap pc = Launcher.getPluginConfig();
732
                ArrayList array = new ArrayList();
733
                Iterator iter = pc.keySet().iterator();
734

    
735
                while (iter.hasNext()) {
736
                        Object obj = iter.next();
737
                        PluginConfig pconfig = (PluginConfig) pc.get(obj);
738
                        FileWriter writer;
739

    
740
                        try {
741
                                writer = new FileWriter(Launcher.getAndamiConfig().getPluginsDirectory() +
742
                                                File.separator + (String) obj + File.separator +
743
                                                "config.xml");
744

    
745
                                try {
746
                                        pconfig.marshal(writer);
747
                                } catch (MarshalException e1) {
748
                                        e1.printStackTrace();
749
                                } catch (ValidationException e1) {
750
                                        e1.printStackTrace();
751
                                }
752
                        } catch (IOException e) {
753
                                e.printStackTrace();
754
                        }
755

    
756
                        //hay que refrescar la aplicaci?n
757
                        ///((App)App.instance).run();
758
                }
759
        }
760

    
761
        /**
762
         * Lee del config.xml la configuraci?n.
763
         */
764
        public void unmarshalPlugins() {
765
                HashMap pc = Launcher.getPluginConfig();
766
                ArrayList array = new ArrayList();
767
                Iterator iter = pc.keySet().iterator();
768

    
769
                while (iter.hasNext()) {
770
                        Object obj = iter.next();
771
                        PluginConfig pconfig = (PluginConfig) pc.get(obj);
772

    
773
                        try {
774
                                FileReader reader = new FileReader(Launcher.getAndamiConfig().getPluginsDirectory() +
775
                                                File.separator + (String) obj + File.separator +
776
                                                "config.xml");
777
                                PluginConfig.unmarshal(reader);
778
                        } catch (Exception e) {
779
                                System.out.println("Exception unmarshalPlugin " + e);
780
                        }
781
                }
782

    
783

    
784
                //hay que refrescar la aplicaci?n
785
                ///((App)App.instance).run();
786
        }
787

    
788
        public Object getWindowProfile() {
789
                return WindowInfo.DIALOG_PROFILE;
790
        }
791
} //  @jve:decl-index=0:visual-constraint="10,10"