gvsig-projects-pool / org.gvsig.winmgr / trunk / org.gvsig.winmgr.app / org.gvsig.winmgr.app.mainplugin / src / main / java / org / gvsig / coreplugin / configExtensions / ConfigPlugins.java @ 682
History | View | Annotate | Download (21 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 |
package org.gvsig.coreplugin.configExtensions; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.Component; |
28 |
import java.io.File; |
29 |
import java.io.FileReader; |
30 |
import java.io.FileWriter; |
31 |
import java.io.IOException; |
32 |
import java.util.ArrayList; |
33 |
import java.util.HashMap; |
34 |
import java.util.Iterator; |
35 |
import java.util.Locale; |
36 |
|
37 |
import javax.swing.BoxLayout; |
38 |
import javax.swing.DefaultComboBoxModel; |
39 |
import javax.swing.JButton; |
40 |
import javax.swing.JCheckBox; |
41 |
import javax.swing.JComboBox; |
42 |
import javax.swing.JDialog; |
43 |
import javax.swing.JFileChooser; |
44 |
import javax.swing.JLabel; |
45 |
import javax.swing.JPanel; |
46 |
import javax.swing.JScrollPane; |
47 |
import javax.swing.JSplitPane; |
48 |
import javax.swing.JTabbedPane; |
49 |
import javax.swing.JTextArea; |
50 |
import javax.swing.JTextField; |
51 |
import javax.swing.JTree; |
52 |
import javax.swing.tree.DefaultMutableTreeNode; |
53 |
|
54 |
import org.exolab.castor.xml.MarshalException; |
55 |
import org.exolab.castor.xml.ValidationException; |
56 |
import org.gvsig.andami.Launcher; |
57 |
import org.gvsig.andami.PluginServices; |
58 |
import org.gvsig.andami.plugins.config.generate.Extension; |
59 |
import org.gvsig.andami.plugins.config.generate.Extensions; |
60 |
import org.gvsig.andami.plugins.config.generate.PluginConfig; |
61 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
62 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
63 |
import org.gvsig.utils.GenericFileFilter; |
64 |
|
65 |
/**
|
66 |
* Di?logo de Configuraci?n de ANDAMI.
|
67 |
*
|
68 |
* @author Vicente Caballero Navarro
|
69 |
* @deprecated
|
70 |
*/
|
71 |
public class ConfigPlugins extends JPanel implements IWindow { |
72 |
private JTree jTree = null; |
73 |
private JPanel jPanel = null; // @jve:decl-index=0:visual-constraint="113,10" |
74 |
private JPanel jPanel1 = null; |
75 |
private JSplitPane jSplitPane = null; |
76 |
private JCheckBox chbActivar = null; |
77 |
private JTextField jTextField = null; |
78 |
private JPanel pGeneral = null; |
79 |
private JButton jButton = null; |
80 |
private JPanel pOpciones = null; |
81 |
private JTabbedPane jTabbedPane1 = null; |
82 |
private JPanel pDescripcion = null; |
83 |
private JPanel pDirectorio = null; |
84 |
private JPanel jPanel2 = null; |
85 |
private JScrollPane jScrollPane1 = null; |
86 |
private WindowInfo m_viewinfo = null; |
87 |
private JPanel pBotones = null; |
88 |
private JButton bAceptar = null; |
89 |
private JButton bCancelar = null; |
90 |
private HashMap listExt = new HashMap(); |
91 |
private HashMap listPlugins = new HashMap(); |
92 |
private JTextArea taDescripcion = null; |
93 |
private JScrollPane jScrollPane = null; |
94 |
private Extension ext = null; |
95 |
private JTextField jTextField1 = null; |
96 |
private JLabel jLabel = null; |
97 |
private JPanel jPanel3 = null; |
98 |
|
99 |
private JPanel jPanel4 = null; |
100 |
private JLabel jLabel1 = null; |
101 |
private JComboBox cmbIdioma = null; |
102 |
/**
|
103 |
* This is the default constructor
|
104 |
*/
|
105 |
public ConfigPlugins() {
|
106 |
super();
|
107 |
initialize(); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* A?ade los nodes al arbol que representa a todos los plugins y extesiones que hay.
|
112 |
*
|
113 |
* @param top
|
114 |
*/
|
115 |
private void addNodes(DefaultMutableTreeNode top) { |
116 |
DefaultMutableTreeNode nameExtension = null; |
117 |
DefaultMutableTreeNode namePlugin = null; |
118 |
HashMap pc = Launcher.getPluginConfig();
|
119 |
ArrayList array = new ArrayList(); |
120 |
Iterator iter = pc.values().iterator();
|
121 |
|
122 |
while (iter.hasNext()) {
|
123 |
array.add(((PluginConfig) iter.next()).getExtensions()); |
124 |
} |
125 |
|
126 |
Extensions[] exts = (Extensions[]) array.toArray(new Extensions[0]); |
127 |
|
128 |
for (int i = 0; i < exts.length; i++) { |
129 |
if (exts[i].getSkinExtension() != null) { |
130 |
} |
131 |
|
132 |
for (int j = 0; j < exts[i].getExtensionCount(); j++) { |
133 |
Extension ext = exts[i].getExtension(j); |
134 |
String pn = null; |
135 |
String sExt = ext.getClassName().toString();
|
136 |
pn = sExt.substring(0, sExt.lastIndexOf(".")); |
137 |
namePlugin = new DefaultMutableTreeNode(pn); |
138 |
|
139 |
if (!listPlugins.containsKey(namePlugin.getUserObject()
|
140 |
.toString())) { |
141 |
listPlugins.put(namePlugin.getUserObject().toString(), |
142 |
namePlugin); |
143 |
top.add(namePlugin); |
144 |
nameExtension = new DefaultMutableTreeNode(sExt.substring(sExt.lastIndexOf( |
145 |
".") + 1, sExt.length())); //replaceFirst(namePlugin.getUserObject().toString()+".","")); |
146 |
listExt.put(sExt, ext); |
147 |
namePlugin.add(nameExtension); |
148 |
} else {
|
149 |
nameExtension = new DefaultMutableTreeNode(sExt.substring(sExt.lastIndexOf( |
150 |
".") + 1, sExt.length())); //sExt.replaceFirst(namePlugin.getUserObject().toString()+".","")); |
151 |
listExt.put(sExt, ext); |
152 |
((DefaultMutableTreeNode) listPlugins.get(namePlugin.getUserObject()
|
153 |
.toString())).add(nameExtension); |
154 |
} |
155 |
} |
156 |
} |
157 |
} |
158 |
|
159 |
/**
|
160 |
* This method initializes jTree
|
161 |
*
|
162 |
* @return javax.swing.JTree
|
163 |
*/
|
164 |
private JTree getJTree() { |
165 |
if (jTree == null) { |
166 |
DefaultMutableTreeNode root = new DefaultMutableTreeNode("ANDAMI"); |
167 |
addNodes(root); |
168 |
jTree = new JTree(root); |
169 |
|
170 |
jTree.setName("ANDAMI");
|
171 |
jTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
172 |
public void valueChanged( |
173 |
javax.swing.event.TreeSelectionEvent e) { |
174 |
if (e.getPath().getParentPath() != null) { |
175 |
ext = (Extension) listExt.get(e.getPath() |
176 |
.getParentPath() |
177 |
.getLastPathComponent() |
178 |
.toString() + "." +
|
179 |
e.getPath().getLastPathComponent().toString()); |
180 |
|
181 |
if (ext == null) { |
182 |
getChbActivar().setVisible(false);
|
183 |
getTaDescripcion().setText("Plugin : " +
|
184 |
e.getNewLeadSelectionPath().toString()); |
185 |
} else {
|
186 |
try {
|
187 |
getChbActivar().setSelected((Launcher.getExtension( |
188 |
ext.getClassName())).getActive()); |
189 |
getChbActivar().setVisible(true);
|
190 |
getTaDescripcion().setText((Launcher.getExtension( |
191 |
ext.getClassName())).getDescription()); |
192 |
getJTextField1().setText(String.valueOf(
|
193 |
ext.getPriority())); |
194 |
} catch (NullPointerException npe) { |
195 |
getChbActivar().setVisible(false);
|
196 |
getTaDescripcion().setText("Plugin : " +
|
197 |
e.getNewLeadSelectionPath().toString()); |
198 |
} |
199 |
} |
200 |
} |
201 |
} |
202 |
}); |
203 |
} |
204 |
|
205 |
return jTree;
|
206 |
} |
207 |
|
208 |
/**
|
209 |
* This method initializes jPanel
|
210 |
*
|
211 |
* @return javax.swing.JPanel
|
212 |
*/
|
213 |
private JPanel getJPanel() { |
214 |
if (jPanel == null) { |
215 |
jPanel = new JPanel(); |
216 |
jPanel.setLayout(new BorderLayout()); |
217 |
jPanel.setName("jPanel");
|
218 |
jPanel.setPreferredSize(new java.awt.Dimension(150, 150)); |
219 |
jPanel.setSize(435, 299); |
220 |
jPanel.add(getJSplitPane(), java.awt.BorderLayout.CENTER); |
221 |
jPanel.add(getPBotones(), java.awt.BorderLayout.SOUTH); |
222 |
} |
223 |
|
224 |
return jPanel;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* This method initializes jPanel1
|
229 |
*
|
230 |
* @return javax.swing.JPanel
|
231 |
*/
|
232 |
private JPanel getJPanel1() { |
233 |
if (jPanel1 == null) { |
234 |
jPanel1 = new JPanel(); |
235 |
jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.Y_AXIS)); |
236 |
jPanel1.setName("jPanel1");
|
237 |
jPanel1.setPreferredSize(new java.awt.Dimension(200, 100)); |
238 |
jPanel1.add(getJTabbedPane1(), null);
|
239 |
} |
240 |
|
241 |
return jPanel1;
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* This method initializes jSplitPane
|
246 |
*
|
247 |
* @return javax.swing.JSplitPane
|
248 |
*/
|
249 |
private JSplitPane getJSplitPane() { |
250 |
if (jSplitPane == null) { |
251 |
jSplitPane = new JSplitPane(); |
252 |
jSplitPane.setRightComponent(getJPanel1()); |
253 |
jSplitPane.setLeftComponent(getJPanel2()); |
254 |
} |
255 |
|
256 |
return jSplitPane;
|
257 |
} |
258 |
|
259 |
/**
|
260 |
* This method initializes chbActivar
|
261 |
*
|
262 |
* @return javax.swing.JCheckBox
|
263 |
*/
|
264 |
private JCheckBox getChbActivar() { |
265 |
if (chbActivar == null) { |
266 |
chbActivar = new JCheckBox(); |
267 |
chbActivar.setSelected(true);
|
268 |
chbActivar.setVisible(false);
|
269 |
chbActivar.setText(PluginServices.getText(this, "extension_activada")); |
270 |
chbActivar.addActionListener(new java.awt.event.ActionListener() {
|
271 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
272 |
ext.setActive(chbActivar.isSelected()); |
273 |
} |
274 |
}); |
275 |
} |
276 |
|
277 |
return chbActivar;
|
278 |
} |
279 |
|
280 |
/**
|
281 |
* This method initializes jTextField
|
282 |
*
|
283 |
* @return javax.swing.JTextField
|
284 |
*/
|
285 |
private JTextField getJTextField() { |
286 |
if (jTextField == null) { |
287 |
jTextField = new JTextField(); |
288 |
jTextField.setPreferredSize(new java.awt.Dimension(200, 20)); |
289 |
jTextField.setText(Launcher.getAndamiConfig().getPluginsDirectory()); |
290 |
} |
291 |
|
292 |
return jTextField;
|
293 |
} |
294 |
|
295 |
/**
|
296 |
* This method initializes pGeneral
|
297 |
*
|
298 |
* @return javax.swing.JPanel
|
299 |
*/
|
300 |
private JPanel getPGeneral() { |
301 |
if (pGeneral == null) { |
302 |
pGeneral = new JPanel(); |
303 |
pGeneral.add(getPDirectorio(), null);
|
304 |
pGeneral.add(getJPanel4(), null);
|
305 |
} |
306 |
|
307 |
return pGeneral;
|
308 |
} |
309 |
|
310 |
/**
|
311 |
* This method initializes jButton
|
312 |
*
|
313 |
* @return javax.swing.JButton
|
314 |
*/
|
315 |
private JButton getJButton() { |
316 |
if (jButton == null) { |
317 |
jButton = new JButton(); |
318 |
jButton.setText(PluginServices.getText(this, "examinar")); |
319 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
320 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
321 |
JFileChooser jfc = new JFileChooser(); |
322 |
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
323 |
jfc.addChoosableFileFilter(new GenericFileFilter("", |
324 |
PluginServices.getText(this,
|
325 |
"directorio_extensiones")));
|
326 |
|
327 |
if (jfc.showOpenDialog(
|
328 |
(Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
329 |
getJTextField().setText(jfc.getSelectedFile() |
330 |
.getAbsolutePath()); |
331 |
} |
332 |
} |
333 |
}); |
334 |
} |
335 |
|
336 |
return jButton;
|
337 |
} |
338 |
|
339 |
/**
|
340 |
* This method initializes pOpciones
|
341 |
*
|
342 |
* @return javax.swing.JPanel
|
343 |
*/
|
344 |
private JPanel getPOpciones() { |
345 |
if (pOpciones == null) { |
346 |
jLabel = new JLabel(); |
347 |
pOpciones = new JPanel(); |
348 |
pOpciones.setLayout(new BorderLayout()); |
349 |
jLabel.setText(PluginServices.getText(this, "prioridad")); |
350 |
pOpciones.add(getChbActivar(), java.awt.BorderLayout.NORTH); |
351 |
pOpciones.add(getPDescripcion(), java.awt.BorderLayout.CENTER); |
352 |
pOpciones.add(getJPanel3(), java.awt.BorderLayout.SOUTH); |
353 |
} |
354 |
|
355 |
return pOpciones;
|
356 |
} |
357 |
|
358 |
/**
|
359 |
* This method initializes jTabbedPane1
|
360 |
*
|
361 |
* @return javax.swing.JTabbedPane
|
362 |
*/
|
363 |
private JTabbedPane getJTabbedPane1() { |
364 |
if (jTabbedPane1 == null) { |
365 |
jTabbedPane1 = new JTabbedPane(); |
366 |
jTabbedPane1.addTab(PluginServices.getText(this, "opciones"), null, |
367 |
getPOpciones(), null);
|
368 |
jTabbedPane1.addTab(PluginServices.getText(this, "general"), null, |
369 |
getPGeneral(), null);
|
370 |
} |
371 |
|
372 |
return jTabbedPane1;
|
373 |
} |
374 |
|
375 |
/**
|
376 |
* This method initializes pDescripcion
|
377 |
*
|
378 |
* @return javax.swing.JPanel
|
379 |
*/
|
380 |
private JPanel getPDescripcion() { |
381 |
if (pDescripcion == null) { |
382 |
pDescripcion = new JPanel(); |
383 |
pDescripcion.setLayout(new BorderLayout()); |
384 |
pDescripcion.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
385 |
pDescripcion.setBorder(javax.swing.BorderFactory.createTitledBorder( |
386 |
null, PluginServices.getText(this, "descripcion"), |
387 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
388 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
389 |
} |
390 |
|
391 |
return pDescripcion;
|
392 |
} |
393 |
|
394 |
/**
|
395 |
* This method initializes pDirectorio
|
396 |
*
|
397 |
* @return javax.swing.JPanel
|
398 |
*/
|
399 |
private JPanel getPDirectorio() { |
400 |
if (pDirectorio == null) { |
401 |
pDirectorio = new JPanel(); |
402 |
pDirectorio.setBorder(javax.swing.BorderFactory.createTitledBorder( |
403 |
null, PluginServices.getText(this, "directorio"), |
404 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
405 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
406 |
pDirectorio.add(getJTextField(), null);
|
407 |
pDirectorio.add(getJButton(), null);
|
408 |
} |
409 |
|
410 |
return pDirectorio;
|
411 |
} |
412 |
|
413 |
/**
|
414 |
* This method initializes jPanel2
|
415 |
*
|
416 |
* @return javax.swing.JPanel
|
417 |
*/
|
418 |
private JPanel getJPanel2() { |
419 |
if (jPanel2 == null) { |
420 |
jPanel2 = new JPanel(); |
421 |
jPanel2.setLayout(new BorderLayout()); |
422 |
jPanel2.setPreferredSize(new java.awt.Dimension(120, 200)); |
423 |
jPanel2.add(getJScrollPane1(), java.awt.BorderLayout.CENTER); |
424 |
} |
425 |
|
426 |
return jPanel2;
|
427 |
} |
428 |
|
429 |
/**
|
430 |
* This method initializes jScrollPane1
|
431 |
*
|
432 |
* @return javax.swing.JScrollPane
|
433 |
*/
|
434 |
private JScrollPane getJScrollPane1() { |
435 |
if (jScrollPane1 == null) { |
436 |
jScrollPane1 = new JScrollPane(); |
437 |
jScrollPane1.setViewportView(getJTree()); |
438 |
} |
439 |
|
440 |
return jScrollPane1;
|
441 |
} |
442 |
|
443 |
/**
|
444 |
* This method initializes pBotones
|
445 |
*
|
446 |
* @return javax.swing.JPanel
|
447 |
*/
|
448 |
private JPanel getPBotones() { |
449 |
if (pBotones == null) { |
450 |
pBotones = new JPanel(); |
451 |
pBotones.add(getBAceptar(), null);
|
452 |
pBotones.add(getBCancelar(), null);
|
453 |
} |
454 |
|
455 |
return pBotones;
|
456 |
} |
457 |
|
458 |
/**
|
459 |
* This method initializes bAceptar
|
460 |
*
|
461 |
* @return javax.swing.JButton
|
462 |
*/
|
463 |
private JButton getBAceptar() { |
464 |
if (bAceptar == null) { |
465 |
bAceptar = new JButton(); |
466 |
bAceptar.setText(PluginServices.getText(this, "aceptar")); |
467 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
468 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
469 |
//Se escribe el config de los plugins
|
470 |
marshalPlugins(); |
471 |
|
472 |
//Se escribe el directorio de los plugins
|
473 |
Launcher.getAndamiConfig().setPluginsDirectory(getJTextField().getText()); |
474 |
|
475 |
//Se escribe el idioma
|
476 |
LanguageItem sel = (LanguageItem) cmbIdioma.getSelectedItem(); |
477 |
Launcher.getAndamiConfig().setLocaleLanguage(sel.locale.getLanguage()); |
478 |
Launcher.getAndamiConfig().setLocaleCountry(sel.locale.getCountry()); |
479 |
Launcher.getAndamiConfig().setLocaleVariant(sel.locale.getVariant()); |
480 |
|
481 |
PluginServices.getMDIManager().closeWindow(ConfigPlugins.this); |
482 |
} |
483 |
}); |
484 |
} |
485 |
|
486 |
return bAceptar;
|
487 |
} |
488 |
|
489 |
/**
|
490 |
* This method initializes bCancelar
|
491 |
*
|
492 |
* @return javax.swing.JButton
|
493 |
*/
|
494 |
private JButton getBCancelar() { |
495 |
if (bCancelar == null) { |
496 |
bCancelar = new JButton(); |
497 |
bCancelar.setText(PluginServices.getText(this, "cancelar")); |
498 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
499 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
500 |
unmarshalPlugins(); |
501 |
PluginServices.getMDIManager().closeWindow(ConfigPlugins.this); |
502 |
} |
503 |
}); |
504 |
} |
505 |
|
506 |
return bCancelar;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* This method initializes jTextArea1
|
511 |
*
|
512 |
* @return javax.swing.JTextArea
|
513 |
*/
|
514 |
private JTextArea getTaDescripcion() { |
515 |
if (taDescripcion == null) { |
516 |
taDescripcion = new JTextArea(); |
517 |
taDescripcion.setPreferredSize(new java.awt.Dimension(200, 100)); |
518 |
taDescripcion.setText("");
|
519 |
taDescripcion.setEditable(false);
|
520 |
taDescripcion.setEnabled(false);
|
521 |
taDescripcion.setLineWrap(true);
|
522 |
} |
523 |
|
524 |
return taDescripcion;
|
525 |
} |
526 |
|
527 |
/**
|
528 |
* This method initializes jScrollPane
|
529 |
*
|
530 |
* @return javax.swing.JScrollPane
|
531 |
*/
|
532 |
private JScrollPane getJScrollPane() { |
533 |
if (jScrollPane == null) { |
534 |
jScrollPane = new JScrollPane(); |
535 |
jScrollPane.setViewportView(getTaDescripcion()); |
536 |
jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
537 |
jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
538 |
} |
539 |
|
540 |
return jScrollPane;
|
541 |
} |
542 |
|
543 |
/**
|
544 |
* This method initializes jTextField1
|
545 |
*
|
546 |
* @return javax.swing.JTextField
|
547 |
*/
|
548 |
private JTextField getJTextField1() { |
549 |
if (jTextField1 == null) { |
550 |
jTextField1 = new JTextField(); |
551 |
jTextField1.setPreferredSize(new java.awt.Dimension(20, 20)); |
552 |
|
553 |
jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
|
554 |
public void keyTyped(java.awt.event.KeyEvent e) { |
555 |
ext.setPriority(Integer.parseInt(jTextField1.getText()));
|
556 |
} |
557 |
}); |
558 |
} |
559 |
|
560 |
return jTextField1;
|
561 |
} |
562 |
|
563 |
/**
|
564 |
* This method initializes jPanel3
|
565 |
*
|
566 |
* @return javax.swing.JPanel
|
567 |
*/
|
568 |
private JPanel getJPanel3() { |
569 |
if (jPanel3 == null) { |
570 |
jPanel3 = new JPanel(); |
571 |
jPanel3.add(getJTextField1(), null);
|
572 |
jPanel3.add(jLabel, null);
|
573 |
} |
574 |
|
575 |
return jPanel3;
|
576 |
} |
577 |
|
578 |
/**
|
579 |
* This method initializes jPanel4
|
580 |
*
|
581 |
* @return javax.swing.JPanel
|
582 |
*/
|
583 |
private JPanel getJPanel4() { |
584 |
if (jPanel4 == null) { |
585 |
jLabel1 = new JLabel(); |
586 |
jPanel4 = new JPanel(); |
587 |
jLabel1.setText("Idioma:");
|
588 |
jPanel4.add(jLabel1, null);
|
589 |
jPanel4.add(getCmbIdioma(), null);
|
590 |
} |
591 |
return jPanel4;
|
592 |
} |
593 |
/**
|
594 |
* This method initializes cmbIdioma
|
595 |
*
|
596 |
* @return javax.swing.JComboBox
|
597 |
*/
|
598 |
private JComboBox getCmbIdioma() { |
599 |
if (cmbIdioma == null) { |
600 |
cmbIdioma = new JComboBox(); |
601 |
cmbIdioma.setPreferredSize(new java.awt.Dimension(195,20)); |
602 |
|
603 |
Locale esp = new Locale("es"); |
604 |
Locale eng = new Locale("en"); |
605 |
Locale fra = new Locale("fr"); |
606 |
Locale ita = new Locale("it"); |
607 |
Locale val = new Locale("ca"); |
608 |
Locale cs = new Locale("cs"); // Checo |
609 |
Locale eu = new Locale("eu"); // euskera |
610 |
Locale brasil = new Locale("pt", "BR"); |
611 |
Locale de = new Locale("de"); // Alem?n |
612 |
Locale gr = new Locale("el", "GR"); // Griego |
613 |
Locale gl = new Locale("gl", "GL"); // Griego |
614 |
|
615 |
// Parche para valenciano/catal?n valenci?/catal?
|
616 |
String strValenciano = PluginServices.getText(this, "__valenciano"); |
617 |
// Parche para euskera
|
618 |
|
619 |
Locale localeActual = Locale.getDefault(); // Se configura en la clase Launcher |
620 |
String strEuskera;
|
621 |
if (eu.getDisplayLanguage().compareTo("vascuence") == 0) { |
622 |
strEuskera = "Euskera";
|
623 |
} else {
|
624 |
strEuskera = eu.getDisplayLanguage(); |
625 |
} |
626 |
|
627 |
|
628 |
LanguageItem[] lenguajes = new LanguageItem[]{ |
629 |
new LanguageItem(esp, esp.getDisplayLanguage()),
|
630 |
new LanguageItem(eng, eng.getDisplayLanguage()),
|
631 |
new LanguageItem(fra, fra.getDisplayLanguage()),
|
632 |
new LanguageItem(ita, ita.getDisplayLanguage()),
|
633 |
new LanguageItem(val, strValenciano),
|
634 |
new LanguageItem(cs, cs.getDisplayLanguage()),
|
635 |
new LanguageItem(eu, strEuskera),
|
636 |
new LanguageItem(brasil, brasil.getDisplayLanguage()),
|
637 |
new LanguageItem(de, de.getDisplayLanguage()),
|
638 |
new LanguageItem(gr, gr.getDisplayLanguage()),
|
639 |
new LanguageItem(gl, gl.getDisplayLanguage())};
|
640 |
|
641 |
DefaultComboBoxModel model = new DefaultComboBoxModel(lenguajes); |
642 |
|
643 |
for (int i = 0; i < lenguajes.length; i++) { |
644 |
if (lenguajes[i].locale.equals(Locale.getDefault())){ |
645 |
model.setSelectedItem(lenguajes[i]); |
646 |
} |
647 |
} |
648 |
|
649 |
cmbIdioma.setModel(model); |
650 |
} |
651 |
return cmbIdioma;
|
652 |
} |
653 |
|
654 |
private class LanguageItem { |
655 |
public Locale locale; |
656 |
public String description; |
657 |
|
658 |
public LanguageItem(Locale loc, String str){ |
659 |
locale = loc; |
660 |
description = str; |
661 |
} |
662 |
|
663 |
public String toString(){ |
664 |
return description;
|
665 |
} |
666 |
} |
667 |
/**
|
668 |
* DOCUMENT ME!
|
669 |
*
|
670 |
* @param args DOCUMENT ME!
|
671 |
*/
|
672 |
public static void main(String[] args) { |
673 |
ConfigPlugins cp = new ConfigPlugins();
|
674 |
cp.setVisible(true);
|
675 |
|
676 |
JDialog dialog = new JDialog(); |
677 |
dialog.getContentPane().add(cp); |
678 |
dialog.setSize(400, 300); |
679 |
dialog.show(true);
|
680 |
} |
681 |
|
682 |
/**
|
683 |
* This method initializes this
|
684 |
*/
|
685 |
private void initialize() { |
686 |
this.setLayout(new BorderLayout()); |
687 |
this.setSize(443, 299); |
688 |
this.setLocation(1, 1); |
689 |
this.add(getJPanel(), java.awt.BorderLayout.CENTER);
|
690 |
} |
691 |
|
692 |
/**
|
693 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
694 |
*/
|
695 |
public WindowInfo getWindowInfo() {
|
696 |
if (m_viewinfo == null) { |
697 |
m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
698 |
m_viewinfo.setTitle(PluginServices.getText(this, "configurar_ANDAMI")); |
699 |
} |
700 |
|
701 |
return m_viewinfo;
|
702 |
} |
703 |
|
704 |
/**
|
705 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
706 |
*/
|
707 |
public void viewActivated() { |
708 |
} |
709 |
|
710 |
/**
|
711 |
* Escribe sobre el config.xml, la nueva configuraci?n.
|
712 |
*/
|
713 |
public void marshalPlugins() { |
714 |
HashMap pc = Launcher.getPluginConfig();
|
715 |
ArrayList array = new ArrayList(); |
716 |
Iterator iter = pc.keySet().iterator();
|
717 |
|
718 |
while (iter.hasNext()) {
|
719 |
Object obj = iter.next();
|
720 |
PluginConfig pconfig = (PluginConfig) pc.get(obj); |
721 |
FileWriter writer;
|
722 |
|
723 |
try {
|
724 |
writer = new FileWriter(Launcher.getAndamiConfig().getPluginsDirectory() + |
725 |
File.separator + (String) obj + File.separator + |
726 |
"config.xml");
|
727 |
|
728 |
try {
|
729 |
pconfig.marshal(writer); |
730 |
} catch (MarshalException e1) { |
731 |
e1.printStackTrace(); |
732 |
} catch (ValidationException e1) {
|
733 |
e1.printStackTrace(); |
734 |
} |
735 |
} catch (IOException e) { |
736 |
e.printStackTrace(); |
737 |
} |
738 |
|
739 |
//hay que refrescar la aplicaci?n
|
740 |
///((App)App.instance).run();
|
741 |
} |
742 |
} |
743 |
|
744 |
/**
|
745 |
* Lee del config.xml la configuraci?n.
|
746 |
*/
|
747 |
public void unmarshalPlugins() { |
748 |
HashMap pc = Launcher.getPluginConfig();
|
749 |
ArrayList array = new ArrayList(); |
750 |
Iterator iter = pc.keySet().iterator();
|
751 |
|
752 |
while (iter.hasNext()) {
|
753 |
Object obj = iter.next();
|
754 |
PluginConfig pconfig = (PluginConfig) pc.get(obj); |
755 |
|
756 |
try {
|
757 |
FileReader reader = new FileReader(Launcher.getAndamiConfig().getPluginsDirectory() + |
758 |
File.separator + (String) obj + File.separator + |
759 |
"config.xml");
|
760 |
PluginConfig.unmarshal(reader); |
761 |
} catch (Exception e) { |
762 |
System.out.println("Exception unmarshalPlugin " + e); |
763 |
} |
764 |
} |
765 |
|
766 |
|
767 |
//hay que refrescar la aplicaci?n
|
768 |
///((App)App.instance).run();
|
769 |
} |
770 |
|
771 |
public Object getWindowProfile() { |
772 |
return WindowInfo.DIALOG_PROFILE;
|
773 |
} |
774 |
} // @jve:decl-index=0:visual-constraint="10,10"
|