ability to share multiple files and directories

pull/24/head
Zlatin Balevsky 2019-10-08 21:30:34 +01:00
parent 600fc98868
commit 4133384e48
1 changed files with 12 additions and 7 deletions

View File

@ -772,9 +772,12 @@ class MainFrameView {
chooser.setFileHidingEnabled(false) chooser.setFileHidingEnabled(false)
chooser.setDialogTitle("Select file to share") chooser.setDialogTitle("Select file to share")
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY) chooser.setFileSelectionMode(JFileChooser.FILES_ONLY)
chooser.setMultiSelectionEnabled(true)
int rv = chooser.showOpenDialog(null) int rv = chooser.showOpenDialog(null)
if (rv == JFileChooser.APPROVE_OPTION) { 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.setFileHidingEnabled(false)
chooser.setDialogTitle("Select directory to watch") chooser.setDialogTitle("Select directory to watch")
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
chooser.setMultiSelectionEnabled(true)
int rv = chooser.showOpenDialog(null) int rv = chooser.showOpenDialog(null)
if (rv == JFileChooser.APPROVE_OPTION) { if (rv == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile() chooser.getSelectedFiles().each { f ->
model.watched << f.getAbsolutePath() model.watched << f.getAbsolutePath()
application.context.get("muwire-settings").watchedDirectories << f.getAbsolutePath() application.context.get("muwire-settings").watchedDirectories << f.getAbsolutePath()
mvcGroup.controller.saveMuWireSettings() mvcGroup.controller.saveMuWireSettings()
builder.getVariable("watched-directories-table").model.fireTableDataChanged() builder.getVariable("watched-directories-table").model.fireTableDataChanged()
model.core.eventBus.publish(new FileSharedEvent(file : f)) model.core.eventBus.publish(new FileSharedEvent(file : f))
}
} }
} }