public class SwingGuiDriver extends AbstractGuiDriver<java.awt.Font>
| Modifier and Type | Class and Description |
|---|---|
private static class |
SwingGuiDriver.BrowserHelper
Parses the provided command line and returns the executable and its options.
|
AbstractGuiDriver.TextMetrics, AbstractGuiDriver.UriScreenDriver.UriPathAnchor| Modifier and Type | Field and Description |
|---|---|
private java.io.ByteArrayInputStream |
beepAudioData
Cached beep sound audio data.
|
private MousePtrWrapper |
globalCursor
The application-wide cursor.
|
private java.awt.KeyboardFocusManager |
keyboardFocusManager
The driver's level keyboard focus manager.
|
private SwingKeyboardReader |
keyReader
The key reader.
|
private static CentralLogger |
LOGGER
The logger to log class events.
|
static java.lang.String |
NAME
Driver name.
|
config, control, driverWidgets, ews, LOG, tmpDir, translatedOrigin, win32MousePositionBEEP_FILE_PATH, direct, factory| Constructor and Description |
|---|
SwingGuiDriver(BootstrapConfig config)
Create a new GUI screen driver.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMessageListener(MsgBlasterPeer listener,
int windowId,
int widgetId)
Add a low-level message listener for a specific window.
|
void |
beep()
Provide an audible feedback to user by generating a beep signal.
|
private java.net.URI |
buildOpenResourcePage(java.lang.String mimeType,
java.lang.String url)
Builds the html document that embeds the target resource given by its url path and its mime
type.
|
java.lang.String |
clipboardContents()
Get the current contents from the OS clipboard.
|
void |
copyToClipboard(java.lang.String txt)
Copy the given text to the system clipboard.
|
FontDetails<java.awt.Font> |
createFont(FontDetails<java.awt.Font> specs)
Create a font with the given details and register it with the driver.
|
MousePtrWrapper |
createMousePointer(java.io.InputStream inputStream,
java.lang.String ptrName)
Load mouse pointer from the InputStream
|
<T extends DriverWidget> |
createWidget(java.lang.Class<T> widgetClass,
int widgetId)
Create a driver-implemented widget.
|
void |
createWidget(java.lang.String type,
int widgetId)
Create a driver-implemented widget.
|
void |
deliverDocumentOutput(java.util.function.Consumer<java.io.OutputStream> consumer,
java.lang.Runnable finalizer,
MediaType format,
java.lang.String uuid,
boolean promptUser)
The method delivers document output to the client.
|
void |
deregisterWidget(int wid)
Deregister the specified widget for mouse events.
|
void |
deriveFont(FontDetails<java.awt.Font> fd)
Scale the given font to match the screen resolution.
|
protected Tuple<java.lang.String,java.awt.Rectangle> |
getAdjustmentInfo(java.awt.Point p,
java.awt.Dimension dim)
Determines the type of overflow and the screen bounds.
|
MousePtrWrapper |
getGlobalCursor()
Returns the application-wide cursor.
|
NativePoint |
getMousePosition()
Returns current mouse cursor display position relative to the display origin.
|
java.lang.String |
getName()
Get the driver name.
|
private java.io.File |
getPrintOutputDir()
Returns the directory for print output.
|
int |
getScreenResolution()
Reports the screen resolution in dots per inch (DPI).
|
NativeDimension |
getVirtualScreenSize()
Returns the size of the virtual screen, i.e.
|
boolean |
isFontInstalled(java.lang.String fontName,
boolean boldFont)
Tests if the target font is known to JRE.
|
boolean |
isWindowDecorationSupported()
Returns true if a window can be decorated in this graphics environment, otherwise false.
|
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.
|
EmulatedWindowState |
newChildWindowEmulator(int windowId,
EmulatedWindowState owner,
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.
|
private static void |
openDocument(java.net.URI uri)
Open the target document given by its URI.
|
void |
openMimeResource(boolean deleteContent,
java.lang.String mimeType,
java.lang.String uriString,
boolean embedded)
Opens the specified resource in a browser's window.
|
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 |
registerHoverableWidget(MouseHoverAction action)
Register this widget as being editable, so that the mouse cursor will adjust properly when
the widget is entered.
|
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.
|
void |
removeGlobalCursor()
Assign a cursor for the entire web application, simulating Win32.SetCursor functionality.
|
void |
removeMessageListener(MsgBlasterPeer listener,
int windowId,
int widgetId)
Removes a low-level message listener for a specific window.
|
void |
restackWindows(int[] windowIds)
Force the list of all GUI windows to be stacked as in the specified order.
|
void |
setAlwaysOnTop(int windowId,
boolean topOnly,
boolean alwaysOnTop)
Makes the supplied window to be on top of other windows.
|
void |
setCurrentSelection(java.lang.String txt)
Sets the current selection.
|
void |
setCursor(java.awt.Cursor c)
Set the mouse cursor to the given one.
|
void |
setCursor(CursorType type)
Set the mouse cursor to the given type.
|
void |
setCursor(MousePtrWrapper ptr)
Set the mouse cursor
|
void |
setCursor(java.lang.String icon)
Set the mouse cursor from a given resource.
|
void |
setGlobalCursor(MousePtrWrapper ptr)
Assign a cursor for the entire web application, simulating Win32.SetCursor functionality.
|
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.
|
cacheTextMetrics, captureMouseEvents, changeSensitivity, changeVisibility, clear, copyResource, copyResource, createGreyImage, createIcon, createImage, createMouseDirectManipulationInstance, createOutputManager, deiconifyWindow, deregisterTooltipWorkers, deregisterWindow, destroyWidget, doTextShift, draw, draw, draw3DRect, drawCursor, drawEdge, drawEllipse, drawFromOrigin, drawHighlight, drawIbeam, drawImage, drawImage, drawLine, drawParagraph, drawRect, drawRoundRect, drawSelection, drawString, drawStringCentered, drawStringCentered, drawStringScaled, drawStringWithinBox, drawStringWithinBoxScaled, drawStringWithinBoxWithMnemonic, drawStringWithMnemonic, drawTextSelection, enableEvents, endBatch, fill3DRect, fillEllipse, fillPolygon, fillRect, fillRectAroundText, fillRoundRect, fitStringWithEllipsis, getBgColor, getBgStdColor, getChildProcessFactory, getDisplayBounds, getDisplayWorkArea, getDriverWidget, getFgColor, getFgStdColor, getFontHeight, getFontMaxWidth, getFontWidth, getFontWidths, getParagraphHeight, getPrintOutputFile, getSubImage, getSysColor, getTextHeight, getTextMetrics, getTextWidth, getTextWidths, getTextWidths, getWindowDimension, getWindowLocation, handleMouseEvent, hasWindowEmulator, iconifyWindow, initDragAndDrop, invokeWidgetCommand, invokeWidgetCommand, isActualTextMetricsCached, isEmptyText, isWindowVisible, makeImage, moveResource, needsExplicitTextMetricsCaching, placeWidget, registerChildWindow, registerDirectManipulation, registerEmptySelector, registerInteractiveWidgets, registerPendingTooltipWorkers, registerTooltipWorker, registerWidgetPopup, registerWindow, releaseWindow, resetComposite, resetMode, resizeWindow, resolveTextMetrics, restoreDrawingState, resume, resume, saveDrawingState, scaleFont, selectWindow, setColor, setColor, setControl, setCursorStatus, setDesktopBgColor, setDisableRedraw, setDrawingArea, setDrawingAreas, setFontStyle, setGuiFont, setIcon, setLineStroke, setLineStroke, setTextMetrics, setTitle, setWidgetAttribute, setWidgetBounds, setWin32MousePosition, setWindowBounds, setWindowEnabled, setWindowLocation, setWindowLocation, setWindowVisible, setXORComposite, setXORMode, shutdown, squeeze, stackWindows, startBatch, suspend, suspend, translatePop, translatePush, updateClientMetricsgetFactory, getHostByName, getHostName, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, init, isChui, playBeep, setBackgroundMode, setBatchMode, setTerminalType, terminalTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBasicWebPalette, getClientFontHeight, getClientTextWidth, notifyWait, parseEditorContent, propagateWaitState, resetSelection, setUploadFileSizeLimits, withSelectedWindowchooseFiles, clientReady, getFactory, getHostByName, getHostName, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, init, isChui, isEmbeddedClient, isWeb, lockMousePointer, openMimeResource, setCurrentLanguage, setTerminalType, terminalType, widgetStateChangedpublic static final java.lang.String NAME
private static final CentralLogger LOGGER
private final SwingKeyboardReader keyReader
private final java.awt.KeyboardFocusManager keyboardFocusManager
private java.io.ByteArrayInputStream beepAudioData
Clip, but in JDK 8 with PulseAudio enabled (default JDK settings), a clip
cannot be properly replayed.private MousePtrWrapper globalCursor
public SwingGuiDriver(BootstrapConfig config)
config - The BootstrapConfig configuration.public java.lang.String getName()
public void beep()
public void registerMoveableWidget(int wid)
wid - The widget ID.public void registerHoverableWidget(MouseHoverAction action)
action - The widget mouse action.public void registerResizeableWidget(int wid)
wid - The widget ID.public void setResizeableWindow(boolean resize,
int minWidth,
int minHeight,
int maxWidth,
int maxHeight)
This is a no-op for Swing.
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 deregisterWidget(int wid)
deregisterWidget in interface ScreenDriver<GuiOutputManager>deregisterWidget in class AbstractGuiDriver<java.awt.Font>wid - The widget ID.public int getScreenResolution()
public KeyCode readKey()
null if no keys were pressed since last call.public EmulatedWindowState newEmulator(int windowId, boolean showInTaskbar)
newEmulator in class AbstractGuiDriver<java.awt.Font>windowId - The window ID.showInTaskbar - This flag is not supported by swing driver.public EmulatedWindowState newChildWindowEmulator(int windowId, EmulatedWindowState owner, java.lang.String windowTitle, boolean resizable, boolean isShareActivationWithOwner, boolean modal)
newChildWindowEmulator in class AbstractGuiDriver<java.awt.Font>windowId - The window ID.owner - The owning 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.awt.Font> createFont(FontDetails<java.awt.Font> specs)
specs - The font specifications.public void deriveFont(FontDetails<java.awt.Font> fd)
deriveFont in class AbstractGuiDriver<java.awt.Font>fd - Font to scale. This instance's contained font will be modified.public void copyToClipboard(java.lang.String txt)
txt - The text to be copied.public java.lang.String clipboardContents()
public void restackWindows(int[] windowIds)
This is a no-op. Swing handle this automatically.
restackWindows in class AbstractGuiDriver<java.awt.Font>windowIds - The stack order to be enforced.public void moveToTop(int windowId,
boolean focus)
This is a no-op. Swing handle this automatically.
moveToTop in interface GuiDriver<java.awt.Font,java.awt.image.BufferedImage>moveToTop in class AbstractGuiDriver<java.awt.Font>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)
This is a no-op. Swing handle this automatically.
moveToBottom in interface GuiDriver<java.awt.Font,java.awt.image.BufferedImage>moveToBottom in class AbstractGuiDriver<java.awt.Font>windowId - The window to be moved.public NativeDimension getVirtualScreenSize()
public void setCurrentSelection(java.lang.String txt)
txt - The current selection.public MousePtrWrapper createMousePointer(java.io.InputStream inputStream, java.lang.String ptrName)
inputStream - cursor dataptrName - pointer namenullpublic void propagate(int windowId,
int wid,
MousePtrWrapper ptr)
windowId - to level window idwid - widgetIdptr - mouse pointerpublic void setCursor(MousePtrWrapper ptr)
ptr - mouse cursorpublic void setCursor(CursorType type)
type - The cursor type.public void setCursor(java.awt.Cursor c)
c - The custom cursor.public void setCursor(java.lang.String icon)
icon - The name of custom cursor.public boolean isFontInstalled(java.lang.String fontName,
boolean boldFont)
fontName - The target font name.boldFont - Indicates that the bold font is queried.public boolean isWindowDecorationSupported()
public NativePoint getMousePosition()
nullpublic void deliverDocumentOutput(java.util.function.Consumer<java.io.OutputStream> consumer,
java.lang.Runnable finalizer,
MediaType format,
java.lang.String uuid,
boolean promptUser)
This implementation outputs the document data to a file. The output directory is given by
getPrintOutputDir() and file name by AbstractGuiDriver.getPrintOutputFile(String, MediaType).
consumer - Output consumer, must not be null. See above.finalizer - Finalizer callback, may be null. See above.format - Report output format.uuid - Unique id of the operation.promptUser - if true the user is eventually prompted for a name for the output file,
otherwise a name is picked automatically if needed.public 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 this string presentation of the target resource is not formatted strictly
according to to RFC2396 and cannot be converted to a URI.public void setAlwaysOnTop(int windowId,
boolean topOnly,
boolean alwaysOnTop)
AbstractGuiDriver.stackWindows(int[]) is not fully supported by the driver.windowId - The window to be changed.topOnly - Corresponds to the WINDOW:TOP-ONLY attribute.alwaysOnTop - Corresponds to the WINDOW:ALWAYS-ON-TOP attribute.public void addMessageListener(MsgBlasterPeer listener, int windowId, int widgetId)
listener - The listener to be added.windowId - The windows id.widgetId - The widget's id.public void removeMessageListener(MsgBlasterPeer listener, int windowId, int widgetId)
listener - The listener to be removed.windowId - The windows id.widgetId - The widget's id.public void createWidget(java.lang.String type,
int widgetId)
type - The widget type, one of the LegacyResource widget names.widgetId - The widget.public <T extends DriverWidget> void createWidget(java.lang.Class<T> widgetClass, int widgetId)
widgetClass - The widget class.widgetId - The widget ID to be set.public void setGlobalCursor(MousePtrWrapper ptr)
ptr - Wrapper for the cursor.public void removeGlobalCursor()
public MousePtrWrapper getGlobalCursor()
private java.io.File getPrintOutputDir()
File object representing the output directory.private java.net.URI buildOpenResourcePage(java.lang.String mimeType,
java.lang.String url)
throws java.io.IOException
mimeType - The resource mime type.url - The url of the target resource.java.io.IOException - Iff the target IO operation is failed.private static void openDocument(java.net.URI uri)
throws java.io.IOException
uri - The document URIjava.io.IOException - Iff the target IO operation is failedprotected Tuple<java.lang.String,java.awt.Rectangle> getAdjustmentInfo(java.awt.Point p, java.awt.Dimension dim)
p - The point representing the top-left corner of the window.dim - The dimensions of the window.