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