Package com.inductiveautomation.snap.ui
Class UIOwner<EVENT extends UIEvent,UITYPE>
- java.lang.Object
-
- com.inductiveautomation.snap.ui.UIOwner<EVENT,UITYPE>
-
- Direct Known Subclasses:
RMViewerOwner
,SwingOwner
public abstract class UIOwner<EVENT extends UIEvent,UITYPE> extends java.lang.Object
A base controller class class that manages a SwingPanel usually loaded from a rib file.
-
-
Field Summary
Fields Modifier and Type Field Description static UIEvent.Type
DragDrop
static UIEvent.Type
DragEnter
UIEvent.Type[]
DragEvents
static UIEvent.Type
DragExit
static UIEvent.Type
DragOver
UIEvent.Type[]
KeyEvents
static UIEvent.Type
KeyFinished
static UIEvent.Type
KeyPressed
static UIEvent.Type
KeyReleased
static UIEvent.Type
KeyTyped
static UIEvent.Type
MouseClicked
static UIEvent.Type
MouseDragged
static UIEvent.Type
MouseEntered
UIEvent.Type[]
MouseEvents
static UIEvent.Type
MouseExited
static UIEvent.Type
MouseFinished
static UIEvent.Type
MouseMoved
static UIEvent.Type
MousePressed
static UIEvent.Type
MouseReleased
-
Constructor Summary
Constructors Constructor Description UIOwner()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addKeyActionEvent(java.lang.String aName, java.lang.String aKey)
Configures an ActionEvent to be sent to owner for given name and key description (in KeyStroke string format).void
addNodeBinding(java.lang.Object anObj, java.lang.String aPropertyName, java.lang.String aKeyPath)
Adds a binding to a UI node.protected abstract UITYPE
createUI()
Creates the UI panel.void
disableEvents(java.lang.Object anObj, UIEvent.Type... theTypes)
Enables events on given object.void
enableEvents(java.lang.Object anObj, UIEvent.Type... theTypes)
Enables events on given object.protected java.lang.Object
getBindingModelValue(Binding aBinding)
Returns the key value for a given binding.protected java.lang.Object
getBindingNodeValue(Binding aBinding)
Returns the UI node value for the given binding.java.util.Map<java.lang.String,java.lang.String>
getConversionMap(java.lang.String aName)
Returns a named map to perform value conversions.protected java.lang.Object
getConversionMapKey(java.lang.String aConversionMapName, java.lang.Object aValue)
Converts a UI node value to binder object value using conversion key map.java.util.Map<java.lang.String,java.util.Map>
getConversionMaps()
Returns the map of maps, each of which is used to perform value conversions.java.lang.Object
getConversionMapValue(java.lang.String aConversionMapName, java.lang.Object aKey)
Converts a binder object value to UI node using conversion key map.java.lang.Object
getFirstFocus()
Returns the first focus UI node for when window/dialog is made visible.java.lang.Object
getModelValue(java.lang.String aKey)
Returns the model value for given key expression from this UIOwner.protected UITYPE
getNode(java.lang.Object anObj)
Returns the specific UI child node for given object (name, event or node).UITYPE
getNode(java.lang.String aName)
Returns the specific UI child node with the given name.<T extends UITYPE>
TgetNode(java.lang.String aName, java.lang.Class<T> aClass)
Returns the specific UI child node with the given name as the given class.java.lang.String
getNodeAction(java.lang.Object anObj)
Returns a node action.boolean
getNodeBoolValue(java.lang.Object anObj)
Returns the boolean value for a given name or UI node.float
getNodeFloatValue(java.lang.Object anObj)
Returns the float value for a given name or UI node.protected abstract UIHelper
getNodeHelper(java.lang.Object anObj)
Returns the helper for a given UI node.int
getNodeIntValue(java.lang.Object anObj)
Returns the int value for a given name or UI node.java.lang.String
getNodeItemDisplayKey(java.lang.Object anObj, java.lang.String aKey)
Returns the display key for given name or UI node.java.util.List
getNodeItems(java.lang.Object anObj)
Returns the items for a given name or UI node.int
getNodeSelectedIndex(java.lang.Object anObj)
Returns the selected index for given name or UI node.java.lang.Object
getNodeSelectedItem(java.lang.Object anObj)
Returns the selected item for given name or UI node.java.lang.String
getNodeStringValue(java.lang.Object anObj)
Returns the string value for a given name or UI node.java.lang.String
getNodeText(java.lang.Object anObj)
Returns the text value for a given name or UI node.java.lang.Object
getNodeValue(java.lang.Object anObj)
Returns the object value for a given name or UI node.UITYPE
getUI()
Returns the main UI node.<T extends UITYPE>
TgetUI(java.lang.Class<T> aClass)
Returns the main UI node with the given name as the given class.protected UIHelper
getUIHpr()
Returns the helper for a given object.protected void
initUI()
Initializes the UI panel.protected void
initUI(java.lang.Object anObj)
Initialize UI.protected abstract boolean
isEventThread()
Returns whether current thread is event thread.void
isNodeEnabled(java.lang.Object anObj)
Returns whether given name or UI node is enabled.boolean
isNodeValueAdjusting(java.lang.Object anObj)
Returns whether given name or UI node is currently being modified.boolean
isSendEventDisabled()
Returns whether Ribs' send event facility is disabled (so controls can be updated without triggering response).boolean
isUISet()
Returns whether UI has been set.protected void
processResetUI()
Called to reset bindings and resetUI().protected void
processRespondUI(EVENT anEvent)
Called to invoke respondUI().abstract void
requestFocus(java.lang.Object anObj)
Focuses given UI node (name or node).void
resetLater()
Resets UI later.protected void
resetNodeBindings(java.lang.Object anObj)
Reset bindings for UI node (recurses for children).protected void
resetUI()
Reset UI controls.protected void
respondUI(EVENT anEvent)
Respond to UI controls.abstract void
runLater(java.lang.Runnable aRunnable)
Runs the given runnable in the next event.void
runLaterDelayed(int aDelay, java.lang.Runnable aRunnable)
Runs the runnable after the given delay in milliseconds.void
runLaterOnce(java.lang.String aName, java.lang.Runnable aRunnable)
Invokes the given runnable for name once (cancels unexecuted previous runLater registered with same name).void
sendEvent(EVENT anEvent)
Sends an event for a UI node.abstract void
sendEvent(java.lang.Object anObj)
Sends an event for a UI node (name or node).protected void
sendNodeAction(java.lang.Object anObj, java.lang.String anAction)
Sends a node action.protected void
setBindingModelValue(Binding aBinding)
Sets the key value for the given binding from the UI node.protected void
setBindingNodeValue(Binding aBinding)
Sets the UI node value for the given binding from the key value.void
setFirstFocus(java.lang.Object anObj)
Sets the first focus UI node.void
setModelValue(java.lang.String aKey, java.lang.Object aValue)
Sets the model value for given key expression and value for this UIOwner.void
setNodeAction(java.lang.Object anObj, java.lang.String anAction)
Sets a node action.void
setNodeEnabled(java.lang.Object anObj, boolean aValue)
Sets whether given name or UI node is enabled.void
setNodeItemDisplayKey(java.lang.Object anObj, java.lang.String aKey)
Sets the display key for given name or UI node.void
setNodeItems(java.lang.Object anObj, java.lang.Object... theItems)
Sets the items for a given name or UI node.void
setNodeItems(java.lang.Object anObj, java.util.List theItems)
Sets the items for a given name or UI node.void
setNodeSelectedIndex(java.lang.Object anObj, int aValue)
Sets the selected index for given name or UI node.void
setNodeSelectedItem(java.lang.Object anObj, java.lang.Object anItem)
Sets the selected item for given name or UI node.void
setNodeText(java.lang.Object anObj, java.lang.String aValue)
Sets the object value for a given name or UI node.void
setNodeValue(java.lang.Object anObj, java.lang.Object aValue)
Sets the object value for a given name or UI node.boolean
setSendEventDisabled(boolean aFlag)
Sets whether Ribs' send event facility is disabled (so controls can be updated without triggering response).
-
-
-
Field Detail
-
KeyPressed
public static final UIEvent.Type KeyPressed
-
KeyReleased
public static final UIEvent.Type KeyReleased
-
KeyTyped
public static final UIEvent.Type KeyTyped
-
KeyFinished
public static final UIEvent.Type KeyFinished
-
MousePressed
public static final UIEvent.Type MousePressed
-
MouseDragged
public static final UIEvent.Type MouseDragged
-
MouseReleased
public static final UIEvent.Type MouseReleased
-
MouseClicked
public static final UIEvent.Type MouseClicked
-
MouseFinished
public static final UIEvent.Type MouseFinished
-
MouseEntered
public static final UIEvent.Type MouseEntered
-
MouseMoved
public static final UIEvent.Type MouseMoved
-
MouseExited
public static final UIEvent.Type MouseExited
-
DragEnter
public static final UIEvent.Type DragEnter
-
DragOver
public static final UIEvent.Type DragOver
-
DragExit
public static final UIEvent.Type DragExit
-
DragDrop
public static final UIEvent.Type DragDrop
-
KeyEvents
public UIEvent.Type[] KeyEvents
-
MouseEvents
public UIEvent.Type[] MouseEvents
-
DragEvents
public UIEvent.Type[] DragEvents
-
-
Method Detail
-
isUISet
public boolean isUISet()
Returns whether UI has been set.
-
getUI
public UITYPE getUI()
Returns the main UI node.
-
getUI
public <T extends UITYPE> T getUI(java.lang.Class<T> aClass)
Returns the main UI node with the given name as the given class.
-
createUI
protected abstract UITYPE createUI()
Creates the UI panel.
-
initUI
protected void initUI()
Initializes the UI panel.
-
initUI
protected void initUI(java.lang.Object anObj)
Initialize UI.
-
resetUI
protected void resetUI()
Reset UI controls.
-
respondUI
protected void respondUI(EVENT anEvent)
Respond to UI controls.
-
resetLater
public void resetLater()
Resets UI later.
-
processResetUI
protected void processResetUI()
Called to reset bindings and resetUI().
-
processRespondUI
protected void processRespondUI(EVENT anEvent)
Called to invoke respondUI().
-
getNode
public UITYPE getNode(java.lang.String aName)
Returns the specific UI child node with the given name.
-
getNode
protected UITYPE getNode(java.lang.Object anObj)
Returns the specific UI child node for given object (name, event or node).
-
getNode
public <T extends UITYPE> T getNode(java.lang.String aName, java.lang.Class<T> aClass)
Returns the specific UI child node with the given name as the given class.
-
getNodeValue
public java.lang.Object getNodeValue(java.lang.Object anObj)
Returns the object value for a given name or UI node.
-
setNodeValue
public void setNodeValue(java.lang.Object anObj, java.lang.Object aValue)
Sets the object value for a given name or UI node.
-
getNodeStringValue
public java.lang.String getNodeStringValue(java.lang.Object anObj)
Returns the string value for a given name or UI node.
-
getNodeBoolValue
public boolean getNodeBoolValue(java.lang.Object anObj)
Returns the boolean value for a given name or UI node.
-
getNodeIntValue
public int getNodeIntValue(java.lang.Object anObj)
Returns the int value for a given name or UI node.
-
getNodeFloatValue
public float getNodeFloatValue(java.lang.Object anObj)
Returns the float value for a given name or UI node.
-
getNodeText
public java.lang.String getNodeText(java.lang.Object anObj)
Returns the text value for a given name or UI node.
-
setNodeText
public void setNodeText(java.lang.Object anObj, java.lang.String aValue)
Sets the object value for a given name or UI node.
-
getNodeItems
public java.util.List getNodeItems(java.lang.Object anObj)
Returns the items for a given name or UI node.
-
setNodeItems
public void setNodeItems(java.lang.Object anObj, java.util.List theItems)
Sets the items for a given name or UI node.
-
setNodeItems
public void setNodeItems(java.lang.Object anObj, java.lang.Object... theItems)
Sets the items for a given name or UI node.
-
getNodeItemDisplayKey
public java.lang.String getNodeItemDisplayKey(java.lang.Object anObj, java.lang.String aKey)
Returns the display key for given name or UI node.
-
setNodeItemDisplayKey
public void setNodeItemDisplayKey(java.lang.Object anObj, java.lang.String aKey)
Sets the display key for given name or UI node.
-
getNodeSelectedIndex
public int getNodeSelectedIndex(java.lang.Object anObj)
Returns the selected index for given name or UI node.
-
setNodeSelectedIndex
public void setNodeSelectedIndex(java.lang.Object anObj, int aValue)
Sets the selected index for given name or UI node.
-
getNodeSelectedItem
public java.lang.Object getNodeSelectedItem(java.lang.Object anObj)
Returns the selected item for given name or UI node.
-
setNodeSelectedItem
public void setNodeSelectedItem(java.lang.Object anObj, java.lang.Object anItem)
Sets the selected item for given name or UI node.
-
isNodeEnabled
public void isNodeEnabled(java.lang.Object anObj)
Returns whether given name or UI node is enabled.
-
setNodeEnabled
public void setNodeEnabled(java.lang.Object anObj, boolean aValue)
Sets whether given name or UI node is enabled.
-
isNodeValueAdjusting
public boolean isNodeValueAdjusting(java.lang.Object anObj)
Returns whether given name or UI node is currently being modified.
-
getNodeHelper
protected abstract UIHelper getNodeHelper(java.lang.Object anObj)
Returns the helper for a given UI node.
-
getNodeAction
public java.lang.String getNodeAction(java.lang.Object anObj)
Returns a node action.
-
setNodeAction
public void setNodeAction(java.lang.Object anObj, java.lang.String anAction)
Sets a node action.
-
sendNodeAction
protected void sendNodeAction(java.lang.Object anObj, java.lang.String anAction)
Sends a node action.
-
addNodeBinding
public void addNodeBinding(java.lang.Object anObj, java.lang.String aPropertyName, java.lang.String aKeyPath)
Adds a binding to a UI node.
-
resetNodeBindings
protected void resetNodeBindings(java.lang.Object anObj)
Reset bindings for UI node (recurses for children).
-
getBindingNodeValue
protected java.lang.Object getBindingNodeValue(Binding aBinding)
Returns the UI node value for the given binding.
-
setBindingNodeValue
protected void setBindingNodeValue(Binding aBinding)
Sets the UI node value for the given binding from the key value.
-
getBindingModelValue
protected java.lang.Object getBindingModelValue(Binding aBinding)
Returns the key value for a given binding.
-
setBindingModelValue
protected void setBindingModelValue(Binding aBinding)
Sets the key value for the given binding from the UI node.
-
getFirstFocus
public java.lang.Object getFirstFocus()
Returns the first focus UI node for when window/dialog is made visible.
-
setFirstFocus
public void setFirstFocus(java.lang.Object anObj)
Sets the first focus UI node.
-
requestFocus
public abstract void requestFocus(java.lang.Object anObj)
Focuses given UI node (name or node).
-
getConversionMaps
public java.util.Map<java.lang.String,java.util.Map> getConversionMaps()
Returns the map of maps, each of which is used to perform value conversions.
-
getConversionMap
public java.util.Map<java.lang.String,java.lang.String> getConversionMap(java.lang.String aName)
Returns a named map to perform value conversions.
-
getConversionMapKey
protected java.lang.Object getConversionMapKey(java.lang.String aConversionMapName, java.lang.Object aValue)
Converts a UI node value to binder object value using conversion key map.
-
getConversionMapValue
public java.lang.Object getConversionMapValue(java.lang.String aConversionMapName, java.lang.Object aKey)
Converts a binder object value to UI node using conversion key map.
-
enableEvents
public void enableEvents(java.lang.Object anObj, UIEvent.Type... theTypes)
Enables events on given object.
-
disableEvents
public void disableEvents(java.lang.Object anObj, UIEvent.Type... theTypes)
Enables events on given object.
-
sendEvent
public abstract void sendEvent(java.lang.Object anObj)
Sends an event for a UI node (name or node).
-
sendEvent
public void sendEvent(EVENT anEvent)
Sends an event for a UI node.
-
isSendEventDisabled
public boolean isSendEventDisabled()
Returns whether Ribs' send event facility is disabled (so controls can be updated without triggering response).
-
setSendEventDisabled
public boolean setSendEventDisabled(boolean aFlag)
Sets whether Ribs' send event facility is disabled (so controls can be updated without triggering response).
-
addKeyActionEvent
public abstract void addKeyActionEvent(java.lang.String aName, java.lang.String aKey)
Configures an ActionEvent to be sent to owner for given name and key description (in KeyStroke string format).- See Also:
KeyStroke
-
runLater
public abstract void runLater(java.lang.Runnable aRunnable)
Runs the given runnable in the next event.
-
runLaterDelayed
public void runLaterDelayed(int aDelay, java.lang.Runnable aRunnable)
Runs the runnable after the given delay in milliseconds.
-
runLaterOnce
public void runLaterOnce(java.lang.String aName, java.lang.Runnable aRunnable)
Invokes the given runnable for name once (cancels unexecuted previous runLater registered with same name).
-
isEventThread
protected abstract boolean isEventThread()
Returns whether current thread is event thread.
-
getUIHpr
protected UIHelper getUIHpr()
Returns the helper for a given object.
-
getModelValue
public java.lang.Object getModelValue(java.lang.String aKey)
Returns the model value for given key expression from this UIOwner.
-
setModelValue
public void setModelValue(java.lang.String aKey, java.lang.Object aValue)
Sets the model value for given key expression and value for this UIOwner.
-
-