Module org.snapfx

Class DockNode

java.lang.Object
org.snapfx.model.DockNode
All Implemented Interfaces:
DockElement

public class DockNode extends Object implements DockElement
Wrapper class for a dockable JavaFX node. Encapsulates a JavaFX Node with metadata such as title and ID.

Uses two types of IDs:

  • dockNodeId: Type-based identifier used by the factory to create nodes (e.g., "editor", "console")
  • layoutId: Unique identifier for this specific instance in the layout (managed by framework)
  • Property Details

  • Constructor Details

    • DockNode

      public DockNode(javafx.scene.Node content, String title)
      Creates a DockNode with an auto-generated UUID as both dockNodeId and layoutId. Note: UUIDs change between sessions, making persistence unreliable. For proper save/load support, use the constructor with a custom dockNodeId.
      Parameters:
      content - JavaFX content node
      title - node title
    • DockNode

      public DockNode(String dockNodeId, javafx.scene.Node content, String title)
      Creates a DockNode with a custom dockNodeId. Use this constructor for nodes that need to be persisted across sessions. The layoutId will be auto-generated by the framework when added to the layout.
      Parameters:
      dockNodeId - Type-based identifier for this node (e.g., "editor", "console", "projectExplorer")
      content - The JavaFX node to display
      title - The title shown in headers and tabs
  • Method Details

    • getId

      public String getId()
      Returns the unique layout ID for this node instance. This ID is used for positioning in the layout structure. It is automatically generated by the framework when the node is added to a layout.
      Specified by:
      getId in interface DockElement
      Returns:
      unique layout element ID
    • getDockNodeId

      public String getDockNodeId()
      Returns the type-based dockNodeId used by the factory. This ID identifies the type of node (e.g., "editor", "console").
      Returns:
      type-based dock-node ID
    • setLayoutId

      public void setLayoutId(String layoutId)
      Sets the unique layout ID for this node instance. This is called by the framework when the node is added to a layout.
      Parameters:
      layoutId - unique layout instance ID
    • getTitle

      public String getTitle()
      Gets the value of the title property.
      Property description:
      Returns the observable title property.
      Returns:
      the value of the title property
      See Also:
    • titleProperty

      public javafx.beans.property.StringProperty titleProperty()
      Returns the observable title property.
      Returns:
      title property
      See Also:
    • setTitle

      public void setTitle(String title)
      Sets the value of the title property.
      Property description:
      Returns the observable title property.
      Parameters:
      title - the value for the title property
      See Also:
    • getContent

      public javafx.scene.Node getContent()
      Gets the value of the content property.
      Property description:
      Returns the observable content property.
      Returns:
      the value of the content property
      See Also:
    • contentProperty

      public javafx.beans.property.ObjectProperty<javafx.scene.Node> contentProperty()
      Returns the observable content property.
      Returns:
      content property
      See Also:
    • setContent

      public void setContent(javafx.scene.Node content)
      Sets the value of the content property.
      Property description:
      Returns the observable content property.
      Parameters:
      content - the value for the content property
      See Also:
    • getIcon

      public javafx.scene.image.Image getIcon()
      Gets the value of the icon property.
      Property description:
      Returns the observable icon property.
      Returns:
      the value of the icon property
      See Also:
    • iconProperty

      public javafx.beans.property.ObjectProperty<javafx.scene.image.Image> iconProperty()
      Returns the observable icon property.
      Returns:
      icon property
      See Also:
    • setIcon

      public void setIcon(javafx.scene.image.Image icon)
      Sets the value of the icon property.
      Property description:
      Returns the observable icon property.
      Parameters:
      icon - the value for the icon property
      See Also:
    • isCloseable

      public boolean isCloseable()
      Gets the value of the closeable property.
      Property description:
      Returns the observable closeable property.
      Returns:
      the value of the closeable property
      See Also:
    • closeableProperty

      public javafx.beans.property.BooleanProperty closeableProperty()
      Returns the observable closeable property.
      Returns:
      closeable property
      See Also:
    • setCloseable

      public void setCloseable(boolean closeable)
      Sets the value of the closeable property.
      Property description:
      Returns the observable closeable property.
      Parameters:
      closeable - the value for the closeable property
      See Also:
    • getParent

      public DockContainer getParent()
      Description copied from interface: DockElement
      Returns the parent container, or null if this is the root.
      Specified by:
      getParent in interface DockElement
      Returns:
      parent container or null
    • setParent

      public void setParent(DockContainer parent)
      Description copied from interface: DockElement
      Sets the parent container.
      Specified by:
      setParent in interface DockElement
      Parameters:
      parent - parent container, or null for detached/root state
    • getLastKnownTarget

      public DockElement getLastKnownTarget()
      Returns the remembered restore target element used for hidden/sidebar/floating restore flows.
      Returns:
      last known target element, or null
    • setLastKnownTarget

      public void setLastKnownTarget(DockElement lastKnownTarget)
      Sets the remembered restore target element.
      Parameters:
      lastKnownTarget - remembered target element, or null
    • getLastKnownPosition

      public DockPosition getLastKnownPosition()
      Returns the remembered restore dock position.
      Returns:
      last known dock position, or null
    • setLastKnownPosition

      public void setLastKnownPosition(DockPosition lastKnownPosition)
      Sets the remembered restore dock position.
      Parameters:
      lastKnownPosition - remembered dock position, or null
    • getLastKnownTabIndex

      public Integer getLastKnownTabIndex()
      Returns the remembered tab index for center/tab restores.
      Returns:
      last known tab index, or null
    • setLastKnownTabIndex

      public void setLastKnownTabIndex(Integer lastKnownTabIndex)
      Sets the remembered tab index for center/tab restores.
      Parameters:
      lastKnownTabIndex - remembered tab index, or null
    • getLastFloatingX

      public Double getLastFloatingX()
      Returns the remembered floating x-position.
      Returns:
      last known floating x-position, or null
    • setLastFloatingX

      public void setLastFloatingX(Double lastFloatingX)
      Sets the remembered floating x-position.
      Parameters:
      lastFloatingX - floating x-position, or null
    • getLastFloatingY

      public Double getLastFloatingY()
      Returns the remembered floating y-position.
      Returns:
      last known floating y-position, or null
    • setLastFloatingY

      public void setLastFloatingY(Double lastFloatingY)
      Sets the remembered floating y-position.
      Parameters:
      lastFloatingY - floating y-position, or null
    • getLastFloatingWidth

      public Double getLastFloatingWidth()
      Returns the remembered floating width.
      Returns:
      last known floating width, or null
    • setLastFloatingWidth

      public void setLastFloatingWidth(Double lastFloatingWidth)
      Sets the remembered floating width.
      Parameters:
      lastFloatingWidth - floating width, or null
    • getLastFloatingHeight

      public Double getLastFloatingHeight()
      Returns the remembered floating height.
      Returns:
      last known floating height, or null
    • setLastFloatingHeight

      public void setLastFloatingHeight(Double lastFloatingHeight)
      Sets the remembered floating height.
      Parameters:
      lastFloatingHeight - floating height, or null
    • getLastFloatingAlwaysOnTop

      public Boolean getLastFloatingAlwaysOnTop()
      Returns the last known floating always-on-top state for this node.
      Returns:
      last known always-on-top state, or null
    • setLastFloatingAlwaysOnTop

      public void setLastFloatingAlwaysOnTop(Boolean lastFloatingAlwaysOnTop)
      Sets the last known floating always-on-top state for this node.
      Parameters:
      lastFloatingAlwaysOnTop - remembered always-on-top state, or null
    • getHiddenRestoreTarget

      public DockNode.HiddenRestoreTarget getHiddenRestoreTarget()
      Returns where this hidden node should be restored.
      Returns:
      hidden restore target
    • setHiddenRestoreTarget

      public void setHiddenRestoreTarget(DockNode.HiddenRestoreTarget hiddenRestoreTarget)
      Sets where this hidden node should be restored.
      Parameters:
      hiddenRestoreTarget - hidden restore target, defaults to DockNode.HiddenRestoreTarget.DOCKED when null
    • toString

      public String toString()
      Overrides:
      toString in class Object