svn-gvsig-desktop / trunk / frameworks / _fwAndami / src / com / iver / andami / preferences / GenericDlgPreferences.java @ 38212
History | View | Annotate | Download (18.6 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.andami.preferences; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Component; |
45 |
import java.awt.Dimension; |
46 |
import java.awt.FlowLayout; |
47 |
import java.awt.Font; |
48 |
import java.awt.event.ActionEvent; |
49 |
import java.awt.event.ActionListener; |
50 |
import java.util.ArrayList; |
51 |
import java.util.Enumeration; |
52 |
import java.util.Hashtable; |
53 |
import java.util.Iterator; |
54 |
|
55 |
import javax.swing.JButton; |
56 |
import javax.swing.JLabel; |
57 |
import javax.swing.JOptionPane; |
58 |
import javax.swing.JPanel; |
59 |
import javax.swing.JScrollPane; |
60 |
import javax.swing.JSeparator; |
61 |
import javax.swing.JSplitPane; |
62 |
import javax.swing.JTree; |
63 |
import javax.swing.UIManager; |
64 |
import javax.swing.tree.DefaultMutableTreeNode; |
65 |
import javax.swing.tree.DefaultTreeCellRenderer; |
66 |
import javax.swing.tree.DefaultTreeModel; |
67 |
import javax.swing.tree.TreeSelectionModel; |
68 |
|
69 |
import com.iver.andami.PluginServices; |
70 |
import com.iver.andami.ui.mdiManager.IWindow; |
71 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
72 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
73 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
74 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
75 |
|
76 |
/**
|
77 |
* @author fjp
|
78 |
*
|
79 |
* The reason behind this class is to have the opportunity of use a DlgPreferences
|
80 |
* in a local way. Then, you don't need to be a SingletonView.
|
81 |
*/
|
82 |
public class GenericDlgPreferences extends JPanel implements IWindow { |
83 |
private WindowInfo viewInfo = null; |
84 |
private IPreference activePreference;
|
85 |
|
86 |
private Hashtable preferences = new Hashtable(); |
87 |
DefaultTreeModel treeModel = null; |
88 |
|
89 |
private JTree jTreePlugins = null; |
90 |
|
91 |
private JPanel jPanelButtons = null; |
92 |
|
93 |
private JButton jButtonOK = null; |
94 |
|
95 |
private JButton jButtonCancel = null; |
96 |
private DefaultMutableTreeNode root = new DefaultMutableTreeNode(); |
97 |
|
98 |
private JPanel jPanelCenter = null; |
99 |
|
100 |
private JLabel jLabelBigTitle = null; |
101 |
|
102 |
private JScrollPane jScrollPane = null; |
103 |
|
104 |
private JSplitPane jSplitPaneCenter = null; |
105 |
|
106 |
private JPanel jPanelContainer = null; |
107 |
private JButton jButtonRestore; |
108 |
private ActionListener action; |
109 |
private boolean dirtyTree = false; |
110 |
|
111 |
private class MyTreeCellRenderer extends DefaultTreeCellRenderer |
112 |
{ |
113 |
public MyTreeCellRenderer() {
|
114 |
} |
115 |
|
116 |
public Component getTreeCellRendererComponent( |
117 |
JTree tree,
|
118 |
Object value,
|
119 |
boolean sel,
|
120 |
boolean expanded,
|
121 |
boolean leaf,
|
122 |
int row,
|
123 |
boolean hasFocus) {
|
124 |
|
125 |
super.getTreeCellRendererComponent(
|
126 |
tree, value, sel, |
127 |
expanded, leaf, row, |
128 |
hasFocus); |
129 |
if (value instanceof DefaultMutableTreeNode) |
130 |
{ |
131 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; |
132 |
if (node.getUserObject() instanceof IPreference) |
133 |
{ |
134 |
IPreference pref = (IPreference) node.getUserObject(); |
135 |
this.setText(pref.getTitle());
|
136 |
} |
137 |
} |
138 |
return this; |
139 |
} |
140 |
|
141 |
} |
142 |
|
143 |
|
144 |
public GenericDlgPreferences() {
|
145 |
super();
|
146 |
this.action = new ActionListener() { |
147 |
public void actionPerformed(ActionEvent e) { |
148 |
PluginServices.getMDIManager().setWaitCursor(); |
149 |
String actionCommand = e.getActionCommand();
|
150 |
if ("RESTORE".equals(actionCommand)) { |
151 |
// Restore default values in current page
|
152 |
if (activePreference!=null) { |
153 |
activePreference.initializeDefaults(); |
154 |
// bug 240
|
155 |
// try {
|
156 |
// activePreference.saveValues();
|
157 |
// } catch (StoreException sEx) {
|
158 |
// /*
|
159 |
// * If you reach this code you coded your page
|
160 |
// * with wrong factory default values.
|
161 |
// * Check them out.
|
162 |
// */
|
163 |
// PluginServices.getMDIManager().restoreCursor();
|
164 |
//
|
165 |
// // Show error message
|
166 |
// JOptionPane.showMessageDialog((Component) PluginServices.
|
167 |
// getMainFrame(),sEx.getMessage());
|
168 |
//
|
169 |
// }
|
170 |
} |
171 |
} else {
|
172 |
Iterator it = preferences.keySet().iterator();
|
173 |
|
174 |
if ("CANCEL".equals(actionCommand)) { |
175 |
// Restore previous values in all pages
|
176 |
while (it.hasNext()) {
|
177 |
IPreference pref = (IPreference) preferences.get(it.next()); |
178 |
if (pref.isValueChanged())
|
179 |
pref.initializeValues(); //
|
180 |
} |
181 |
closeView(); |
182 |
} else if ("OK".equals(actionCommand)) { |
183 |
// Apply values in all pages
|
184 |
boolean shouldClose = true; |
185 |
while (it.hasNext()) {
|
186 |
IPreference preference = (IPreference) preferences.get(it.next()); |
187 |
try{
|
188 |
if (preference.isValueChanged()) {
|
189 |
preference.saveValues(); |
190 |
preference.initializeValues(); |
191 |
} |
192 |
}catch (StoreException ex) {
|
193 |
// Reach this code should mean that the page has wrong values
|
194 |
shouldClose = false;
|
195 |
PluginServices.getMDIManager().restoreCursor(); |
196 |
|
197 |
// Show error message
|
198 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),ex.getMessage()); |
199 |
|
200 |
// Focus on error page
|
201 |
setActivePage(preference); |
202 |
} |
203 |
} |
204 |
if (shouldClose)
|
205 |
closeView(); |
206 |
} |
207 |
} |
208 |
PluginServices.getMDIManager().restoreCursor(); |
209 |
} |
210 |
}; |
211 |
initialize(); |
212 |
} |
213 |
|
214 |
private void initialize() { |
215 |
setLayout(new BorderLayout()); |
216 |
setSize(new java.awt.Dimension(750,479)); |
217 |
super.add(getJPanelButtons(), BorderLayout.SOUTH); |
218 |
setPreferredSize(new java.awt.Dimension(390,369)); |
219 |
super.add(getJSplitPaneCenter(), java.awt.BorderLayout.CENTER);
|
220 |
getJSplitPaneCenter().setLeftComponent(getJScrollPane()); |
221 |
getJSplitPaneCenter().setRightComponent(getJPanelNorth()); |
222 |
treeModel = new DefaultTreeModel(root); |
223 |
} |
224 |
|
225 |
public void refreshExtensionPoints() { |
226 |
ExtensionPoints extensionPoints = |
227 |
ExtensionPointsSingleton.getInstance(); |
228 |
|
229 |
ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("AplicationPreferences");
|
230 |
|
231 |
Iterator iterator = extensionPoint.keySet().iterator();
|
232 |
while (iterator.hasNext()) {
|
233 |
try {
|
234 |
IPreference obj = (IPreference)extensionPoint.create((String)iterator.next());
|
235 |
this.addPreferencePage(obj);
|
236 |
} catch (InstantiationException e) { |
237 |
e.printStackTrace(); |
238 |
} catch (IllegalAccessException e) { |
239 |
e.printStackTrace(); |
240 |
} catch (ClassCastException e) { |
241 |
e.printStackTrace(); |
242 |
} |
243 |
} |
244 |
ArrayList<IPreference> prefList = new ArrayList<IPreference>(preferences.values()); |
245 |
addPreferencePages(prefList); |
246 |
} |
247 |
// TODO este m?todo es un parche provisional mientras se hace un refactoring de
|
248 |
//las PreferencePages para disponer de un m?todo que inicialize las variables
|
249 |
//a partir de las preferencias.
|
250 |
public void storeValues() { |
251 |
ExtensionPoints extensionPoints = |
252 |
ExtensionPointsSingleton.getInstance(); |
253 |
|
254 |
ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("AplicationPreferences");
|
255 |
|
256 |
Iterator iterator = extensionPoint.keySet().iterator();
|
257 |
while (iterator.hasNext()) {
|
258 |
try {
|
259 |
IPreference obj = (IPreference)extensionPoint.create((String)iterator.next());
|
260 |
this.addPreferencePage(obj);
|
261 |
|
262 |
{ |
263 |
try {
|
264 |
obj.saveValues(); |
265 |
} catch (StoreException e) {
|
266 |
/*
|
267 |
* If you reach this code you coded your page
|
268 |
* with wrong factory default values.
|
269 |
* Check them out.
|
270 |
*/
|
271 |
PluginServices.getMDIManager().restoreCursor(); |
272 |
// Show error message
|
273 |
JOptionPane.showMessageDialog((Component) PluginServices. |
274 |
getMainFrame(),e.getMessage()); |
275 |
} |
276 |
} |
277 |
} catch (InstantiationException e) { |
278 |
e.printStackTrace(); |
279 |
} catch (IllegalAccessException e) { |
280 |
e.printStackTrace(); |
281 |
} catch (ClassCastException e) { |
282 |
e.printStackTrace(); |
283 |
} |
284 |
} |
285 |
|
286 |
} |
287 |
|
288 |
/**
|
289 |
* It is very common to be confused with this method. But
|
290 |
* the one you are looking for is addPreferencePage(IPreference)
|
291 |
*/
|
292 |
public Component add(Component c) { |
293 |
//throw new Error("Do not use com.iver.cit.gvsig.gui.preferences.DlgPreferences.add(Component) use com.iver.cit.gvsig.gui.preferences.DlgPreferences.addPreferencePage(IPreference) instead");
|
294 |
throw new Error("Do not use com.iver.cit.gvsig.gui.preferences.DlgPreferences.add(Component) register an extension point instead"); |
295 |
} |
296 |
|
297 |
public Component add(Component c, int i) { |
298 |
return add(c);
|
299 |
} |
300 |
|
301 |
public void add(Component c, Object o) { |
302 |
add(c); |
303 |
} |
304 |
|
305 |
public void add(Component c, Object o, int i) { |
306 |
add(c); |
307 |
} |
308 |
|
309 |
public WindowInfo getWindowInfo() {
|
310 |
if (viewInfo == null) { |
311 |
viewInfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE | WindowInfo.PALETTE);
|
312 |
viewInfo.setTitle(PluginServices.getText(this,
|
313 |
"Preferences"));
|
314 |
viewInfo.setWidth(this.getWidth()+8); |
315 |
viewInfo.setHeight(this.getHeight());
|
316 |
} |
317 |
return viewInfo;
|
318 |
} |
319 |
|
320 |
/**
|
321 |
* This method initializes jTreePlugins
|
322 |
*
|
323 |
* @return javax.swing.JTree
|
324 |
*/
|
325 |
private JTree getJTreePlugins() { |
326 |
if (jTreePlugins == null) { |
327 |
jTreePlugins = new JTree(); |
328 |
jTreePlugins.setRootVisible(false);
|
329 |
MyTreeCellRenderer treeCellRenderer = new MyTreeCellRenderer();
|
330 |
treeCellRenderer.setOpenIcon(null);
|
331 |
treeCellRenderer.setClosedIcon(null);
|
332 |
treeCellRenderer.setLeafIcon(null);
|
333 |
|
334 |
jTreePlugins.setCellRenderer(treeCellRenderer); |
335 |
jTreePlugins.setShowsRootHandles(true);
|
336 |
jTreePlugins |
337 |
.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
338 |
public void valueChanged(javax.swing.event.TreeSelectionEvent e) { |
339 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) |
340 |
jTreePlugins.getLastSelectedPathComponent(); |
341 |
|
342 |
if (node == null) return; |
343 |
setActivePage((IPreference) node.getUserObject()); |
344 |
} |
345 |
}); |
346 |
jTreePlugins.putClientProperty("JTree.linestyle", "Angled"); |
347 |
jTreePlugins.getSelectionModel(). |
348 |
setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
349 |
} |
350 |
|
351 |
return jTreePlugins;
|
352 |
} |
353 |
|
354 |
/**
|
355 |
* It takes an IPreference page and adds it to the application's preferences
|
356 |
* dialog. The preference page is added in alphabetical order within the
|
357 |
* branch where the page is hanging on, and defined by its title.
|
358 |
* @param page
|
359 |
*/
|
360 |
public void addPreferencePage(IPreference page) |
361 |
{ |
362 |
if (preferences.containsKey(page.getID()))
|
363 |
return;
|
364 |
preferences.put(page.getID(), page); |
365 |
page.initializeValues(); // init values from the last settings
|
366 |
if (dirtyTree) {
|
367 |
// rebuild page tree
|
368 |
dirtyTree = false;
|
369 |
|
370 |
DefaultTreeModel model = new DefaultTreeModel(root); |
371 |
treeModel = model; |
372 |
jTreePlugins.setModel(model); |
373 |
} |
374 |
|
375 |
doInsertNode(treeModel, page); |
376 |
getJTreePlugins().setModel(treeModel); |
377 |
getJTreePlugins().repaint(); |
378 |
} |
379 |
private void addPreferencePages(ArrayList<IPreference> prefs){ |
380 |
while (prefs.size()>0){ |
381 |
IPreference pref=prefs.get(0);
|
382 |
// System.err.println("IPreference a persistir= "+pref.getID());
|
383 |
if (pref.getParentID()!=null && preferences.get(pref.getParentID())==null){ |
384 |
prefs.remove(pref); |
385 |
addPreferencePages(prefs); |
386 |
// System.err.println("IPreference = "+pref.getID());
|
387 |
addPreference(pref); |
388 |
}else{
|
389 |
// System.err.println("IPreference = "+pref.getID());
|
390 |
addPreference(pref); |
391 |
prefs.remove(pref); |
392 |
} |
393 |
} |
394 |
} |
395 |
private void addPreference(IPreference pref) { |
396 |
DefaultTreeModel model = new DefaultTreeModel(root); |
397 |
doInsertNode(model, pref); |
398 |
} |
399 |
|
400 |
private DefaultMutableTreeNode findNode(String searchID) |
401 |
{ |
402 |
Enumeration e = root.breadthFirstEnumeration();
|
403 |
while (e.hasMoreElements())
|
404 |
{ |
405 |
DefaultMutableTreeNode nodeAux = (DefaultMutableTreeNode) e.nextElement(); |
406 |
if (nodeAux != null) |
407 |
{ |
408 |
IPreference pref = (IPreference) nodeAux.getUserObject(); |
409 |
if (pref == null) continue; // Root node |
410 |
if (pref.getID().equals(searchID))
|
411 |
{ |
412 |
return nodeAux;
|
413 |
} |
414 |
} |
415 |
} |
416 |
return null; |
417 |
|
418 |
} |
419 |
|
420 |
private void doInsertNode(DefaultTreeModel treeModel, IPreference page) |
421 |
{ |
422 |
|
423 |
dirtyTree = ((page.getParentID() != null) && (findNode(page.getParentID())==null)); |
424 |
if (findNode(page.getID()) != null) // It is already added |
425 |
return;
|
426 |
if (page.getParentID() != null) |
427 |
{ |
428 |
if (preferences.containsKey(page.getParentID()))
|
429 |
{ |
430 |
IPreference parent = (IPreference) preferences.get(page.getParentID()); |
431 |
DefaultMutableTreeNode nodeParent = findNode(parent.getID());
|
432 |
if (nodeParent == null) // the parent is empty |
433 |
{ |
434 |
// Recursively add it
|
435 |
doInsertNode(treeModel, parent); |
436 |
} |
437 |
else
|
438 |
{ |
439 |
DefaultMutableTreeNode nodeValue = new DefaultMutableTreeNode(page); |
440 |
int children = nodeParent.getChildCount();
|
441 |
int pos=0; |
442 |
for (int i = 0; i < children; i++) { |
443 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeModel.getChild(nodeParent, i); |
444 |
if (node.getUserObject() instanceof IPreference) { |
445 |
String pageTitle = ((IPreference) node.getUserObject()).getTitle();
|
446 |
if (pageTitle.compareTo(page.getTitle()) < 0) ++pos; |
447 |
} |
448 |
} |
449 |
treeModel.insertNodeInto(nodeValue, nodeParent, pos); |
450 |
} |
451 |
} |
452 |
} |
453 |
else // First level node ("General", "Edition") |
454 |
{ |
455 |
DefaultMutableTreeNode nodeValue = new DefaultMutableTreeNode(page); |
456 |
int children = root.getChildCount();
|
457 |
int pos=0; |
458 |
for (int i = 0; i < children; i++) { |
459 |
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeModel.getChild(root, i); |
460 |
if (node.getUserObject() instanceof IPreference) { |
461 |
String pageTitle = ((IPreference) node.getUserObject()).getTitle();
|
462 |
if (pageTitle.compareTo(page.getTitle()) < 0) ++pos; |
463 |
} |
464 |
} |
465 |
treeModel.insertNodeInto(nodeValue, root, pos); |
466 |
} |
467 |
} |
468 |
|
469 |
/**
|
470 |
* This method initializes jPanelButtons
|
471 |
*
|
472 |
* @return javax.swing.JPanel
|
473 |
*/
|
474 |
private JPanel getJPanelButtons() { |
475 |
if (jPanelButtons == null) { |
476 |
jPanelButtons = new JPanel(new BorderLayout()); |
477 |
JPanel jPanelAux = new JPanel(); |
478 |
JLabel l = new JLabel(); |
479 |
l.setPreferredSize(new Dimension(40, 20)); |
480 |
jPanelButtons.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.NORTH); |
481 |
jPanelAux.add(getJButtonRestore(), BorderLayout.WEST);
|
482 |
jPanelAux.add(l, BorderLayout.CENTER);
|
483 |
jPanelAux.add(getJButtonOK(), BorderLayout.EAST);
|
484 |
jPanelAux.add(getJButtonCancel(), BorderLayout.EAST);
|
485 |
|
486 |
jPanelButtons.add(jPanelAux); |
487 |
} |
488 |
return jPanelButtons;
|
489 |
} |
490 |
|
491 |
/**
|
492 |
* This method initializes jPanelButtons
|
493 |
*
|
494 |
* @return javax.swing.JPanel
|
495 |
*/
|
496 |
|
497 |
|
498 |
/**
|
499 |
* This method initializes jButtonOK
|
500 |
*
|
501 |
* @return JButton
|
502 |
*/
|
503 |
private JButton getJButtonOK() { |
504 |
if (jButtonOK == null) { |
505 |
jButtonOK = new JButton(); |
506 |
jButtonOK.setText(PluginServices.getText(this, "aceptar")); |
507 |
jButtonOK.setActionCommand("OK");
|
508 |
jButtonOK.addActionListener(action); |
509 |
} |
510 |
return jButtonOK;
|
511 |
} |
512 |
|
513 |
/**
|
514 |
* This method initializes jButtonOK
|
515 |
*
|
516 |
* @return JButton
|
517 |
*/
|
518 |
private JButton getJButtonRestore() { |
519 |
if (jButtonRestore == null) { |
520 |
jButtonRestore = new JButton(); |
521 |
jButtonRestore.setText(PluginServices.getText(this, "restore_defaults")); |
522 |
jButtonRestore.setActionCommand("RESTORE");
|
523 |
jButtonRestore.addActionListener(action); |
524 |
} |
525 |
return jButtonRestore;
|
526 |
} |
527 |
|
528 |
private void closeView() { |
529 |
PluginServices.getMDIManager().closeWindow(this);
|
530 |
} |
531 |
|
532 |
/**
|
533 |
* This method initializes jButtonCancel
|
534 |
*
|
535 |
* @return JButton
|
536 |
*/
|
537 |
private JButton getJButtonCancel() { |
538 |
if (jButtonCancel == null) { |
539 |
jButtonCancel = new JButton(); |
540 |
jButtonCancel.setText(PluginServices.getText(this, "cancelar")); |
541 |
jButtonCancel.setActionCommand("CANCEL");
|
542 |
jButtonCancel.addActionListener(action); |
543 |
} |
544 |
return jButtonCancel;
|
545 |
} |
546 |
|
547 |
/**
|
548 |
* This method initializes jPanelNorth
|
549 |
*
|
550 |
* @return javax.swing.JPanel
|
551 |
*/
|
552 |
private JPanel getJPanelNorth() { |
553 |
if (jPanelCenter == null) { |
554 |
jLabelBigTitle = new JLabel(); |
555 |
jLabelBigTitle.setText("General");
|
556 |
Font font = UIManager.getFont("Label.font"); |
557 |
font = font.deriveFont(Font.BOLD, font.getSize() * 1.1f); |
558 |
jLabelBigTitle.setFont(font); |
559 |
jLabelBigTitle.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); |
560 |
jLabelBigTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
561 |
jPanelCenter = new JPanel(); |
562 |
JPanel jPanelPageTitle = new JPanel(new BorderLayout()); |
563 |
JPanel jPanelAux = new JPanel(new BorderLayout()); |
564 |
jPanelAux.add(jLabelBigTitle, java.awt.BorderLayout.NORTH); |
565 |
jPanelPageTitle.add(jPanelAux, java.awt.BorderLayout.WEST); |
566 |
jPanelPageTitle.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); |
567 |
jPanelCenter.setLayout(new BorderLayout()); |
568 |
jPanelCenter.add(jPanelPageTitle, BorderLayout.NORTH);
|
569 |
jPanelCenter.add(getJPanelContainer(), java.awt.BorderLayout.CENTER); |
570 |
|
571 |
} |
572 |
return jPanelCenter;
|
573 |
} |
574 |
|
575 |
/**
|
576 |
* This method initializes jScrollPane
|
577 |
*
|
578 |
* @return javax.swing.JScrollPane
|
579 |
*/
|
580 |
private JScrollPane getJScrollPane() { |
581 |
if (jScrollPane == null) { |
582 |
jScrollPane = new JScrollPane(); |
583 |
jScrollPane.setPreferredSize(new java.awt.Dimension(140,322)); |
584 |
jScrollPane.setViewportView(getJTreePlugins()); |
585 |
} |
586 |
return jScrollPane;
|
587 |
} |
588 |
|
589 |
/**
|
590 |
* This method initializes jSplitPaneCenter
|
591 |
*
|
592 |
* @return javax.swing.JSplitPane
|
593 |
*/
|
594 |
private JSplitPane getJSplitPaneCenter() { |
595 |
if (jSplitPaneCenter == null) { |
596 |
jSplitPaneCenter = new JSplitPane(); |
597 |
jSplitPaneCenter.setResizeWeight(0.2);
|
598 |
jSplitPaneCenter.setDividerLocation(200);
|
599 |
} |
600 |
return jSplitPaneCenter;
|
601 |
} |
602 |
|
603 |
/**
|
604 |
* This method initializes jPanelContainer
|
605 |
*
|
606 |
* @return javax.swing.JPanel
|
607 |
*/
|
608 |
private JPanel getJPanelContainer() { |
609 |
if (jPanelContainer == null) { |
610 |
jPanelContainer = new JPanel(); |
611 |
} |
612 |
return jPanelContainer;
|
613 |
} |
614 |
|
615 |
/**
|
616 |
*
|
617 |
*/
|
618 |
public void setActivePage(IPreference page) { |
619 |
activePreference = page; |
620 |
jLabelBigTitle.setText(activePreference.getTitle()); |
621 |
JPanel prefPanel = activePreference.getPanel();
|
622 |
jLabelBigTitle.setIcon(activePreference.getIcon()); |
623 |
jPanelContainer.removeAll(); |
624 |
if ((prefPanel instanceof AbstractPreferencePage) && |
625 |
((AbstractPreferencePage) prefPanel).isResizeable()) { |
626 |
jPanelContainer.setLayout(new BorderLayout()); |
627 |
jPanelContainer.add(prefPanel, BorderLayout.CENTER);
|
628 |
} else {
|
629 |
jPanelContainer.setLayout(new FlowLayout()); |
630 |
jPanelContainer.add(prefPanel); |
631 |
} |
632 |
prefPanel.setVisible(true);
|
633 |
repaint(); |
634 |
} |
635 |
|
636 |
public Object getWindowProfile() { |
637 |
return WindowInfo.DIALOG_PROFILE;
|
638 |
} |
639 |
} |