IO
- Type of objects that will represent I/O instances (e.g. tabs in
output window).WRITER
- Type of writers for standard and error streams.POS
- Type of object that describes position of a character in the
output window. If the implementation does not support this type of
information, use Void
here.FOLD
- Type of object that describes a fold in output window. If the
implementation does not support this type of information, use Void
here.public interface InputOutputProvider<IO,WRITER extends PrintWriter,POS,FOLD>
Use ServiceProvider
annotation for registration.
Note: Methods of this interface can be called in any thread by the infrastructure, so implementations should ensure proper synchronization.
Modifier and Type | Method and Description |
---|---|
void |
closeIO(IO io)
Close the I/O, its output pane and release resources.
|
void |
endFold(IO io,
WRITER writer,
FOLD fold)
Finish a fold specified by its start position.
|
POS |
getCurrentPosition(IO io,
WRITER writer)
Get current position.
|
WRITER |
getErr(IO io)
Get error stream of the passed I/O.
|
String |
getId()
Get identifier of this provider.
|
Reader |
getIn(IO io)
Get input of the passed I/O.
|
IO |
getIO(String name,
boolean newIO,
Lookup lookup)
Get or create an object that encapsulates state of a single I/O instance
(e.g.
|
String |
getIODescription(IO io)
Get description of an I/O instance.
|
Lookup |
getIOLookup(IO io)
Get lookup of an I/O instance, which can contain various extensions and
additional info.
|
WRITER |
getOut(IO io)
Get output stream of the passed I/O.
|
boolean |
isIOClosed(IO io)
Check whether the I/O is closed.
|
void |
print(IO io,
WRITER writer,
String text,
Hyperlink link,
OutputColor color,
boolean printLineEnd)
Print enhanced text.
|
void |
resetIO(IO io)
Reset the I/O.
|
void |
scrollTo(IO io,
WRITER writer,
POS position)
Scroll to a position.
|
void |
setFoldExpanded(IO io,
WRITER writer,
FOLD fold,
boolean expanded)
Expand or collapse a fold.
|
void |
setIODescription(IO io,
String description)
Set description of an I/O instance.
|
void |
showIO(IO io,
Set<ShowOperation> operations)
Show output pane for the passed I/O instance.
|
FOLD |
startFold(IO io,
WRITER writer,
boolean expanded)
Start fold at the current position.
|
@NonNull String getId()
@NonNull IO getIO(@NonNull String name, boolean newIO, @NonNull Lookup lookup)
name
- Display name of the output pane.newIO
- True to always create new I/O, false to return already
existing instance if available.lookup
- Lookup with additional information.InputOutput
@NonNull Reader getIn(@NonNull IO io)
io
- I/O instance.Reader
Reader for the input entered in the output pane.@NonNull WRITER getOut(@NonNull IO io)
io
- I/O instance.PrintWriter
for the output stream.@NonNull WRITER getErr(@NonNull IO io)
io
- The I/O instance.PrintWriter
for the error stream.void print(@NonNull IO io, @NonNull WRITER writer, @NullAllowed String text, @NullAllowed Hyperlink link, @NullAllowed OutputColor color, boolean printLineEnd)
If the implementation doesn't support this feature, this method should
call something like
writer.print(text); if (printLineEnd) {writer.println();}
.
io
- The I/O instance.writer
- The Stream to write into.text
- Text to print.link
- Link which should be represented by the text, can be null for
standard text.color
- Color of the text, can be null for the default color of the
stream.printLineEnd
- True if new-line should be appended after printing
{code text}.@NonNull Lookup getIOLookup(@NonNull IO io)
io
- The I/O instance.void resetIO(@NonNull IO io)
If the implementation doesn't support this feature, this method should do nothing.
io
- The I/O instance.void showIO(@NonNull IO io, Set<ShowOperation> operations)
If the implementation doesn't support this feature, this method should do nothing.
io
- The I/O instance.operations
- Operations that should be performed to show the output.
If the set is empty, the output pane (e.g. tab) can be selected, but no
GUI component should be shown or made visible if it is currently closed
or hidden.ShowOperation
void closeIO(@NonNull IO io)
io
- The I/O instance.InputOutputProvider.isIOClosed(java.lang.Object)
boolean isIOClosed(@NonNull IO io)
io
- The I/O instance.InputOutputProvider.closeIO(java.lang.Object)
@CheckForNull POS getCurrentPosition(@NonNull IO io, @NonNull WRITER writer)
io
- The I/O instance.writer
- Output or error writer. If the streams are merged, the
value can be ignored.void scrollTo(@NonNull IO io, @NonNull WRITER writer, @NonNull POS position)
If this feature is not supported
(InputOutputProvider.getCurrentPosition(Object, PrintWriter)
returns null), this
method should do nothing, it will be never called.
io
- The I/O instance.writer
- Output or error writer. If the streams are merged, the
value can be ignored.position
- The position to scroll to.InputOutputProvider.getCurrentPosition(java.lang.Object, java.io.PrintWriter)
@CheckForNull FOLD startFold(@NonNull IO io, @NonNull WRITER writer, boolean expanded)
io
- The I/O instance.writer
- Output or error writer. If the streams are merged, the
value can be ignored.expanded
- True if the new fold should be expanded by default, false
if it should be collapsed.void endFold(@NonNull IO io, @NonNull WRITER writer, @NonNull FOLD fold)
If this feature is not supported
(InputOutputProvider.startFold(Object, PrintWriter, boolean)
returns null), this
method should do nothing, it will be never called.
io
- The I/O instance.writer
- Output or error writer. If the streams are merged, the
value can be ignored.fold
- The fold to finish.void setFoldExpanded(@NonNull IO io, @NonNull WRITER writer, FOLD fold, boolean expanded)
If this feature is not supported
(InputOutputProvider.startFold(Object, PrintWriter, boolean)
returns null), this
method should do nothing, it will be never called.
io
- The I/O instance.writer
- Output or error writer. If the streams are merged, the
value can be ignored.fold
- The fold to finish.expanded
- True to expand the fold, false to collapse the fold.@CheckForNull String getIODescription(@NonNull IO io)
io
- The I/O instance.void setIODescription(@NonNull IO io, @NullAllowed String description)
If this feature is not supported, this method should do nothing.
io
- The I/O instance.description
- The description, can be null.InputOutputProvider.getIODescription(java.lang.Object)