站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

Settings (Editor Library) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.lib/1 1.14.0 3

org.netbeans.editor
Class Settings

java.lang.Object
  extended by org.netbeans.editor.Settings

public class Settings
extends Object

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 foar 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.


Nested Class Summary
static class Settings.AbstractInitializer
          Abstract implementation of the initializer dealing with the name.
static interface Settings.Evaluator
          Evaluator can be used in cases when value of some setting depends on the value for other setting and it allows to compute the value dynamically based on the other setting(s) value.
static interface Settings.Filter
          Filter is applied on every value or KitAndValue pairs returned from getValue().
static class Settings.FilterInitializerSorter
          Initializer sorter that delegates to another sorter.
static interface Settings.Initializer
          Initializer of the settings updates the map filled with settings for the particular kit class when asked.
static interface Settings.InitializerSorter
          Sort the settings initializers that were added to the settings.
static class Settings.KitAndValue
          Kit class and value pair
 
Field Summary
static int CORE_LEVEL
          Core level used by the settings initializers.
static int EXTENSION_LEVEL
          Extension level used by the settings initializers.
static int OPTION_LEVEL
          Option level used by the settings initializers.
static int SYSTEM_LEVEL
          System level used by the settings initializers.
static int USER_LEVEL
          User level used by the settings initializers.
 
Method Summary
static void addFilter(Settings.Filter f)
          Add filter instance to the list of current filters.
static void addInitializer(Settings.Initializer i)
          Add the initializer at the system level and perform reset.
static void addInitializer(Settings.Initializer i, int level)
          Add initializer instance to the list of current initializers.
static void addSettingsChangeListener(SettingsChangeListener l)
          Add weak listener to listen to change of any property.
static Settings.InitializerSorter getInitializerSorter()
          Get the current initializer sorter.
static Object getValue(Class kitClass, String settingName)
          Get the value and evaluate the evaluators.
static 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.
static Settings.KitAndValue[] getValueHierarchy(Class kitClass, String settingName)
          Get the value hierarchy and evaluate the evaluators
static Settings.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).
static String initializersToString()
          Debug the current initializers
static 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.
static void removeFilter(Settings.Filter f)
           
static void removeInitializer(String name)
          Remove the initializer of the given name from all the levels where it occurs.
static void removeSettingsChangeListener(SettingsChangeListener l)
          Remove listener for changes in properties
static 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.
static void setInitializerSorter(Settings.InitializerSorter initializerSorter)
          Set the current initializer sorter.
static void setValue(Class kitClass, String settingName, Object newValue)
          Set the new value for property on kit level.
static void touchValue(Class kitClass, String settingName)
          Don't change the value of the setting, but fire change event.
static void update(Runnable r)
          Run the given runnable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CORE_LEVEL

public static final int CORE_LEVEL
Core level used by the settings initializers. This is the level used for the base and ext editor packages initializers only.

See Also:
Constant Field Values

SYSTEM_LEVEL

public static final int SYSTEM_LEVEL
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.

See Also:
Constant Field Values

EXTENSION_LEVEL

public static final int EXTENSION_LEVEL
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.

See Also:
Constant Field Values

OPTION_LEVEL

public static final int OPTION_LEVEL
Option level used by the settings initializers. This is the third level. It should be used by the visual options created by the IDE.

See Also:
Constant Field Values

USER_LEVEL

public static final int USER_LEVEL
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.

See Also:
Constant Field Values
Method Detail

addInitializer

public static void addInitializer(Settings.Initializer i)
Add the initializer at the system level and perform reset.


addInitializer

public static void addInitializer(Settings.Initializer i,
                                  int level)
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
level - initializer level. It defines in which order the initializers will be called. There are currently three levels CORE_LEVEL, SYSTEM_LEVEL and USER_LEVEL. It's guaranteed that initializers with the particular level will be called in the order shown above. The order of the initializers at the same level is given by the order of their addition.

removeInitializer

public static void removeInitializer(String name)
Remove the initializer of the given name from all the levels where it occurs.

Parameters:
name - name of the initializer sorter to remove.

getInitializerSorter

public static Settings.InitializerSorter getInitializerSorter()
Get the current initializer sorter.


setInitializerSorter

public static void setInitializerSorter(Settings.InitializerSorter initializerSorter)
Set the current initializer sorter.


addFilter

public static void addFilter(Settings.Filter f)
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

removeFilter

public static void removeFilter(Settings.Filter f)

getValue

public static Object getValue(Class kitClass,
                              String settingName)
Get the value and evaluate the evaluators.


getValue

public static 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 be retrieved. The null can be used as the root of the whole hierarchy.
settingName - name of the setting for which the value should be retrieved
Returns:
the value of the setting

getValueHierarchy

public static Settings.KitAndValue[] getValueHierarchy(Class kitClass,
                                                       String settingName)
Get the value hierarchy and evaluate the evaluators


getValueHierarchy

public static Settings.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). 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 be retrieved. The null can be used as the root of the whole hierarchy.
settingName - name of the setting for which the value should be retrieved
evaluateEvaluators - whether the evaluators should be evaluated or not
Returns:
the array containing KitAndValue instances describing the particular setting's value on the specific kit level.

setValue

public static void setValue(Class kitClass,
                            String settingName,
                            Object newValue)
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.
settingName - the string used for searching the value
newValue - new value to set for the property; the value can be null to clear the value for the specified kit

touchValue

public static void touchValue(Class kitClass,
                              String settingName)
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.


propagateValue

public static 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. 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. The null can be used as the root of the whole hierarchy.
settingName - the string used for searching the value
newValue - new value to set for the property; the value can be null to clear the value for the specified kit

update

public static void update(Runnable r)
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'.


reset

public static 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. The settings that were changed using setValue() and propagateValue() are lost. Initializers will be asked for the settings values when necessary.


initializersToString

public static String initializersToString()
Debug the current initializers


addSettingsChangeListener

public static void addSettingsChangeListener(SettingsChangeListener l)
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.


removeSettingsChangeListener

public static void removeSettingsChangeListener(SettingsChangeListener l)
Remove listener for changes in properties


org.netbeans.modules.editor.lib/1 1.14.0 3

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.