public class GuiWebDriver extends AbstractGuiDriver<java.lang.Integer> implements EmbeddedWebServer, ClientProtocolHooks, EmbeddedClient, DocumentOutputStorage
Modifier and Type | Class and Description |
---|---|
private class |
GuiWebDriver.RepaintThread
Dedicated thread responsible of processing repaint requests.
|
AbstractGuiDriver.TextMetrics
Modifier and Type | Field and Description |
---|---|
private int |
activeWindowId
The active window.
|
private static java.awt.Component |
BOGUS_AWT_COMPONENT
A bogus AWT component used to raise mouse events, on notification from the JS code.
|
private NativeDimension |
desktop
Desktop bounds.
|
private java.util.Map<java.util.UUID,DocumentOutput> |
documentOutputs
Map of document outputs pending to be sent to the Javascript part of the client.
|
private boolean |
embedded
Indicates if the web client embedded mode is on or off.
|
private static java.lang.String |
FILE_SCHEMA
Define the file schema to get local resources
|
private java.util.Map<java.lang.Integer,FontMetricsHelper> |
fontMetricsCache
A cache of font metrics objects, by their remote font ID.
|
private static java.util.Set<java.lang.Integer> |
HOVER_ACTIONS
Actions for hoverable widgets
|
private java.util.Map<java.util.List<java.lang.Integer>,java.lang.Integer> |
imageSeals
Maps the image seal to the unique image identity.
|
private java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.Integer>> |
imageUsages
Image usages is a mapping of an image loaded by a client to its owner windows.
|
private java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> |
lastAnyWidgets
A map with the last widgets listening for "any mouse action" sent to the JS side in
[ windowid : [widgetId(s) ...
|
private java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> |
lastMouseWidgets
A map with the last widgets sent to the JS side in [ windowid : [widgetId : actions] ]
form.
|
private java.lang.Object |
lock
Lock object for shared syncrhonization of the web socket.
|
private static java.util.logging.Logger |
LOG
Logger.
|
private static java.lang.String |
MAIN_TARGET
Main page root target.
|
private static long |
MAX_PRINT_OUTPUT_AGE
Max age of print outputs in milliseconds.
|
private boolean |
needsNotificationOnWait
The notify-user-input state.
|
private int |
nextFontId
A counter for font IDs to be mapped on the js-side.
|
private java.util.Map<java.lang.Integer,java.util.Set<java.util.List<java.lang.Integer>>> |
ownedImages
Owned images is a mapping of a window to its owned images seals.
|
private boolean |
registerMouseWidgets
Flag indicating if
registerMouseWidgets() must be executed. |
private java.util.LinkedList<GuiWebEmulatedWindow> |
repaints
A queue of pending repaint requests which needs to be processed by the
GuiWebDriver.RepaintThread thread. |
private boolean |
taskbar
Flag indicating if the virtual desktop taskbar is shown.
|
static int |
TASKBAR_HEIGHT
Taskbar height in pixels when it exists.
|
private static java.lang.String |
tmpDir
Temporary files directory.
|
private VirtualScreen |
virtualScreen
Virtual screen for drawing in a memory
|
private GuiWebSocket |
websock
Web-Socket which provides a GUI-specific protocol for communication with the browser.
|
private EmbeddedWebServerImpl |
websrv
Delgated implementation for the embedded web server.
|
private static java.lang.String |
WELCOME_PAGE
Welcome page.
|
private java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,NativeRectangle>> |
widgetsRegions
Collects the mouse widgets belonging to a window.
|
private NativeDimension |
workarea
Work-Area bounds.
|
config, control, ews, translatedOrigin
direct, factory
Constructor and Description |
---|
GuiWebDriver(BootstrapConfig config)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addImageUsage(java.util.List<java.lang.Integer> imageHash,
int windowId)
Register a usage of the given image by the given window.
|
void |
beep()
Provide an audible feedback to user by generating a beep signal.
|
void |
cacheTextMetrics(java.util.Map<FontDetails<java.lang.Integer>,java.util.Set<java.lang.String>> texts,
java.lang.Integer windowId)
Get and cache metrics for the given texts.
|
boolean |
captureMouseEvents(boolean state)
Enable or disable capture of mouse events.
|
void |
clearMessages(int windowId)
Clear all message texts of specified window.
|
void |
clientReady()
Notify the driver that the client is ready (useful for embedded mode, to notify the embedded
app the client can handle messages).
|
java.lang.String |
clipboardContents()
Get the current contents from the OS clipboard.
|
private void |
collectWidgets(Widget w,
java.util.function.Predicate<Widget> filter,
java.util.function.Consumer<Widget> actionsCollector)
Add the widget (and all its possible children) in the specified set, maintaining z-order in
a left-to-right (topmost to bottommost) order.
|
void |
copyToClipboard(java.lang.String txt)
Copy the given text to the system clipboard.
|
FontDetails<java.lang.Integer> |
createFont(FontDetails<java.lang.Integer> details)
Create a font with the given details and register it with the driver.
|
MousePtrWrapper |
createMousePointer(java.io.InputStream data,
java.lang.String ptrName)
Load mouse pointer from the InputStream
|
void |
deliverDocumentOutput(java.util.function.Consumer<java.io.OutputStream> consumer,
java.lang.Runnable finalizer,
MediaType format)
The method delivers document output to the client.
|
DocumentOutput |
dequeueDocumentOutput(java.lang.String id)
Returns the document outputs previously enqueued with
enqueueDocumentOutput(String, DocumentOutput) . |
void |
deregisterWidget(int wid)
Deregister the specified widget for mouse events.
|
void |
deriveFont(FontDetails<java.lang.Integer> fd)
Scale the given font to match the screen resolution.
|
void |
desktopResized(int width,
int height)
Called when the desktop on the client has changed its dimensions.
|
void |
enableEvents(int[] windowIds,
boolean capture)
Enable or Disable OS-level events for the specified windows.
|
void |
enqueueDocumentOutput(java.lang.String id,
DocumentOutput docOutput)
The method stores document outputs pending to be sent to the Javascript part of FWD client.
|
NativeRectangle |
getDisplayBounds()
Since web interface is inherently a single-display setup the method
effectively returns a rectangle with top-level corner equal to 0,0.
|
NativeRectangle |
getDisplayWorkArea()
Returns an application-usable display area.
|
private int |
getMouseModifiers(int button,
int modifiersMask)
Gets the mouse modifiers mask for this event.
|
NativePoint |
getMousePosition()
Returns current mouse cursor display position relative to the display origin.
|
int |
getScreenResolution()
Reports the screen resolution in dots per inch (DPI).
|
java.lang.String |
getServerURI()
Get the embedded web server's URI.
|
int[] |
getTextWidths(java.lang.String text,
FontDetails<java.lang.Integer> fd)
Get the widths of the specified text, using the given font.
|
java.lang.Integer |
getUniqueIdForSeal(java.util.List<java.lang.Integer> imageSeal)
Gets the unique image id by its identity array.
|
VirtualScreen |
getVirtualScreen()
Returns its virtual screen that represents the physical screen in a memory
using a sRGB pixel model.
|
private java.util.Set<java.lang.Integer> |
getWebActions(Widget widget)
Returns the set of mouse actions handled by this widget.
|
void |
init()
Initialize driver.
|
void |
initDragAndDrop(ServerExports srv)
Initializes several web client specific internal variables used with drag-n-drop.
|
void |
initRemoteClient()
Called each time a connect occurs, this allows caller-controlled initialization of the
remote client.
|
void |
injectVT100Key(int keyCode,
char charCode)
Input key events when in VT100 mode.
|
boolean |
isEmbeddedClient()
Returns true if this client runs in embedded mode.
|
boolean |
isFontInstalled(java.lang.String fontName,
boolean boldFont)
Returns the boolean value if the target font is installed or not.
|
private boolean |
isInLastAnyWidgets(java.lang.Integer widgetId,
java.lang.Integer windowId)
Tests if the given any mouse widget is in the last any mouse widgets map.
|
private boolean |
isInLastMouseWidgets(java.lang.Integer widgetId,
java.lang.Integer windowId)
Tests if the given mouse widget is in the last mouse widgets map.
|
private boolean |
isInsideVisibleFrameOrStandalone(Widget wid)
Checks if the given widget is belonging to visible frame or not inside any frame, like
window decorations.
|
boolean |
isWindowDecorationSupported()
Returns true if a window can be decorated in this graphics environment, otherwise false.
|
void |
lockMousePointer(int widgetId,
MousePtrWrapper ptr)
Lock the mouse pointer (suppress widget-specific changes) or unlock it
|
void |
mapSealToUniqueId(java.util.List<java.lang.Integer> imageSeal,
java.lang.Integer uniqueId)
Maps the image identity array to the unique image id.
|
void |
moveToBottom(int windowId)
Move the specified window to the bottom of the z-order, at the OS level.
|
void |
moveToTop(int windowId,
boolean focus)
Move the specified window to the top of the z-order, at the OS level.
|
boolean |
needsExplicitTextMetricsCaching()
Returns
true if getting actual text metrics is an expensive operation for this
driver and you want to manually manage metrics cache using
GuiDriver.cacheTextMetrics(Map, Integer) . |
EmulatedWindowState |
newChildWindowEmulator(int windowId,
EmulatedWindowState parentWindow,
java.lang.String windowTitle,
boolean resizable,
boolean isShareActivationWithOwner,
boolean modal)
Create a new child window emulator.
|
EmulatedWindowState |
newEmulator(int windowId,
boolean showInTaskbar)
Create a new window emulator.
|
void |
notifyWait()
The method is called when the 4GL program execution enters a modal or wait-for event loop, in other
words when user input is expected.
|
void |
openMimeResource(java.lang.String mimeType,
java.lang.String urlString,
boolean embedded)
Opens the specified resource in a browser's window.
|
int[][] |
parseEditorContent(int widgetId,
int windowId,
int maxWidth,
java.lang.String text,
int delta,
FontDetails<java.lang.Integer> font)
Split the text for a editor widget, so that it fits the specified maximum width.
|
protected void |
postRepaint(GuiWebEmulatedWindow ews)
Post a new repaint for the specified window to the
repaints queue. |
void |
propagate(int windowId,
int wid,
MousePtrWrapper ptr)
Push information about the loaded mouse pointer for widget
|
void |
propagateWaitState(boolean isWaitState)
Propagate wait state
|
void |
publish(long subId,
java.lang.String event,
java.lang.String[] param)
Send a PUBLISH notification to a remote application.
|
void |
raiseMouseEvent(int windowId,
int mouseOp,
long tstamp,
int mouseX,
int mouseY,
int button,
int clickCount,
int modifiersMask,
int[] wheelParameters,
int widgetId)
Raise a mouse event.
|
int |
readKey()
Read single keystroke from keyboard.
|
void |
registerHoverableWidget(MouseHoverAction action)
Register this widget as being editable, so that the mouse cursor will adjust properly when
the widget is entered.
|
void |
registerMouseWidgets()
Register all the mouse-aware widgets (in all Windows) with the JS side.
|
void |
registerMoveableWidget(int wid)
Register the specified widget as a moveable widget, via mouse.
|
void |
registerResizeableWidget(int wid)
Register the specified widget as a resizeable widget, via mouse.
|
UnformattedPayload |
remoteCall(UnformattedPayload request)
This is a special API which is used to delegate a call from converted 4GL code
(via _P2J_REMOTE_CALL_ functions) to the remote side.
|
java.util.Set<java.lang.Integer> |
removeUnusedImages(int windowId)
Returns all unused images.
|
void |
resetSelection()
Reset selection boxes painting mode and return to normal drawing mode.
|
void |
restackWindows(int[] windowIds)
Force the list of all GUI windows to be stacked as in the specified order.
|
void |
saveDropTargetFile(java.lang.String name,
byte[] data,
int size)
Stores the given byte array date as file in Java temporary directory with the given name.
|
void |
saveDropTargetFile(java.lang.String name,
java.nio.channels.FileChannel channel,
int length)
Reads the data from the given file channel starting from its current position and stores
the retrieved data into the file in Java temporary directory with the given name.
|
void |
setControl(boolean control)
Notify the driver which side has control (client-side (when
true ) or server,
otherwise). |
void |
setCurrentSelection(java.lang.String txt)
Sets the current editors selection.
|
void |
setMessageText(int windowId,
java.lang.String[] message)
Add message texts of specified window.
|
void |
setNeedsNotificationOnWait(boolean newState)
The method is executed by the JS client when it requires to be notified when 4GL program execution
enters modal or wait-for event loop, in other words when user input is expected.
|
void |
setResizeableWindow(boolean resize,
int minWidth,
int minHeight,
int maxWidth,
int maxHeight)
Set the window details for resize; this includes the minimum and maximun dimensions, and
also the window's resizeable state.
|
void |
setStatusText(int windowId,
java.lang.String message)
Set status text message of specified window.
|
void |
setUploadFileSizeLimits(int single,
int total)
Setting up file size limits for cases when drag and drop needs file uploads from web client
to Java side.
|
void |
setWindowDimension(int windowId,
int width,
int height)
Set the dimension for the specified window.
|
void |
setWindowLocation(int windowId,
int x,
int y)
Set the location for the specified window.
|
void |
shutdown()
Perform driver shutdown.
|
void |
shutdownServer()
Shutdown the embedded web server.
|
void |
startDropTarget(int windowId,
int widgetId,
java.util.List<java.lang.String> fileNameList)
Initiates the process of the file list dropping for web clients.
|
java.lang.String |
startupServer(ServerKeyStore keyStore,
BootstrapConfig config,
java.lang.String host,
int port)
Startup the embedded server using the server's key store to build the web server SSL
context.
|
private void |
syncDesktopDimensions() |
private boolean |
updateCachedWidgetBounds(int windowId,
Widget widget,
NativeRectangle[] widgetBounds)
Updates the cached widgets bounds and returns true iff the cached widgets bounds has been
updated.
|
private void |
updateDesktopDimensions(int width,
int height)
Updates the class state that relies on the client desktop dimensions.
|
void |
waitInitialization()
Wait for the page to notify that it has fully initialized its JS code.
|
void |
windowActivated(int deactivatingWindowId,
int activatingWindowId)
Raise an event indicating that the target window has been activated or deactivated.
|
void |
windowIconified(int windowId,
boolean state)
Raise an event as the window was (de)iconified.
|
clear, createGreyImage, createIcon, createImage, createOutputManager, deiconifyWindow, deregisterTooltipWorkers, deregisterWindow, draw, draw, draw3DRect, drawCursor, drawEllipse, drawFromOrigin, drawHighlight, drawImage, drawLine, drawParagraph, drawRect, drawRoundRect, drawSelection, drawString, drawStringCentered, drawStringCentered, drawStringScaled, drawStringWithMnemonic, drawTextSelection, endBatch, fill3DRect, fillEllipse, fillPolygon, fillRect, fillRectAroundText, fillRoundRect, getBgColor, getBgStdColor, getChildProcessFactory, getDisplayBounds, getDisplayWorkArea, getFgColor, getFgStdColor, getFontHeight, getFontMaxWidth, getFontWidth, getFontWidths, getParagraphHeight, getPrintOutputFile, getSubImage, getSysColor, getTextHeight, getTextMetrics, getTextWidth, getTextWidths, getWindowDimension, getWindowLocation, handleMouseEvent, hasWindowEmulator, iconifyWindow, isActualTextMetricsCached, isEmptyText, isWindowVisible, listenAnyMouseEvent, makeImage, registerChildWindow, registerDirectManipulation, registerPendingTooltipWorkers, registerTooltipWorker, registerWidgetPopup, registerWindow, releaseWindow, resetComposite, resetMode, resizeWindow, resolveTextMetrics, restoreDrawingState, resume, resume, saveDrawingState, scaleFont, selectWindow, setColor, setColor, setCursorStatus, setDesktopBgColor, setDisableRedraw, setDrawingArea, setDrawingAreas, setFontStyle, setGuiFont, setIcon, setLineStroke, setLineStroke, setTextMetrics, setTitle, setWindowBounds, setWindowEnabled, setWindowLocation, setWindowVisible, setXORComposite, setXORMode, stackWindows, startBatch, suspend, suspend, translatePop, translatePush
getFactory, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, isChui, setBackgroundMode, setBatchMode, setTerminalType, terminalType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setAlwaysOnTop, setCursor, withSelectedWindow
getFactory, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, isChui, setTerminalType, terminalType
public static final int TASKBAR_HEIGHT
private static final java.util.logging.Logger LOG
private static final java.lang.String MAIN_TARGET
private static final java.lang.String WELCOME_PAGE
private static final java.lang.String FILE_SCHEMA
private static final java.awt.Component BOGUS_AWT_COMPONENT
private static final java.util.Set<java.lang.Integer> HOVER_ACTIONS
private static final long MAX_PRINT_OUTPUT_AGE
documentOutputs
form where it is later served to JS client. Print outputs are removed
from the map either upon successful delivery to the JS client or when the age extends over this value.private static java.lang.String tmpDir
private EmbeddedWebServerImpl websrv
private GuiWebSocket websock
private java.lang.Object lock
private NativeDimension desktop
private NativeDimension workarea
private VirtualScreen virtualScreen
private final java.util.Map<java.util.List<java.lang.Integer>,java.lang.Integer> imageSeals
private final java.util.Map<java.util.List<java.lang.Integer>,java.util.Set<java.lang.Integer>> imageUsages
private final java.util.Map<java.lang.Integer,java.util.Set<java.util.List<java.lang.Integer>>> ownedImages
private java.util.Map<java.lang.Integer,FontMetricsHelper> fontMetricsCache
private int nextFontId
private java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>>> lastMouseWidgets
private java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> lastAnyWidgets
private java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,NativeRectangle>> widgetsRegions
private java.util.LinkedList<GuiWebEmulatedWindow> repaints
GuiWebDriver.RepaintThread
thread.private int activeWindowId
private final boolean embedded
private boolean taskbar
private java.util.Map<java.util.UUID,DocumentOutput> documentOutputs
private volatile boolean needsNotificationOnWait
private boolean registerMouseWidgets
registerMouseWidgets()
must be executed. This is to minimize
the amount of calls, and is performed only when client-side receives control.public GuiWebDriver(BootstrapConfig config)
config
- The BootstrapConfig
configuration.public void init()
init
in interface ScreenDriver<GuiOutputManager>
init
in class AbstractDriver<GuiPrimitives,GuiOutputManager>
public void clientReady()
clientReady
in interface ScreenDriver<GuiOutputManager>
public void initRemoteClient()
Whenever the main page is loaded or re-loaded, the WebSocket will connect and we must put the virtual terminal into a known state.
initRemoteClient
in interface ClientProtocolHooks
public void waitInitialization()
waitInitialization
in interface EmbeddedWebServer
public void initDragAndDrop(ServerExports srv)
initDragAndDrop
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
srv
- Server to make config related calls.public UnformattedPayload remoteCall(UnformattedPayload request)
This API is expected to block waiting for a response.
remoteCall
in interface EmbeddedClient
request
- The request data incoming from 4GL.public void publish(long subId, java.lang.String event, java.lang.String[] param)
publish
in interface EmbeddedClient
subId
- The subscriber's ID, known by the remote application.event
- The published event name.param
- The parameters for this event.public void setStatusText(int windowId, java.lang.String message)
setStatusText
in interface EmbeddedClient
windowId
- Window ID.message
- Text message.public void setMessageText(int windowId, java.lang.String[] message)
setMessageText
in interface EmbeddedClient
windowId
- Window ID.message
- Text message.public void clearMessages(int windowId)
clearMessages
in interface EmbeddedClient
windowId
- Window ID.public void injectVT100Key(int keyCode, char charCode)
injectVT100Key
in interface ClientProtocolHooks
keyCode
- The key code from the input event.charCode
- The character code from the input event.public NativeRectangle getDisplayBounds()
public VirtualScreen getVirtualScreen()
public boolean addImageUsage(java.util.List<java.lang.Integer> imageHash, int windowId)
imageHash
- The image hash id.windowId
- The window id.public java.util.Set<java.lang.Integer> removeUnusedImages(int windowId)
windowId
- The window id.public void mapSealToUniqueId(java.util.List<java.lang.Integer> imageSeal, java.lang.Integer uniqueId)
imageSeal
- The image identity array.uniqueId
- The image unique id.public java.lang.Integer getUniqueIdForSeal(java.util.List<java.lang.Integer> imageSeal)
imageSeal
- The image identity array.public NativeRectangle getDisplayWorkArea()
public void beep()
beep
in interface ScreenDriver<GuiOutputManager>
public int readKey()
readKey
in interface ScreenDriver<GuiOutputManager>
public EmulatedWindowState newEmulator(int windowId, boolean showInTaskbar)
The method ignores the alwaysOnTop flag.
newEmulator
in class AbstractGuiDriver<java.lang.Integer>
windowId
- The window ID.showInTaskbar
- If set to true
the window will be shown in the virtual desktop's taskbar.public EmulatedWindowState newChildWindowEmulator(int windowId, EmulatedWindowState parentWindow, java.lang.String windowTitle, boolean resizable, boolean isShareActivationWithOwner, boolean modal)
newChildWindowEmulator
in class AbstractGuiDriver<java.lang.Integer>
windowId
- The window ID.parentWindow
- The parent window.windowTitle
- Title of the window emulator.resizable
- true
if the window is resizable.isShareActivationWithOwner
- Indicates whether the window shares activation state with its owner.modal
- true
if this is a modal window.public FontDetails<java.lang.Integer> createFont(FontDetails<java.lang.Integer> details)
createFont
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
details
- The font specifications.public void deriveFont(FontDetails<java.lang.Integer> fd)
deriveFont
in class AbstractGuiDriver<java.lang.Integer>
fd
- Font to scale. This instance's contained font will be modified.public int getScreenResolution()
getScreenResolution
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
public void copyToClipboard(java.lang.String txt)
copyToClipboard
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
txt
- The text to be copied.public java.lang.String clipboardContents()
clipboardContents
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
public void restackWindows(int[] windowIds)
restackWindows
in class AbstractGuiDriver<java.lang.Integer>
windowIds
- The stack order to be enforced.public void moveToTop(int windowId, boolean focus)
moveToTop
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
moveToTop
in class AbstractGuiDriver<java.lang.Integer>
windowId
- The window to be moved.focus
- If true
, the window will become the focused window
and its state changed to active.public void moveToBottom(int windowId)
moveToBottom
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
moveToBottom
in class AbstractGuiDriver<java.lang.Integer>
windowId
- The window to be moved.public void shutdown()
shutdown
in interface ScreenDriver<GuiOutputManager>
shutdown
in class AbstractGuiDriver<java.lang.Integer>
public java.lang.String startupServer(ServerKeyStore keyStore, BootstrapConfig config, java.lang.String host, int port)
There are two page handlers. One is for the root ("/") target and the other is for the index ("/index.html") target. Both load the same page index.html.
When the user is first redirected the URL is https://server:port/
and the
target is "/". The index.html page is loaded for this target.
After redirection and the main page is loaded, the URL in the browser address bar will
become https://server:port/index.html
and the corresponding target is now
"/index.html".
When the user reloads the main page within the browser environment the "/index.html" target is sent to the web server and the same main page index.html is loaded.
startupServer
in interface EmbeddedWebServer
keyStore
- The exported server KeyStore.config
- Client configuration.port
- An explicit port to start the web server or 0 to let the OS assign one.host
- An explicit host to start the web server or null
to use the server's
host.public void shutdownServer()
shutdownServer
in interface EmbeddedWebServer
public java.lang.String getServerURI()
getServerURI
in interface EmbeddedWebServer
public boolean captureMouseEvents(boolean state)
It also notifies the JS side to enable/disable mouse events.
captureMouseEvents
in interface ScreenDriver<GuiOutputManager>
captureMouseEvents
in class AbstractGuiDriver<java.lang.Integer>
state
- true
to capture mouse events, false
to ignore them.public void raiseMouseEvent(int windowId, int mouseOp, long tstamp, int mouseX, int mouseY, int button, int clickCount, int modifiersMask, int[] wheelParameters, int widgetId)
raiseMouseEvent
in interface ClientProtocolHooks
windowId
- The window ID.mouseOp
- The mouse event code.tstamp
- The event timestamp.mouseX
- The absolute mouse X for this event.mouseY
- The absolute mouse Y for this event.button
- The button which was pressed.clickCount
- The click count.modifiersMask
- The bit mask that represents the modifiers keys are pressed. The 0-bit corresponds
to the shift key, the 1-bit to the ctrl key, the 2-bit to the meta key and
the 3-bit to the alt key.wheelParameters
- The array that represents the wheel rotation amount and its unit.widgetId
- The explicit widget ID to which this event needs to be posted.public void startDropTarget(int windowId, int widgetId, java.util.List<java.lang.String> fileNameList)
startDropTarget
in interface ClientProtocolHooks
windowId
- The window ID.widgetId
- The widget ID.fileNameList
- The oredered file name list to be dropped.public void saveDropTargetFile(java.lang.String name, byte[] data, int size)
saveDropTargetFile
in interface ClientProtocolHooks
name
- The file name to create.data
- The data to store in the file.size
- The size of the to create, used to check the input array.public void saveDropTargetFile(java.lang.String name, java.nio.channels.FileChannel channel, int length)
saveDropTargetFile
in interface ClientProtocolHooks
name
- The file name to createchannel
- The file channellength
- The length of the contentprivate int getMouseModifiers(int button, int modifiersMask)
button
- The mouse button that is currently pressedmodifiersMask
- The bit mask that represents the modifiers keys are pressed. The 0-bit corresponds
to the shift key, the 1-bit to the ctrl key, the 2-bit to the meta key and
the 3-bit to the alt key.public void setWindowLocation(int windowId, int x, int y)
setWindowLocation
in interface ClientProtocolHooks
windowId
- The window ID.x
- The X coordinate of the top-left corner.y
- The Y coordinate of the top-left corner.public void setWindowDimension(int windowId, int width, int height)
setWindowDimension
in interface ClientProtocolHooks
windowId
- The window ID.width
- The window width.height
- The window height.public void windowActivated(int deactivatingWindowId, int activatingWindowId)
windowActivated
in interface ClientProtocolHooks
deactivatingWindowId
- Id of the window being deactivated, may be negative.activatingWindowId
- Id of the window being activated, always valid.public void windowIconified(int windowId, boolean state)
windowIconified
in interface ClientProtocolHooks
windowId
- The window ID.state
- true
if the window was iconified.public void desktopResized(int width, int height)
desktopResized
in interface ClientProtocolHooks
width
- New desktop width.height
- New desktop height.public void setControl(boolean control)
true
) or server,
otherwise).
When control is received, registerMouseWidgets()
is enabled.
setControl
in interface ScreenDriver<GuiOutputManager>
setControl
in class AbstractGuiDriver<java.lang.Integer>
control
- Flag indicating (when true
) that the client-side has control.public void registerMouseWidgets()
To register a widget, it must be visible, displayed and enabled, and part of a visible window.
This method is executed only when registerMouseWidgets
flag is set
(via setControl(boolean)
). Once executed, it disables this flag.
registerMouseWidgets
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
registerMouseWidgets
in class AbstractGuiDriver<java.lang.Integer>
public int[][] parseEditorContent(int widgetId, int windowId, int maxWidth, java.lang.String text, int delta, FontDetails<java.lang.Integer> font)
delta
parameter represents the start position of this text, in the editor's
content; when the full content is parsed, this will be zero.parseEditorContent
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
widgetId
- The editor's ID.windowId
- The editor's window ID.maxWidth
- The width for the content to fit (the editor's editable area).text
- The text to split into lines.delta
- The start position of this text in the editor's full content.font
- The editor's font.public void resetSelection()
resetSelection
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
public void setUploadFileSizeLimits(int single, int total)
setUploadFileSizeLimits
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
single
- Single file size limit.total
- Total file size limit for single operation.private boolean updateCachedWidgetBounds(int windowId, Widget widget, NativeRectangle[] widgetBounds)
windowId
- The target window id.widget
- The target widget with its cached bounds.widgetBounds
- On index 0, the computed bounds will be saved.private java.util.Set<java.lang.Integer> getWebActions(Widget widget)
widget
- The collected mouse widget.private boolean isInLastMouseWidgets(java.lang.Integer widgetId, java.lang.Integer windowId)
widgetId
- The widget id.windowId
- The window id.private boolean isInLastAnyWidgets(java.lang.Integer widgetId, java.lang.Integer windowId)
widgetId
- The widget id.windowId
- The window id.public void registerMoveableWidget(int wid)
This is a no-op for the web client: the work is done by registerMouseWidgets()
.
registerMoveableWidget
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
wid
- The widget ID.public void registerHoverableWidget(MouseHoverAction action)
This is a no-op for the web client: the work is done by registerMouseWidgets()
.
registerHoverableWidget
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
action
- The widget mouse action.public void propagateWaitState(boolean isWaitState)
propagateWaitState
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
isWaitState
- wait statepublic void registerResizeableWidget(int wid)
This is a no-op for the web client: the work is done by registerMouseWidgets()
.
registerResizeableWidget
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
wid
- The widget ID.public void deregisterWidget(int wid)
deregisterWidget
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
deregisterWidget
in class AbstractGuiDriver<java.lang.Integer>
wid
- The widget ID.public void setResizeableWindow(boolean resize, int minWidth, int minHeight, int maxWidth, int maxHeight)
setResizeableWindow
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
resize
- Flag indicating if the window can be resized or not.minWidth
- The window's minimum width.minHeight
- The window's minimum height.maxWidth
- The window's maximum width.maxHeight
- The window's maximum height.public void enqueueDocumentOutput(java.lang.String id, DocumentOutput docOutput)
Before the supplied print output is inserted into the storage, the method removes all outputs
older than MAX_PRINT_OUTPUT_AGE
. The actual age is calculated from the current time
stamp and the time stamp of the document output when enqueued.
enqueueDocumentOutput
in interface DocumentOutputStorage
id
- Id of the document output.docOutput
- The object that encapsulates the document output being enqueued.public DocumentOutput dequeueDocumentOutput(java.lang.String id)
enqueueDocumentOutput(String, DocumentOutput)
.
The returned entry is removed from the storage before it is returned to the caller.dequeueDocumentOutput
in interface DocumentOutputStorage
id
- Id of the document output.null
when the id is invalid or doesn't
represent a previously enqueued document output.protected void postRepaint(GuiWebEmulatedWindow ews)
repaints
queue. This will
be processed by the GuiWebDriver.RepaintThread
.ews
- The window requiring repaint.private void collectWidgets(Widget w, java.util.function.Predicate<Widget> filter, java.util.function.Consumer<Widget> actionsCollector)
w
- The parent widget.filter
- The condition predicate that must be evaluated for collected widgets.actionsCollector
- Collects a widget's action if the target is selected by the filter condition.private boolean isInsideVisibleFrameOrStandalone(Widget wid)
wid
- Widget to check.TRUE
if the widget is inside visible frame or standalone,
FALSE
otherwise.public void setCurrentSelection(java.lang.String txt)
setCurrentSelection
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
txt
- The current editors selection.public MousePtrWrapper createMousePointer(java.io.InputStream data, java.lang.String ptrName)
createMousePointer
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
data
- cursor dataptrName
- pointer namenull
public void lockMousePointer(int widgetId, MousePtrWrapper ptr)
lockMousePointer
in interface ScreenDriver<GuiOutputManager>
widgetId
- the id of the active DropDown which caused the pointer lock or -1ptr
- the locked mouse pointer or null
for unlockpublic void propagate(int windowId, int wid, MousePtrWrapper ptr)
propagate
in interface ScreenDriver<GuiOutputManager>
windowId
- to level window idwid
- widgetIdptr
- mouse pointerpublic boolean isFontInstalled(java.lang.String fontName, boolean boldFont)
isFontInstalled
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
fontName
- The target font name.boldFont
- Indicates that the bold font is queried.public void enableEvents(int[] windowIds, boolean capture)
enableEvents
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
enableEvents
in class AbstractGuiDriver<java.lang.Integer>
windowIds
- The window IDs which need to be processed.capture
- Flag indicating OS level events are captured (when true
).public boolean isWindowDecorationSupported()
isWindowDecorationSupported
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
public boolean isEmbeddedClient()
isEmbeddedClient
in interface EmbeddedClient
public NativePoint getMousePosition()
getMousePosition
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
null
public int[] getTextWidths(java.lang.String text, FontDetails<java.lang.Integer> fd)
getTextWidths
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
getTextWidths
in class AbstractGuiDriver<java.lang.Integer>
text
- The text.fd
- The font details used to draw and measure the text.public void deliverDocumentOutput(java.util.function.Consumer<java.io.OutputStream> consumer, java.lang.Runnable finalizer, MediaType format)
This implementation stores the provided consumer with
enqueueDocumentOutput(String, DocumentOutput)
and notifies the JavaScript part
to download the document output. The document output is identified with a random UUID
generated by this method.
deliverDocumentOutput
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
consumer
- Output consumer, must not be null. See above.finalizer
- Finalizer callback, may be null. See above.format
- Report output format.public void openMimeResource(java.lang.String mimeType, java.lang.String urlString, boolean embedded) throws java.net.MalformedURLException
openMimeResource
in interface ScreenDriver<GuiOutputManager>
mimeType
- The resource mime type.urlString
- The string presentation of the target resource url.embedded
- The document is embedded in the template document.MalformedURLException,
- IOException
If the string presentation of the target resource url is malformed.java.net.MalformedURLException
- If the string presentation of the target resource url is malformed.public void notifyWait()
notifyWait
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
public void setNeedsNotificationOnWait(boolean newState)
setNeedsNotificationOnWait
in interface ClientProtocolHooks
newState
- true
turns ON the notification while false
turns it OFF.public void cacheTextMetrics(java.util.Map<FontDetails<java.lang.Integer>,java.util.Set<java.lang.String>> texts, java.lang.Integer windowId)
cacheTextMetrics
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
cacheTextMetrics
in class AbstractGuiDriver<java.lang.Integer>
texts
- Map of texts for which metrics should be calculated, keyed by fonts which are used
for drawing specific texts.windowId
- ID of the parent window. Can be null
if there is no need to select a
window.public boolean needsExplicitTextMetricsCaching()
true
if getting actual text metrics is an expensive operation for this
driver and you want to manually manage metrics cache using
GuiDriver.cacheTextMetrics(Map, Integer)
.needsExplicitTextMetricsCaching
in interface GuiDriver<java.lang.Integer,java.awt.image.BufferedImage>
needsExplicitTextMetricsCaching
in class AbstractGuiDriver<java.lang.Integer>
private void syncDesktopDimensions()
private void updateDesktopDimensions(int width, int height)
width
- New desktop width.height
- New desktop height.