Module xaos.ui

Class TreeDirectoryModel<I,​T>

    • Field Detail

      • DEFAULT_GRAPHIC_FACTORY

        public static final TreeDirectoryModel.GraphicFactory DEFAULT_GRAPHIC_FACTORY
        Graphic factory that returns a folder icon for a directory and a document icon for a regular file.
    • Constructor Detail

      • TreeDirectoryModel

        public TreeDirectoryModel​(I defaultInitiator,
                                  Function<T,​Path> projector,
                                  Function<Path,​T> injector)
        Create a new instance of this model.
        Parameters:
        defaultInitiator - The initiator used when not explicitly provided as parameter in methods.
        projector - A Function converting the object returned by TreeItem.getValue()) into the corresponding Path.
        injector - A Function converting a Path into the object used as value in the corresponding TreeItem.
    • Method Detail

      • addDirectory

        public void addDirectory​(Path directory)
        Add a no-top-lever directory to the model.
        Parameters:
        directory - The Path to be added as a directory.
      • addDirectory

        public void addDirectory​(Path directory,
                                 I initiator)
        Add a no-top-level directory to the model.
        Parameters:
        directory - The Path to be added as a directory.
        initiator - The initiator of changes to the model.
      • addFile

        public void addFile​(Path file,
                            FileTime lastModified)
        Add a file to the model.
        Parameters:
        file - The Path to be added as a file.
        lastModified - The timestamp of the last modification to the file.
      • addFile

        public void addFile​(Path file,
                            FileTime lastModified,
                            I initiator)
        Add a file to the model.
        Parameters:
        file - The Path to be added as a file.
        lastModified - The timestamp of the last modification to the file.
        initiator - The initiator of changes to the model.
      • addTopLevelDirectory

        public void addTopLevelDirectory​(Path directory)
        Add a top-lever directory to the model.

        Note: The model is not synchronized automatically with the given directory. An explicit call to sync(Path), or sync(Path, java.lang.Object) has to be performed if synchronization is required.

        Parameters:
        directory - The Path to be added as a top-level directory.
      • contains

        public boolean contains​(Path path)
        Description copied from interface: DirectoryModel
        Indicates whether this directory model contains the given path.
        Specified by:
        contains in interface DirectoryModel<I,​T>
        Parameters:
        path - The Path to be verified.
        Returns:
        true if the given path is contained in this model.
      • containsPrefixOf

        public boolean containsPrefixOf​(Path path)
        Indicates whether this directory model contains roots whose name is a prefix in the given path name.
        Parameters:
        path - The Path to be verified.
        Returns:
        true if this directory model contains roots whose name is a prefix in the given path name.
      • delete

        public void delete​(Path path)
        Delete the given path from the model.
        Parameters:
        path - The Path to be removed.
      • delete

        public void delete​(Path path,
                           I initiator)
        Delete the given path from the model.
        Parameters:
        path - The Path to be removed.
        initiator - The initiator of changes to the model.
      • dispose

        public void dispose()
        Specified by:
        dispose in interface io.reactivex.disposables.Disposable
      • errors

        public io.reactivex.Observable<Throwable> errors()
        Specified by:
        errors in interface DirectoryModel<I,​T>
        Returns:
        An observable stream of errors.
      • isDisposed

        public boolean isDisposed()
        Specified by:
        isDisposed in interface io.reactivex.disposables.Disposable
      • sync

        public void sync​(Path directory)
        Synchronize the model with the given directory element. Missing items will be added to the model for the expanded tree items, and a callback is registered to update the collapsed tree items when will expand. Items will be removed from the model if no more existing. Files timestamps will be updated too.
        Parameters:
        directory - The Path used to synchronize the model.
      • sync

        public void sync​(Path directory,
                         I initiator)
        Synchronize the model with the given directory element. Missing items will be added to the model for the expanded tree items, and a callback is registered to update the collapsed tree items when will expand. Items will be removed from the model if no more existing. Files timestamps will be updated too.
        Parameters:
        directory - The Path used to synchronize the model.
        initiator - The initiator of changes to the model.
      • updateModificationTime

        public void updateModificationTime​(Path path,
                                           FileTime lastModified)
        Updates the modification time for the item associated to the given Path.
        Parameters:
        path - The path whose associated item must be updated.
        lastModified - The new modification time.
      • updateModificationTime

        public void updateModificationTime​(Path path,
                                           FileTime lastModified,
                                           I initiator)
        Updates the modification time for the item associated to the given Path.
        Parameters:
        path - The path whose associated item must be updated.
        lastModified - The new modification time.
        initiator - The initiator of changes to the model.