KickJava   Java API By Example, From Geeks To Geeks.

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


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.editor.options;
21
22 import java.io.IOException JavaDoc;
23 import java.io.ObjectInput JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import org.netbeans.editor.Settings;
27 import org.openide.options.ContextSystemOption;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30 import org.openide.text.PrintSettings;
31 import org.netbeans.editor.EditorState;
32
33 /**
34 * Root node for all available editor options
35 * @deprecated the AllOptions class has been replaced by AllOptionsFolder
36 *
37 * @author Miloslav Metelka
38 * @version 1.00
39 */

40 public class AllOptions extends ContextSystemOption {
41
42     static final long serialVersionUID =-5703125420292694573L;
43
44     private static final String JavaDoc HELP_ID = "editing.global"; // !!! NOI18N
45

46     // Initialize global options
47
private transient BaseOptions baseOptions
48         = (BaseOptions)BaseOptions.findObject(BaseOptions.class, true);
49
50     /**
51      * @deprecated the AllOptions has been replaced by AllOptionsFolder
52      */

53     public AllOptions() {
54         // Dead class
55
// Add the initializer for the base options. It will not be removed
56
Settings.addInitializer(baseOptions.getSettingsInitializer(),
57             Settings.OPTION_LEVEL);
58     }
59     
60     /** Initialization of the options contains adding listener
61      * watching for adding/removing child options to <code>AllOptions</code>
62      * and <code>org.openide.text.PrintSettings</code>
63      * and adding standard (java, html, plain) child options.
64      */

65     public void init() {
66         refreshContextListeners();
67     }
68     
69     private void refreshContextListeners() {
70         PrintSettings ps = (PrintSettings) PrintSettings.findObject(PrintSettings.class, true);
71         // Start listening on AllOptions and PrintSettings
72
ContextOptionsListener.processExistingAndListen(ps);
73         ContextOptionsListener.processExistingAndListen(this);
74     }
75
76     public String JavaDoc displayName() {
77         return NbBundle.getBundle(AllOptions.class).getString("OPTIONS_all"); // NOI18N
78
}
79
80     public HelpCtx getHelpCtx () {
81         return new HelpCtx (HELP_ID);
82     }
83
84     public List JavaDoc getKeyBindingList() {
85         return baseOptions.getKeyBindingList();
86     }
87
88     public void setKeyBindingList(List JavaDoc list) {
89         baseOptions.setKeyBindingList(list);
90     }
91
92     public int getOptionsVersion() {
93         return baseOptions.getOptionsVersion();
94     }
95
96     public void setOptionsVersion(int optionsVersion) {
97         baseOptions.setOptionsVersion(optionsVersion);
98     }
99
100     public HashMap JavaDoc getEditorState() {
101         return EditorState.getStateObject();
102     }
103     
104     public void setEditorState( HashMap JavaDoc stateObject ) {
105         EditorState.setStateObject( stateObject );
106     }
107     
108     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
109         /* Make the current options version to be zero
110          * temporarily to distinguish whether the options
111          * imported were old and the setOptionsVersion()
112          * was not called or whether the options
113          * were new so the options version was set
114          * to the LATEST_OPTIONS_VERSION value.
115          */

116         baseOptions.setOptionsVersion(0);
117
118         super.readExternal(in);
119         
120         // Possibly upgrade the options
121
int ov = baseOptions.getOptionsVersion();
122         if (ov < BaseOptions.LATEST_OPTIONS_VERSION) {
123             baseOptions.upgradeOptions(ov, BaseOptions.LATEST_OPTIONS_VERSION);
124         }
125         
126         // Now they are at the latest version
127
baseOptions.setOptionsVersion(BaseOptions.LATEST_OPTIONS_VERSION);
128
129         refreshContextListeners(); // beanContext was changed in super
130

131     }
132
133 }
134
Popular Tags