|
org.netbeans.modules.editor.settings/1 1.16 | |||||||||
| 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:
Strings) of colorings and their parameters
(i.e. AttributeSets).
Strings) and their bodies
(i.e. Strings).
MultiKeyBindings.
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);
Several new constants were added to EditorStyleConstants to
support drawing rectangular boxes around text in the editor.
The CodeTemplateDescription.getMimePath and a new
constructor were added to accomodate a mime path where a code
template was registered.
The EditorStyleConstants.Tooltip constant was added
allowing to specify tooltips in highlighting layers.
The CodeTemplateDescription.getUniqueId method was added
and the constructor was extended to accept uniqueId
parameter.
The CodeTemplateSettings.getCodeTemplates signature was changed
to return Collection<CodeTemplateDescription> instead
of List. Although an incompatible change this class
had never been functional and should not have been used by anybody.
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 the NetBeans Mercurial repositories.
Read more about the implementation in the answers to architecture questions.
|
org.netbeans.modules.editor.settings/1 1.16 | |||||||||
| PREV NEXT | FRAMES NO FRAMES | |||||||||