diff --git a/pom.xml b/pom.xml index 468e5842d..f1b9aec33 100644 --- a/pom.xml +++ b/pom.xml @@ -134,6 +134,11 @@ https://imagej.net/people/jaywarrick jaywarrick + + Christian Tischer + https://imagej.net/people/tischi + tischi + diff --git a/src/main/java/org/scijava/ui/UserInterface.java b/src/main/java/org/scijava/ui/UserInterface.java index 54dbfb767..f4c6d0c70 100644 --- a/src/main/java/org/scijava/ui/UserInterface.java +++ b/src/main/java/org/scijava/ui/UserInterface.java @@ -41,6 +41,7 @@ import org.scijava.ui.console.ConsolePane; import org.scijava.ui.viewer.DisplayWindow; import org.scijava.widget.FileWidget; +import org.scijava.widget.WidgetStyle; /** * An end-user SciJava application user interface. @@ -160,11 +161,11 @@ DialogPrompt dialogPrompt(String message, String title, default File chooseFile(final File file, final String style) { final String title; // style can be a string with multiple comma-separated keywords - // TODO use a utility class for style handling, e.g. StyleUtils.isStyle(style, ...) if (style == null) title = "Choose a file"; - else if (style.toLowerCase().contains(FileWidget.DIRECTORY_STYLE)) title = "Choose a directory"; - else if (style.toLowerCase().contains(FileWidget.OPEN_STYLE)) title = "Open"; - else if (style.toLowerCase().contains(FileWidget.SAVE_STYLE)) title = "Save"; + else if (WidgetStyle.isStyle(style, FileWidget.DIRECTORY_STYLE)) title = "Choose a directory"; + else if (WidgetStyle.isStyle(style, FileWidget.FILE_AND_DIRECTORY_STYLE)) title = "Choose a file or directory"; + else if (WidgetStyle.isStyle(style, FileWidget.OPEN_STYLE)) title = "Open"; + else if (WidgetStyle.isStyle(style, FileWidget.SAVE_STYLE)) title = "Save"; else title = "Choose a file"; return chooseFile(title, file, style); @@ -180,6 +181,7 @@ default File chooseFile(final File file, final String style) { *
  • {@link FileWidget#OPEN_STYLE}
  • *
  • {@link FileWidget#SAVE_STYLE}
  • *
  • {@link FileWidget#DIRECTORY_STYLE}
  • + *
  • {@link FileWidget#FILE_AND_DIRECTORY_STYLE}
  • * * @return The {@link File} chosen by the user, or null if prompt is not * available diff --git a/src/main/java/org/scijava/widget/FileWidget.java b/src/main/java/org/scijava/widget/FileWidget.java index a4322554d..e72d41c37 100644 --- a/src/main/java/org/scijava/widget/FileWidget.java +++ b/src/main/java/org/scijava/widget/FileWidget.java @@ -59,4 +59,11 @@ public interface FileWidget extends InputWidget { */ String DIRECTORY_STYLE = "directory"; + /** + * Widget style for directory chooser dialogs. + * + * @see org.scijava.plugin.Parameter#style() + */ + String FILE_AND_DIRECTORY_STYLE = "both"; + }