editor/settings/storage module provides friend
comprising classes in the
package. It also defines the structure of the settings storage and the structure
of XML files with settings. The following XML files are supported.
-//NetBeans//DTD Editor Fonts and Colors settings 1.1//EN
-//NetBeans//DTD Editor KeyBindings settings 1.1//EN
The setting files are stored in
MimeLookup in the folders hierarchy
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
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.
editor/settings/storage module dedicates a special folder for
each profile and stores all the profile related files in that folder.
The module provides a special treatment for profiles with names starting with
"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
starts with the
"test*_" string (e.g.
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
test*_ string, but it contains
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.
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
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.
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
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
nbeditor-settings-ColoringType, which value can
highlight. If a coloring file does
not specify this attribute it is automatically expected to contain token-related
Generally, the files with default values are stored in
subfolders while the files with user changes are stored directly in the
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.
coloring.xml- defines colorings used for rendering tokens from a particular language (i.e. mime type).
defaultColoring.xml- defines language neutral colorings, which can be used as fallback for language specific colorings. This file can only be specified in the
Editors/<profile-name>/Defaultsfolders. If specified in a mime type subfolder it will be ignored.
editorColoring.xml- defines colorings that do not apply for tokens. These colorings define for example the color for highlighting the row with a caret, etc. They are not mime type specific and can only be specified in the
Editors/<profile-name>/Defaultsfolders. If specified in a mime type subfolder it will be ignored.
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
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
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
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
The rules for its use follow.
nbeditor-settings-targetOSis loaded on all platforms. All such files will be loaded exactly in the same order as they appear on the system filesystem.
nbeditor-settings-targetOSattribute, but its value does not correspond to the current Operating System, the file is ignored.
nbeditor-settings-targetOSattribute and its value designates the current Operating System, the file will be loaded. Furthermore, any such a file will be loaded after other files in the same folder that do not define this attribute and therefore its settings will override settings from those other files.
nbeditor-settings-targetOSattribute and are eligible for loading on the current Operating System, they will be loaded in the same order as they appear on the system filesystem.
The available values that can be used for the
attribute are the string names of the
OS_* constants in
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>Question (arch-usecases): Describe the main use cases of the new API. Who will use it under what circumstances? What kind of code would typically need to be written to use the module? Answer:
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.
Various modules need to provide predefined font a colors for text tokens from
languages they support. An example of such a module is
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.
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.Question (arch-time): What are the time estimates of the work? Answer: The modules is available in CVS trunk. Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented? Answer: There are unit tests available covering the module's functionality. Question (arch-where): Where one can find sources for your module? Answer:
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
These modules are required in project.xml:
The module stores settings in its own XML files in the folders hierarchy under
Editors folder on the default file system. Changes in
settings are stored as differences from the default values.
The legacy settings are not handled by this module. The editor module itself supports the legacy settings and combines them with the new ones.Question (compat-deprecation): How the introduction of your project influences functionality provided by previous version of the product? Answer: No changes.
java.io.Filedirectly? Answer: No. Question (resources-layer): Does your module provide own layer? Does it create any files or folders in it? What it is trying to communicate by that and with which components? Answer: Yes. The layer is used for registering DTDs in the Netbeans catalog and MIME type resolvers for editor settings files. Question (resources-read): Does your module read any resources from layers? For what purpose? Answer: Yes. It reads settings files. Please see the format types descriptions here. Question (resources-mask): Does your module mask/hide/override any resources provided by other modules in their layers? Answer: No. Question (resources-preferences): Does your module uses preferences via Preferences API? Does your module use NbPreferences or or regular JDK Preferences ? Does it read, write or both ? Does it share preferences with other modules ? If so, then why ? Answer: No.
org.openide.util.Lookupor any similar technology to find any components to communicate with? Which ones? Answer: Yes. module creates a new MimeDataProvider and plug it into the MimeLookup. Also EditorSettings implementation is registered into default lookup. Question (lookup-register): Do you register anything into lookup for other code to find? Answer: Yes. The implementation of
MimeDataProvideris registered via
META-INF/services. Question (lookup-remove): Do you remove entries of other modules from lookup? Answer: No.
System.getProperty) property? On a similar note, is there something interesting that you pass to
java.util.logging.Logger? Or do you observe what others log? Answer: No. Question (exec-component): Is execution of your code influenced by any (string) property of any of your components? Answer: No. Question (exec-ant-tasks): Do you define or register any ant tasks that other can use? Answer: No. Question (exec-classloader): Does your code create its own class loader(s)? Answer: No. Question (exec-reflection): Does your code use Java Reflection to execute other code? Answer: No. Question (exec-privateaccess): Are you aware of any other parts of the system calling some of your methods by reflection? Answer: No. Question (exec-process): Do you execute an external process from your module? How do you ensure that the result is the same on different platforms? Do you parse output? Do you depend on result code? Answer: No. Question (exec-introspection): Does your module use any kind of runtime type information (
instanceof, work with
java.lang.Class, etc.)? Answer: No. Question (exec-threading): What threading models, if any, does your module adhere to? How the project behaves with respect to threading? Answer: No special threading model is used. Question (security-policy): Does your functionality require modifications to the standard policy file? Answer: No. Question (security-grant): Does your code grant additional rights to some other code? Answer: No.
The module reads and writes XML files in the folders hierarchy under the
Editors folder on the default filesystem. The structure of the files
is governed by the following DTDs.
java.awt.datatransfer.Transferable? Answer: No clipboard support.