From ba596af778e3ee094cfff553b7060f024b2a7e67 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 2 Jun 2019 05:40:44 +0100 Subject: [PATCH] Trust panel, wip --- .../com/muwire/gui/MainFrameModel.groovy | 31 +++++++++++++--- .../views/com/muwire/gui/MainFrameView.groovy | 36 +++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 2bb64964..c4e59769 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -45,6 +45,8 @@ class MainFrameModel { def shared = [] def connectionList = [] def searches = new LinkedList() + def trusted = [] + def distrusted = [] @Observable int connections @Observable String me @@ -56,6 +58,13 @@ class MainFrameModel { volatile Core core + void updateTablePreservingSelection(String tableName) { + def downloadTable = builder.getVariable(tableName) + int selectedRow = downloadTable.getSelectedRow() + downloadTable.model.fireTableDataChanged() + downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow) + } + void mvcGroupInit(Map args) { Timer timer = new Timer("download-pumper", true) @@ -64,11 +73,10 @@ class MainFrameModel { if (!mvcGroup.alive) return builder.getVariable("uploads-table")?.model.fireTableDataChanged() - - def downloadTable = builder.getVariable("downloads-table") - int selectedRow = downloadTable.getSelectedRow() - downloadTable.model.fireTableDataChanged() - downloadTable.selectionModel.setSelectionInterval(selectedRow,selectedRow) + + updateTablePreservingSelection("downloads-table") + updateTablePreservingSelection("trusted-table") + updateTablePreservingSelection("distrusted-table") } }, 1000, 1000) @@ -100,7 +108,12 @@ class MainFrameModel { }, retryInterval, retryInterval) } + runInsideUIAsync { + trusted.addAll(core.trustService.good.values()) + distrusted.addAll(core.trustService.bad.values()) + } }) + } void onUIResultEvent(UIResultEvent e) { @@ -190,6 +203,14 @@ class MainFrameModel { runInsideUIAsync { JTable table = builder.getVariable("results-table") table.model.fireTableDataChanged() + + trusted.clear() + trusted.addAll(core.trustService.good.values()) + distrusted.clear() + distrusted.addAll(core.trustService.bad.values()) + + updateTablePreservingSelection("trusted-table") + updateTablePreservingSelection("distrusted-table") } } diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index d0cf9113..d9b5802e 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -51,6 +51,7 @@ class MainFrameView { button(text: "Searches", actionPerformed : showSearchWindow) button(text: "Uploads", actionPerformed : showUploadsWindow) button(text: "Monitor", actionPerformed : showMonitorWindow) + button(text: "Trust", actionPerformed : showTrustWindow) } panel(id: "top-panel", constraints: BorderLayout.CENTER) { cardLayout() @@ -181,6 +182,36 @@ class MainFrameView { } } } + panel(constraints : "trust window") { + gridLayout(rows: 1, cols :3) + panel { + borderLayout() + panel (constraints : BorderLayout.NORTH) { + label("Trusted users") + } + scrollPane(constraints : BorderLayout.CENTER) { + table(id : "trusted-table") { + tableModel(list : model.trusted) { + closureColumn(type : String, read : { it.getHumanReadableName() } ) + } + } + } + } + panel { label("buttons go here")} + panel { + borderLayout() + panel (constraints : BorderLayout.NORTH) { + label("Distrusted users") + } + scrollPane(constraints : BorderLayout.CENTER) { + table(id : "distrusted-table") { + tableModel(list : model.distrusted) { + closureColumn(type : String, read : { it.getHumanReadableName() } ) + } + } + } + } + } } panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) { borderLayout() @@ -234,6 +265,11 @@ class MainFrameView { cardsPanel.getLayout().show(cardsPanel,"monitor window") } + def showTrustWindow = { + def cardsPanel = builder.getVariable("cards-panel") + cardsPanel.getLayout().show(cardsPanel,"trust window") + } + def shareFiles = { def chooser = new JFileChooser() chooser.setDialogTitle("Select file or directory to share")