Skip to content

Instantly share code, notes, and snippets.

@guigarage
guigarage / gist:23b4bbed2823e84b9a52
Created October 22, 2014 22:27
DataFX dependency
<dependencies>
<dependency>
<groupId>org.javafxdata</groupId>
<artifactId>datafx-core</artifactId>
<version>8.0</version>
</dependency>
</dependencies>
@guigarage
guigarage / ProcessChain usage
Created October 22, 2014 16:41
Background thread DataFX way - ProcessChain
ProcessChain.create().
addRunnableInPlatformThread(() -> blockUI()).
addSupplierInExecutor(() -> loadFromServer()).
addConsumerInPlatformThread(d -> updateUI(d)).
onException(e -> handleException(e)).
withFinal(() -> unblockUI()).
run();
@guigarage
guigarage / background thread - old way
Created October 22, 2014 16:40
background thread - old way
Runnable backgroundRunnable = () -> {
try {
data = loadFromServer();
Platform.runLater(() -> {
updateUI(data);
});
} catch(Exception e) {
Platform.runLater(() -> {
handleException(e);
});
@guigarage
guigarage / DataFX concurreny
Created October 22, 2014 16:22
JavaFX concurreny
ProcessChain.create().
addRunnableInPlatformThread(() -> blockUI()).
addSupplierInExecutor(() -> loadFromServer()).
addConsumerInPlatformThread(d -> updateUI(d)).
onException(e -> handleException(e)).
withFinal(() -> unblockUI()).
run();
@guigarage
guigarage / gist:1344280c2b5d52e1022e
Last active August 29, 2015 14:06
Test by using DialogObjects
@Test
public void checkSearchResult() {
new SearchView(this).search("Rise Against").assertContainsAlbum("The Black Market");
}
@Test
public void checkTrackCount() {
new SearchView(this).search("Rise Against").openAlbum("The Black Market").checkTrackCountOfSelectedAlbum(12);
}
@guigarage
guigarage / gist:5a3b3b2ad9c881e442e2
Last active August 29, 2015 14:06
DialogObject example
public class AlbumOverviewView extends ViewObject {
public AlbumDetailView openAlbum(String name) {
click((Text t) -> t.getText().contains(name));
return new AlbumDetailView(getTestHandler());
}
public AlbumOverviewView checkAlbumCount(int count) {
assertEquals(count, getList().size());
return this;
@guigarage
guigarage / gist:f2e063f2dcfb2c13a0dc
Created September 16, 2014 20:18
Confusing test
click("#user-field").type("steve");
click("#password-field").type("duke4ever");
click("#login-button");
click("#menu-button");
click("#action-35");
click("#tab-5");
click("#next");
click("#next");
click("#next");
click("#details");
@guigarage
guigarage / gist:fdd0b18b388e4d52645a
Created September 16, 2014 20:12
TestFX example
click(".text-field").type("steve");
click(".password-field").type("duke4ever");
click(".button:default");
assertNodeExists( ".dialog" );
@guigarage
guigarage / gist:481588c1f5148d348886
Created September 16, 2014 19:57
new CSS Parser
#myButton {
-fx-icon: "fa fa-pencil";
}
@guigarage
guigarage / gist:73bb8632aaf658216ae1
Created September 16, 2014 19:52
Define an awesome icon for a button
#myButton {
-fx-icon-text: "\uf0a9";
}