Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize TreeItem used in root and children of a TreeView #7

Merged
merged 25 commits into from
Mar 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d2339f8
Generalize PathItem so that TreeItem subclasses can be used without n…
JordanMartinez Feb 16, 2016
4f2dbdd
Implemented NormalLiveDirs, the new LiveDirs instance that uses the r…
JordanMartinez Feb 16, 2016
016c961
Fix minor code bugs
JordanMartinez Feb 16, 2016
9d29f34
Switched DirectoryModel generics: Initiator before TreeItem#getValue …
JordanMartinez Feb 16, 2016
bef6ac0
Implemented CheckBoxTreeItem-like display for `LiveDirs.model().getRo…
JordanMartinez Feb 19, 2016
20c2e86
Update cases of `CheckBoxContent` to generic
JordanMartinez Feb 19, 2016
1391fb8
Fixed two bugs relating to the checkbox's state:
JordanMartinez Feb 19, 2016
48c0ae9
Partial commit: set up structure needed to separate CheckBoxTreeCell-…
JordanMartinez Feb 19, 2016
58357c0
Partial commit: Moved `src` folder to `livedirsfx` module and copied …
JordanMartinez Feb 19, 2016
fd61bb0
Partial Commit: Update `build.gradle` files to build respective proje…
JordanMartinez Feb 19, 2016
49e3bac
Partial Commit: Update `settings.gradle` files to include both projects.
JordanMartinez Feb 19, 2016
78de587
Partial Commit: Removed factory methods
JordanMartinez Feb 19, 2016
5953f15
Partial Commit: Moved CheckBox related contents to demo package
JordanMartinez Feb 19, 2016
a2425ea
Finish commit: Create a CheckBoxLiveDirs demo
JordanMartinez Feb 19, 2016
3ec63a9
Add a task to execute CheckBoxLiveDirs demo
JordanMartinez Feb 19, 2016
0e2f195
Move NormalLiveDirs' constructors into LiveDirs as static factory met…
JordanMartinez Feb 19, 2016
0d80fd2
Added demo for LiveDirs instances that don't display items as though …
JordanMartinez Feb 19, 2016
f3ce1d9
Added gradle task for NormalLiveDirs demo
JordanMartinez Feb 19, 2016
e60c4c3
Fixed bug in demos: after closing, DirWatcher's threads wouldn't term…
JordanMartinez Feb 19, 2016
7be7a36
Rename `getNormalInstance` to shorter `getInstance`
JordanMartinez Feb 19, 2016
69c4683
Merge branch 'treeItemGeneral' of github.com:JordanMartinez/LiveDirsF…
TomasMikula Feb 19, 2016
1d6c51d
Eliminate some type casts and warnings.
TomasMikula Feb 19, 2016
1f73283
Minor edit that makes code more readable
JordanMartinez Feb 19, 2016
f4b5f63
Merge pull request #1 from TomasMikula/treeItemGeneral
JordanMartinez Feb 19, 2016
8e0f6f0
Dedicate demos to public domain to get around BSD license restrictions
JordanMartinez Mar 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
111 changes: 11 additions & 100 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,107 +1,18 @@
version = '1.0.0-SNAPSHOT'
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'signing'
version = '1.0.0-SNAPSHOT'

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

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

group = 'org.fxmisc.livedirs'

dependencies {
compile group: 'org.reactfx', name: 'reactfx', version: '2.0-M4u1'
}

javadoc {
// ignore missing Javadoc comments or tags
options.addStringOption('Xdoclint:all,-missing', '-quiet')
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives jar

archives javadocJar
archives sourcesJar
}

signing {
sign configurations.archives
}

signArchives.onlyIf {
project.hasProperty('signing.keyId') && project.hasProperty('signing.password') && project.hasProperty('signing.secretKeyRingFile')
}

def doUploadArchives = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')

if(doUploadArchives) {
uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}

pom.project {
name 'LiveDirsFX'
packaging 'jar'
description 'Directory tree model for JavaFX that watches the filesystem for changes.'
url 'http://www.fxmisc.org/livedirs/'

scm {
url 'scm:git@github.com:TomasMikula/LiveDirsFX.git'
connection 'scm:git@github.com:TomasMikula/LiveDirsFX.git'
developerConnection 'scm:git@github.com:TomasMikula/LiveDirsFX.git'
}

licenses {
license {
name 'The BSD 2-Clause License'
url 'http://opensource.org/licenses/BSD-2-Clause'
distribution 'repo'
}
}

developers {
developer {
name 'Tomas Mikula'
}
}
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}

uploadArchives.onlyIf { doUploadArchives }
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

task fatJar(type: Jar, dependsOn: classes) {
appendix = 'fat'
from sourceSets.main.output
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
compileJava.options.deprecation = true
}

assemble.dependsOn fatJar
27 changes: 27 additions & 0 deletions livedirsfx-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
group 'org.fxmisc.livedirs'

dependencies {
compile project(":livedirsfx")
compile group: 'org.reactfx', name: 'reactfx', version: '2.0-M4u1'
}

task fatJar(type: Jar, dependsOn: classes) {
appendix = 'fat'
from sourceSets.main.output
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
}

assemble.dependsOn fatJar

task CheckBoxLiveDirs(type: JavaExec, dependsOn: classes) {
main = 'org.fxmisc.livedirs.demo.CheckBoxLiveDirs'
classpath = files(sourceSets.main.output, configurations.runtime)
description = 'Demonstrates a working LiveDirs instance that displays its items as though' +
'they are CheckBoxTreeItems'
}

task NormalLiveDirs(type: JavaExec, dependsOn: classes) {
main = 'org.fxmisc.livedirs.demo.NormalLiveDirs'
classpath = files(sourceSets.main.output, configurations.runtime)
description = 'Demonstrates a working LiveDirs instance that displays its items normally'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Created 2016 by Jordan Martinez
*
* The author dedicates this to the public domain
*/

package org.fxmisc.livedirs.demo;


public enum ChangeSource {
INTERNAL,
EXTERNAL
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Created 2016 by Jordan Martinez
*
* The author dedicates this to the public domain
*/

package org.fxmisc.livedirs.demo;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.TreeView;
import javafx.stage.Stage;
import org.fxmisc.livedirs.LiveDirs;
import org.fxmisc.livedirs.demo.checkbox.CheckBoxContentImpl;
import org.fxmisc.livedirs.demo.checkbox.TreeCellFactories;

import java.io.IOException;
import java.nio.file.Paths;

public class CheckBoxLiveDirs extends Application {

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
TreeView<CheckBoxContentImpl> view = new TreeView<>();
view.setShowRoot(false);
view.setCellFactory(TreeCellFactories.checkBoxFactory());

try {
// create a LiveDirs instance for use on the JavaFX Application Thread
// and make it display its items as though they were CheckBoxTreeItems
LiveDirs<ChangeSource, CheckBoxContentImpl> dirs = new LiveDirs<>(ChangeSource.EXTERNAL,
CheckBoxContentImpl::getPath, CheckBoxContentImpl::new, Platform::runLater);

// set directory to watch
dirs.addTopLevelDirectory(Paths.get(System.getProperty("user.home"), "Documents").toAbsolutePath());
view.setRoot(dirs.model().getRoot());

// stop DirWatcher's thread
primaryStage.setOnCloseRequest(val -> dirs.dispose());
} catch (IOException e) {
e.printStackTrace();
}

primaryStage.setScene(new Scene(view, 500, 500));
primaryStage.show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Created 2016 by Jordan Martinez
*
* The author dedicates this to the public domain
*/

package org.fxmisc.livedirs.demo;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TreeView;
import javafx.stage.Stage;
import org.fxmisc.livedirs.LiveDirs;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class NormalLiveDirs extends Application {

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
TreeView<Path> view = new TreeView<>();
view.setShowRoot(false);

try {
// create a LiveDirs instance for use on the JavaFX Application Thread
LiveDirs<ChangeSource, Path> dirs = LiveDirs.getInstance(ChangeSource.EXTERNAL);

// set directory to watch
dirs.addTopLevelDirectory(Paths.get(System.getProperty("user.home"), "Documents").toAbsolutePath());
view.setRoot(dirs.model().getRoot());

// stop DirWatcher's thread
primaryStage.setOnCloseRequest(val -> dirs.dispose());
} catch (IOException e) {
e.printStackTrace();
}

primaryStage.setScene(new Scene(view, 500, 500));
primaryStage.show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Created 2016 by Jordan Martinez
*
* The author dedicates this to the public domain
*/

package org.fxmisc.livedirs.demo.checkbox;

import org.reactfx.value.Var;

import java.nio.file.Path;

public interface CheckBoxContent {

/** The State of the {@link javafx.scene.control.CheckBox} */
enum State {
UNCHECKED,
UNDEFINED,
CHECKED
}

State getState();
void setState(State value);
Var<State> stateProperty();

Path getPath();
void setPath(Path p);

void lock();
void unlock();
boolean isLocked();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Created 2016 by Jordan Martinez
*
* The author dedicates this to the public domain
*/

package org.fxmisc.livedirs.demo.checkbox;

import org.reactfx.value.Var;

import java.nio.file.Path;

/**
* A basic implementation of {@link CheckBoxContent}
*/
public class CheckBoxContentImpl implements CheckBoxContent {

private final Var<State> state = Var.newSimpleVar(State.UNCHECKED);
public final State getState() { return state.getValue(); }
public final void setState(State value) { state.setValue(value); }
public final Var<State> stateProperty() { return state; }

private Path path;
public final Path getPath() { return path; }
public final void setPath(Path p) { path = p; }

private boolean locked = false;
public final boolean isLocked() { return locked; }
public final void lock() { locked = true; }
public final void unlock() { locked = false; }

public CheckBoxContentImpl(Path p) {
path = p;
}
}