From 70fb789abfae9ee4af5ac46ad97730c008f1ae49 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Tue, 15 Oct 2019 04:51:21 +0100 Subject: [PATCH] remove the watched directories table --- .../com/muwire/gui/MainFrameController.groovy | 14 ---- .../com/muwire/gui/MainFrameModel.groovy | 5 +- .../views/com/muwire/gui/MainFrameView.groovy | 80 +------------------ 3 files changed, 4 insertions(+), 95 deletions(-) diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 93b4d7cb..d3dd1cce 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -291,20 +291,6 @@ class MainFrameController { mvcGroup.createMVCGroup("add-comment", "Add Comment", params) } - void stopWatchingDirectory() { - List directories = mvcGroup.view.getSelectedWatchedDirectories() - if (directories == null) - return - directories.each { directory -> - core.muOptions.watchedDirectories.remove(directory) - core.eventBus.publish(new DirectoryUnsharedEvent(directory : new File(directory))) - model.watched.remove(directory) - } - saveMuWireSettings() - - builder.getVariable("watched-directories-table").model.fireTableDataChanged() - } - void saveMuWireSettings() { File f = new File(core.home, "MuWire.properties") f.withOutputStream { diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 37b4dca4..5489a2d2 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -76,7 +76,6 @@ class MainFrameModel { def sharedTree def treeRoot final Map fileToNode = new HashMap<>() - def watched = [] def connectionList = [] def searches = new LinkedList() def trusted = [] @@ -248,9 +247,7 @@ class MainFrameModel { void onAllFilesLoadedEvent(AllFilesLoadedEvent e) { runInsideUIAsync { - watched.addAll(core.muOptions.watchedDirectories) - builder.getVariable("watched-directories-table").model.fireTableDataChanged() - watched.each { core.eventBus.publish(new FileSharedEvent(file : new File(it))) } + core.muOptions.watchedDirectories.each { core.eventBus.publish(new FileSharedEvent(file : new File(it))) } core.muOptions.trustSubscriptions.each { core.eventBus.publish(new TrustSubscriptionEvent(persona : it, subscribe : true)) diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 004b4042..8a0ab1a7 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -59,7 +59,6 @@ class MainFrameView { def downloadsTable def lastDownloadSortEvent def lastSharedSortEvent - def lastWatchedSortEvent def trustTablesSortEvents = [:] UISettings settings @@ -198,18 +197,8 @@ class MainFrameView { }) } panel (border : etchedBorder(), constraints : BorderLayout.CENTER) { - gridLayout(cols : 2, rows : 1) - panel { - borderLayout() - scrollPane (constraints : BorderLayout.CENTER) { - table(id : "watched-directories-table", autoCreateRowSorter: true) { - tableModel(list : model.watched) { - closureColumn(header: "Watched Directories", type : String, read : { it }) - } - } - } - } - panel (id : "shared-files-panel"){ + borderLayout() + panel (id : "shared-files-panel", constraints : BorderLayout.CENTER){ cardLayout() panel (constraints : "shared files table") { borderLayout() @@ -236,8 +225,8 @@ class MainFrameView { panel (constraints : BorderLayout.SOUTH) { gridLayout(rows:1, cols:2) panel { - button(text : "Add directories to watch", actionPerformed : watchDirectories) button(text : "Share files", actionPerformed : shareFiles) + button(text : "Add Comment", enabled : bind {model.addCommentButtonEnabled}, addCommentAction) } panel { gridLayout(rows : 1, cols : 2) @@ -245,9 +234,6 @@ class MainFrameView { label("Shared:") label(text : bind {model.loadedFiles}, id : "shared-files-count") } - panel { - button(text : "Add Comment", enabled : bind {model.addCommentButtonEnabled}, addCommentAction) - } panel { buttonGroup(id : "sharedViewType") radioButton(text : "Tree", selected : true, buttonGroup : sharedViewType, actionPerformed : showSharedFilesTree) @@ -588,27 +574,6 @@ class MainFrameView { } }) - // watched directories table - def watchedTable = builder.getVariable("watched-directories-table") - watchedTable.rowSorter.addRowSorterListener({evt -> lastWatchedSortEvent = evt}) - watchedTable.rowSorter.setSortsOnUpdates(true) - JPopupMenu watchedMenu = new JPopupMenu() - JMenuItem stopWatching = new JMenuItem("Stop sharing") - stopWatching.addActionListener({mvcGroup.controller.stopWatchingDirectory()}) - watchedMenu.add(stopWatching) - watchedTable.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - if (e.isPopupTrigger()) - showPopupMenu(watchedMenu, e) - } - @Override - public void mousePressed(MouseEvent e) { - if (e.isPopupTrigger()) - showPopupMenu(watchedMenu, e) - } - }) - // subscription table def subscriptionTable = builder.getVariable("subscription-table") subscriptionTable.setDefaultRenderer(Integer.class, centerRenderer) @@ -903,45 +868,6 @@ class MainFrameView { } } - def watchDirectories = { - def chooser = new JFileChooser() - 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) { - chooser.getSelectedFiles().each { f -> - watchDirectory(f) - } - } - } - - private void watchDirectory(File 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)) - } - - List getSelectedWatchedDirectories() { - def watchedTable = builder.getVariable("watched-directories-table") - int[] selectedRows = watchedTable.getSelectedRows() - if (selectedRows.length == 0) - return null - if (lastWatchedSortEvent != null) { - for(int i = 0;i < selectedRows.length; i++) - selectedRows[i] = watchedTable.rowSorter.convertRowIndexToModel(selectedRows[i]) - } - - List rv = new ArrayList<>() - selectedRows.each { - rv.add(model.watched[it]) - } - rv - } - int getSelectedTrustTablesRow(String tableName) { def table = builder.getVariable(tableName) int selectedRow = table.getSelectedRow()