Class ResourceTree

Object
Node
Parent
Region
Control
TreeView<Resource>
ResourceTree
All Implemented Interfaces:
Styleable, Event­Target, Skinnable

public class ResourceTree extends TreeView<Resource>
A view of data Resources organized as a tree. This view can be used for showing the content of one or many Data­Stores. A resource can be added by a call to add­Resource(Resource) or loaded from a file by load­Resource(Object).

Resource­Tree registers the necessarily handlers for making this view a target of "drag and drop" events. Users can drop files or URLs for opening data files.

Limitations

  • The root­Property should be considered read-only. For changing content, use the set­Resource(Resource) instead.
  • If the user selects "close" in the contextual menu, the resource is unconditionally closed (if it is an instance of Data­Store). There is not yet a mechanism for keeping it open if the resource is shared by another Resource­Tree instance.
Since:
1.1

Defined in the sis-javafx module

  • Property Summary

    Properties inherited from class TreeView

    cell­Factory, editable, editing­Item, expanded­Item­Count, fixed­Cell­Size, focus­Model, on­Edit­Cancel, on­Edit­Commit, on­Edit­Start, on­Scroll­To, root, selection­Model, show­Root

    Properties inherited from class Control

    context­Menu, skin, tooltip

    Properties inherited from class Region

    background, border, cache­Shape, center­Shape, height, insets, max­Height, max­Width, min­Height, min­Width, opaque­Insets, padding, pref­Height, pref­Width, scale­Shape, shape, snap­To­Pixel, width

    Properties inherited from class Parent

    needs­Layout

    Properties inherited from class Node

    accessible­Help, accessible­Role­Description, accessible­Role, accessible­Text, blend­Mode, bounds­In­Local, bounds­In­Parent, cache­Hint, cache, clip, cursor, depth­Test, disabled, disable, effective­Node­Orientation, effect, event­Dispatcher, focused, focus­Traversable, hover, id, input­Method­Requests, layout­Bounds, layout­X, layout­Y, local­To­Parent­Transform, local­To­Scene­Transform, managed, mouse­Transparent, node­Orientation, on­Context­Menu­Requested, on­Drag­Detected, on­Drag­Done, on­Drag­Dropped, on­Drag­Entered, on­Drag­Exited, on­Drag­Over, on­Input­Method­Text­Changed, on­Key­Pressed, on­Key­Released, on­Key­Typed, on­Mouse­Clicked, on­Mouse­Drag­Entered, on­Mouse­Drag­Exited, on­Mouse­Dragged, on­Mouse­Drag­Over, on­Mouse­Drag­Released, on­Mouse­Entered, on­Mouse­Exited, on­Mouse­Moved, on­Mouse­Pressed, on­Mouse­Released, on­Rotate, on­Rotation­Finished, on­Rotation­Started, on­Scroll­Finished, on­Scroll, on­Scroll­Started, on­Swipe­Down, on­Swipe­Left, on­Swipe­Right, on­Swipe­Up, on­Touch­Moved, on­Touch­Pressed, on­Touch­Released, on­Touch­Stationary, on­Zoom­Finished, on­Zoom, on­Zoom­Started, opacity, parent, pick­On­Bounds, pressed, rotate, rotation­Axis, scale­X, scale­Y, scale­Z, scene, style, translate­X, translate­Y, translate­Z, view­Order, visible
  • Nested Class Summary

    Nested classes/interfaces inherited from class TreeView

    Tree­View​.Edit­Event<T extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Object­Property<Event­Handler<Resource­Event>>
    Function to be called after a resource has been closed from a file or URL.
    final Object­Property<Event­Handler<Resource­Event>>
    Function to be called after a resource has been loaded from a file or URL.

    Fields inherited from class Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new tree of resources with initially no resource to show.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Adds a resource in this tree below previously added resources.
    Returns the root Resource of this tree.
    void
    Loads in a background thread the resources from the given source, then adds the resource to this tree.
    void
    Removes the given resource from this tree and closes the resource if it is a Data­Store instance.
    void
    Sets the root Resource of this tree.

    Methods inherited from class TreeView

    cell­Factory­Property, create­Default­Skin, edit, editable­Property, edit­Any­Event, edit­Cancel­Event, edit­Commit­Event, editing­Item­Property, edit­Start­Event, expanded­Item­Count­Property, fixed­Cell­Size­Property, focus­Model­Property, get­Cell­Factory, get­Class­Css­Meta­Data, get­Control­Css­Meta­Data, get­Editing­Item, get­Expanded­Item­Count, get­Fixed­Cell­Size, get­Focus­Model, get­Node­Level, get­On­Edit­Cancel, get­On­Edit­Commit, get­On­Edit­Start, get­On­Scroll­To, get­Root, get­Row, get­Selection­Model, get­Tree­Item, get­Tree­Item­Level, is­Editable, is­Show­Root, layout­Children, on­Edit­Cancel­Property, on­Edit­Commit­Property, on­Edit­Start­Property, on­Scroll­To­Property, query­Accessible­Attribute, refresh, root­Property, scroll­To, selection­Model­Property, set­Cell­Factory, set­Editable, set­Fixed­Cell­Size, set­Focus­Model, set­On­Edit­Cancel, set­On­Edit­Commit, set­On­Edit­Start, set­On­Scroll­To, set­Root, set­Selection­Model, set­Show­Root, show­Root­Property

    Methods inherited from class Control

    compute­Max­Height, compute­Max­Width, compute­Min­Height, compute­Min­Width, compute­Pref­Height, compute­Pref­Width, context­Menu­Property, execute­Accessible­Action, get­Baseline­Offset, get­Context­Menu, get­Css­Meta­Data, get­Initial­Focus­Traversable, get­Skin, get­Tooltip, is­Resizable, set­Context­Menu, set­Skin, set­Tooltip, skin­Property, tooltip­Property

    Methods inherited from class Region

    background­Property, border­Property, cache­Shape­Property, center­Shape­Property, get­Background, get­Border, get­Height, get­Insets, get­Max­Height, get­Max­Width, get­Min­Height, get­Min­Width, get­Opaque­Insets, get­Padding, get­Pref­Height, get­Pref­Width, get­Shape, get­User­Agent­Stylesheet, get­Width, height­Property, insets­Property, is­Cache­Shape, is­Center­Shape, is­Scale­Shape, is­Snap­To­Pixel, layout­In­Area, layout­In­Area, layout­In­Area, layout­In­Area, max­Height, max­Height­Property, max­Width, max­Width­Property, min­Height, min­Height­Property, min­Width, min­Width­Property, opaque­Insets­Property, padding­Property, position­In­Area, position­In­Area, pref­Height, pref­Height­Property, pref­Width, pref­Width­Property, resize, scale­Shape­Property, set­Background, set­Border, set­Cache­Shape, set­Center­Shape, set­Height, set­Max­Height, set­Max­Size, set­Max­Width, set­Min­Height, set­Min­Size, set­Min­Width, set­Opaque­Insets, set­Padding, set­Pref­Height, set­Pref­Size, set­Pref­Width, set­Scale­Shape, set­Shape, set­Snap­To­Pixel, set­Width, shape­Property, snapped­Bottom­Inset, snapped­Left­Inset, snapped­Right­Inset, snapped­Top­Inset, snap­Position, snap­Position­X, snap­Position­Y, snap­Size, snap­Size­X, snap­Size­Y, snap­Space, snap­Space­X, snap­Space­Y, snap­To­Pixel­Property, width­Property

    Methods inherited from class Parent

    get­Children, get­Children­Unmodifiable, get­Managed­Children, get­Stylesheets, is­Needs­Layout, layout, lookup, needs­Layout­Property, request­Layout, request­Parent­Layout, set­Needs­Layout, update­Bounds

    Methods inherited from class Node

    accessible­Help­Property, accessible­Role­Description­Property, accessible­Role­Property, accessible­Text­Property, add­Event­Filter, add­Event­Handler, apply­Css, autosize, blend­Mode­Property, bounds­In­Local­Property, bounds­In­Parent­Property, build­Event­Dispatch­Chain, cache­Hint­Property, cache­Property, clip­Property, compute­Area­In­Screen, contains, contains, cursor­Property, depth­Test­Property, disabled­Property, disable­Property, effective­Node­Orientation­Property, effect­Property, event­Dispatcher­Property, fire­Event, focused­Property, focus­Traversable­Property, get­Accessible­Help, get­Accessible­Role, get­Accessible­Role­Description, get­Accessible­Text, get­Blend­Mode, get­Bounds­In­Local, get­Bounds­In­Parent, get­Cache­Hint, get­Clip, get­Content­Bias, get­Cursor, get­Depth­Test, get­Effect, get­Effective­Node­Orientation, get­Event­Dispatcher, get­Id, get­Initial­Cursor, get­Input­Method­Requests, get­Layout­Bounds, get­Layout­X, get­Layout­Y, get­Local­To­Parent­Transform, get­Local­To­Scene­Transform, get­Node­Orientation, get­On­Context­Menu­Requested, get­On­Drag­Detected, get­On­Drag­Done, get­On­Drag­Dropped, get­On­Drag­Entered, get­On­Drag­Exited, get­On­Drag­Over, get­On­Input­Method­Text­Changed, get­On­Key­Pressed, get­On­Key­Released, get­On­Key­Typed, get­On­Mouse­Clicked, get­On­Mouse­Drag­Entered, get­On­Mouse­Drag­Exited, get­On­Mouse­Dragged, get­On­Mouse­Drag­Over, get­On­Mouse­Drag­Released, get­On­Mouse­Entered, get­On­Mouse­Exited, get­On­Mouse­Moved, get­On­Mouse­Pressed, get­On­Mouse­Released, get­On­Rotate, get­On­Rotation­Finished, get­On­Rotation­Started, get­On­Scroll, get­On­Scroll­Finished, get­On­Scroll­Started, get­On­Swipe­Down, get­On­Swipe­Left, get­On­Swipe­Right, get­On­Swipe­Up, get­On­Touch­Moved, get­On­Touch­Pressed, get­On­Touch­Released, get­On­Touch­Stationary, get­On­Zoom, get­On­Zoom­Finished, get­On­Zoom­Started, get­Opacity, get­Parent, get­Properties, get­Pseudo­Class­States, get­Rotate, get­Rotation­Axis, get­Scale­X, get­Scale­Y, get­Scale­Z, get­Scene, get­Style, get­Styleable­Parent, get­Style­Class, get­Transforms, get­Translate­X, get­Translate­Y, get­Translate­Z, get­Type­Selector, get­User­Data, get­View­Order, has­Properties, hover­Property, id­Property, input­Method­Requests­Property, intersects, intersects, is­Cache, is­Disable, is­Disabled, is­Focused, is­Focus­Traversable, is­Hover, is­Managed, is­Mouse­Transparent, is­Pick­On­Bounds, is­Pressed, is­Visible, layout­Bounds­Property, layout­XProperty, layout­YProperty, local­To­Parent, local­To­Parent, local­To­Parent, local­To­Parent, local­To­Parent, local­To­Parent­Transform­Property, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene, local­To­Scene­Transform­Property, local­To­Screen, local­To­Screen, local­To­Screen, local­To­Screen, local­To­Screen, lookup­All, managed­Property, mouse­Transparent­Property, node­Orientation­Property, notify­Accessible­Attribute­Changed, on­Context­Menu­Requested­Property, on­Drag­Detected­Property, on­Drag­Done­Property, on­Drag­Dropped­Property, on­Drag­Entered­Property, on­Drag­Exited­Property, on­Drag­Over­Property, on­Input­Method­Text­Changed­Property, on­Key­Pressed­Property, on­Key­Released­Property, on­Key­Typed­Property, on­Mouse­Clicked­Property, on­Mouse­Drag­Entered­Property, on­Mouse­Drag­Exited­Property, on­Mouse­Dragged­Property, on­Mouse­Drag­Over­Property, on­Mouse­Drag­Released­Property, on­Mouse­Entered­Property, on­Mouse­Exited­Property, on­Mouse­Moved­Property, on­Mouse­Pressed­Property, on­Mouse­Released­Property, on­Rotate­Property, on­Rotation­Finished­Property, on­Rotation­Started­Property, on­Scroll­Finished­Property, on­Scroll­Property, on­Scroll­Started­Property, on­Swipe­Down­Property, on­Swipe­Left­Property, on­Swipe­Right­Property, on­Swipe­Up­Property, on­Touch­Moved­Property, on­Touch­Pressed­Property, on­Touch­Released­Property, on­Touch­Stationary­Property, on­Zoom­Finished­Property, on­Zoom­Property, on­Zoom­Started­Property, opacity­Property, parent­Property, parent­To­Local, parent­To­Local, parent­To­Local, parent­To­Local, parent­To­Local, pick­On­Bounds­Property, pressed­Property, pseudo­Class­State­Changed, relocate, remove­Event­Filter, remove­Event­Handler, request­Focus, resize­Relocate, rotate­Property, rotation­Axis­Property, scale­XProperty, scale­YProperty, scale­ZProperty, scene­Property, scene­To­Local, scene­To­Local, scene­To­Local, scene­To­Local, scene­To­Local, scene­To­Local, scene­To­Local, scene­To­Local, screen­To­Local, screen­To­Local, screen­To­Local, set­Accessible­Help, set­Accessible­Role, set­Accessible­Role­Description, set­Accessible­Text, set­Blend­Mode, set­Cache, set­Cache­Hint, set­Clip, set­Cursor, set­Depth­Test, set­Disable, set­Disabled, set­Effect, set­Event­Dispatcher, set­Event­Handler, set­Focused, set­Focus­Traversable, set­Hover, set­Id, set­Input­Method­Requests, set­Layout­X, set­Layout­Y, set­Managed, set­Mouse­Transparent, set­Node­Orientation, set­On­Context­Menu­Requested, set­On­Drag­Detected, set­On­Drag­Done, set­On­Drag­Dropped, set­On­Drag­Entered, set­On­Drag­Exited, set­On­Drag­Over, set­On­Input­Method­Text­Changed, set­On­Key­Pressed, set­On­Key­Released, set­On­Key­Typed, set­On­Mouse­Clicked, set­On­Mouse­Drag­Entered, set­On­Mouse­Drag­Exited, set­On­Mouse­Dragged, set­On­Mouse­Drag­Over, set­On­Mouse­Drag­Released, set­On­Mouse­Entered, set­On­Mouse­Exited, set­On­Mouse­Moved, set­On­Mouse­Pressed, set­On­Mouse­Released, set­On­Rotate, set­On­Rotation­Finished, set­On­Rotation­Started, set­On­Scroll, set­On­Scroll­Finished, set­On­Scroll­Started, set­On­Swipe­Down, set­On­Swipe­Left, set­On­Swipe­Right, set­On­Swipe­Up, set­On­Touch­Moved, set­On­Touch­Pressed, set­On­Touch­Released, set­On­Touch­Stationary, set­On­Zoom, set­On­Zoom­Finished, set­On­Zoom­Started, set­Opacity, set­Pick­On­Bounds, set­Pressed, set­Rotate, set­Rotation­Axis, set­Scale­X, set­Scale­Y, set­Scale­Z, set­Style, set­Translate­X, set­Translate­Y, set­Translate­Z, set­User­Data, set­View­Order, set­Visible, snapshot, snapshot, start­Drag­And­Drop, start­Full­Drag, style­Property, to­Back, to­Front, to­String, translate­XProperty, translate­YProperty, translate­ZProperty, uses­Mirroring, view­Order­Property, visible­Property

    Methods inherited from class Object

    clone, equals, finalize, get­Class, hash­Code, notify, notify­All, wait, wait, wait

    Methods inherited from interface Styleable

    get­Styleable­Node
  • Field Details

    • onResourceLoaded

      public final ObjectProperty<EventHandler<ResourceEvent>> onResourceLoaded
      Function to be called after a resource has been loaded from a file or URL. The default value is null.
      See Also:
    • onResourceClosed

      public final ObjectProperty<EventHandler<ResourceEvent>> onResourceClosed
      Function to be called after a resource has been closed from a file or URL. The default value is null.
      Since:
      1.2
      See Also:
  • Constructor Details

    • ResourceTree

      public ResourceTree()
      Creates a new tree of resources with initially no resource to show. For showing a resource, invoke set­Resource(Resource) after construction.
  • Method Details

    • getResource

      public Resource getResource()
      Returns the root Resource of this tree. The returned value depends on how the resource was set:
      Returns:
      root Resource, or null if none.
    • setResource

      public void setResource(Resource resource)
      Sets the root Resource of this tree. The root resource is typically, but not necessarily, a Data­Store instance. If another root resource existed before this method call, it is discarded without being closed. Closing the previous resource is caller's responsibility.

      Modified tree view properties

      This method updates the root and show­Root properties of Tree­View in an implementation-dependent way.
      Parameters:
      resource - the root resource to show, or null if none.
      See Also:
    • addResource

      public boolean addResource(Resource resource)
      Adds a resource in this tree below previously added resources. This method does nothing if the given resource is already present in this tree.

      Modified tree view properties

      This method updates the root and show­Root properties of Tree­View in an implementation-dependent way.
      Parameters:
      resource - the root resource to add, or null if none.
      Returns:
      true if the given resource has been added, or false if it was already presents or if the given resource is null.
      See Also:
    • loadResource

      public void loadResource(Object source)
      Loads in a background thread the resources from the given source, then adds the resource to this tree. If the resource has already been loaded, then this method will use the existing instance instead of loading the data again.

      Notifications

      If on­Resource­Loaded has a non-null value, the Event­Handler will be notified in JavaFX thread after the background thread finished to open the resource. If an exception occurs while opening the resource, then Event­Handler is not notified and the error is reported in a dialog box instead.
      Parameters:
      source - the source of the resource to load. This is usually a File or Path.
      See Also:
    • removeAndClose

      public void removeAndClose(Resource resource)
      Removes the given resource from this tree and closes the resource if it is a Data­Store instance. It is caller's responsibility to ensure that the given resource is not used anymore.

      Only the "root" resources (such as the resources given to set­Resource(Resource) or add­Resource(Resource) methods) can be removed. Children of Aggregate resource and not scanned. If the given resource can not be removed, then this method does nothing.

      Notifications

      If on­Resource­Closed has a non-null value, the Event­Handler will be notified. The notification may happen in same time that the resource is closing in a background thread. If an exception occurs while closing the resource, the error is reported in a dialog box.
      Parameters:
      resource - the resource to remove. Null values are ignored.
      See Also: