|
org.netbeans.modules.editor.settings/1 1.9 | |||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Editor Settings | |
---|---|
org.netbeans.api.editor.settings |
The editor/settings
module consists of several
EditorSettingsAPIAPI
classes for accessing editor related settings. The classes are stored in the
org.netbeans.api.editor.settings
package. Each class is responsible
for a different group of settings:
String
s) of colorings and their parameters
(i.e. AttributeSet
s).
String
s) and their bodies
(i.e. String
s).
MultiKeyBinding
s.
Each MultiKeyBinding
is a list of keyboard shortcuts associated
to an Action
.
Editor settings for a particular mime type can be obtained through MimeLookup
MimePath mimePath = MimePath.parse("text/x-java"); FontColorSettings fcs = (FontColorSettings) MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
The AttributesUtilities
class has been added.
Deprecating FontColorSettings.PROP_FONT_COLORS
. It
should have never been made public in the first place. Nobody can
listen on this property anyway and the general contract is that
settings instances in MimeLookup are immutable and if anything
changes the whole instance (e.g. FontColorSettings
) is replaced.
The module is now autoload and it needs the org.netbeans.api.editor.settings.implementation
token. This token is provided by the editor/settings/storage
module
by default.
The FontColorNames and SimpleValueNames classes used to have a default construtor, even though it had never made sense to create instances of them. The default constructors have been removed and a privat noargs constructor has been added to both of them preventing an accidental instantiation.
Editor Settings API was created. It defines settings classes, which can be looked up via mimelookup.
All editor settings are mime type specific and therefore should be retrieved
using MimeLookup
. The following example shows how to retrieve
the FontColorSettings
for java files and how to get AttributeSet
with coloring attributes for a particular coloring (i.e. in this case the
colors used for highlighting selected text)
MimePath mimePath = MimePath.parse("text/x-java"); FontColorSettings fcs = (FontColorSettings) MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class); AttributeSet coloring = fcs.getFontColors(FontColorNames.SELECTION_COLORING);
If clients need to react on changes in editor settings they can attach LookupListener
to the LookupResult
they got for their particular settings class
from MimeLookup
. The following example shows how to do it.
MimePath mimePath = MimePath.parse("text/x-java"); Lookup lookup = MimeLookup.getLookup(mimePath); LookupResult result = lookup.lookup(new Lookup.Template(FontColorSettings.class)); result.addLookupListener(new LookupListener() { public void resultChanged(LookupEvent ev) { //... the client's response to the settings change } });
The FontColorSettings
class implementor is responsible and will create
a new instance of FontColorSettings
whenever some coloring will change.
This new instance will be placed in MimeLookup
replacing the old one.
|
The sources for the module are in NetBeans CVS in editor/settings directory.
Read more about the implementation in the answers to architecture questions.
|
org.netbeans.modules.editor.settings/1 1.9 | |||||||||
PREV NEXT | FRAMES NO FRAMES |