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