What is this project good for?
The editor module provides a full-featured source text editor
that is integrated with the Form Editor, Explorer, compiler, and debugger.
List of the main features:
Describe the overall architecture.
The editor functionality are mainly implementations of the Swing Text package APIs
plus extension features such as Syntax Coloring, Code Completion,
Word Matching, Abbreviations or Macros.
- Syntax highlighting of java, HTML, XML and other languages.
- Code Completion enables to type a few characters
and then display a list of suggestions appropriate
in the given context that can be then used
to automatically complete the expression.
- Word Matching enables enables to type the beginning characters
of a word used elsewhere in the code and then have the editor
generate the rest of the word.
- Abbreviations allow to expand typed text from a few
predefined characters into a full word or phrase.
- Goto Class enables to open a Java file in the Source Editor
by typing only the class name.
The IDE helps to identify the correct package name for the class.
- The Fast Import feature enables to quickly add import statements
for Java classes in the source file.
- Goto Declaration feature allows to quickly jump to a declaration
of a variable under the cursor.
- Goto Source allows to open source file containing
definition of a type that the variable under the cursor is of.
- Code folding allows to collapse sections of the code that are
unimportant to the user at the given time.
For example in java source the collapsable sections include
imports section, inner classes, methods and javadocs.
The editor consists of a library part (located under editor/lib
and described in a separate arch document)
and the module part (under src subfolder)
that depends on NetBeans APIs specified in this document.
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?
What are the time estimates of the work?
How will the quality
of your code be tested and
how are future regressions going to be prevented?
Where one can find sources for your module?
WARNING: Question with id="arch-where" has not been answered!
Project and platform dependencies
What other NetBeans projects and modules does this one depend on?
Editor defines APIs and SPIs both by
Providing java classes in public packages for further reuse.
Most of the classes were created spontaneously (several years ago)
without fulfilling of the rules imposed on APIs and SPIs
at the present time.
There is an ongoing work to revisit the existing classes
and create stable APIs and SPIs (and possibly extract functionality
into a submodule where appropriate). However this is a long-term
task spanning several promotions.
- Being sensitive to content of certain directories in xml layer.
Set of various editor-related utility classes and methods.
What other projects outside NetBeans does this one depend on?
Standard XML APIs (DOM, SAX) - distributed with the IDE (in ../editor.lib/ext/xml-apis*.jar),
already part of JDK 1.4 and newer).
On which platforms does your module run? Does it run in the same
way on each?
The module is 100% pure Java and runs on any platform.
Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
Needs at least JRE 1.4.
Do you require the JDK or is the JRE enough?
Requires JRE only.
Do you deploy just module JAR file(s) or other files as well?
org-netbeans-modules-editor.jar - standard module jar file
Can you deploy an NBM via the Update Center?
Do you need to be installed in the shared location only, or in the user directory only,
or can your module be installed anywhere?
Module can be installed anywhere.
Are packages of your module made inaccessible by not declaring them
Description of public packages:
What do other modules need to do to declare a dependency on this one,
in addition to or instead of the normal module dependency declaration
(e.g. tokens to require)?
org.netbeans.modules.editor - NetBeans-specific editor infrastructure
org.netbeans.modules.editor.html - NetBeans-specific editor infrastructure
org.netbeans.modules.editor.java - NetBeans-specific java editor infrastructure
org.netbeans.modules.editor.options - Editor generic options support plus options for ../editor.plain, html and java editors
org.netbeans.modules.editor.plain - NetBeans-specific plain text editor infrastructure
Compatibility with environment
Is your module correctly internationalized?
Does the module implement or define any standards? Is the
implementation exact or does it deviate somehow?
It conforms to the Swing Text Package API.
Can your module coexist with earlier and future
versions of itself? Can you correctly read all old settings? Will future
versions be able to read your current settings? Can you read
or politely ignore settings stored by a future version?
Only one version of the module can be installed at a time.
The settings are shared across different versions, they are stored
in a human readable form in XML files.
How the introduction of your project influences functionality
provided by previous version of the product?
WARNING: Question with id="compat-deprecation" has not been answered!
Access to resources
Does your module use
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
Yes, files are created for menus, actions, shortcuts, annotations,
Global Goto Source action (
JavaFastOpenAction) registered into /Actions/Edit
and its shortcut into /Shortcuts folder.
Appropriate menu actions under /Menu/File, /Menu/Edit and /Menu/View.
Indentation Engines under /Services/IndentEngine folder and /Templates/Services/IndentEngine.
Editor's warm-up task under /WarmUp folder.
Editor's options and Annotation Type nodes under /UI/Services/Editing folder
Annotation Types can be registered as .xml files under Editors/AnnotationTypes.
An example of a bookmark annotation description xml file can be found
DTDs can be found
Mime-type specific editor data under /Editors/mime-type folder (e.g. /Editors/text/plain).
A special mime-type "text/base" means global level inherited by each particular mime-type.
Files and subfolders of Editors/|mime-type|:
Editor kit registration by using EditorKit.instance:
<attr name="instanceClass" stringvalue="org.netbeans.modules.html.editor.HTMLKit"/>
Popup menu items (actions) can be registered in the
Both system actions and editor's actions can be added to the popup.
The actions can be ordered using a standard filesystem ordering attributes.
<attr name="position" intvalue="100"/>
<attr name="position" intvalue="110"/>
Note: The ordering attributes should take in account the fact that
popup items for a mime type are merged with "all languages" (global)
items from the root of the hierarchy under
The editor actions are referenced by their name (
mandatory for all editor actions). For example the code below will add
the editor action for code formatting.
Since version 1.39 the editor actions, ie the actions that are installed
to every JEditorPane that acts as a Netbeans editor,
can be registered in the
<file name="org-netbeans-modules-java-editor-imports-FastImportAction.instance" />
Side bar components can be registered in the
Their appearance can be specified using two optional attributes -
"West") and boolean
scrollable. Default values are
"true" (i.e. the side bar component
will appear in the row header of a
<attr name="location" stringvalue="South"/>
<attr name="scrollable" boolvalue="false"/>
Please see layer.xml for further details.
Does your module read any resources from layers? For what purpose?
Does your module mask/hide/override any resources provided by other modules in
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 ?
WARNING: Question with id="resources-preferences" has not been answered!
instances can be registered by editors for the particular mime-types
There can be multiple providers registered and their order
will be respected during querying by the hyperlinking infrastructure
(first provider which recognizes the given offset as a hyperlinking point
will be used).
Lookup of components
Does your module use
or any similar technology to find any components to communicate with? Which ones?
In src/org/netbeans/modules/editor/EditorModule.java: Lookup.getDefault().lookup(DataLoaderPool.class)
In src/org/netbeans/modules/editor/EditorModule.java: Lookup.getDefault().lookup(DataLoaderPool.class))
In src/org/netbeans/modules/editor/EditorModule.java: Lookup.getDefault().lookup(WindowManager.class)
In src/org/netbeans/modules/editor/NbEditorKit.java: Lookup.getDefault().lookup(Keymap.class)
In src/org/netbeans/modules/editor/NbEditorKit.java: Lookup.getDefault().lookup(ClassLoader.class)
In src/org/netbeans/modules/editor/NbEditorUtilities.java: Lookup.getDefault().lookup(ErrorManager.class)
In src/org/netbeans/modules/editor/NbImplementationProvider.java: Lookup.getDefault().lookup(ClassLoader.class)
In src/org/netbeans/modules/editor/options/BaseOptions.java: Lookup.getDefault().lookup(getDefaultIndentEngineClass())
In src/org/netbeans/modules/editor/options/ColoringArrayEditorPanel.java: Lookup.getDefault().lookup(ClassLoader.class)
In src/org/netbeans/modules/editor/options/KeyBindingsEditorPanel.java: Lookup.getDefault().lookup(ClassLoader.class);
In src/org/netbeans/modules/editor/options/MIMEOptionFile.java: Lookup.getDefault().lookup(ModuleInfo.class);
Do you register anything into lookup for other code to find?
is registered using
It is an extension of
allowing to instantiate the
instances from the xml layer of the System FS for particular mime-types.
Do you remove entries of other modules from lookup?
Is execution of your code influenced by any environment or
Java system (
On a similar note, is there something interesting that you
java.util.logging.Logger? Or do you observe
what others log?
System property to debug execution of the editor's warmup task (e.g. time intervals that each warmup section takes etc.).
Obsolete now, we will remove those when time allows.
Boolean system property to set whether the search bar will close on hitting Enter key.
Is execution of your code influenced by any (string) property
of any of your components?
There are certain document properties (
that influence the document execution:
Document property containing mime-type of the particular document e.g. "text/x-java".
It allows to search for particular editor settings based on
the mime-type such as tooltip annotations providers etc.
Document property containing either
from which the
Document content was loaded.
Document property containing line separator that was used when the document content was
loaded from a
java.io.Reader by an
Document property that determines the number of characters in the longest line
determined during the document loading from a reader by the editor kit.
Following component client properties incluence the component behavior:
The component should only be displayed with the error stripe side bar.
The other side bars will not be displayed.
Do you define or register any ant tasks that other can use?
Does your code create its own class loader(s)?
Does your code use Java Reflection to execute other code?
Reflection is used for:
- in the src/org/netbeans/modules/editor/EditorModule.java
the "kitRegistryKey" field JEditorPane is accessed in order
to plug the layer.xml registration of editor kits
into the JeditorPane's method of kit registration seamlessly.
- in the src/org/netbeans/modules/editor/options/MIMEOptionFolder.java
there are two fields "TAG_ROOT" and "FILENAME" accessed by reflection
from a MIMEOptionFile class associated with a given MIMEProcessor.
This could possibly be fixed by adding corresponding package-private methods
into MIMEOptionFile abstract class and access those in the MIMEOptionFolder.
context field is accessed by reflection
Are you aware of any other parts of the system calling some of
your methods by reflection?
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?
Does your module use any kind of runtime type information (
What threading models, if any, does your module adhere to? How the
project behaves with respect to threading?
Threading model of the document model adheres to javax.swing.text.Document
interface. There can be multiple reader threads accessing
the document simultaneously but only one mutating thread at the time.
Document.render(Runnable) must be used for all the readonly operations
accessing the document. The editor fully supports org.openide.text.NbDocument.runAtomic()
and NbDocument.runAtomicAsUser() extensions that allow transactions
on top of the document.
All the UI-related tasks adhere to Swing/AWT conventions i.e. they
must be performed in EQ thread.
Does your functionality require modifications to the standard policy file?
XXX no answer for security-policy
Does your code grant additional rights to some other code?
XXX no answer for security-grant
Format of files and protocols
Which protocols and file formats (if any) does your module read or write on disk,
or transmit or receive over the network? Do you generate an ant build script?
Can it be edited and modified?
Which protocols (if any) does your code understand during Drag & Drop?
Which data flavors (if any) does your code read from or insert to
the clipboard (by access to clipboard on means calling methods on
Editor settings are stored in .xml files of custom XML format
(DTDs in /src/org/netbeans/modules/editor/resources/DTDs/Options directory)
Annotations are stored in the .xml files
(DTDs in /cvs/editor/src/org/netbeans/modules/editor/AnnotationTypes/annotation-type-1_0.dtd and
Key Bindings are stored in keybindings.xml files
- Editor just forwards the clipboard operation requests
into javax.swing.text.JTextComponent's cut(), copy() and paste() methods.
Performance and Scalability
Does your module run any code on startup?
It registers an operation listener to watch for changes in dataobjects.
Does your module run any code on exit?
Which external criteria influence the performance of your
program (size of file in editor, number of files in menu,
in source directory, etc.) and how well your code scales?
The number of characters of the source file multiplied by 2 to respect
2bytes for each unicode characters.
Each line separator adds another line element plus a position
Are there any hard-coded or practical limits in the number or size of
elements your code can handle?
No explicit limits. Technically, the available memory size is the limit...
How much memory does your component consume? Estimate
with a relation to the number of windows, etc.
Does any piece of your code wake up periodically and do something
even when the system is otherwise idle (no user interaction)?
Does your module execute any long-running tasks?
Opening a editor can be quite long task.
- one source file opened in the editor: 534KB
The creation of the text component (JEditorPane instance) has to be done in AWT event queue
Setting of the document into the text component has to be done in AWT as well
as the document is regular property and thus it must be modified in AWT only.
Other tasks during editor opening (such as parsing)
do not need to be run in the AWT and they are run on the background.
Does your module contain any dialogs or wizards with a large number of
GUI controls such as combo boxes, lists, trees, or text areas?
Does your module use dynamically updated context menus, or
context-sensitive actions with complicated and slow enablement logic?
The "goto declaration" and "goto source" are somewhat complicated
especially during the first invocation.
How the performance of the plugged in code will be enforced?