scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

Handle spaces in parameter style declarations

Open imagejan opened this issue 7 years ago • 2 comments

Currently, these two parameter declarations behave differently:

#@ File[] (style="files,extensions:xls/xlsx") files

and

#@ File[] (style="files, extensions:xls/xlsx") files

The latter ignores the file extension filter because after splitting, the style string has a leading space.

Let's fix this by changing style.split(",") to style.trim().split("\\s*,\\s*") in all places where it is relevant:

  • [ ] scijava-common: https://github.com/scijava/scijava-common/blob/821c8294f753535c86a23dad9e277f78d572a79b/src/main/java/org/scijava/widget/DefaultWidgetModel.java#L133

  • [ ] scijava-ui-swing: https://github.com/scijava/scijava-ui-swing/blob/d0802b1a09d380898f77022b4010682cf330fc28/src/main/java/org/scijava/ui/swing/widget/SwingFileWidget.java#L210

  • [ ] imagej-legacy: https://github.com/imagej/imagej-legacy/blob/325fd0933778dabd6ee8c09867961c698ffe945c/src/main/java/net/imagej/legacy/plugin/MacroRecorderPostprocessor.java#L95

imagejan avatar Jul 19 '18 13:07 imagejan

Let's make a utility method (in a new WidgetStyle class, perhaps?) to handle this in a unified way?

ctrueden avatar Apr 24 '20 23:04 ctrueden

@ctrueden do we want to be case-insensitive when testing style attributes (i.e. allowing all of message, MESSAGE and mEsSaGe)?

imagejan avatar Apr 28 '20 19:04 imagejan