Package | Description |
---|---|
org.netbeans.api.io | |
org.netbeans.spi.io | |
org.netbeans.spi.io.support |
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
As there are now two types of hyperlinks, which may be handled differently in some situations, we need some way to get info about the type and internals of hyperlinks.
Added new enum HyperlinkType and new methods into class Hyperlinks:
Besides hyperlinks based on Runnables, support also hyperlinks that are defined by an Intent instance.
Added new static methods into class Hyperlink:
Introduce new lightweight, UI-independent I/O API, recommended alternative for API module openide.io.
Introduce new SPI for custom Output Window implementations. The SPI classes are separated from API classes, so they can be easily extended in the future without breaking current code.
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();
|
The sources for the module are in the NetBeans Mercurial repositories.
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.
Read more about the implementation in the answers to architecture questions.