Package snap.view

Class ViewOwner

All Implemented Interfaces:
PropChange.DoChange
Direct Known Subclasses:
ColorPanel, DevPane, DevPaneConsole, DevPaneExceptions, DevPaneFiles, DevPaneGraphics, DevPaneViewOwners, DevPaneViews, ExceptionReporter, FilePanel, FontPicker, FormBuilder, RecentFiles, SpellCheckPanel, StylerOwner, TaskMonitorPanel, TextPane, WebSitePane

public class ViewOwner extends PropObject
A base controller class that manages a UI View (usually loaded from a snp UI file).
  • Field Details

  • Constructor Details

    • ViewOwner

      public ViewOwner()
      Constructor.
    • ViewOwner

      public ViewOwner(View aView)
      Constructor with given View for UI.
  • Method Details

    • isUISet

      public boolean isUISet()
      Returns whether UI has been set.
    • getUI

      public View getUI()
      Returns top level view.
    • getUI

      public <T extends View> T getUI(Class<T> aClass)
      Returns top level view as given class.
    • createUI

      protected View createUI()
      Creates the top level view for this class.
    • createUIForClass

      protected View createUIForClass(Class<?> aClass)
      Creates the top level view for given class.
    • getUISource

      protected Object getUISource()
      Returns the UI source.
    • initUI

      protected void initUI()
      Initializes the UI panel.
    • getFirstFocus

      public Object getFirstFocus()
      Returns the first focus UI view for when window/dialog is made visible.
    • setFirstFocus

      public void setFirstFocus(Object anObj)
      Sets the first focus UI view.
    • isShowing

      public boolean isShowing()
      Returns whether ViewOwner UI is showing.
    • setShowing

      protected void setShowing(boolean aValue)
      Sets whether ViewOwner UI is showing.
    • initShowing

      protected void initShowing()
      Called when ViewOwner is first shown.
    • getNative

      public Object getNative()
      Returns the native object for the UI (JComponent).
    • getView

      public View getView(Object anObj)
      Returns the specific child view for given object (name, event or view).
    • getView

      public <T> T getView(Object anObj, Class<T> aClass)
      Returns the specific child view with the given name as the given class.
    • getViewValue

      public Object getViewValue(Object anObj)
      Returns the object value for a given name or UI view.
    • setViewValue

      public void setViewValue(Object anObj, Object aValue)
      Sets the object value for a given name or UI view.
    • getViewStringValue

      public String getViewStringValue(Object anObj)
      Returns the string value for a given name or UI view.
    • getViewBoolValue

      public boolean getViewBoolValue(Object anObj)
      Returns the boolean value for a given name or UI view.
    • getViewIntValue

      public int getViewIntValue(Object anObj)
      Returns the int value for a given name or UI view.
    • getViewFloatValue

      public float getViewFloatValue(Object anObj)
      Returns the float value for a given name or UI view.
    • getViewText

      public String getViewText(Object anObj)
      Returns the text value for a given name or UI view.
    • setViewText

      public void setViewText(Object anObj, String aValue)
      Sets the object value for a given name or UI view.
    • getViewItems

      public List<?> getViewItems(Object anObj)
      Returns the items for a given name or UI view.
    • setViewItems

      public void setViewItems(Object anObj, List<?> theItems)
      Sets the items for a given name or UI view.
    • setViewItems

      public void setViewItems(Object anObj, Object[] theItems)
      Sets the items for a given name or UI view.
    • getViewSelIndex

      public int getViewSelIndex(Object anObj)
      Returns the selected index for given name or UI view.
    • setViewSelIndex

      public void setViewSelIndex(Object anObj, int aValue)
      Sets the selected index for given name or UI view.
    • getViewSelItem

      public Object getViewSelItem(Object anObj)
      Returns the selected item for given name or UI view.
    • setViewSelItem

      public void setViewSelItem(Object anObj, Object anItem)
      Sets the selected item for given name or UI view.
    • isViewEnabled

      public boolean isViewEnabled(Object anObj)
      Returns whether given name or UI view is enabled.
    • setViewEnabled

      public void setViewEnabled(Object anObj, boolean aValue)
      Sets whether given name or UI view is enabled.
    • isViewDisabled

      public boolean isViewDisabled(Object anObj)
      Returns whether given name or UI view is disabled.
    • setViewDisabled

      public void setViewDisabled(Object anObj, boolean aValue)
      Sets whether given name or UI view is disabled.
    • isViewVisible

      public boolean isViewVisible(Object anObj)
      Returns whether given name or UI view is visible.
    • setViewVisible

      public void setViewVisible(Object anObj, boolean aValue)
      Sets whether given name or UI view is visible.
    • getImage

      public Image getImage(String aPath)
      Returns an image with given name or path from this class.
    • getToggleGroup

      public ToggleGroup getToggleGroup(String aName)
      Return the toggle group for the given name (creating if needed).
    • resetUI

      protected void resetUI()
      Reset UI controls.
    • respondUI

      protected void respondUI(ViewEvent anEvent)
      Respond to UI controls.
    • resetLater

      public void resetLater()
      Resets UI later.
    • cancelReset

      protected void cancelReset()
      Whether this ViewOwner should suppress the next automatic reset that normally happens after respondUI.
    • invokeResetUI

      protected void invokeResetUI()
      A wrapper to call resetUI() properly so resulting view action events are ignored.
    • invokeRespondUI

      protected void invokeRespondUI(ViewEvent anEvent)
      A hook to allow subclasses to wrap respondUI invocation easier.
    • dispatchEventToOwner

      public void dispatchEventToOwner(ViewEvent anEvent)
      Sends an event to this ViewOwner through processEvent method.
    • enableEvents

      public void enableEvents(Object anObj, ViewEvent.Type... theTypes)
      Enables events on given object.
    • disableEvents

      public void disableEvents(Object anObj, ViewEvent.Type... theTypes)
      Enables events on given object.
    • fireActionEventForObject

      public void fireActionEventForObject(Object anObj, ViewEvent parentEvent)
      Triggers and action event for a UI view (name or view).
    • isSendEventDisabled

      public boolean isSendEventDisabled()
      Returns whether send event facility is disabled (so controls can be updated without triggering response).
    • setSendEventDisabled

      public boolean setSendEventDisabled(boolean aFlag)
      Sets whether send event facility is disabled (so controls can be updated without triggering response).
    • addKeyActionFilter

      public void addKeyActionFilter(String aName, String aKey)
      Registers an event filter to send event with given name to owner.respondUI() on key press for key description. Key description is in Swing KeyStroke string format.
    • addKeyActionHandler

      public void addKeyActionHandler(String aName, String aKey)
      Registers an event handler to send event with given name to owner.respondUI() on key press for key description. Key description is in Swing KeyStroke string format.
    • requestFocus

      public void requestFocus(Object anObj)
      Focuses given UI view (name or view).
    • isWindowSet

      public boolean isWindowSet()
      Returns whether Window has been created (happens when first accessed).
    • getWindow

      public WindowView getWindow()
      Returns the Window to manage this ViewOwner's window.
    • isWindowVisible

      public boolean isWindowVisible()
      Returns whether window is visible.
    • setWindowVisible

      public void setWindowVisible(boolean aValue)
      Sets whether window is visible.
    • isEventThread

      protected boolean isEventThread()
      Returns whether current thread is event thread.
    • runLater

      public void runLater(Runnable aRunnable)
      Runs the given runnable in the next event.
    • runLaterDelayed

      public void runLaterDelayed(int aDelay, Runnable aRunnable)
      Runs the runnable after the given delay in milliseconds.
    • runLaterOnce

      public void runLaterOnce(String aName, Runnable aRunnable)
      Invokes the given runnable for name once (cancels unexecuted previous runLater registered with same name).
    • beep

      public void beep()
      Plays a beep.
    • getEnv

      public ViewEnv getEnv()
      Returns the ViewEnv for this owner.