-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from JordanMartinez/treeItemGeneral
Generalize the content of TreeItems from Path to arbitrary T, given functions T -> Path and Path -> T.
- Loading branch information
Showing
23 changed files
with
650 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:[email protected]:TomasMikula/LiveDirsFX.git' | ||
connection 'scm:[email protected]:TomasMikula/LiveDirsFX.git' | ||
developerConnection 'scm:[email protected]: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
13 changes: 13 additions & 0 deletions
13
livedirsfx-demo/src/main/java/org/fxmisc/livedirs/demo/ChangeSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
52 changes: 52 additions & 0 deletions
52
livedirsfx-demo/src/main/java/org/fxmisc/livedirs/demo/CheckBoxLiveDirs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
livedirsfx-demo/src/main/java/org/fxmisc/livedirs/demo/NormalLiveDirs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
livedirsfx-demo/src/main/java/org/fxmisc/livedirs/demo/checkbox/CheckBoxContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
livedirsfx-demo/src/main/java/org/fxmisc/livedirs/demo/checkbox/CheckBoxContentImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.