Class AbstractView
java.lang.Object
org.springframework.shell.component.view.control.AbstractControl
org.springframework.shell.component.view.control.AbstractView
- Direct Known Subclasses:
BoxView
,WindowView
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Cleans running state of aView
so that it can be left to get garbage collected.protected void
dispatch
(org.springframework.messaging.Message<?> message) Dispatch aMessage
into an event loop.protected boolean
dispatchKeyRunCommand
(KeyEvent event, org.springframework.shell.component.view.control.AbstractView.KeyBindingValue keyBindingValue) protected boolean
dispatchMouseRunCommand
(MouseEvent event, org.springframework.shell.component.view.control.AbstractView.MouseBindingValue mouseBindingValue) protected boolean
dispatchRunnable
(Runnable runnable) final void
Calls drawing logic in two stages.protected void
drawBackground
(Screen screen) Internal drawing method for background.protected abstract void
drawInternal
(Screen screen) Component internal drawing method.void
Called whenView
gets or loses a focus.Gets a draw function.protected EventLoop
Get anEventLoop
.protected Map<Integer,
org.springframework.shell.component.view.control.AbstractView.KeyBindingValue> Get hotkey bindings.Gets aView
hotkeyKeyHandler
.protected Map<Integer,
org.springframework.shell.component.view.control.AbstractView.KeyBindingValue> Get key bindings.Handles keys by dispatching registered command runnable into an event loop.protected int
getLayer()
protected Map<Integer,
org.springframework.shell.component.view.control.AbstractView.MouseBindingValue> Get mouse bindings.Handles mouse events by dispatching registered consumers into an event loop.Get supported commands.protected ViewService
Get aViewService
boolean
hasFocus()
Gets if thisView
has a focus.final void
init()
Initialize a view.protected void
Internal init method called frominit()
.protected void
onDestroy
(reactor.core.Disposable disposable) RegisterDisposable
to get disposed when view terminates.protected void
registerHotKeyBinding
(Integer keyType, Runnable keyRunnable) protected void
registerHotKeyBinding
(Integer keyType, String keyCommand) protected void
registerHotKeyBinding
(Integer keyType, KeyBindingConsumer keyConsumer) protected void
registerKeyBinding
(Integer keyType, Runnable keyRunnable) protected void
registerKeyBinding
(Integer keyType, String keyCommand) protected void
registerKeyBinding
(Integer keyType, KeyBindingConsumer keyConsumer) protected void
registerMouseBinding
(Integer keyType, Runnable mouseRunnable) protected void
registerMouseBinding
(Integer keyType, String mouseCommand) protected void
registerMouseBinding
(Integer keyType, MouseBindingConsumer mouseConsumer) protected void
registerViewCommand
(String command, Runnable runnable) boolean
runViewCommand
(String command) Run command.void
setDrawFunction
(BiFunction<Screen, Rectangle, Rectangle> drawFunction) Sets a callback function which is invoked after aView
has been drawn.void
setEventLoop
(EventLoop eventLoop) Set anEventLoop
.void
setLayer
(int index) Sets a layer index thisView
operates on.void
setViewService
(ViewService viewService) Set aViewService
void
Methods inherited from class org.springframework.shell.component.view.control.AbstractControl
getRect, getThemeName, getThemeResolver, resolveThemeBackground, resolveThemeForeground, resolveThemeSpinner, resolveThemeStyle, setRect, setThemeName, setThemeResolver
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.shell.component.view.control.Control
getRect, setRect, setThemeName, setThemeResolver
-
Constructor Details
-
AbstractView
public AbstractView()
-
-
Method Details
-
onDestroy
protected void onDestroy(reactor.core.Disposable disposable) RegisterDisposable
to get disposed when view terminates.- Parameters:
disposable
- a disposable to dispose
-
destroy
public void destroy()Cleans running state of aView
so that it can be left to get garbage collected. -
init
public final void init()Initialize a view. Mostly reserved for future use and simply callsinitInternal()
. -
shortcut
-
initInternal
protected void initInternal()Internal init method called frominit()
. Override to do something usefull. Typically key and mousebindings are registered from this method. -
setLayer
public void setLayer(int index) Description copied from interface:View
Sets a layer index thisView
operates on. -
getLayer
protected int getLayer() -
draw
Calls drawing logic in two stages. First a background is drawn and then an actual content. This logic allows to separate how child implementation can use drawing logic from its parent as usually background should get overridden in child but actual content should get overridden in a parent. -
drawInternal
Component internal drawing method. Implementing classes needs to define this method to draw something into aScreen
.- Parameters:
screen
- the screen
-
drawBackground
Internal drawing method for background.- Parameters:
screen
- the screen
-
focus
Description copied from interface:View
Called whenView
gets or loses a focus. -
hasFocus
public boolean hasFocus()Description copied from interface:View
Gets if thisView
has a focus. -
getMouseHandler
Handles mouse events by dispatching registered consumers into an event loop. Override to change default behaviour.- Specified by:
getMouseHandler
in interfaceView
- Returns:
- a view mouse handler
- See Also:
-
getKeyHandler
Handles keys by dispatching registered command runnable into an event loop. Override to change default behaviour.- Specified by:
getKeyHandler
in interfaceView
- Returns:
- a view key handler
- See Also:
-
getHotKeyHandler
Description copied from interface:View
- Specified by:
getHotKeyHandler
in interfaceView
- Returns:
- a view hotkey handler
- See Also:
-
setDrawFunction
Sets a callback function which is invoked after aView
has been drawn.- Parameters:
drawFunction
- the draw function
-
getDrawFunction
Gets a draw function.- Returns:
- null if function is not set
- See Also:
-
setEventLoop
Set anEventLoop
.- Specified by:
setEventLoop
in interfaceView
- Parameters:
eventLoop
- the event loop
-
getEventLoop
Get anEventLoop
.- Returns:
- event loop
-
setViewService
Set aViewService
- Specified by:
setViewService
in interfaceView
- Parameters:
viewService
- the view service
-
getViewService
Get aViewService
- Returns:
- view service
-
registerViewCommand
-
getViewCommands
Description copied from interface:View
Get supported commands.- Specified by:
getViewCommands
in interfaceView
- Returns:
- supported commands
- See Also:
-
registerKeyBinding
-
registerKeyBinding
-
registerKeyBinding
-
registerHotKeyBinding
-
registerHotKeyBinding
-
registerHotKeyBinding
-
getKeyBindings
protected Map<Integer,org.springframework.shell.component.view.control.AbstractView.KeyBindingValue> getKeyBindings()Get key bindings.- Returns:
- key bindings
-
getHotKeyBindings
protected Map<Integer,org.springframework.shell.component.view.control.AbstractView.KeyBindingValue> getHotKeyBindings()Get hotkey bindings.- Returns:
- hotkey bindings
-
getMouseBindings
protected Map<Integer,org.springframework.shell.component.view.control.AbstractView.MouseBindingValue> getMouseBindings()Get mouse bindings.- Returns:
- mouse bindings
-
registerMouseBinding
-
registerMouseBinding
-
registerMouseBinding
-
dispatch
protected void dispatch(org.springframework.messaging.Message<?> message) Dispatch aMessage
into an event loop.- Parameters:
message
- the message to dispatch
-
dispatchRunnable
-
runViewCommand
Description copied from interface:View
Run command.- Specified by:
runViewCommand
in interfaceView
- Parameters:
command
- the command to run- Returns:
- true if command was succesfully dispatched
- See Also:
-
dispatchKeyRunCommand
protected boolean dispatchKeyRunCommand(KeyEvent event, org.springframework.shell.component.view.control.AbstractView.KeyBindingValue keyBindingValue) -
dispatchMouseRunCommand
protected boolean dispatchMouseRunCommand(MouseEvent event, org.springframework.shell.component.view.control.AbstractView.MouseBindingValue mouseBindingValue)
-