Skip to content

Commit

Permalink
Use WidgetStyle.isStyle for style logic
Browse files Browse the repository at this point in the history
  • Loading branch information
imagejan committed Jul 1, 2024
1 parent 00512f5 commit 79a92d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/scijava/ui/UserInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -160,12 +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.FILE_AND_DIRECTORY_STYLE )) title = "Choose a file or 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);
Expand Down

0 comments on commit 79a92d8

Please sign in to comment.