KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > options > editor > EditorPanelController


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.editor;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import javax.swing.JComponent JavaDoc;
24 import org.netbeans.modules.options.codetemplates.CodeTemplatesPanelController;
25 import org.netbeans.modules.options.generaleditor.GeneralEditorPanelController;
26 import org.netbeans.modules.options.indentation.IndentationPanelController;
27 import org.netbeans.modules.options.macros.MacrosPanelController;
28 import org.netbeans.spi.options.OptionsPanelController;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.Lookup;
31
32
33 /**
34  * Implementation of one panel in Options Dialog.
35  *
36  * @author Jan Jancura
37  */

38 public final class EditorPanelController extends OptionsPanelController {
39
40     private GeneralEditorPanelController general = new GeneralEditorPanelController ();
41     private IndentationPanelController indentation = new IndentationPanelController ();
42     private CodeTemplatesPanelController codeTemplates = new CodeTemplatesPanelController ();
43     private MacrosPanelController macros = new MacrosPanelController ();
44     
45     
46     public void update () {
47         general.update ();
48         indentation.update ();
49         codeTemplates.update ();
50         macros.update ();
51     }
52     
53     public void applyChanges () {
54         general.applyChanges ();
55         indentation.applyChanges ();
56         codeTemplates.applyChanges ();
57         macros.applyChanges ();
58     }
59     
60     public void cancel () {
61         general.cancel ();
62         indentation.cancel ();
63         codeTemplates.cancel ();
64         macros.cancel ();
65     }
66     
67     public boolean isValid () {
68         if (!general.isValid ()) return false;
69         if (!indentation.isValid ()) return false;
70         if (!codeTemplates.isValid ()) return false;
71         if (!macros.isValid ()) return false;
72         return true;
73     }
74     
75     public boolean isChanged () {
76         if (general.isChanged ()) return true;
77         if (indentation.isChanged ()) return true;
78         if (codeTemplates.isChanged ()) return true;
79         if (macros.isChanged ()) return true;
80         return false;
81     }
82     
83     public HelpCtx getHelpCtx () {
84         return new HelpCtx ("netbeans.optionsDialog.editor");
85     }
86     
87     private EditorPanel editorPanel;
88     public JComponent JavaDoc getComponent (Lookup masterLookup) {
89         if (editorPanel == null)
90             editorPanel = new EditorPanel (
91                 general.getComponent (masterLookup),
92                 indentation.getComponent (masterLookup),
93                 codeTemplates.getComponent (masterLookup),
94                 macros.getComponent (masterLookup)
95             );
96         return editorPanel;
97     }
98
99     public void addPropertyChangeListener (PropertyChangeListener JavaDoc l) {
100         general.addPropertyChangeListener (l);
101         indentation.addPropertyChangeListener (l);
102         codeTemplates.addPropertyChangeListener (l);
103         macros.addPropertyChangeListener (l);
104     }
105
106     public void removePropertyChangeListener (PropertyChangeListener JavaDoc l) {
107         general.removePropertyChangeListener (l);
108         indentation.removePropertyChangeListener (l);
109         codeTemplates.removePropertyChangeListener (l);
110         macros.removePropertyChangeListener (l);
111     }
112 }
113
Popular Tags