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