From d128b72e94b123189e9ff8bdacea9d50cf4d5252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ko=C5=BEusznik?= <jan@kozusznik.cz> Date: Wed, 13 Jun 2018 11:16:39 +0200 Subject: [PATCH] feature: get ready for update pom.xml - define UTF8 as encoding, add copy dependend jars refactoring - extract problematic inner classes --- haas-imagej-client/pom.xml | 28 ++++++--- .../it4i/fiji/haas/ui/FutureValueUpdater.java | 32 ++++++++++ .../cz/it4i/fiji/haas/ui/JavaFXRoutines.java | 60 ------------------- .../it4i/fiji/haas/ui/StringValueUpdater.java | 15 +++++ .../it4i/fiji/haas/ui/TableCellAdapter.java | 24 ++++++++ haas-java-client/pom.xml | 9 +-- .../configuration.properties.template | 0 haas-spim-benchmark/pom.xml | 36 +++++------ .../ui/BenchmarkSPIMControl.java | 9 ++- .../SPIMPipelineProgressViewController.java | 3 +- .../configuration.properties.template | 4 -- java-scpclient/pom.xml | 3 + 12 files changed, 122 insertions(+), 101 deletions(-) create mode 100644 haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FutureValueUpdater.java create mode 100644 haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/StringValueUpdater.java create mode 100644 haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/TableCellAdapter.java rename haas-java-client/src/{main => test}/resources/configuration.properties.template (100%) delete mode 100644 haas-spim-benchmark/src/main/resources/configuration.properties.template diff --git a/haas-imagej-client/pom.xml b/haas-imagej-client/pom.xml index 93bb30ca..c9d490c6 100644 --- a/haas-imagej-client/pom.xml +++ b/haas-imagej-client/pom.xml @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -60,16 +61,16 @@ <properties> <license.licenseName>${license.base.licenseName}</license.licenseName> <license.copyrightOwners>${license.base.copyrightOwners}</license.copyrightOwners> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> - - + <dependencies> <dependency> <groupId>net.imagej</groupId> <artifactId>imagej</artifactId> <scope>provided</scope> </dependency> - + <dependency> <groupId>cz.it4i.fiji</groupId> <artifactId>haas-java-client</artifactId> @@ -90,10 +91,21 @@ <!-- https://mvnrepository.com/artifact/org.yaml/snakeyaml --> <dependency> - <groupId>org.yaml</groupId> - <artifactId>snakeyaml</artifactId> - <version>1.19</version> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>1.19</version> </dependency> - </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FutureValueUpdater.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FutureValueUpdater.java new file mode 100644 index 00000000..8400e18a --- /dev/null +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FutureValueUpdater.java @@ -0,0 +1,32 @@ +package cz.it4i.fiji.haas.ui; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + +import cz.it4i.fiji.haas.ui.TableCellAdapter.TableCellUpdater; +import javafx.scene.control.TableCell; + +public class FutureValueUpdater<S, T, U extends CompletableFuture<T>> implements TableCellUpdater<S, U> { + + private final TableCellUpdater<S, T> inner; + private final Executor executor; + + public FutureValueUpdater(TableCellUpdater<S, T> inner, Executor exec) { + this.inner = inner; + this.executor = exec; + } + + @Override + public void accept(TableCell<?, ?> cell, U value, boolean empty) { + if (value != null) { + if (!value.isDone()) { + inner.accept(cell, null, empty); + } + value.thenAcceptAsync(val -> { + inner.accept(cell, val, empty); + }, executor); + } else { + inner.accept(cell, null, empty); + } + } +} \ No newline at end of file diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/JavaFXRoutines.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/JavaFXRoutines.java index f3c67a34..bbe3f18c 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/JavaFXRoutines.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/JavaFXRoutines.java @@ -2,7 +2,6 @@ package cz.it4i.fiji.haas.ui; import java.io.IOException; import java.util.concurrent.Callable; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.function.Function; @@ -11,11 +10,9 @@ import java.util.function.Predicate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import cz.it4i.fiji.haas.ui.JavaFXRoutines.TableCellAdapter.TableCellUpdater; import javafx.application.Platform; import javafx.beans.value.ObservableValue; import javafx.fxml.FXMLLoader; -import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; @@ -23,63 +20,6 @@ public interface JavaFXRoutines { Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas.ui.CloseableControl.class); - static public class TableCellAdapter<S, T> extends TableCell<S, T> { - public interface TableCellUpdater<A, B> { - void accept(TableCell<?, ?> cell, B value, boolean empty); - } - - private final TableCellUpdater<S, T> updater; - - public TableCellAdapter(TableCellUpdater<S, T> updater) { - this.updater = updater; - } - - @Override - protected void updateItem(T item, boolean empty) { - if(empty) { - this.setText(""); - } else { - updater.accept(this, item, empty); - } - } - } - - static public class FutureValueUpdater<S, T, U extends CompletableFuture<T>> implements TableCellUpdater<S, U> { - - private final TableCellUpdater<S, T> inner; - private final Executor executor; - - public FutureValueUpdater(TableCellUpdater<S, T> inner, Executor exec) { - this.inner = inner; - this.executor = exec; - } - - @Override - public void accept(TableCell<?, ?> cell, U value, boolean empty) { - if (value != null) { - if (!value.isDone()) { - inner.accept(cell, null, empty); - } - value.thenAcceptAsync(val -> { - inner.accept(cell, val, empty); - }, executor); - } else { - inner.accept(cell, null, empty); - } - } - } - - static public class StringValueUpdater<S> implements TableCellUpdater<S, String> { - @Override - public void accept(TableCell<?, ?> cell, String value, boolean empty) { - if (value != null) { - cell.setText(value); - } else if (!empty) { - cell.setText("N/A"); - } - } - } - static void initRootAndController(String string, Object parent) { initRootAndController(string, parent, false); } diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/StringValueUpdater.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/StringValueUpdater.java new file mode 100644 index 00000000..337e5c29 --- /dev/null +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/StringValueUpdater.java @@ -0,0 +1,15 @@ +package cz.it4i.fiji.haas.ui; + +import cz.it4i.fiji.haas.ui.TableCellAdapter.TableCellUpdater; +import javafx.scene.control.TableCell; + +public class StringValueUpdater<S> implements TableCellUpdater<S, String> { + @Override + public void accept(TableCell<?, ?> cell, String value, boolean empty) { + if (value != null) { + cell.setText(value); + } else if (!empty) { + cell.setText("N/A"); + } + } +} \ No newline at end of file diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/TableCellAdapter.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/TableCellAdapter.java new file mode 100644 index 00000000..c623bcec --- /dev/null +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/TableCellAdapter.java @@ -0,0 +1,24 @@ +package cz.it4i.fiji.haas.ui; + +import javafx.scene.control.TableCell; + +public class TableCellAdapter<S, T> extends TableCell<S, T> { + public interface TableCellUpdater<A, B> { + void accept(TableCell<?, ?> cell, B value, boolean empty); + } + + private final TableCellAdapter.TableCellUpdater<S, T> updater; + + public TableCellAdapter(TableCellAdapter.TableCellUpdater<S, T> updater) { + this.updater = updater; + } + + @Override + protected void updateItem(T item, boolean empty) { + if(empty) { + this.setText(""); + } else { + updater.accept(this, item, empty); + } + } +} \ No newline at end of file diff --git a/haas-java-client/pom.xml b/haas-java-client/pom.xml index f70f208e..4f946537 100644 --- a/haas-java-client/pom.xml +++ b/haas-java-client/pom.xml @@ -6,6 +6,9 @@ <version>0.0.2-SNAPSHOT</version> <name>HaaS library for Java</name> <packaging>jar</packaging> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> <build> <plugins> <plugin> @@ -19,6 +22,7 @@ </plugin> <plugin> <artifactId>maven-source-plugin</artifactId> + <version>3.0.1</version> <executions> <execution> <id>attach-sources</id> @@ -42,8 +46,7 @@ <artifactId>java-scpclient</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> - <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2 --> - + <!-- https://mvnrepository.com/artifact/javax.activation/activation --> <dependency> <groupId>javax.activation</groupId> @@ -74,8 +77,6 @@ <artifactId>jaxrpc</artifactId> <version>1.1</version> </dependency> - <!-- https://mvnrepository.com/artifact/javax.xml/saaj-api --> - <!-- https://mvnrepository.com/artifact/javax.xml/saaj-api --> <!-- https://mvnrepository.com/artifact/javax.xml.soap/saaj-api --> <dependency> <groupId>javax.xml.soap</groupId> diff --git a/haas-java-client/src/main/resources/configuration.properties.template b/haas-java-client/src/test/resources/configuration.properties.template similarity index 100% rename from haas-java-client/src/main/resources/configuration.properties.template rename to haas-java-client/src/test/resources/configuration.properties.template diff --git a/haas-spim-benchmark/pom.xml b/haas-spim-benchmark/pom.xml index 10057406..fbd07153 100644 --- a/haas-spim-benchmark/pom.xml +++ b/haas-spim-benchmark/pom.xml @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -59,13 +60,14 @@ <system>None</system> </ciManagement> - + <properties> <license.licenseName>${license.base.licenseName}</license.licenseName> <license.copyrightOwners>${license.base.copyrightOwners}</license.copyrightOwners> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> - + <dependencies> <dependency> <groupId>net.imagej</groupId> @@ -78,14 +80,14 @@ <artifactId>haas-imagej-client</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> - + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.6</version> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.6</version> </dependency> - + <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> @@ -103,21 +105,13 @@ <build> <plugins> <plugin> - <artifactId>maven-assembly-plugin</artifactId> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> + <outputDirectory> + ${project.build.directory}/jars + </outputDirectory> </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> </plugin> </plugins> diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java index dbe847aa..07db5b7d 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java @@ -28,11 +28,14 @@ import org.slf4j.LoggerFactory; import cz.it4i.fiji.haas.UploadingFileFromResource; import cz.it4i.fiji.haas.ui.CloseableControl; import cz.it4i.fiji.haas.ui.DummyProgress; +import cz.it4i.fiji.haas.ui.FutureValueUpdater; import cz.it4i.fiji.haas.ui.InitiableControl; import cz.it4i.fiji.haas.ui.JavaFXRoutines; import cz.it4i.fiji.haas.ui.ModalDialogs; import cz.it4i.fiji.haas.ui.ProgressDialog; import cz.it4i.fiji.haas.ui.ShellRoutines; +import cz.it4i.fiji.haas.ui.StringValueUpdater; +import cz.it4i.fiji.haas.ui.TableCellAdapter; import cz.it4i.fiji.haas.ui.TableViewContextMenu; import cz.it4i.fiji.haas_java_client.JobState; import cz.it4i.fiji.haas_java_client.UploadingFile; @@ -323,9 +326,9 @@ public class BenchmarkSPIMControl extends BorderPane implements CloseableControl private void setCellValueFactoryCompletable(int index, Function<BenchmarkJob, CompletableFuture<String>> mapper) { JavaFXRoutines.setCellValueFactory(jobs, index, mapper); ((TableColumn<ObservableBenchmarkJob, CompletableFuture<String>>) jobs.getColumns().get(index)).setCellFactory( - column -> new JavaFXRoutines.TableCellAdapter<ObservableBenchmarkJob, CompletableFuture<String>>( - new JavaFXRoutines.FutureValueUpdater<ObservableBenchmarkJob, String, CompletableFuture<String>>( - new JavaFXRoutines.StringValueUpdater<ObservableBenchmarkJob>(), executorServiceFX))); + column -> new TableCellAdapter<ObservableBenchmarkJob, CompletableFuture<String>>( + new FutureValueUpdater<ObservableBenchmarkJob, String, CompletableFuture<String>>( + new StringValueUpdater<ObservableBenchmarkJob>(), executorServiceFX))); } private interface P_JobAction { diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java index 3580264f..1a74b7a8 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewController.java @@ -23,6 +23,7 @@ import cz.it4i.fiji.haas.ui.CloseableControl; import cz.it4i.fiji.haas.ui.InitiableControl; import cz.it4i.fiji.haas.ui.JavaFXRoutines; import cz.it4i.fiji.haas.ui.ModalDialogs; +import cz.it4i.fiji.haas.ui.TableCellAdapter; import cz.it4i.fiji.haas.ui.TableViewContextMenu; import cz.it4i.fiji.haas_java_client.JobState; import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob; @@ -208,7 +209,7 @@ public class SPIMPipelineProgressViewController extends BorderPane implements Cl } }); ((TableColumn<ObservableValue<Task>, TaskComputation>) this.tasks.getColumns().get(index)) - .setCellFactory(column -> new JavaFXRoutines.TableCellAdapter<>((cell, val, empty) -> { + .setCellFactory(column -> new TableCellAdapter<>((cell, val, empty) -> { if (val == null || empty) { cell.setText(EMPTY_VALUE); cell.setStyle(""); diff --git a/haas-spim-benchmark/src/main/resources/configuration.properties.template b/haas-spim-benchmark/src/main/resources/configuration.properties.template deleted file mode 100644 index 892ed0d0..00000000 --- a/haas-spim-benchmark/src/main/resources/configuration.properties.template +++ /dev/null @@ -1,4 +0,0 @@ -USER_NAME= -PASSWORD= -EMAIL= -PHONE= \ No newline at end of file diff --git a/java-scpclient/pom.xml b/java-scpclient/pom.xml index c4722b7f..6028d171 100644 --- a/java-scpclient/pom.xml +++ b/java-scpclient/pom.xml @@ -7,6 +7,9 @@ <version>0.0.1-SNAPSHOT</version> <name>Scp client library for Java</name> <packaging>jar</packaging> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> <build> <plugins> <plugin> -- GitLab