ability to share multiple files and directories

This commit is contained in:
Zlatin Balevsky
2019-10-08 21:30:34 +01:00
parent 600fc98868
commit 4133384e48

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,9 +786,10 @@ 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()
@@ -793,6 +797,7 @@ class MainFrameView {
model.core.eventBus.publish(new FileSharedEvent(file : f)) model.core.eventBus.publish(new FileSharedEvent(file : f))
} }
} }
}
String getSelectedWatchedDirectory() { String getSelectedWatchedDirectory() {
def watchedTable = builder.getVariable("watched-directories-table") def watchedTable = builder.getVariable("watched-directories-table")