|
The Input/Output API and SPI is a small module
which contains InputOutput
and related interfaces used in
driving the Output Window.
The normal implementation is org.netbeans.core.output2
.
The module contains APIs for creating output panes (e.g. output tabs in Output Window in the IDE) and for writing data into them. It also supports some advanced techniques, e.g. color text, hyperlinks, code folding, scrolling to stored positions.
NbInputOutputSPI -
SPI for providing custom implementations of output window is also included in this module, in package
org.netbeans.spi.io
The basic use-case is printing a simple text, e.g. text output of an application, into a dedicated pane in the UI, e.g. a tab in Output Window in the IDE.
InputOutput io = InputOutput.get("UseCase1", true); io.getOut().println("This is a simple output"); io.getOut().close();
Hyperlinks can be also used to invoke some code when clicked.
InputOutput io = InputOutput.get("UseCase3", true); io.getOut().print("A line containing a "); io.getOut().print("hyperlink", Hyperlink.from(new Runnable() { public void run() { System.gc(); } })); io.getOut().println(" for invocation of custom code."); io.getOut().close();
Print a color text. Users can select a predefined color for common cases (debug, warning, failure, success), or custom color specified as RGB value.
InputOutput io = InputOutput.get("UseCase4", true); io.getOut().println("Let's print some info", OutputColor.debug()); io.getOut().println("or warning with appropriate color", OutputColor.warning()); io.getOut().println("Maybe also text with custom reddish color", OutputColor.rgb(255, 16, 16)); io.getOut().close();
It is possible to reuse already created output pane and clear all the previously printed text if it is not needed any more.
InputOutput io = InputOutput.get("UseCase5", true); io.getOut().println("Let's print some text"); io.getErr().println("and reset the pane immediately."); io.reset(); io.getOut().println("The pane is now empty and we can reuse it simply"); io.getOut().close();Question (arch-time): What are the time estimates of the work? Answer:
The design, implementation, preparing unit tests and reviews will probably take several weeks.
Question (arch-quality): How will the quality of your code be tested and how are future regressions going to be prevented? Answer:Unit test will be prepared for invocable code in API classes. But most of the code is just definition of API and SPI.
Question (arch-where): Where one can find sources for your module? Answer:
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
These modules are required in project.xml:
Just the module JAR.
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:Anywhere.
Question (deploy-packages): Are packages of your module made inaccessible by not declaring them public? Answer:No; only API classes are public.
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:Normal module dependency is enough.
Availability of some implementation of the SPI is guaranteed by "OpenIDE-Module-Needs: org.netbeans.spi.io.InputOutputProvider" in the manifest of this module.
Yes. There is not much to internationalize.
Question (compat-standards): Does the module implement or define any standards? Is the implementation exact or does it deviate somehow? Answer:The module defines an 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:N/A. No settings are read or written by this module.
Question (compat-deprecation): How the introduction of your project influences functionality provided by previous version of the product? Answer:Backward compatibility of other modules is not broken.
This module should replace original I/O API module
org.openide.io
, which has the same goals, but which is
not UI independent, and which is difficult to extend.
java.io.File
directly?
Answer:
No, but the implementation may.
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:No.
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:No.
org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
IOProvider.getDefault()
asks lookup for the first instance
of InputOutputProvider
. This is normally provided by
org.netbeans.core.output2
.
No.
Question (lookup-remove): Do you remove entries of other modules from lookup? Answer:No.
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:
No.
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:
No.
Question (exec-threading): What threading models, if any, does your module adhere to? How the project behaves with respect to threading? Answer:API classes are thread safe, they mostly represent immutable objects, or delegate to the SPI.
Implementators of the SPI should ensure that their code is properly synchronized, as it can be called from any thread.
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.
None.
Question (format-dnd): Which protocols (if any) does your code understand during Drag & Drop? Answer:N/A
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:
Plain Unicode text only.
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:Scalability in GUI speed and memory consumption is probably limited only by the Output Window implementation.
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:N/A
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:No.
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:No special behavior.