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.Uri
Modifier and Type | Field and Description |
---|---|
private java.awt.KeyboardFocusManager |
keyboardFocusManager
The driver's level keyboard focus manager.
|
private SwingKeyboardReader |
keyReader
The key reader.
|
private static java.util.logging.Logger |
LOGGER
The logger to log class events.
|
config, control, driverWidgets, ews, LOG, tmpDir, translatedOrigin
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.
|
NativePoint |
getMousePosition()
Returns current mouse cursor display position relative to the display origin.
|
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,
boolean webScale)
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 |
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 |
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, 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, registerMouseWidgets, 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, setWindowBounds, setWindowEnabled, setWindowLocation, setWindowVisible, setXORComposite, setXORMode, shutdown, stackWindows, startBatch, suspend, suspend, translatePop, translatePush, updateClientMetrics
getClientStorage, getFactory, getHostByName, getHostName, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, init, isChui, setBackgroundMode, setBatchMode, setTerminalType, terminalType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBasicWebPalette, notifyWait, parseEditorContent, propagateWaitState, resetSelection, setUploadFileSizeLimits, withSelectedWindow
chooseFiles, clientReady, getClientStorage, getFactory, getHostByName, getHostName, getPrimitives, getWindowSystem, inBackgroundMode, inBatchMode, init, isChui, isWeb, lockMousePointer, setTerminalType, terminalType, widgetStateChanged
private static final java.util.logging.Logger LOGGER
private final SwingKeyboardReader keyReader
private final java.awt.KeyboardFocusManager keyboardFocusManager
public SwingGuiDriver(BootstrapConfig config)
config
- The BootstrapConfig
configuration.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 GuiDriver<java.awt.Font,java.awt.image.BufferedImage>
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 namenull
public 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, boolean webScale)
fontName
- The target font name.boldFont
- Indicates that the bold font is queried.webScale
- Check if this font is ready for web scaling. Not needed in
this Swing environment.public boolean isWindowDecorationSupported()
public NativePoint getMousePosition()
null
public 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.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 failed