Skip navigation links
org.netbeans.modules.editor.settings.storage/1 1.76.0

Editor Settings Storage
Friend, Private or Third Party

See: Description

Editor Settings Storage 
Package Description
org.netbeans.modules.editor.settings.storage.api  
org.netbeans.modules.editor.settings.storage.spi.support  

The editor/settings/storage module provides friend EditorSettingsStorageAPI comprising classes in the org.netbeans.modules.editor.settings.storage.api package. It also defines the structure of the settings storage and the structure of XML files with settings. The following XML files are supported.

Profiles and setting folders

The setting files are stored in MimeLookup in the folders hierarchy under the Editors/ folder on the default filesystem. The storage follows the main principle of MimeLookup and allows to define mime type specific settings as well as settings that apply for all editors. This is achieved by placing the setting files in the appropriate folder (i.e. in the mime type folder such as Editors/<mime-type> or in the Editors/ folder itself for the global settings).

No matter whether the files are stored in Editors/ or in a mime type specific folder their further position relative to that folder and their meaning is the same.

Both font & colors and key bindings are grouped in so called profiles that allow user switching quickly between predefined sets of colorings or key bindings. An example of profiles can be key bindings for NetBeans, Eclipse and Emacs. Each of those profiles defines keyboard shortcuts for IDE actions that are known from other products. Another example is the profiles defining normal and inverse color schemes. In Netbeans they are called NetBeans and CityLights.

The editor/settings/storage module dedicates a special folder for each profile and stores all the profile related files in that folder.

Special profiles and mime types

The module provides a special treatment for profiles with names starting with the "test" string. These profiles are handled as a temporary in-memory profiles, which are not persisted to the disk. They are mainly used for 'preview' purposes in the Options dialog.

The module also recognizes special mime paths, which String representation starts with the "test*_" string (e.g. "test123ed_text/x-java") and provides MimeLookup for those mime paths. The contents of MimeLookup for those special mime paths is basically the same as MimeLookup for the mime path without the leading test*_ string, but it contains FontColorsSettings and KeyBindingSettings instances specially constructed for the 'test' mime type. Again this is mainly used for 'preview' purposes by the Options dialog.

Since this functionality is defacto an API it is being tracked as SpecialProfilesAndMimeTypesAPI.

User changes and defaults

The editor settings storage is organized in the way that allows storing user changes separately from the default values provided by modules. This is useful when a users wants to reset their profiles back to the original values shipped with the product. This is achieved by defining a special subfolder called Defaults for every profile. The default colorings and key bindings provided by modules are then registered in this Defaults subfolder while user changes are stored directly in the profile's folder. When restoring the original values the files with user changes are simply deleted and the profile is reloaded from the default files.

Font & color files

Since version 1.10 the storage module does not require coloring files to be called any special name. The coloring profiles and files are expected to be registered by modules under a special folder called FontsColors. The structure below shows an example of registering several different coloring files for all editors and the text/x-java mime type.

    Editors
     |- FontsColors
     |   |- NetBeans
     |       |- Defaults
     |           |- foo.xml
     |           |- bar.xml
     |- text
         |- x-java
             |- FontsColors
                 |- NetBeans
                     |- Defaults
                         |- xyz.xml
                         |- abc.xml

In order to distinguish files containing token-related colorings from those with highlight-related colorings the storage module recognizes a special file attribute called nbeditor-settings-ColoringType, which value can either be token or highlight. If a coloring file does not specify this attribute it is automatically expected to contain token-related colorings.

Generally, the files with default values are stored in Defaults subfolders while the files with user changes are stored directly in the profile's folder.

The default profile for font & colors is called 'NetBeans'.

Prior to version 1.10 the storage module expected colorings in the three different types of files. They are still recognized to support backwards compatibility, but modules are suggusted to use the new registration scheme. All of those three files had the same structure, but different purpose.

Key bindings files

Since version 1.10 modules can provide their keybindings in multiple files placed under the special folder called Keybindings and its profiles' subfolders. Similarily as for colorings the files with default key bindings are stored in Defaults subfolder and user changes are stored in files directly in the profile's folder. The example below shows registration of several keybinding files for all editors and the text/x-java mime type.

    Editors
     |- Keybindings
     |   |- NetBeans
     |       |- Defaults
     |           |- foo.xml
     |           |- bar.xml
     |- text
         |- x-java
             |- Keybindings
                 |- NetBeans
                     |- Defaults
                         |- xyz.xml
                         |- abc.xml

Prior to version 1.10 the default profile for key bindings, called NetBeans, had not been stored in its own folder. Therefore the default key bindings for the NetBeans profile used to be stored directly in Editors/<mime-type>/Defaults/keybindings.xml and similarily user changes used to be stored in Editors/<mime-type>/keybindings.xml. This has been deprecated, but is still supported for backwards compatibility reasons.

Also the special mime type called text/base, has been deprecated and should not be used anymore. It is however still supported to preserve backwards compatibility.

Platform specific settings

Since 1.10 it is possible to mark setting files as applicable only on a certain platform (a.k.a. operating system). This was mainly introduced for keybindings, which are generally platform sensitive settings, but can be used for any other setting type supported by the storage module.

Some platforms (eg. Mac) define their own special rules for the use of some combinations of keystrokes (eg. ctrl+Q closes the app) that applications on that platform have to obey. NetBeans mitigates this problem by introducing a special module ide/applemenu, which is only loaded on Mac and which overrides keybindings.xml files provided by some Netbeans modules (eg. editor and java). This approach works albeit some severe limitations. However with introducing multiple setting files this would no longer be practical, which is why platform specific settings have been introduced.

The storage module recognizes a special file attribute for marking platform specific setting files called nbeditor-settings-targetOS. The rules for its use follow.

The available values that can be used for the nbeditor-settings-targetOS attribute are the string names of the OS_* constants in org.openide.util.Utilities class. So, for example the following file will only be loaded on MacOS and its settings will override settings from all other files that do not specify the target OS attribute.

<folder name="Editors">
  <folder name="Keybindings">
    <folder name="NetBeans">
      <folder name="Defaults">
        <file name="keybindings-for-mac.xml" url="...">
          <attr name="nbeditor-settings-targetOS" stringvalue="OS_MAC"/>
        </file>
      </folder>
    </folder>
  </folder>
</folder>

What is New (see all changes)?

Use Cases

New Options Dialog

The friend API provided by this module is used only by the new options dialog. It is not expected to have any other clients or users. The API gives the options dialog a read/write access to the editor settings storage allowing it to implement UI for maintaining the settings.

Defining a coloring

Various modules need to provide predefined font a colors for text tokens from languages they support. An example of such a module is java/editor which defines colorings for tokens in java files. Defining colorings is as simple as writing an XML file with the appropriate information. The example below shows how to do that.

<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE fontscolors PUBLIC "-//NetBeans//DTD Editor Fonts and Colors settings 1.2//EN" "https://netbeans.apache.org/dtds/EditorFontsColors-1_2.dtd">

<fontscolors>
    <colordef name="bg0" color="202020"/>
    <fontcolor name="mylang-keyword" foreColor="0000CC" bgColor="bg0" default="keyword">
        <font style="bold" />
    </fontcolor>
</fontscolors>

Please see the http://www.netbeans.org/dtds/EditorFontsColors-1_2.dtd for more details.

Defining a key binding

As well as providing predefined colorings modules need to provide predefined key bindings. This can be accomplished by writing another simple XML file.

<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE bindings PUBLIC "-//NetBeans//DTD Editor KeyBindings settings 1.1//EN" "http://www.netbeans.org/dtds/EditorKeyBindings-1_1.dtd">

<bindings>
    <bind actionName="goto-source" key="O-O"/>
</bindings>

Please see the http://www.netbeans.org/dtds/EditorKeyBindings-1_1.dtd for more details.

Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...
Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document?
EditorSettingsStorageAPIExportedFriend
SpecialProfilesAndMimeTypesAPIExportedFriend

Group of dtd interfaces
Interface NameIn/OutStabilitySpecified in What Document?
EditorFontsColors-1_1.dtdExportedOfficial .../dtds/EditorFontsColors-1_1.dtd

-//NetBeans//DTD Editor Fonts and Colors settings 1.1//EN

EditorKeyBindings-1_1.dtdExportedOfficial .../dtds/EditorKeyBindings-1_1.dtd

-//NetBeans//DTD Editor KeyBindings settings 1.1//EN

Implementation Details

Where are the sources for the module?

The sources for the module are in the Apache Git repositories or in the GitHub repositories.

What do other modules need to do to declare a dependency on this one, in addition to or instead of a plain module dependency?
Nothing.

Read more about the implementation in the answers to architecture questions.

Skip navigation links
org.netbeans.modules.editor.settings.storage/1 1.76.0