stop watching multiple directories at once

This commit is contained in:
Zlatin Balevsky
2019-10-14 23:16:05 +01:00
parent a24982e0df
commit d22b403e2a
2 changed files with 20 additions and 11 deletions

View File

@@ -290,14 +290,16 @@ class MainFrameController {
}
void stopWatchingDirectory() {
String directory = mvcGroup.view.getSelectedWatchedDirectory()
if (directory == null)
List<String> directories = mvcGroup.view.getSelectedWatchedDirectories()
if (directories == null)
return
core.muOptions.watchedDirectories.remove(directory)
directories.each { directory ->
core.muOptions.watchedDirectories.remove(directory)
core.eventBus.publish(new DirectoryUnsharedEvent(directory : new File(directory)))
model.watched.remove(directory)
}
saveMuWireSettings()
core.eventBus.publish(new DirectoryUnsharedEvent(directory : new File(directory)))
model.watched.remove(directory)
builder.getVariable("watched-directories-table").model.fireTableDataChanged()
}

View File

@@ -925,14 +925,21 @@ class MainFrameView {
model.core.eventBus.publish(new FileSharedEvent(file : f))
}
String getSelectedWatchedDirectory() {
List<String> getSelectedWatchedDirectories() {
def watchedTable = builder.getVariable("watched-directories-table")
int selectedRow = watchedTable.getSelectedRow()
if (selectedRow < 0)
int[] selectedRows = watchedTable.getSelectedRows()
if (selectedRows.length == 0)
return null
if (lastWatchedSortEvent != null)
selectedRow = watchedTable.rowSorter.convertRowIndexToModel(selectedRow)
model.watched[selectedRow]
if (lastWatchedSortEvent != null) {
for(int i = 0;i < selectedRows.length; i++)
selectedRows[i] = watchedTable.rowSorter.convertRowIndexToModel(selectedRows[i])
}
List<String> rv = new ArrayList<>()
selectedRows.each {
rv.add(model.watched[it])
}
rv
}
int getSelectedTrustTablesRow(String tableName) {