What is this project good for?
The editor library module provides subset of editor functionality independent
on the NetBeans IDE (except few specific standalone classes).
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 library part is located under editor/lib/src folder.
It depends on the following classes from openide:
The above classes should remain to be isolated in a sense
that they operate without loading other openide classes
(if they need an implementation class they get it from Lookup).
Hyperlink SPI in
allows the editors for a particular mime-type to respond to the situation
when a user hovers over the text with a Ctrl key pressed.
The Hyperlink SPI resolves whether the text under the mouse is hyperlink-able
and defines the span of the hyperlink and the action to be performed
when the user clicks on the hyperlink.
The SPI consists of a single
class that contains a javadoc with instructions
about how to register the implementation in the xml layer for the given
mime-type (mentioned in the layer section here as well).
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?
The sources for the module are in the
NetBeans Mercurial repositories.
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 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-lib.jar - NetBeans editor library independent of the rest of the NetBeans APIs depending on the JRE only.
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.editor - core of the editor generic infrastructure; indenpendent of the NetBeans IDE.
org.netbeans.editor.ext - extra (non-essential) generic editor infrastructure; indenpendent of the NetBeans IDE.
org.netbeans.editor.ext.html - HTML editor infrastructure; independent of the NetBeans IDE.
org.netbeans.editor.ext.html.dtd - DTD parsing support for determining of the valid input at particular place of a HTML source (offered by code completion); independent of the NetBeans IDE.
org.netbeans.editor.ext.java - Java editor infrastructure; independent of the NetBeans IDE.
org.netbeans.editor.ext.plain - Plain text editor infrastructure; independent of the NetBeans IDE.
org.netbeans.editor.view.spi - A rudiment of a generic view architecture SPI though now it is only used privately in the editor module; independent of the NetBeans IDE.
Compatibility with environment
Access to resources
Lookup of components
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 deubg inserts and removals done in the document.
System property to dump thread stacks during inserts and removals done in the document.
System property to debug loading of the document from a
java.io.Reader by an
System property to debug undoing/redoing of the modifications done in the document.
System property to debug the view regions being rebuilt during document modifications.
System property to debug paint operations done in views (clipping regions sizes etc.).
System property to debug when repaints are initiated in views.
System property to debug the tokens that the drawing engine is rendering.
System property to debug particular fragments of the text being rendered by the editor's drawing engine.
System property to debug graphics operations that the editor sends to a
of the component being rendered.
System property to debug particular token modifications during the text formatting process.
System property to debug when a focus is gained and lost by the editor's caret.
System property to debug details of a focus related processing of the editor's caret (e.g. caret blinking timer etc.).
System property to debug when atomic transactions are performed over the editor's document.
System property to debug thread stacks during atomic transactions performed over the editor's document.
System property to debug execution of the editor's warmup task (e.g. time intervals that each warmup section takes etc.).
System property to debug creation of the editor's popup menu. It shows the added popup menu item's text, whether it's invisible and action that produced the item.
Obsolete now, we will remove those when time allows.
To determine the line separator on a particular platform.
To specify modifiers for which the hyperlinking should be enabled, or to switch the hyperlinking off.
Valid values are "[CSMA]+" (to specify combination of modifiers) or "off" (to switch hyperlinking off).
The client property must be defined on JTextComponent managed by the NetBeans editor.
Mouse gestures require to determine whether the point at caret is folded or not. Plain text is then selected.
The client property org.netbeans.api.fold.expander (if defined) should contains a Callable<Boolean> that
returns false, if the point is a plaintext, true otherwise. Fold expansion should be handled by the Callable.
editor.fold module uses this client property to hook into BaseCaret processing.
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.
Component client property that determines a column index where a text limit line
will be displayed. This overrides a default value from editor settings
for a particular component.
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.
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:
Are you aware of any other parts of the system calling some of
your methods by reflection?
yes. core/multiview module is retrieving value of a setting property (visibility of toolbar in editor) and is
listening on changes.
That's an undeclared dependency on editor(org.netbeans.editor.Settings).
A test is included in commit validation that checks the editor code changes.
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 (
- in the libsrc/org/netbeans/editor/ext/ToolTipSupport.java
there is a method "setText" searched in the tooltip component
that is unfortunately defined to be a generic javax.swing.JComponent,
so that the tooltip text can be propagated into it.
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 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?