Class AbstractView
java.lang.Object
org.springframework.shell.component.view.control.AbstractControl
org.springframework.shell.component.view.control.AbstractView
- Direct Known Subclasses:
BoxView
-
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 booleandispatchMouseRunCommand(MouseEvent event, org.springframework.shell.component.view.control.AbstractView.MouseBindingValue command) protected booleandispatchRunCommand(KeyEvent event, org.springframework.shell.component.view.control.AbstractView.KeyBindingValue command) protected booleandispatchRunnable(Runnable runnable) final voidprotected 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 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.booleanhasFocus()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 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) 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.Methods 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
Description copied from interface:Control -
drawInternal
Component internal drawing method. Implementing classes needs to define this method to draw something into aScreen.- 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 mouse 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.- Parameters:
eventLoop- the event loop
-
getEventLoop
Get anEventLoop.- Returns:
- event loop
-
registerKeyBinding
-
registerKeyBinding
-
registerKeyBinding
-
getKeyBindings
protected Map<Integer,org.springframework.shell.component.view.control.AbstractView.KeyBindingValue> getKeyBindings()Get key bindings.- Returns:
- key 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
-
dispatchRunCommand
protected boolean dispatchRunCommand(KeyEvent event, org.springframework.shell.component.view.control.AbstractView.KeyBindingValue command) -
dispatchMouseRunCommand
protected boolean dispatchMouseRunCommand(MouseEvent event, org.springframework.shell.component.view.control.AbstractView.MouseBindingValue command)
-