| java.lang.Object org.netbeans.editor.Settings
All known Subclasses: org.netbeans.editor.ext.java.JavaSettingsInitializer, org.netbeans.editor.ext.ExtSettingsInitializer, org.netbeans.editor.BaseSettingsInitializer, org.netbeans.editor.ext.html.HTMLSettingsInitializer,
Settings | public class Settings (Code) | | Configurable settings that editor uses. All the methods are static The editor
is configurable mainly by using the following static method in Settings
class:
org.netbeans.editor.Settings.setValue(Class kitClass, String settingName,
Object newValue);
kitClass - this is the class of the editor kit for which the setting is
changed. The current hierarchy of editor kits starts with the
org.netbeans.editor.BaseKit kit, the begining of the whole kit
hierarchy. There should be a different editor kit for each mime-type.
When the particular setting is not set for a given kit, then the superclass
of the given kit class is retrieved and the search for the setting value is
performed. Example: If the java document calls Settings.getValue() to
retrieve the value for TAB_SIZE setting and it passes JavaKit.class as the
kitClass parameter and the setting has no value on this level, then the super
class of the JavaKit is retrieved (by using Class.getSuperclass() call) which
is BaseKit in this case and the search for the value of TAB_SIZE setting is
performed again. It is finished by reaching the null value for the kitClass.
The null value can be also used as the kitClass parameter value. In a more
general look not only the kit-class hierarchy could be used in
Settings. Any class inheritance hierarchy could be used here
having the null as the common root.
This way the inheritance of the setting values is guaranteed. By changing the
setting value on the BaseKit level (or even on the null level), all the kit
classes that don't override the particular setting are affected.
settingName - name of the setting to change. The base setting names are
defined as public String constants in SettingsNames class. The
additional packages that extend the basic editor functionality can define
additional setting names.
newValue - new value for the setting. It must be always an object even if the
setting is logicaly the basic datatype such as int (java.lang.Integer would
be used in this case). A particular class types that can be used for the
value of the settings are documented for each setting.
WARNING! Please read carefully the description for each option you're going
to change as you can make the editor stop working if you'll change the
setting in a wrong way.
author: Miloslav Metelka version: 1.00 |
Inner Class :public static class KitAndValue | |
Inner Class :public static interface Initializer | |
Inner Class :abstract public static class AbstractInitializer implements Initializer | |
Inner Class :public static interface InitializerSorter | |
Inner Class :abstract public static class FilterInitializerSorter | |
Inner Class :public static interface Evaluator | |
Inner Class :public static interface Filter | |
Field Summary | |
final public static int | CORE_LEVEL Core level used by the settings initializers. | final public static int | EXTENSION_LEVEL Extension level used by the settings initializers. | final public static int | OPTION_LEVEL Option level used by the settings initializers. | final public static int | SYSTEM_LEVEL System level used by the settings initializers. | final public static int | USER_LEVEL User level used by the settings initializers. |
Method Summary | |
public static synchronized void | addFilter(Filter f) Add filter instance to the list of current filters. | public static synchronized void | addInitializer(Initializer i) Add the initializer at the system level and perform reset. | public static synchronized void | addInitializer(Initializer i, int level) Add initializer instance to the list of current initializers. | public static void | addSettingsChangeListener(SettingsChangeListener l) Add weak listener to listen to change of any property. | public static synchronized InitializerSorter | getInitializerSorter() Get the current initializer sorter. | public static Object | getValue(Class kitClass, String settingName) Get the value and evaluate the evaluators. | public static synchronized Object | getValue(Class kitClass, String settingName, boolean evaluateEvaluators) Get the property by searching the given kit class settings and if not
found then the settings for super class and so on.
Parameters: kitClass - editor kit class for which the value of setting should beretrieved. | public static KitAndValue[] | getValueHierarchy(Class kitClass, String settingName) | public static synchronized KitAndValue[] | getValueHierarchy(Class kitClass, String settingName, boolean evaluateEvaluators) Get array of KitAndValue objects sorted from the given kit class to its
deepest superclass and the last member can be filled whether there is
global setting (kit class of that member would be null). | public static synchronized String | initializersToString() | public static synchronized void | propagateValue(Class kitClass, String settingName, Object newValue) Set the value for the current kit and propagate it to all the children of
the given kit by removing the possible values for the setting from the
children kit setting maps. | public static synchronized void | removeFilter(Filter f) | public static synchronized void | removeInitializer(String name) Remove the initializer of the given name from all the levels where it
occurs. | public static void | removeSettingsChangeListener(SettingsChangeListener l) | public static synchronized void | reset() Reset all the settings and fire the change of the settings so that all
the listeners will be notified and will reload the settings. | public static synchronized void | setInitializerSorter(InitializerSorter initializerSorter) Set the current initializer sorter. | public static synchronized void | setValue(Class kitClass, String settingName, Object newValue) Set the new value for property on kit level. | public static synchronized void | touchValue(Class kitClass, String settingName) Don't change the value of the setting, but fire change event. | public static synchronized void | update(Runnable r) Run the given runnable. |
CORE_LEVEL | final public static int CORE_LEVEL(Code) | | Core level used by the settings initializers. This is the level used for
the base and ext editor packages initializers only.
|
EXTENSION_LEVEL | final public static int EXTENSION_LEVEL(Code) | | Extension level used by the settings initializers. This is the second
level. It should be used by all the modules that want to extend or modify
the settings but they don't install their own kits. The example can be a
module extending the popup menu of an existing kit.
|
OPTION_LEVEL | final public static int OPTION_LEVEL(Code) | | Option level used by the settings initializers. This is the third level.
It should be used by the visual options created by the IDE.
|
SYSTEM_LEVEL | final public static int SYSTEM_LEVEL(Code) | | System level used by the settings initializers. This is the (default)
first level. It should be used by all the modules that install the new
kits into the editor.
|
USER_LEVEL | final public static int USER_LEVEL(Code) | | User level used by the settings initializers. This is the fourth level.
All the initializers with this level will be called AFTER all the
initializers at the system level. All the user custom initializers should
be added at this level to guarantee they will overwrite the settings
added by the system.
|
addFilter | public static synchronized void addFilter(Filter f)(Code) | | Add filter instance to the list of current filters. If there are already
existing editor components, and you want to apply the changes that this
filter makes to these existing components, you can call reset(). However
all the changes that were made explicitly by calling setValue() will be
lost in this case.
Parameters: f - filter to add to the list of the filters |
addInitializer | public static synchronized void addInitializer(Initializer i)(Code) | | Add the initializer at the system level and perform reset.
|
addInitializer | public static synchronized void addInitializer(Initializer i, int level)(Code) | | Add initializer instance to the list of current initializers. You can
call reset() after adding the initializer to make sure it will update the
current settings with its values. However all the changes that were made
explicitly by calling setValue() will be lost in this case.
Parameters: i - initializer to add to the current list of initializers Parameters: level - initializer level. It defines in which order the initializerswill be called. There are currently three levelsCORE_LEVEL, SYSTEM_LEVEL andUSER_LEVEL. It's guaranteed that initializers withthe particular level will be called in the order shown above.The order of the initializers at the same level is given bythe order of their addition. |
addSettingsChangeListener | public static void addSettingsChangeListener(SettingsChangeListener l)(Code) | | Add weak listener to listen to change of any property. The caller must
hold the listener object in some instance variable to prevent it from
being garbage collected.
|
getInitializerSorter | public static synchronized InitializerSorter getInitializerSorter()(Code) | | Get the current initializer sorter.
|
getValue | public static Object getValue(Class kitClass, String settingName)(Code) | | Get the value and evaluate the evaluators.
|
getValue | public static synchronized Object getValue(Class kitClass, String settingName, boolean evaluateEvaluators)(Code) | | Get the property by searching the given kit class settings and if not
found then the settings for super class and so on.
Parameters: kitClass - editor kit class for which the value of setting should beretrieved. The null can be used as the root of the wholehierarchy. (which is top of kit class hierarchy) before theprocessing begins. Parameters: settingName - name of the setting for which the value should be retrieved the value of the setting |
getValueHierarchy | public static KitAndValue[] getValueHierarchy(Class kitClass, String settingName)(Code) | | Get the value hierarchy and evaluate the evaluators
|
getValueHierarchy | public static synchronized KitAndValue[] getValueHierarchy(Class kitClass, String settingName, boolean evaluateEvaluators)(Code) | | Get array of KitAndValue objects sorted from the given kit class to its
deepest superclass and the last member can be filled whether there is
global setting (kit class of that member would be null). This method is
useful for objects like keymaps that need to create all the parent
keymaps to work properly. The method can either evaluate evaluators or
leave them untouched which can become handy in some cases.
Parameters: kitClass - editor kit class for which the value of setting should beretrieved. The null can be used as the root of the wholehierarchy. Parameters: settingName - name of the setting for which the value should be retrieved Parameters: evaluateEvaluators - whether the evaluators should be evaluated or not the array containing KitAndValue instances describing theparticular setting's value on the specific kit level. |
initializersToString | public static synchronized String initializersToString()(Code) | | Debug the current initializers
|
propagateValue | public static synchronized void propagateValue(Class kitClass, String settingName, Object newValue)(Code) | | Set the value for the current kit and propagate it to all the children of
the given kit by removing the possible values for the setting from the
children kit setting maps. Note: This call only affects the settings for
the kit classes for which the kit setting map with the setting values
currently exists, i.e. when there was at least one getValue() or
setValue() call performed for any setting on that particular kit class
level. Other kit classes maps will be initialized by the particular
initializer(s) as soon as the first getValue() or setValue() will be
performed for them. However that future process will not be affected by
the current propagateValue() call. This method is useful for the visual
options that always set the value on all the kit levels without regard
whether it's necessary or not. If the value is then changed for the base
kit, it's not propagated naturally as there's a special setting This
method enables
The current implementation always fires the change regardless whether
there was real change in setting value or not.
Parameters: kitClass - editor kit class for which the value of setting should be set.When given null, it's automatically set to BaseKit.class(which is top of kit class hierarchy) before the processingbegins. Therefore you get exactly the same results forkitClass == null and kitClass == BaseKit.class. Parameters: settingName - the string used for searching the value Parameters: newValue - new value to set for the property; the value can be null toclear the value for the specified kit |
removeFilter | public static synchronized void removeFilter(Filter f)(Code) | | |
removeInitializer | public static synchronized void removeInitializer(String name)(Code) | | Remove the initializer of the given name from all the levels where it
occurs.
Parameters: name - name of the initializer sorter to remove. |
removeSettingsChangeListener | public static void removeSettingsChangeListener(SettingsChangeListener l)(Code) | | Remove listener for changes in properties
|
reset | public static synchronized void reset()(Code) | | Reset all the settings and fire the change of the settings so that all
the listeners will be notified and will reload the settings. The settings
that were changed using setValue() and propagateValue() are lost.
Initializers will be asked for the settings values when necessary.
|
setInitializerSorter | public static synchronized void setInitializerSorter(InitializerSorter initializerSorter)(Code) | | Set the current initializer sorter.
|
setValue | public static synchronized void setValue(Class kitClass, String settingName, Object newValue)(Code) | | Set the new value for property on kit level. The old and new values are
compared and if they are equal the setting is not changed and nothing is
fired.
Parameters: kitClass - editor kit class for which the value of setting should be set.The null can be used as the root of the whole hierarchy. Parameters: settingName - the string used for searching the value Parameters: newValue - new value to set for the property; the value can be null toclear the value for the specified kit |
touchValue | public static synchronized void touchValue(Class kitClass, String settingName)(Code) | | Don't change the value of the setting, but fire change event. This is
useful when there's internal change in the value object of some setting.
|
update | public static synchronized void update(Runnable r)(Code) | | Run the given runnable. All the changes in the settings are not fired
until the whole runnable completes. Nesting of update() call
is allowed. Only one firing is performed after the whole runnable
completes using the 'null triple'.
|
|
|