From daf3aba1873fd5eabc9d6d765caaf6656d409b52 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Sat, 4 Apr 2020 14:52:35 +0000 Subject: [PATCH 1/5] Mark 2.0.1-SNAPSHOT --- com.io7m.jwheatsheaf.api/pom.xml | 2 +- com.io7m.jwheatsheaf.documentation/pom.xml | 2 +- com.io7m.jwheatsheaf.examples/pom.xml | 2 +- com.io7m.jwheatsheaf.oxygen/pom.xml | 2 +- com.io7m.jwheatsheaf.tests/pom.xml | 2 +- com.io7m.jwheatsheaf.ui/pom.xml | 2 +- pom.xml | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/com.io7m.jwheatsheaf.api/pom.xml b/com.io7m.jwheatsheaf.api/pom.xml index 4af6646..8152b3a 100644 --- a/com.io7m.jwheatsheaf.api/pom.xml +++ b/com.io7m.jwheatsheaf.api/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT com.io7m.jwheatsheaf.api diff --git a/com.io7m.jwheatsheaf.documentation/pom.xml b/com.io7m.jwheatsheaf.documentation/pom.xml index 6463c54..1938a09 100644 --- a/com.io7m.jwheatsheaf.documentation/pom.xml +++ b/com.io7m.jwheatsheaf.documentation/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT com.io7m.jwheatsheaf.documentation diff --git a/com.io7m.jwheatsheaf.examples/pom.xml b/com.io7m.jwheatsheaf.examples/pom.xml index 82c852d..b4226ed 100644 --- a/com.io7m.jwheatsheaf.examples/pom.xml +++ b/com.io7m.jwheatsheaf.examples/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT com.io7m.jwheatsheaf.examples diff --git a/com.io7m.jwheatsheaf.oxygen/pom.xml b/com.io7m.jwheatsheaf.oxygen/pom.xml index aa7e666..73605b3 100644 --- a/com.io7m.jwheatsheaf.oxygen/pom.xml +++ b/com.io7m.jwheatsheaf.oxygen/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT com.io7m.jwheatsheaf.oxygen diff --git a/com.io7m.jwheatsheaf.tests/pom.xml b/com.io7m.jwheatsheaf.tests/pom.xml index e4399eb..9f1cedf 100644 --- a/com.io7m.jwheatsheaf.tests/pom.xml +++ b/com.io7m.jwheatsheaf.tests/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT com.io7m.jwheatsheaf.tests diff --git a/com.io7m.jwheatsheaf.ui/pom.xml b/com.io7m.jwheatsheaf.ui/pom.xml index 9d07f59..1b1eb20 100644 --- a/com.io7m.jwheatsheaf.ui/pom.xml +++ b/com.io7m.jwheatsheaf.ui/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT com.io7m.jwheatsheaf.ui diff --git a/pom.xml b/pom.xml index fb4c60e..46eb27b 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.0 + 2.0.1-SNAPSHOT pom com.io7m.jwheatsheaf @@ -36,7 +36,7 @@ b0ab224c1aa641afbe9d0d34b1f60f1d 2.8.3 - 1.0.0 + 2.0.0 13.0.2 4.0.16-alpha From 2ac0dfd3892f0525582bfe8eaf5d5f31cbef5ce0 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Sun, 5 Apr 2020 12:34:20 +0000 Subject: [PATCH 2/5] Use primogenitor 4.0.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 46eb27b..d1effaf 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.io7m.primogenitor com.io7m.primogenitor.full - 4.0.0 + 4.0.1 com.io7m.jwheatsheaf @@ -194,7 +194,7 @@ com.io7m.primogenitor com.io7m.primogenitor.support - 4.0.0 + 4.0.1 From 0b62693385ed03556214b92f307626e4c94e4f8c Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Fri, 10 Apr 2020 09:36:34 +0000 Subject: [PATCH 3/5] Enable CheckStyle for the project --- .../examples/ExampleApplication.java | 9 + .../examples/ExampleImageSets.java | 1 - .../internal/JWFileChooserViewController.java | 266 ++++++------------ .../ui/internal/JWFileItemTableNameCell.java | 51 ++++ .../ui/internal/JWFileItemTableSizeCell.java | 51 ++++ .../ui/internal/JWFileItemTableTimeCell.java | 62 ++++ .../ui/internal/JWFileItemTableTypeCell.java | 57 ++++ .../jwheatsheaf/ui/internal/JWFileList.java | 4 +- .../ui/internal/JWFileTimeFormatterType.java | 24 ++ .../jwheatsheaf/ui/internal/JWImages.java | 17 ++ .../jwheatsheaf/ui/internal/JWToolTips.java | 49 ++++ .../src/main/java/module-info.java | 3 + pom.xml | 6 + 13 files changed, 415 insertions(+), 185 deletions(-) create mode 100644 com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableNameCell.java create mode 100644 com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableSizeCell.java create mode 100644 com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTimeCell.java create mode 100644 com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTypeCell.java create mode 100644 com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileTimeFormatterType.java create mode 100644 com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWToolTips.java diff --git a/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleApplication.java b/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleApplication.java index 9ed5ace..58832e3 100644 --- a/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleApplication.java +++ b/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleApplication.java @@ -30,6 +30,15 @@ public final class ExampleApplication extends Application private static final Logger LOG = LoggerFactory.getLogger(ExampleApplication.class); + /** + * Construct an application. + */ + + public ExampleApplication() + { + + } + @Override public void start(final Stage stage) throws Exception diff --git a/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleImageSets.java b/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleImageSets.java index 09443aa..1b4cd29 100644 --- a/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleImageSets.java +++ b/com.io7m.jwheatsheaf.examples/src/main/java/com/io7m/jwheatsheaf/examples/ExampleImageSets.java @@ -19,7 +19,6 @@ import com.io7m.jwheatsheaf.api.JWFileImageSetType; import com.io7m.jwheatsheaf.oxygen.JWOxygenIconSet; import com.io7m.jwheatsheaf.ui.JWFileChoosers; -import com.io7m.jwheatsheaf.ui.internal.JWFileImageDefaultSet; import java.util.Map; import java.util.Objects; diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileChooserViewController.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileChooserViewController.java index 4cb463c..da83f4b 100644 --- a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileChooserViewController.java +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileChooserViewController.java @@ -17,13 +17,11 @@ package com.io7m.jwheatsheaf.ui.internal; import com.io7m.jaffirm.core.Preconditions; -import com.io7m.junreachable.UnreachableCodeException; import com.io7m.jwheatsheaf.api.JWDirectoryCreationFailed; import com.io7m.jwheatsheaf.api.JWFileChooserConfiguration; import com.io7m.jwheatsheaf.api.JWFileChooserEventType; import com.io7m.jwheatsheaf.api.JWFileChooserFilterType; import com.io7m.jwheatsheaf.api.JWFileImageSetType; -import com.io7m.jwheatsheaf.api.JWFileKind; import com.io7m.jwheatsheaf.api.JWFileListingFailed; import com.io7m.jwheatsheaf.ui.JWFileChoosers; import javafx.application.Platform; @@ -46,9 +44,6 @@ import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.TextInputDialog; -import javafx.scene.control.Tooltip; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; import javafx.scene.layout.Pane; import javafx.util.Callback; @@ -60,8 +55,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileTime; -import java.time.OffsetDateTime; -import java.time.ZoneId; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -93,34 +86,23 @@ public final class JWFileChooserViewController private List result; private volatile Path currentDirectory; - @FXML - private Pane mainContent; - @FXML - private ChoiceBox pathMenu; - @FXML - private TableView directoryTable; - @FXML - private Button newDirectoryButton; - @FXML - private Button upDirectoryButton; - @FXML - private Button selectDirectButton; - @FXML - private ListView sourcesList; - @FXML - private ComboBox fileTypeMenu; - @FXML - private TextField fileName; - @FXML - private Button okButton; - @FXML - private TextField searchField; - @FXML - private ProgressIndicator progressIndicator; + @FXML private Button newDirectoryButton; + @FXML private Button okButton; + @FXML private Button selectDirectButton; + @FXML private Button upDirectoryButton; + @FXML private ChoiceBox pathMenu; + @FXML private ComboBox fileTypeMenu; + @FXML private ListView sourcesList; + @FXML private Pane mainContent; + @FXML private ProgressIndicator progressIndicator; + @FXML private TableView directoryTable; + @FXML private TextField fileName; + @FXML private TextField searchField; - private JWStrings strings; private ExecutorService ioExecutor; private JWFileChoosersTesting testing; + private JWStrings strings; + private JWToolTips toolTips; /** * Construct a view controller. @@ -154,18 +136,22 @@ private String formatSize( } public void setEventReceiver( - final Consumer eventReceiver) + final Consumer newEventReceiver) { this.eventReceiver.set( - Objects.requireNonNullElse(eventReceiver, event -> { + Objects.requireNonNullElse(newEventReceiver, event -> { })); } /** * Set the file chooser provider and configuration. * - * @param inChoosers The provider - * @param inConfiguration The configuration + * @param inChoosers The provider + * @param inIoExecutor An executor for background I/O operations + * @param inTesting An internal testing interface + * @param inStrings UI strings + * @param inDefaultImageSet The default image set + * @param inConfiguration The configuration */ public void setConfiguration( @@ -189,6 +175,9 @@ public void setConfiguration( Objects.requireNonNull(inDefaultImageSet, "inDefaultImageSet"); + this.toolTips = + new JWToolTips(this.strings); + this.filterAll = JWFileChooserFilterAllFiles.create(this.strings); this.filterOnlyDirectories = @@ -271,33 +260,7 @@ private void configureSourceList( } this.sourcesList.setItems(FXCollections.observableList(sources)); - this.sourcesList.setCellFactory(param -> { - final ListCell cell = new ListCell<>() - { - @Override - protected void updateItem( - final JWFileSourceEntryType item, - final boolean empty) - { - super.updateItem(item, empty); - - if (empty || item == null) { - this.setGraphic(null); - this.setText(null); - return; - } - - item.onListCell( - JWFileChooserViewController.this.imageSet, - JWFileChooserViewController.this.strings, - this - ); - } - }; - - cell.setOnMouseClicked(this::onSourceItemDoubleClicked); - return cell; - }); + this.sourcesList.setCellFactory(new SourceListCellFactory()); } private void configureFileTypeMenu() @@ -615,30 +578,8 @@ private void configureTableView() tableTypeColumn.setSortable(false); tableTypeColumn.setReorderable(false); tableTypeColumn.setCellFactory(column -> { - final TableCell cell = new TableCell<>() - { - @Override - protected void updateItem( - final JWFileItem item, - final boolean empty) - { - super.updateItem(item, empty); - - if (empty || item == null) { - this.setGraphic(null); - this.setText(null); - this.setTooltip(null); - return; - } - - this.setGraphic( - JWFileChooserViewController.this.imageOfKind(item.kind())); - this.setText(null); - this.setTooltip( - JWFileChooserViewController.this.tooltipOf(item)); - } - }; - + final TableCell cell = + new JWFileItemTableTypeCell(this.imageSet, this.toolTips); cell.setOnMouseClicked(this::onTableRowClicked); return cell; }); @@ -646,27 +587,8 @@ protected void updateItem( tableNameColumn.setSortable(true); tableNameColumn.setReorderable(false); tableNameColumn.setCellFactory(column -> { - final TableCell cell = new TableCell<>() - { - @Override - protected void updateItem( - final JWFileItem item, - final boolean empty) - { - super.updateItem(item, empty); - - if (empty || item == null) { - this.setGraphic(null); - this.setText(null); - this.setTooltip(null); - return; - } - - this.setGraphic(null); - this.setText(item.name()); - this.setTooltip(JWFileChooserViewController.this.tooltipOf(item)); - } - }; + final TableCell cell = + new JWFileItemTableNameCell(this.toolTips); cell.setOnMouseClicked(this::onTableRowClicked); return cell; }); @@ -674,25 +596,8 @@ protected void updateItem( tableSizeColumn.setSortable(true); tableSizeColumn.setReorderable(false); tableSizeColumn.setCellFactory(column -> { - final TableCell cell = new TableCell<>() - { - @Override - protected void updateItem( - final Long item, - final boolean empty) - { - super.updateItem(item, empty); - - if (empty || item == null) { - this.setGraphic(null); - this.setText(null); - return; - } - - this.setText(JWFileChooserViewController.this.formatSize(item.longValue())); - this.setGraphic(null); - } - }; + final TableCell cell = + new JWFileItemTableSizeCell(this::formatSize); cell.setOnMouseClicked(this::onTableRowClicked); return cell; }); @@ -700,25 +605,8 @@ protected void updateItem( tableTimeColumn.setSortable(true); tableTimeColumn.setReorderable(false); tableTimeColumn.setCellFactory(column -> { - final TableCell cell = new TableCell<>() - { - @Override - protected void updateItem( - final FileTime item, - final boolean empty) - { - super.updateItem(item, empty); - - if (empty || item == null) { - this.setGraphic(null); - this.setText(null); - return; - } - - this.setText(JWFileChooserViewController.this.formatTime(item)); - this.setGraphic(null); - } - }; + final TableCell cell = + new JWFileItemTableTimeCell(this.configuration.fileTimeFormatter()); cell.setOnMouseClicked(this::onTableRowClicked); return cell; }); @@ -733,20 +621,6 @@ protected void updateItem( param -> new ReadOnlyObjectWrapper<>(param.getValue().modifiedTime())); } - private Tooltip tooltipOf( - final JWFileItem item) - { - switch (item.kind()) { - case REGULAR_FILE: - case SYMBOLIC_LINK: - case UNKNOWN: - return new Tooltip(this.strings.tooltipFile(item.path())); - case DIRECTORY: - return new Tooltip(this.strings.tooltipDirectory(item.path())); - } - throw new UnreachableCodeException(); - } - private void reconfigureOKButton() { boolean enabled = false; @@ -811,28 +685,6 @@ private void onSourceItemDoubleClicked( } } - private ImageView imageOfKind( - final JWFileKind kind) - { - final var imageOpt = this.imageSet.forFileKind(kind); - if (imageOpt.isPresent()) { - final var imageView = new ImageView(); - imageView.setFitWidth(16.0); - imageView.setFitHeight(16.0); - imageView.setImage(new Image(imageOpt.get().toString())); - return imageView; - } - return null; - } - - private String formatTime( - final FileTime item) - { - final var instant = item.toInstant(); - final var time = OffsetDateTime.ofInstant(instant, ZoneId.of("UTC")); - return this.configuration.fileTimeFormatter().format(time); - } - /** * @return The list of selected files, if any */ @@ -841,4 +693,54 @@ public List result() { return this.result; } + + private final class SourceListCellFactory + implements Callback, ListCell> + { + SourceListCellFactory() + { + + } + + @Override + public ListCell call( + final ListView param) + { + final ListCell cell = + new JWFileSourceEntryTypeListCell(); + cell.setOnMouseClicked( + JWFileChooserViewController.this::onSourceItemDoubleClicked); + return cell; + } + } + + private final class JWFileSourceEntryTypeListCell + extends ListCell + { + JWFileSourceEntryTypeListCell() + { + + } + + @Override + protected void updateItem( + final JWFileSourceEntryType item, + final boolean empty) + { + super.updateItem(item, empty); + + if (empty || item == null) { + this.setGraphic(null); + this.setText(null); + return; + } + + item.onListCell( + JWFileChooserViewController.this.imageSet, + JWFileChooserViewController.this.strings, + this + ); + } + } + } diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableNameCell.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableNameCell.java new file mode 100644 index 0000000..a7b842f --- /dev/null +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableNameCell.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2020 Mark Raynsford http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jwheatsheaf.ui.internal; + +import javafx.scene.control.TableCell; + +import java.util.Objects; + +final class JWFileItemTableNameCell extends TableCell +{ + private final JWToolTips toolTips; + + JWFileItemTableNameCell( + final JWToolTips inToolTips) + { + this.toolTips = Objects.requireNonNull(inToolTips, "inToolTips"); + } + + @Override + protected void updateItem( + final JWFileItem item, + final boolean empty) + { + super.updateItem(item, empty); + + if (empty || item == null) { + this.setGraphic(null); + this.setText(null); + this.setTooltip(null); + return; + } + + this.setGraphic(null); + this.setText(item.name()); + this.setTooltip(this.toolTips.tooltipOf(item)); + } +} diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableSizeCell.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableSizeCell.java new file mode 100644 index 0000000..60e4f43 --- /dev/null +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableSizeCell.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2020 Mark Raynsford http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jwheatsheaf.ui.internal; + +import com.io7m.jwheatsheaf.api.JWFileSizeFormatterType; +import javafx.scene.control.TableCell; + +import java.util.Objects; + +final class JWFileItemTableSizeCell extends TableCell +{ + private final JWFileSizeFormatterType sizeFormatter; + + JWFileItemTableSizeCell( + final JWFileSizeFormatterType inSizeFormatter) + { + this.sizeFormatter = + Objects.requireNonNull(inSizeFormatter, "inSizeFormatter"); + } + + @Override + protected void updateItem( + final Long item, + final boolean empty) + { + super.updateItem(item, empty); + + if (empty || item == null) { + this.setGraphic(null); + this.setText(null); + return; + } + + this.setText(this.sizeFormatter.formatSize(item.longValue())); + this.setGraphic(null); + } +} diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTimeCell.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTimeCell.java new file mode 100644 index 0000000..3d68a43 --- /dev/null +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTimeCell.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2020 Mark Raynsford http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jwheatsheaf.ui.internal; + +import javafx.scene.control.TableCell; + +import java.nio.file.attribute.FileTime; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Objects; + +final class JWFileItemTableTimeCell extends TableCell +{ + private final DateTimeFormatter timeFormatter; + + JWFileItemTableTimeCell( + final DateTimeFormatter inTimeFormatter) + { + this.timeFormatter = + Objects.requireNonNull(inTimeFormatter, "inTimeFormatter"); + } + + private String formatTime( + final FileTime item) + { + final var instant = item.toInstant(); + final var time = OffsetDateTime.ofInstant(instant, ZoneId.of("UTC")); + return this.timeFormatter.format(time); + } + + @Override + protected void updateItem( + final FileTime item, + final boolean empty) + { + super.updateItem(item, empty); + + if (empty || item == null) { + this.setGraphic(null); + this.setText(null); + return; + } + + this.setText(this.formatTime(item)); + this.setGraphic(null); + } +} diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTypeCell.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTypeCell.java new file mode 100644 index 0000000..d704dc6 --- /dev/null +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileItemTableTypeCell.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2020 Mark Raynsford http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jwheatsheaf.ui.internal; + +import com.io7m.jwheatsheaf.api.JWFileImageSetType; +import javafx.scene.control.TableCell; + +import java.util.Objects; + +final class JWFileItemTableTypeCell extends TableCell +{ + private final JWToolTips toolTips; + private final JWFileImageSetType images; + + JWFileItemTableTypeCell( + final JWFileImageSetType inImages, + final JWToolTips inToolTips) + { + this.images = + Objects.requireNonNull(inImages, "inImages"); + this.toolTips = + Objects.requireNonNull(inToolTips, "inToolTips"); + } + + @Override + protected void updateItem( + final JWFileItem item, + final boolean empty) + { + super.updateItem(item, empty); + + if (empty || item == null) { + this.setGraphic(null); + this.setText(null); + this.setTooltip(null); + return; + } + + this.setGraphic(JWImages.imageOfKind(this.images, item.kind())); + this.setText(null); + this.setTooltip(this.toolTips.tooltipOf(item)); + } +} diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileList.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileList.java index a8a69df..d952189 100644 --- a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileList.java +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileList.java @@ -65,9 +65,9 @@ private boolean isItemVisible( } public void setItems( - final List items) + final List newItems) { - this.items.setAll(items); + this.items.setAll(newItems); } public void setSearch( diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileTimeFormatterType.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileTimeFormatterType.java new file mode 100644 index 0000000..a253716 --- /dev/null +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWFileTimeFormatterType.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2020 Mark Raynsford http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jwheatsheaf.ui.internal; + +import java.nio.file.attribute.FileTime; + +public interface JWFileTimeFormatterType +{ + String formatTime(FileTime time); +} diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWImages.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWImages.java index 6c5d2bf..07a8988 100644 --- a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWImages.java +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWImages.java @@ -16,6 +16,8 @@ package com.io7m.jwheatsheaf.ui.internal; +import com.io7m.jwheatsheaf.api.JWFileImageSetType; +import com.io7m.jwheatsheaf.api.JWFileKind; import javafx.scene.image.Image; import javafx.scene.image.ImageView; @@ -52,4 +54,19 @@ public static ImageView imageView16x16Of( imageView.setImage(new Image(url.toString())); return imageView; } + + public static ImageView imageOfKind( + final JWFileImageSetType images, + final JWFileKind kind) + { + final var imageOpt = images.forFileKind(kind); + if (imageOpt.isPresent()) { + final var imageView = new ImageView(); + imageView.setFitWidth(16.0); + imageView.setFitHeight(16.0); + imageView.setImage(new Image(imageOpt.get().toString())); + return imageView; + } + return null; + } } diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWToolTips.java b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWToolTips.java new file mode 100644 index 0000000..454ef7f --- /dev/null +++ b/com.io7m.jwheatsheaf.ui/src/main/java/com/io7m/jwheatsheaf/ui/internal/JWToolTips.java @@ -0,0 +1,49 @@ +/* + * Copyright © 2020 Mark Raynsford http://io7m.com + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package com.io7m.jwheatsheaf.ui.internal; + +import com.io7m.junreachable.UnreachableCodeException; +import javafx.scene.control.Tooltip; + +import java.util.Objects; + +public final class JWToolTips +{ + private final JWStrings strings; + + JWToolTips( + final JWStrings inStrings) + { + this.strings = Objects.requireNonNull(inStrings, "strings"); + } + + public Tooltip tooltipOf( + final JWFileItem item) + { + Objects.requireNonNull(item, "item"); + + switch (item.kind()) { + case REGULAR_FILE: + case SYMBOLIC_LINK: + case UNKNOWN: + return new Tooltip(this.strings.tooltipFile(item.path())); + case DIRECTORY: + return new Tooltip(this.strings.tooltipDirectory(item.path())); + } + throw new UnreachableCodeException(); + } +} diff --git a/com.io7m.jwheatsheaf.ui/src/main/java/module-info.java b/com.io7m.jwheatsheaf.ui/src/main/java/module-info.java index decea6d..b75dc94 100644 --- a/com.io7m.jwheatsheaf.ui/src/main/java/module-info.java +++ b/com.io7m.jwheatsheaf.ui/src/main/java/module-info.java @@ -34,5 +34,8 @@ requires transitive com.io7m.jwheatsheaf.api; requires transitive javafx.graphics; + opens com.io7m.jwheatsheaf.ui to javafx.fxml; + opens com.io7m.jwheatsheaf.ui.internal to javafx.fxml; + exports com.io7m.jwheatsheaf.ui; } diff --git a/pom.xml b/pom.xml index d1effaf..cca481f 100644 --- a/pom.xml +++ b/pom.xml @@ -216,6 +216,12 @@ + + + org.apache.maven.plugins + maven-checkstyle-plugin + + com.io7m.minisite From 08ba9c83611e7e3000f91dbb750ee7f61c59f920 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Fri, 10 Apr 2020 14:35:40 +0000 Subject: [PATCH 4/5] Note changes --- README-CHANGES.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README-CHANGES.xml b/README-CHANGES.xml index 63fae45..928adf7 100644 --- a/README-CHANGES.xml +++ b/README-CHANGES.xml @@ -29,9 +29,14 @@ - + - + + + + + + From 111d84b7e5854ecb00834b3e68643f55cdeb33cf Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Fri, 10 Apr 2020 14:36:19 +0000 Subject: [PATCH 5/5] Mark 2.0.1 --- com.io7m.jwheatsheaf.api/pom.xml | 2 +- com.io7m.jwheatsheaf.documentation/pom.xml | 2 +- com.io7m.jwheatsheaf.examples/pom.xml | 2 +- com.io7m.jwheatsheaf.oxygen/pom.xml | 2 +- com.io7m.jwheatsheaf.tests/pom.xml | 2 +- com.io7m.jwheatsheaf.ui/pom.xml | 2 +- pom.xml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/com.io7m.jwheatsheaf.api/pom.xml b/com.io7m.jwheatsheaf.api/pom.xml index 8152b3a..e5b209d 100644 --- a/com.io7m.jwheatsheaf.api/pom.xml +++ b/com.io7m.jwheatsheaf.api/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 com.io7m.jwheatsheaf.api diff --git a/com.io7m.jwheatsheaf.documentation/pom.xml b/com.io7m.jwheatsheaf.documentation/pom.xml index 1938a09..572686d 100644 --- a/com.io7m.jwheatsheaf.documentation/pom.xml +++ b/com.io7m.jwheatsheaf.documentation/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 com.io7m.jwheatsheaf.documentation diff --git a/com.io7m.jwheatsheaf.examples/pom.xml b/com.io7m.jwheatsheaf.examples/pom.xml index b4226ed..112bba4 100644 --- a/com.io7m.jwheatsheaf.examples/pom.xml +++ b/com.io7m.jwheatsheaf.examples/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 com.io7m.jwheatsheaf.examples diff --git a/com.io7m.jwheatsheaf.oxygen/pom.xml b/com.io7m.jwheatsheaf.oxygen/pom.xml index 73605b3..379d918 100644 --- a/com.io7m.jwheatsheaf.oxygen/pom.xml +++ b/com.io7m.jwheatsheaf.oxygen/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 com.io7m.jwheatsheaf.oxygen diff --git a/com.io7m.jwheatsheaf.tests/pom.xml b/com.io7m.jwheatsheaf.tests/pom.xml index 9f1cedf..815e3bd 100644 --- a/com.io7m.jwheatsheaf.tests/pom.xml +++ b/com.io7m.jwheatsheaf.tests/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 com.io7m.jwheatsheaf.tests diff --git a/com.io7m.jwheatsheaf.ui/pom.xml b/com.io7m.jwheatsheaf.ui/pom.xml index 1b1eb20..21130e8 100644 --- a/com.io7m.jwheatsheaf.ui/pom.xml +++ b/com.io7m.jwheatsheaf.ui/pom.xml @@ -9,7 +9,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 com.io7m.jwheatsheaf.ui diff --git a/pom.xml b/pom.xml index cca481f..be28fde 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ com.io7m.jwheatsheaf com.io7m.jwheatsheaf - 2.0.1-SNAPSHOT + 2.0.1 pom com.io7m.jwheatsheaf