|
The API allow clients to get a structural model of a document and listen on changes of the model. The model is read-only and is incrementally updated based on changes of the document content (e.g. when user edits the document). A provider has to implement an SPI (DocumentModelProvider) for a particullar document type (e.g. XML or JSP) and then register itself into the system.
Question (arch-overall): Describe the overall architecture. Answer:The Tag Based Editor Support is a small module based on EditorLibrary module providing DocumentModelAPI.
It consists of
The API is primarily aimed to provide structural views of tags based
document types like XML/JSP/HTML which contents comprise a tree structure of nested elements.
The API allows other modules to plug in their document model provider(s).
DocumentModelProvider
is an SPI interface implemented by other module(s)
which wants to afford a structural view of a particular document type to clients.
The view is then used by clients (navigator/folding etc.) to obtain and work with structure of a particullar document.
The plug-ins are registered via declarative xml layers approach.
The views are tree-like structures consisting of DocumentElement
-s.
The DocumentElement
function as a model's elements,
living in a tree-like structure and describing pieces of the document.
They are a kind of nodes - you can traverse through them in the tree structure and
get some metadata of the related piece of document.
The heart of the API is DocumentModel
which is an entry point allowing clients to get document model structure and listen on its changes.
API:
SPI:
DocumentModelProvider
implementation for a particullar document type.Most of the work is done. The API/SPI and implementation is created, stored in cvs and is stable. However there is a need to provide some unit tests, which are not created yet.
Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented? Answer:There will be a set of unit tests covering the API/SPI classes. Regression tests will be created if it's possible and appropriate.
Question (arch-where): Where one can find sources for your module? Answer:
Sources are stored in xml/tageditorsupport
module in tag_editor_support
branch.
The Tag Based Editor Support module depends on: org.netbeans.modules.editor.mimelookup - Needed for the layer registration mechanism of providers. EditorLib - Needed for access to the Document instance which is the DocumentModel built on.
Question (dep-non-nb): What other projects outside NetBeans does this one depend on? Answer:There aren't any non-netbeans modules or libraries which this module depends on.
Question (dep-platform): On which platforms does your module run? Does it run in the same way on each? Answer:The module does work on all platforms in the same way.
Question (dep-jre): Which version of JRE do you need (1.2, 1.3, 1.4, etc.)? Answer:The module can run on the same JDK which is supported by netbeans.
Question (dep-jrejdk): Do you require the JDK or is the JRE enough? Answer:The module can run on the same JDK which is supported by netbeans. AFAIK JRE is enought.
The only module's jar file needs to be deployed.
Question (deploy-nbm): Can you deploy an NBM via the Update Center? Answer:no
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:It is enought to install the module into a shared location.
Question (deploy-packages): Are packages of your module made inaccessible by not declaring them public? Answer:
There is only org.netbeans.modules.editor.structure
package which is not declared in public-packages.
It contains code responsible for reading data from the layer creating appropriate DocumentModelProviderFactory instancies.
Only clients of the API needs to have a depenedency to it. So far there is only xml/text-edit module depending on this API (it uses it for xml navigator and folding feature)
The module provides neither any localized messages nor UI.
Question (compat-standards): Does the module implement or define any standards? Is the implementation exact or does it deviate somehow? Answer:
No new unusual standard, just layer-based xml registration and SPI
interface DocumentModelProvider
that clients has to implement.
The module has no persistable settings.
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:A DocumentModel folder is created in the appropriate folder inside /Editors/<mime-type>/. The folder is then looked up by mimeLookup to obtain DocumentModelProviderFactory instance.
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.
org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
The module only uses editor's mimeLookup to lookup DocumentModelProviderFactory instancies in the layer.
Question (lookup-register): Do you register anything into lookup for other code to find? Answer:Nothing is registered.
Question (lookup-remove): Do you remove entries of other modules from lookup? Answer:No.
System.getProperty
) property?
Answer:
There is a consistency check of the model enabled/disabled by system property org.netbeans.editor.model.enable_consistency_check
Question (exec-component): Is execution of your code influenced by any (string) property of any of your components? Answer:no.
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:no.
Question (exec-privateaccess): Are you aware of any other parts of the system calling some of your methods by reflection? Answer:no.
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:
The methods declaring javax.swing.text.Document needs in fact an instance of org.netbeans.editor.BaseDocument. There is a runtime test in DocumentModel.getDocumentModel(j.s.t.Document) which warns users that the BaseDocument is necessary by throwing an IAE exception in such case.
Question (exec-threading): What threading models, if any, does your module adhere to? Answer:The model is locked for reading during its modifications. There are no other threading issues.
Question (security-policy): Does your functionality require modifications to the standard policy file? Answer:No.
Question (security-grant): Does your code grant additional rights to some other code? Answer:No.
There are no custom protocols or file formats.
Question (format-dnd): Which protocols (if any) does your code understand during Drag & Drop? Answer:DND is not supported.
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 onjava.awt.datatransfer.Transferable
?
Answer:
there is not clipboard support.
AFAIK no.
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 model creation/update time depends on the size of the underlaying document and also on its structure.
Question (perf-limit): Are there any hard-coded or practical limits in the number or size of elements your code can handle? Answer:No.
Question (perf-mem): How much memory does your component consume? Estimate with a relation to the number of windows, etc. Answer:Each document element held by DocumentModel consumes some memory (???bytes). The entire amount depends on the size and the strucure of the text file.
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:This depends on the implementation of the DocumentModelProvider. It's updateModel method can be performed for quite long time, especially when initializing the model for the first time. It's up to the clients not to run the code from AWT thread.
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:no.
Question (perf-spi): How the performance of the plugged in code will be enforced? Answer:The providers are supposed to plug-in an effective code. There aren't any extra mechanisms to ensure the plugins uses effective mechanisms which do not last for ages.