public interface ScreenDriver<O extends OutputManager<?>>
This interface contains all implementation-specific methods which should be
implemented from scratch for each particular driver implementation. The part
of the driver which is more hardware independent is listed in
OutputPrimitives
interface and DriverPrimitives
abstract
class.
General requirements to the implementation:
At present only character based UI is supported. Therefore, all interaction
with the driver assumes existence of some kind of character-based terminal.
All coordinates passed are coordinates of the character row and column (Y and
X respectively). All coordinates are 0-based and Y axis has down direction.
Upper left corner has coordinates (0,0) and lower right -
(@link OutputPrimitives#screenWidth()} - 1,
{OutputPrimitives.screenHeight()
- 1). There is no limitations on
actual terminal size, but at present dynamic screen size change is not
supported - once application starts it assumes that terminal has fixes size
which remains stable until application if finished. Particular implementation
may return terminal screen size different than phisical screen size, but
in this case it is responsible for handling of necessary
scrolling/panning/clipping, because P2J has no support for this funtionality
and assumes that entire reported by driver screen area is visible to user.
Note that requirement for fixed size of terminal screen applies even if
terminal is suspended and then resumed. Handling size changes (if necessary)
is up to the driver implementation.
Modifier and Type | Method and Description |
---|---|
void |
beep()
Provide an audible feedback to user by generating a beep signal.
|
boolean |
captureMouseEvents(boolean state)
Enable or disable capture of mouse events.
|
default ChooseFileResult |
chooseFiles(java.lang.String title,
boolean multiple,
boolean upload,
java.lang.String uploadDir,
java.lang.String[] filters)
Supported by web-based drivers.
|
void |
clear()
Clear screen.
|
default void |
clientReady()
Notify the driver that the client is ready (useful for embedded mode, to notify the embedded
app the client can handle messages).
|
O |
createOutputManager(BootstrapConfig cfg)
Get the
OutputManager instance associated with this driver. |
ChildProcessFactory |
getChildProcessFactory()
Get driver-specific child process factory.
|
ObjectStorage |
getClientStorage()
Returns the client key and value storage.
|
WidgetFactory<?> |
getFactory()
Get driver-specific widget factory.
|
long |
getHostByName(java.lang.String name)
Returns the currently connected client's machine name for session.
|
java.lang.String |
getHostName()
Returns the currently connected client's machine name for session.
|
OutputPrimitives |
getPrimitives()
Get driver-specific direct output primitives implementation.
|
java.lang.String |
getWindowSystem()
Get the default WINDOW-SYSTEM used by this driver.
|
void |
handleMouseEvent(int sourceID,
java.awt.event.MouseEvent evt)
Handle the specified event, in the context of the specified widget.
|
boolean |
inBackgroundMode()
Checks if the current driver is running in background mode.
|
boolean |
inBatchMode()
Checks if the current driver is running in batch mode.
|
void |
init()
Driver initialization.
|
boolean |
isChui()
Get screen interface type.
|
default boolean |
isWeb()
All web-based drivers return
true . |
default void |
lockMousePointer(int widgetId,
MousePtrWrapper ptr)
Lock the mouse pointer (suppress widget-specific changes) or unlock it
|
default void |
openMimeResource(boolean deleteContent,
java.lang.String mimeType,
java.lang.String uriString,
boolean embedded)
Opens the specified resource in a browser's window.
|
default void |
propagate(int windowId,
int wid,
MousePtrWrapper ptr)
Push information about the loaded mouse pointer for widget
|
KeyCode |
readKey()
Read single keystroke from keyboard.
|
void |
resetMode()
Reset current screen mode.
|
void |
resume()
Resume normal driver operation.
|
default void |
resume(boolean silent)
Resume normal driver operation.
|
default void |
setControl(boolean control)
Notify the driver which side has control (client-side (when
true ) or server,
otherwise). |
boolean |
setCursorStatus(boolean on)
Set cursor status (ON/OFF).
|
void |
setTerminalType(java.lang.String name)
Change terminal type to specified one.
|
void |
shutdown()
Perform driver shutdown.
|
void |
suspend()
Suspend all screen I/O operations.
|
default void |
suspend(boolean silent)
Suspend all screen I/O operations.
|
java.lang.String |
terminalType()
Obtain system/implementation specific terminal type string.
|
void |
updateClientMetrics(ClientMetrics metrics)
Updates the screen metrics.
|
default void |
widgetStateChanged(int widgetId)
Notification that this widget's state has changed (visibility, sensitivity, z-order).
|
O createOutputManager(BootstrapConfig cfg)
OutputManager
instance associated with this driver.cfg
- The initial configuration for this driver.boolean setCursorStatus(boolean on) throws java.lang.IllegalStateException
The implementation of this method should show/hide actual screen cursor visible to user. Remaining code assumes that actual cursor status visible to user is properly changed upon exit from this method.
on
- true
- show cursor, false
- hide cursor.true
if operation was successful.java.lang.IllegalStateException
void clear()
This method should clear the screen and perform necessary flushing of the system-specific buffers if necessary. Users of this method assume that actual screen appearance as it is visible to the user is properly changed upon exit from this method.
void beep()
There is no specific requirements to this method and actual implementation may do nothing if there is no way to perform audible notification to the user.
boolean inBatchMode()
true
for batch mode, false
otherwise.boolean inBackgroundMode()
true
for background mode, false
otherwise.KeyCode readKey()
The list of codes and detailed description is provided in Keyboard
class. The KeyProcessor
can serve as an example of the key
translation implementation.
null
if no keys were pressed since last call.void resetMode()
Upon exit from this method P2J assumes that screen is in correct state and can be used for interaction with the user.
void suspend()
void resume()
default void suspend(boolean silent)
silent
- silent mode flag value that can change driver reaction for some suspend/resume.default void resume(boolean silent)
silent
- silent mode flag value that can change driver reaction for some suspend/resume.java.lang.String terminalType()
At present this is used to implement 4GL TERMINAL function and do some terminal-specific workarounds. At present workarounds exist for "vt320" terminal type. If implementation requires no special workarounds, then it should avoid returning "vt320" as terminal type string.
void setTerminalType(java.lang.String name)
name
- OutputPrimitives getPrimitives()
WidgetFactory<?> getFactory()
ChildProcessFactory getChildProcessFactory()
ObjectStorage getClientStorage()
void init()
java.lang.String getWindowSystem()
ClientParameters
for the list
of possible values.boolean isChui()
true
is ChUI false
is GUIboolean captureMouseEvents(boolean state)
state
- true
to capture mouse events, false
to ignore them.void handleMouseEvent(int sourceID, java.awt.event.MouseEvent evt)
sourceID
- The source widget ID.evt
- The mouse event.void shutdown()
java.lang.String getHostName()
long getHostByName(java.lang.String name)
name
- The name of the host to get IP.default void lockMousePointer(int widgetId, MousePtrWrapper ptr)
widgetId
- the id of the active DropDown which caused the pointer lock or -1ptr
- the locked mouse pointer or null
for unlockdefault void propagate(int windowId, int wid, MousePtrWrapper ptr)
windowId
- to level window idwid
- widgetIdptr
- mouse pointerdefault void openMimeResource(boolean deleteContent, java.lang.String mimeType, java.lang.String uriString, boolean embedded) throws java.net.URISyntaxException
deleteContent
- Indicates if the source content will be deleted after the document is loaded by
the client.mimeType
- The resource mime type.uriString
- The string presentation of the target resource.embedded
- The document is embedded in the template document.java.net.URISyntaxException
- If the string presentation of the target resource is not formatted strictly
according to to RFC2396 and cannot be converted to a URI.default void clientReady()
default void setControl(boolean control)
true
) or server,
otherwise).control
- Flag indicating (when true
) that the client-side has control.default void widgetStateChanged(int widgetId)
void updateClientMetrics(ClientMetrics metrics)
metrics
- The instance to update.default boolean isWeb()
true
.default ChooseFileResult chooseFiles(java.lang.String title, boolean multiple, boolean upload, java.lang.String uploadDir, java.lang.String[] filters)
title
- Upload title.multiple
- true
to allow upload or selection of multiple files.upload
- When true
the selected files will be uploaded to the web server, when false
only the selected file names will be returned.uploadDir
- The directory on the web server the files will be uploaded to.filters
- Defines the file types the file input should accept. The first element denotes a filter name
and the next element defines a file specification expression.ChooseFileResult
instance.