KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > options > advanced > AdvancedPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.options.advanced;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.awt.event.ActionEvent JavaDoc;
25 import java.awt.event.ActionListener JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import javax.swing.JComponent JavaDoc;
28 import javax.swing.JPanel JavaDoc;
29 import javax.swing.JScrollPane JavaDoc;
30
31 import org.netbeans.modules.options.ui.TabbedPanel;
32 import org.netbeans.spi.options.OptionsPanelController;
33 import org.openide.util.HelpCtx;
34 import org.openide.util.Lookup;
35 import org.openide.util.NbBundle;
36 import org.netbeans.modules.options.*;
37
38
39 /**
40  * Implementation of one panel in Options Dialog.
41  *
42  * @author Jan Jancura
43  */

44 public final class AdvancedPanel extends JPanel JavaDoc {
45
46     
47     TabbedPanel tabbedPanel;
48     private final Model model = new Model ();
49     
50     
51     AdvancedPanel () {}
52     
53     public void update () {
54         model.update ();
55     }
56     
57     public void applyChanges () {
58         model.applyChanges ();
59     }
60     
61     public void cancel () {
62         model.cancel ();
63     }
64     
65     public HelpCtx getHelpCtx () {
66         return model.getHelpCtx (tabbedPanel.getSelectedComponent ());
67     }
68     
69     public boolean dataValid () {
70         return model.isValid ();
71     }
72     
73     public boolean isChanged () {
74         return model.isChanged ();
75     }
76     
77     public Lookup getLookup () {
78         return model.getLookup ();
79     }
80     
81     void init (Lookup masterLookup) {
82         // init components
83
tabbedPanel = new WhiteTabbedPanel (model, TabbedPanel.EXPAND_SOME); // expansionPolicy
84
tabbedPanel.setBorder (null);
85         tabbedPanel.addActionListener (new ActionListener JavaDoc () {
86             public void actionPerformed (ActionEvent JavaDoc e) {
87                 firePropertyChange (OptionsPanelController.PROP_HELP_CTX, null, null);
88             }
89         });
90         JScrollPane JavaDoc scrollPane = new JScrollPane JavaDoc (tabbedPanel);
91         scrollPane.getVerticalScrollBar ().setUnitIncrement (20);
92         
93         // define layout
94
setLayout (new BorderLayout JavaDoc ());
95         add (scrollPane, BorderLayout.CENTER);
96         
97         int preferredWith = 0;
98         Iterator JavaDoc it = model.getCategories ().iterator ();
99         while (it.hasNext ()) {
100             String JavaDoc category = (String JavaDoc) it.next ();
101             JComponent JavaDoc component = model.getPanel (category);
102             preferredWith = Math.max (
103                 preferredWith,
104                 component.getPreferredSize ().width + 22
105             );
106         }
107         setPreferredSize (new Dimension JavaDoc (preferredWith, 100));
108         model.setLoookup (masterLookup);
109     }
110 }
111
Popular Tags