Class View

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Dockable, DockingConstants, DockingListener, DockingMonitor

public class View extends JComponent implements Dockable, DockingConstants
The View class is slightly incompatible with JComponent. Similar to JFC/Swing top-level containers, a View contains only a content pane Container and a Titlebar. The content pane should contain all the components displayed by the View. As a convenience add and its variants, remove(Component) and setLayout have been overridden to forward to the contentPane as necessary. This means you can write:
 view.add(child);
 
And the child will be added to the contentPane. The content pane will always be non-null. Attempting to set it to null will cause the View to throw an exception. The default content pane will not have a layout manager set.
Author:
Christopher Butler, Karl Schaefer
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getInstance

      public static View getInstance(String viewId)
    • createContentPane

      protected Container createContentPane()
    • createLayout

      protected LayoutManager createLayout()
    • createTitlebar

      protected Titlebar createTitlebar()
    • getContentPane

      public Container getContentPane()
    • getTitlebar

      public Titlebar getTitlebar()
    • getDockingProperties

      public DockablePropertySet getDockingProperties()
      Description copied from interface: Dockable
      Returns a DockablePropertySet instance associated with this Dockable. Developers implementing the Dockable interface may or may not choose to provide their own DockablePropertySet implementation for use with this method. A default implementation is supplied by the framework and most Dockable implementations, including all implementations provided by the framework, will return the default DockablePropertySet via a call to org.flexdock.docking.props.PropertyManager. Developers are encouraged to take advantage of this by calling PropertyManager.getDockablePropertySet(this).
      Specified by:
      getDockingProperties in interface Dockable
      Returns:
      the DockablePropertySet associated with this Dockable This method may not return a null reference.
      See Also:
    • getViewProperties

      public ViewProps getViewProperties()
    • addAction

      public void addAction(Action action)
    • addAction

      public void addAction(String action)
    • removeActions

      public void removeActions()
    • setIcon

      public void setIcon(Icon icon)
    • setIcon

      public void setIcon(String imgUri)
    • setContentPane

      public void setContentPane(Container c) throws IllegalArgumentException
      Sets the content pane for this view.
      Parameters:
      c - the container to use as the content pane.
      Throws:
      IllegalArgumentException - if c is null or if c is the titlepane.
      See Also:
    • getPreferredTitlebarUIName

      protected String getPreferredTitlebarUIName()
    • setTitlebar

      public void setTitlebar(Titlebar titlebar)
    • getTitlePane

      protected Component getTitlePane()
    • setTitle

      public void setTitle(String title)
    • setTitle

      public void setTitle(String title, boolean alsoTabText)
    • getTitle

      public String getTitle()
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JComponent
    • getUIClassID

      public String getUIClassID()
      Overrides:
      getUIClassID in class JComponent
    • addImpl

      protected void addImpl(Component comp, Object constraints, int index)
      Overrides:
      addImpl in class Container
    • remove

      public void remove(Component comp)
      Overrides:
      remove in class Container
    • getActionButton

      public AbstractButton getActionButton(String actionName)
    • getComponent

      public Component getComponent()
      Description copied from interface: Dockable
      Returns the Component that is to be dragged and docked. This may or may not be included in the list returned by getDragSources().

      The framework performs indexing on the underlying Component. Consequently, this method may not return a null reference.

      Specified by:
      getComponent in interface Dockable
      Returns:
      the component wrapped by this dockable.
    • getDragSources

      public List getDragSources()
      Description copied from interface: Dockable
      Returns a List of the Components that are event sources for drag operations. The list may or may not include the Component returned by getComponent().
      Specified by:
      getDragSources in interface Dockable
      Returns:
      a list containing the components that may be used to drag this dockable.
    • getFrameDragSources

      public Set getFrameDragSources()
      Description copied from interface: Dockable
      Returns a Set of the Components that are used as frame drag sources. When a Dockable is floated into an external frame, that frame may or may not have a titlebar for repositioning. The Components returned by this method will be setup with appropriate event listeners such that dragging them will serve to reposition the containing frame as if they were the frame titlebar. If a Component exists in both the Set returned by this method and the List returned by getDragSources(), the "frame reposition" behavior will supercede any "drag-to-dock" behavior while the Dockable is in a floating state.
      Specified by:
      getFrameDragSources in interface Dockable
      Returns:
      a set containing the components that may be used to drag the frame this dockable resides in, if the dockable is floating.
    • getPersistentId

      public String getPersistentId()
      Description copied from interface: Dockable
      Returns a String identifier that is unique within a JVM instance, but persistent across JVM instances. This is used for configuration mangement, allowing the JVM to recognize a Dockable instance within an application instance, persist the ID, and recall it in later application instances. The ID should be unique within an appliation instance so that there are no collisions with other Dockable instances, but it should also be consistent from JVM to JVM so that the association between a Dockable instance and its ID can be remembered from session to session.

      The framework performs indexing on the persistent ID. Consequently, this method may not return a null reference.

      Specified by:
      getPersistentId in interface Dockable
      Returns:
      the persistence id for this dockable. This id ensures that only one copy of a given dockable will exist.
    • isTerritoryBlocked

      public boolean isTerritoryBlocked(Dockable dockable, String region)
    • setTerritoryBlocked

      public void setTerritoryBlocked(String region, boolean blocked)
    • getTabText

      public String getTabText()
    • setTabText

      public void setTabText(String tabText)
    • getTabIcon

      public Icon getTabIcon()
    • setTabIcon

      public void setTabIcon(Icon icon)
    • dock

      public boolean dock(Dockable dockable)
      Description copied from interface: Dockable
      Implements the semantics for docking an external Dockable to this Dockable and returns a boolean indicating whether or not the docking operation was successful.

      The framework already provides a default implementation for this method through DockingManager.dock(Dockable dockable, Dockable parent). While users are free to provide their own implementation for this method, the recommended approach is to use the default implementation with the following line:

      return DockingManager.dock(dockable, this);

      Specified by:
      dock in interface Dockable
      Parameters:
      dockable - the Dockable to dock relative to this Dockable
      Returns:
      true if the docking operation was successful; false otherwise.
      See Also:
    • getDockingPort

      public DockingPort getDockingPort()
      Description copied from interface: Dockable
      Returns the DockingPort within which this Dockable is currently docked. If not currently docked, this method will return null.
      Specified by:
      getDockingPort in interface Dockable
      Returns:
      the docking port this dockable resides in, or null if the dockable is not currently docked (i.e. in the middle of a drag operation).
    • getSibling

      public Dockable getSibling(String region)
    • getViewport

      public Viewport getViewport()
    • dock

      public boolean dock(Dockable dockable, String relativeRegion)
      Description copied from interface: Dockable
      Implements the semantics for docking an external Dockable to the specified region of this Dockable and returns a boolean indicating whether or not the docking operation was successful. If the docking operation results in a split layout, this method should determine an appropriate ratio of available space to allot to the new sibling Dockable.

      The framework already provides a default implementation for this method through DockingManager.dock(Dockable dockable, Dockable parent, String region). While users are free to provide their own implementation for this method, the recommended approach is to use the default implementation with the following line:

      return DockingManager.dock(dockable, this, relativeRegion);

      Specified by:
      dock in interface Dockable
      Parameters:
      dockable - the Dockable to dock relative to this Dockable
      relativeRegion - the docking region into which to dock the specified Dockable
      Returns:
      true if the docking operation was successful; false otherwise.
      See Also:
    • dock

      public boolean dock(Dockable dockable, String relativeRegion, float ratio)
      Description copied from interface: Dockable
      Implements the semantics for docking an external Dockable to the specified region of this Dockable with the specified layout ratio, returning a boolean indicating whether or not the docking operation was successful. If the docking operation results in a split layout, this method should use the specified ratio to determine the amount of available space to allot to the new sibling Dockable.

      The framework already provides a default implementation for this method through DockingManager.dock(Dockable dockable, Dockable parent, String region, float proportion). While users are free to provide their own implementation for this method, the recommended approach is to use the default implementation with the following line:

      return DockingManager.dock(dockable, this, relativeRegion, ratio);

      Specified by:
      dock in interface Dockable
      Parameters:
      dockable - the Dockable to dock relative to this Dockable
      relativeRegion - the docking region into which to dock the specified Dockable
      ratio - the proportion of available space in the resulting layout to allot to the new sibling Dockable.
      Returns:
      true if the docking operation was successful; false otherwise.
      See Also:
    • setActive

      public void setActive(boolean b)
    • isActive

      public boolean isActive()
    • setActiveStateLocked

      public void setActiveStateLocked(boolean b)
    • isActiveStateLocked

      public boolean isActiveStateLocked()
    • isMinimized

      public boolean isMinimized()
    • getMinimizedConstraint

      public int getMinimizedConstraint()
    • addDockingListener

      public void addDockingListener(DockingListener listener)
      Specified by:
      addDockingListener in interface DockingMonitor
    • getDockingListeners

      public DockingListener[] getDockingListeners()
      Specified by:
      getDockingListeners in interface DockingMonitor
    • removeDockingListener

      public void removeDockingListener(DockingListener listener)
      Specified by:
      removeDockingListener in interface DockingMonitor
    • dockingCanceled

      public void dockingCanceled(DockingEvent evt)
      Description copied from interface: DockingListener
      Fired when docking of a Dockable is canceled during the operation.
      Specified by:
      dockingCanceled in interface DockingListener
      Parameters:
      evt - the DockingEvent event which provides the source Dockable, the old DockingPort and the new DockingPort
    • dockingComplete

      public void dockingComplete(DockingEvent evt)
      Description copied from interface: DockingListener
      Fired when docking of a Dockable has completed.
      Specified by:
      dockingComplete in interface DockingListener
      Parameters:
      evt - the DockingEvent event which provides the source Dockable, the old DockingPort and the new DockingPort
    • dragStarted

      public void dragStarted(DockingEvent evt)
      Description copied from interface: DockingListener
      Fired when the dragging of a Dockable has begun.
      Specified by:
      dragStarted in interface DockingListener
      Parameters:
      evt - the DockingEvent event which provides the source Dockable, the old DockingPort and the new DockingPort
    • dropStarted

      public void dropStarted(DockingEvent evt)
      Description copied from interface: DockingListener
      Fired when the dropping of a Dockable has begun at the release of a drag-operation.
      Specified by:
      dropStarted in interface DockingListener
      Parameters:
      evt - the DockingEvent event which provides the source Dockable, the old DockingPort and the new DockingPort
    • undockingComplete

      public void undockingComplete(DockingEvent evt)
      Specified by:
      undockingComplete in interface DockingListener
    • undockingStarted

      public void undockingStarted(DockingEvent evt)
      Specified by:
      undockingStarted in interface DockingListener
    • setActionBlocked

      public void setActionBlocked(String actionName, boolean blocked)
    • isActionBlocked

      public boolean isActionBlocked(String actionName)
    • isFloating

      public boolean isFloating()
    • paramString

      protected String paramString()
      Overrides:
      paramString in class JComponent
    • isContentPaneCheckingEnabled

      protected boolean isContentPaneCheckingEnabled()
      Returns:
      the contentPaneCheckingEnabled
    • setContentPaneCheckingEnabled

      protected void setContentPaneCheckingEnabled(boolean contentPaneCheckingEnabled)
      Parameters:
      contentPaneCheckingEnabled - the contentPaneCheckingEnabled to set
    • setLayout

      public void setLayout(LayoutManager manager)
      Sets the LayoutManager. Overridden to conditionally forward the call to the contentPane.
      Overrides:
      setLayout in class Container
      Parameters:
      manager - the LayoutManager
      See Also: