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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Cleans running state of aViewso that it can be left to get garbage collected.protected voiddispatch(org.springframework.messaging.Message<?> message) Dispatch aMessageinto an event loop.protected booleandispatchKeyRunCommand(KeyEvent event, org.springframework.shell.component.view.control.AbstractView.KeyBindingValue keyBindingValue) protected booleandispatchMouseRunCommand(MouseEvent event, org.springframework.shell.component.view.control.AbstractView.MouseBindingValue mouseBindingValue) protected booleandispatchRunnable(Runnable runnable) final voidCalls drawing logic in two stages.protected voiddrawBackground(Screen screen) Internal drawing method for background.protected abstract voiddrawInternal(Screen screen) Component internal drawing method.voidCalled whenViewgets or loses a focus.Gets a draw function.protected EventLoopGet anEventLoop.protected Map<Integer,org.springframework.shell.component.view.control.AbstractView.KeyBindingValue> Get hotkey bindings.Gets aViewhotkeyKeyHandler.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 intgetLayer()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 ViewServiceGet aViewServicebooleanhasFocus()Gets if thisViewhas a focus.protected final voidinit()Initialize a view.protected voidInternal init method called frominit().protected voidonDestroy(reactor.core.Disposable disposable) RegisterDisposableto get disposed when view terminates.protected voidregisterHotKeyBinding(Integer keyType, Runnable keyRunnable) protected voidregisterHotKeyBinding(Integer keyType, String keyCommand) protected voidregisterHotKeyBinding(Integer keyType, KeyBindingConsumer keyConsumer) protected voidregisterKeyBinding(Integer keyType, Runnable keyRunnable) protected voidregisterKeyBinding(Integer keyType, String keyCommand) protected voidregisterKeyBinding(Integer keyType, KeyBindingConsumer keyConsumer) protected voidregisterMouseBinding(Integer keyType, Runnable mouseRunnable) protected voidregisterMouseBinding(Integer keyType, String mouseCommand) protected voidregisterMouseBinding(Integer keyType, MouseBindingConsumer mouseConsumer) protected voidregisterViewCommand(String command, Runnable runnable) booleanrunViewCommand(String command) Run command.voidsetDrawFunction(BiFunction<Screen, Rectangle, Rectangle> drawFunction) Sets a callback function which is invoked after aViewhas been drawn.voidsetEventLoop(EventLoop eventLoop) Set anEventLoop.voidsetLayer(int index) Sets a layer index thisViewoperates on.voidsetViewService(ViewService viewService) Set aViewServiceMethods inherited from class org.springframework.shell.component.view.control.AbstractControl
getRect, getThemeName, getThemeResolver, resolveThemeBackground, resolveThemeForeground, resolveThemeStyle, setRect, setThemeName, setThemeResolverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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) RegisterDisposableto get disposed when view terminates.- Parameters:
disposable- a disposable to dispose
-
destroy
public void destroy()Cleans running state of aViewso that it can be left to get garbage collected. -
init
protected final void init()Initialize a view. Mostly reserved for future use and simply callsinitInternal().- See Also:
-
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:ViewSets a layer index thisViewoperates 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:ViewCalled whenViewgets or loses a focus. -
hasFocus
public boolean hasFocus()Description copied from interface:ViewGets if thisViewhas a focus. -
getMouseHandler
Handles mouse events by dispatching registered consumers into an event loop. Override to change default behaviour.- Specified by:
getMouseHandlerin 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:
getKeyHandlerin interfaceView- Returns:
- a view key handler
- See Also:
-
getHotKeyHandler
Description copied from interface:View- Specified by:
getHotKeyHandlerin interfaceView- Returns:
- a view hotkey handler
- See Also:
-
setDrawFunction
Sets a callback function which is invoked after aViewhas 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:
setEventLoopin interfaceView- Parameters:
eventLoop- the event loop
-
getEventLoop
Get anEventLoop.- Returns:
- event loop
-
setViewService
Set aViewService- Specified by:
setViewServicein interfaceView- Parameters:
viewService- the view service
-
getViewService
Get aViewService- Returns:
- view service
-
registerViewCommand
-
getViewCommands
Description copied from interface:ViewGet supported commands.- Specified by:
getViewCommandsin 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 aMessageinto an event loop.- Parameters:
message- the message to dispatch
-
dispatchRunnable
-
runViewCommand
Description copied from interface:ViewRun command.- Specified by:
runViewCommandin 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)
-