Coder Social home page Coder Social logo

livedirsfx's Introduction

LiveDirsFX

LiveDirsFX is a combination of a directory watcher, a directory-tree model (for TreeView) and a simple asynchronous file I/O facility. The extra benefits of this combination are:

  1. Automatic synchronization of the directory model with the filesystem.
  2. Ability to distinguish directory and file modifications made by the application (through the I/O facility) from external modifications.

Example

enum ChangeSource {
    INTERNAL, // indicates a change made by this application
    EXTERNAL, // indicates an external change
}

// create LiveDirs to watch a directory
LiveDirs<ChangeSource> liveDirs = new LiveDirs<>(EXTERNAL);
Path dir = Paths.get("/path/to/watched/directory/");
liveDirs.addTopLevelDirectory(dir);

// use LiveDirs as a TreeView model
TreeView<Path> treeView = new TreeView<>(liveDirs.model().getRoot());
treeView.setShowRoot(false);

// handle external changes
liveDirs.model().modifications().subscribe(m -> {
    if(m.getInitiator() == EXTERNAL) {
        // handle external modification, e.g. reload the modified file
        reload(m.getPath());
    } else {
        // modification done by this application, no extra action needed
    }
});

// Use LiveDirs's I/O facility to write to the filesystem,
// in order to be able to distinguish between internal and external changes.
Path file = dir.resolve("some/file.txt");
liveDirs.io().saveUTF8File(file, "Hello text file!", INTERNAL);

// clean up
liveDirs.dispose();

Use LiveDirsFX in your project

Method 1: as a managed dependency (recommended)

Snapshot releases are deployed to Sonatype snapshot repository with these Maven coordinates

Group ID Artifact ID Version
org.fxmisc.livedirs livedirsfx 1.0.0-SNAPSHOT

Gradle example

repositories {
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots/' 
    }
}

dependencies {
    compile group: 'org.fxmisc.livedirs', name: 'livedirsfx', version: '1.0.0-SNAPSHOT'
}

Sbt example

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

libraryDependencies += "org.fxmisc.livedirs" % "livedirsfx" % "1.0.0-SNAPSHOT"

Method 2: as an unmanaged dependency

Download the latest JAR or fat JAR (including dependencies) and place it on your classpath.

Links

Javadoc

livedirsfx's People

Contributors

jordanmartinez avatar tomasmikula avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

livedirsfx's Issues

Lazy loading

Hi, Tomas! Thanks for bringing ReactFX to the world.

Any chance to implement lazy loading in LiveDirsFX, so that the children list would be loaded as a user expands TreeItem? Could you point me in the right direction?

Consolidate shared directories into one row in TreeView

In Intellij Idea, the TreeView displays their files like so:

some/package/name/
    firstName/
        text.java
        code.java
    secondName/
        subPackage/
            someClass.java
        writer.java

Currently, LiveDirsFX does not support this option to consolidate directories into one row. So, the above files would be displayed as:

some/
    some/package
        some/package/name/
        some/package/name/firstName/
            some/package/name/firstName/text.java
            some/package/name/firstName/code.java
        some/package/name/secondName/
            some/package/name/secondName/subPackage/
                some/package/name/secondName/subPackage/someClass.java
            some/package/name/secondName/writer.java

Allow CheckBoxTreeCell CellFactory

I was hoping to use this library in JGitFX. However, LiveDirs does not allow the option of using the CheckBoxTreeCell factory, which is essential for designing a commit or revert dialog where the user can check which files they want to stage and commit or revert.

Unable to initialize the view

Hi,
I was trying to implement LiveDirsFX in my code. But it is giving me error on LinuxMint (18.1).

Exception in Application start method
   java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
    Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.ExceptionInInitializerError
at org.fxmisc.livedirs.DirectoryModel.<clinit>(DirectoryModel.java:101)
at org.fxmisc.livedirs.LiveDirsModel.<init>(LiveDirsModel.java:27)
at org.fxmisc.livedirs.LiveDirs.<init>(LiveDirs.java:90)
at org.fxmisc.livedirs.LiveDirs.getInstance(LiveDirs.java:65)
at org.fxmisc.livedirs.LiveDirs.getInstance(LiveDirs.java:52)
at in.co.s13.marking.assistant.MarkingAssistant.start(MarkingAssistant.java:61)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
... 1 more
    Caused by: java.lang.NullPointerException
at org.fxmisc.livedirs.DefaultGraphicFactory.<clinit>(DirectoryModel.java:143)
... 15 more
    Exception running application in.co.s13.marking.assistant.MarkingAssistant
    Java Result: 1

Any ideas ??

Maven central?

Hey everyone,
is there a way to use LiveDirs from Maven Central?

best regards
Patrick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.