From 4133384e487dfa8b1282af790782751655686eec Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Tue, 8 Oct 2019 21:30:34 +0100 Subject: [PATCH] ability to share multiple files and directories --- .../views/com/muwire/gui/MainFrameView.groovy | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 0616428c..14ddab84 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -772,9 +772,12 @@ class MainFrameView { chooser.setFileHidingEnabled(false) chooser.setDialogTitle("Select file to share") chooser.setFileSelectionMode(JFileChooser.FILES_ONLY) + chooser.setMultiSelectionEnabled(true) int rv = chooser.showOpenDialog(null) if (rv == JFileChooser.APPROVE_OPTION) { - model.core.eventBus.publish(new FileSharedEvent(file : chooser.getSelectedFile())) + chooser.getSelectedFiles().each { + model.core.eventBus.publish(new FileSharedEvent(file : it)) + } } } @@ -783,14 +786,16 @@ class MainFrameView { chooser.setFileHidingEnabled(false) chooser.setDialogTitle("Select directory to watch") chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) + chooser.setMultiSelectionEnabled(true) int rv = chooser.showOpenDialog(null) if (rv == JFileChooser.APPROVE_OPTION) { - File f = chooser.getSelectedFile() - model.watched << f.getAbsolutePath() - application.context.get("muwire-settings").watchedDirectories << f.getAbsolutePath() - mvcGroup.controller.saveMuWireSettings() - builder.getVariable("watched-directories-table").model.fireTableDataChanged() - model.core.eventBus.publish(new FileSharedEvent(file : f)) + chooser.getSelectedFiles().each { f -> + model.watched << f.getAbsolutePath() + application.context.get("muwire-settings").watchedDirectories << f.getAbsolutePath() + mvcGroup.controller.saveMuWireSettings() + builder.getVariable("watched-directories-table").model.fireTableDataChanged() + model.core.eventBus.publish(new FileSharedEvent(file : f)) + } } }