站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

Editor Library - NetBeans Architecture Questions - NetBeans API Javadoc (Current Development Version)

NetBeans Architecture Answers for Editor Library module

WARNING: answering questions version 1.25 rather than the current 1.29.

Interfaces table

Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document?
EditorHyperlinkSPIExportedUnder Development

Hyperlink SPI in org.netbeans.lib.editor.hyperlink.spi 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.

EditorLibraryModuleAPIExportedUnder Development

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.

CodeFoldingAPIImportedOfficial .../architecture-summary.html

EditorUtilAPIImportedFriend

Set of various editor-related utility classes and methods.

JAXPImportedStandard .../java.sun.com/xml/jaxp/dist/1.1/docs/api/

Standard XML APIs (DOM, SAX) - distributed with the IDE (in lib/ext/xml-apis*.jar), already part of JDK 1.4 and newer).

Group of property interfaces
Interface NameIn/OutStabilitySpecified in What Document?
mimeTypeImportedStable

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.
Maintained by org.openide.text package.

Document.StreamDescriptionPropertyImportedStable

Document property containing either DataObject or FileObject from which the Document content was loaded.
Maintained by org.openide.text package.

TextLimitLineImportedPrivate

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.

DefaultEditorKit.EndOfLineStringPropertyExportedStable

Document property containing line separator that was used when the document content was loaded from a java.io.Reader by an EditorKit.read().

line-limitExportedPrivate

Document property that determines the number of characters in the longest line determined during the document loading from a reader by the editor kit.

netbeans.debug.editor.documentImportedPrivate

System property to deubg inserts and removals done in the document.

netbeans.debug.editor.document.stackImportedPrivate

System property to dump thread stacks during inserts and removals done in the document.

netbeans.debug.editor.document.readImportedPrivate

System property to debug loading of the document from a java.io.Reader by an EditorKit.

netbeans.debug.editor.document.undoImportedPrivate

System property to debug undoing/redoing of the modifications done in the document.

netbeans.debug.editor.view.rebuildImportedPrivate

System property to debug the view regions being rebuilt during document modifications.

netbeans.debug.editor.view.paintImportedPrivate

System property to debug paint operations done in views (clipping regions sizes etc.).

netbeans.debug.editor.view.repaintImportedPrivate

System property to debug when repaints are initiated in views.

netbeans.debug.editor.drawImportedPrivate

System property to debug the tokens that the drawing engine is rendering.

netbeans.debug.editor.draw.fragmentImportedPrivate

System property to debug particular fragments of the text being rendered by the editor's drawing engine.

netbeans.debug.editor.draw.graphicsImportedPrivate

System property to debug graphics operations that the editor sends to a java.awt.Graphics of the component being rendered.

netbeans.debug.editor.format.modifyImportedPrivate

System property to debug particular token modifications during the text formatting process.

netbeans.debug.editor.caret.focusImportedPrivate

System property to debug when a focus is gained and lost by the editor's caret.

netbeans.debug.editor.caret.focus.extraImportedPrivate

System property to debug details of a focus related processing of the editor's caret (e.g. caret blinking timer etc.).

netbeans.debug.editor.atomicImportedPrivate

System property to debug when atomic transactions are performed over the editor's document.

netbeans.debug.editor.atomic.stackImportedPrivate

System property to debug thread stacks during atomic transactions performed over the editor's document.

netbeans.debug.editor.warmupImportedPrivate

System property to debug execution of the editor's warmup task (e.g. time intervals that each warmup section takes etc.).

netbeans.debug.editor.popup.menuImportedPrivate

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.

netbeans.debug.exceptionsImportedPrivate

Obsolete now, we will remove those when time allows.

line.separatorImportedOfficial

To determine the line separator on a particular platform.

org.netbeans.lib.editor.hyperlink.HyperlinkOperation.activationKeyImportedPrivate

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).


General Information

    Question (arch-what): What is this project good for?

    Answer: The editor library module provides subset of editor functionality independent on the NetBeans IDE (except few specific standalone classes).

    List of the main features:

    • 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.

    Question (arch-overall): Describe the overall architecture.

    Answer: 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.

    The library part is located under editor/libsrc folder.
    It depends on the following classes from openide:

    org.openide.DialogDescriptor
    org.openide.DialogDisplayer
    org.openide.ErrorManager
    org.openide.NotifyDescriptor
    
    org.openide.util.Lookup
    org.openide.util.LookupListener
    org.openide.util.LookupEvent
    org.openide.util.NbBundle
    org.openide.util.RequestProcessor
    org.openide.util.Task
    

    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

    EditorHyperlinkSPI - Hyperlink SPI in org.netbeans.lib.editor.hyperlink.spi 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 HyperlinkProvider 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).

    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: No answer

    Question (arch-time): What are the time estimates of the work?

    Answer: No answer

    Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented?

    Answer: No answer

    Question (arch-where): Where one can find sources for your module?

    Answer:

    The sources for the module are in NetBeans CVS in editor/lib directory.


Project and platform dependencies

    Question (dep-nb): What other NetBeans projects and modules does this one depend on?

    Answer:
    EditorLibraryModuleAPI - 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.

    CodeFoldingAPI EditorUtilAPI - Set of various editor-related utility classes and methods.

    Question (dep-non-nb): What other projects outside NetBeans does this one depend on?

    Answer: JAXP - Standard XML APIs (DOM, SAX) - distributed with the IDE (in lib/ext/xml-apis*.jar), already part of JDK 1.4 and newer).

    Question (dep-platform): On which platforms does your module run? Does it run in the same way on each?

    Answer: The module is 100% pure Java and runs on any platform.

    Question (dep-jre): Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?

    Answer: Needs at least JRE 1.4.

    Question (dep-jrejdk): Do you require the JDK or is the JRE enough?

    Answer: Requires JRE only.

Deployment

    Question (deploy-jar): Do you deploy just module JAR file(s) or other files as well?

    Answer: org-netbeans-modules-editor-lib.jar - NetBeans editor library independent of the rest of the NetBeans APIs depending on the JRE only.

    Question (deploy-nbm): Can you deploy an NBM via the Update Center?

    Answer: Yes.

    Question (deploy-shared): Do you need to be installed in the shared location only, or in the user directory only, or can your module be installed anywhere?

    Answer: Module can be installed anywhere.

    Question (deploy-packages): Are packages of your module made inaccessible by not declaring them public?

    Answer: Description of public packages:
    • 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.

    Question (deploy-dependencies): 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)?

    Answer: Nothing.

Compatibility with environment

    Question (compat-i18n): Is your module correctly internationalized?

    Answer: Yes.

    Question (compat-standards): Does the module implement or define any standards? Is the implementation exact or does it deviate somehow?

    Answer: It conforms to the Swing Text Package API.

    Question (compat-version): 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?

    Answer: 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.

    Question (compat-deprecation): How the introduction of your project influences functionality provided by previous version of the product?

    Answer:

    XXX no answer for compat-deprecation


Access to resources

    Question (resources-file): Does your module use java.io.File directly?

    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:

    Question (resources-read): Does your module read any resources from layers? For what purpose?

    Answer: No.

    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:

    XXX no answer for resources-preferences


Lookup of components


Execution Environment

    Question (exec-property): Is execution of your code influenced by any environment or Java system (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:
    netbeans.debug.editor.document - System property to deubg inserts and removals done in the document.
    netbeans.debug.editor.document.stack - System property to dump thread stacks during inserts and removals done in the document.
    netbeans.debug.editor.document.read - System property to debug loading of the document from a java.io.Reader by an EditorKit. netbeans.debug.editor.document.undo - System property to debug undoing/redoing of the modifications done in the document.
    netbeans.debug.editor.view.rebuild - System property to debug the view regions being rebuilt during document modifications.
    netbeans.debug.editor.view.paint - System property to debug paint operations done in views (clipping regions sizes etc.).
    netbeans.debug.editor.view.repaint - System property to debug when repaints are initiated in views.
    netbeans.debug.editor.draw - System property to debug the tokens that the drawing engine is rendering.
    netbeans.debug.editor.draw.fragment - System property to debug particular fragments of the text being rendered by the editor's drawing engine.
    netbeans.debug.editor.draw.graphics - System property to debug graphics operations that the editor sends to a java.awt.Graphics of the component being rendered.
    netbeans.debug.editor.format.modify - System property to debug particular token modifications during the text formatting process.
    netbeans.debug.editor.caret.focus - System property to debug when a focus is gained and lost by the editor's caret.
    netbeans.debug.editor.caret.focus.extra - System property to debug details of a focus related processing of the editor's caret (e.g. caret blinking timer etc.).
    netbeans.debug.editor.atomic - System property to debug when atomic transactions are performed over the editor's document.
    netbeans.debug.editor.atomic.stack - System property to debug thread stacks during atomic transactions performed over the editor's document.
    netbeans.debug.editor.warmup - System property to debug execution of the editor's warmup task (e.g. time intervals that each warmup section takes etc.). netbeans.debug.editor.popup.menu - 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.
    netbeans.debug.exceptions - Obsolete now, we will remove those when time allows.
    line.separator - To determine the line separator on a particular platform.
    org.netbeans.lib.editor.hyperlink.HyperlinkOperation.activationKey - 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).

    Question (exec-component): Is execution of your code influenced by any (string) property of any of your components?

    Answer: There are certain document properties (javax.swing.text.Document.getProperty()) that influence the document execution:
    mimeType - 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.
    Maintained by org.openide.text package.
    Document.StreamDescriptionProperty - Document property containing either DataObject or FileObject from which the Document content was loaded.
    Maintained by org.openide.text package.
    TextLimitLine - 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.
    DefaultEditorKit.EndOfLineStringProperty - Document property containing line separator that was used when the document content was loaded from a java.io.Reader by an EditorKit.read().
    line-limit - Document property that determines the number of characters in the longest line determined during the document loading from a reader by the editor kit.

    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: Reflection is used for:
    • 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.

    Question (exec-privateaccess): Are you aware of any other parts of the system calling some of your methods by reflection?

    Answer: 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.

    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:

    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.

    Question (security-policy): Does your functionality require modifications to the standard policy file?

    Answer:

    XXX no answer for security-policy

    Question (security-grant): Does your code grant additional rights to some other code?

    Answer:

    XXX no answer for security-grant


Format of files and protocols

    Question (format-types): 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?

    Answer:

    Question (format-dnd): Which protocols (if any) does your code understand during Drag & Drop?

    Answer: None.

    Question (format-clipboard): Which data flavors (if any) does your code read from or insert to the clipboard (by access to clipboard on means calling methods on java.awt.datatransfer.Transferable?

    Answer:
    • Editor just forwards the clipboard operation requests into javax.swing.text.JTextComponent's cut(), copy() and paste() methods.

Performance and Scalability

    Question (perf-startup): Does your module run any code on startup?

    Answer: It registers an operation listener to watch for changes in dataobjects.

    Question (perf-exit): Does your module run any code on exit?

    Answer: No.

    Question (perf-scale): 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?

    Answer: 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 object.

    Question (perf-limit): Are there any hard-coded or practical limits in the number or size of elements your code can handle?

    Answer: No explicit limits. Technically, the available memory size is the limit...

    Question (perf-mem): How much memory does your component consume? Estimate with a relation to the number of windows, etc.

    Answer: Rough numbers:
    • one source file opened in the editor: 534KB

    Question (perf-wakeup): Does any piece of your code wake up periodically and do something even when the system is otherwise idle (no user interaction)?

    Answer: No.

    Question (perf-progress): Does your module execute any long-running tasks?

    Answer: Opening a editor can be quite long task.
    The creation of the text component (JEditorPane instance) has to be done in AWT event queue thread.
    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.

    Question (perf-huge_dialogs): Does your module contain any dialogs or wizards with a large number of GUI controls such as combo boxes, lists, trees, or text areas?

    Answer: No.

    Question (perf-menus): Does your module use dynamically updated context menus, or context-sensitive actions with complicated and slow enablement logic?

    Answer: The "goto declaration" and "goto source" are somewhat complicated especially during the first invocation.

    Question (perf-spi): How the performance of the plugged in code will be enforced?

    Answer: No answer

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.