Skip to content

Improve file list widget #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2018
Merged

Improve file list widget #34

merged 1 commit into from
Jun 5, 2018

Conversation

imagejan
Copy link
Member

  • Set button label to Add files... or Add folder... depending on widget style
  • Added Add folder content... button with drag-drop support to allow adding files matching the extensions defined by style from a folder and sub-folders

To test the full functionality, use the following script:

#@ File[] (style="extensions:tif") fileList
#@ File[] (style="directories") folderList

println fileList
println folderList
  • use buttons and/or drag-n-drop (onto the list field, or onto the Add folder content... button) to populate the list
  • double-click on list entries to remove them

Copy link
Member

@ctrueden ctrueden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very sorry this sat for so long, @imagejan. It looks really nice. I was just wondering one thing, about the direct usage of JFileChooser rather than leaning on the UIService file choosing methods. What do you think?

try {
// NB: We show the JFileChooser on the EDT because otherwise there could
// be a deadlock, particularly on macOS. See scijava/scijava-ui-swing#28.
threadService.invoke(() -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this: can we use uiService.chooseFiles? Then we can have this threading logic solved properly in a single place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, I'll change this.

Copy link
Member Author

@imagejan imagejan Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up using ui() instead of uiService because I'd otherwise get the Legacy UI's directory chooser, which led to some of the Swing buttons not being rendered correctly (not "released" after drop), and the look-and-feel being changed when running the example script a second time.

When using ui(), we keep using the SwingUI for both the dialog and the file chooser, which worked fine in my tests. (I also replaced uiService by ui() in the other place where it was used, and thereby got rid of the UIService parameter.)

@ctrueden if you have no concerns with this, I'd say this is ready to be merged.

- new "Add folder content..." button with drag-drop support
@imagejan imagejan force-pushed the improve-file-list-widget branch from 2052290 to 8077b53 Compare April 30, 2018 13:48
@ctrueden ctrueden merged commit b6b7924 into master Jun 5, 2018
@ctrueden ctrueden deleted the improve-file-list-widget branch June 5, 2018 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants