From 32f944a089d72f7939dd7468a8b8a4a504febe05 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 2 Jun 2019 11:56:19 +0100 Subject: [PATCH] trust panel ui --- .../com/muwire/gui/MainFrameController.groovy | 27 +++++++++++++++++++ .../com/muwire/gui/MainFrameModel.groovy | 4 +-- gui/griffon-app/resources/trust.html | 7 +++++ .../views/com/muwire/gui/MainFrameView.groovy | 18 ++++++++++--- 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 gui/griffon-app/resources/trust.html diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index e10b5ebb..c65796e8 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -101,6 +101,33 @@ class MainFrameController { def downloader = selectedDownload() downloader.resume() } + + private void markTrust(String tableName, TrustLevel level, def list) { + int row = builder.getVariable(tableName).getSelectedRow() + if (row < 0) + return + core.eventBus.publish(new TrustEvent(persona : list[row], level : level)) + } + + @ControllerAction + void markTrusted() { + markTrust("distrusted-table", TrustLevel.TRUSTED, model.distrusted) + } + + @ControllerAction + void markNeutralFromDistrusted() { + markTrust("distrusted-table", TrustLevel.NEUTRAL, model.distrusted) + } + + @ControllerAction + void markDistrusted() { + markTrust("trusted-table", TrustLevel.DISTRUSTED, model.trusted) + } + + @ControllerAction + void markNeutralFromTrusted() { + markTrust("trusted-table", TrustLevel.NEUTRAL, model.trusted) + } void mvcGroupInit(Map args) { application.addPropertyChangeListener("core", {e-> diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index c4e59769..326878f2 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -201,8 +201,8 @@ class MainFrameModel { void onTrustEvent(TrustEvent e) { runInsideUIAsync { - JTable table = builder.getVariable("results-table") - table.model.fireTableDataChanged() + + // TODO: refresh any search tabs trusted.clear() trusted.addAll(core.trustService.good.values()) diff --git a/gui/griffon-app/resources/trust.html b/gui/griffon-app/resources/trust.html new file mode 100644 index 00000000..d72ee6ba --- /dev/null +++ b/gui/griffon-app/resources/trust.html @@ -0,0 +1,7 @@ + +Some html goes here + + diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index d9b5802e..3e5fdb79 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -22,6 +22,7 @@ import java.awt.FlowLayout import java.awt.GridBagConstraints import java.awt.GridBagLayout import java.awt.Insets +import java.nio.charset.StandardCharsets import javax.annotation.Nonnull @@ -183,8 +184,8 @@ class MainFrameView { } } panel(constraints : "trust window") { - gridLayout(rows: 1, cols :3) - panel { + gridLayout(rows: 1, cols :2) + panel (border : etchedBorder()){ borderLayout() panel (constraints : BorderLayout.NORTH) { label("Trusted users") @@ -196,9 +197,13 @@ class MainFrameView { } } } + panel (constraints : BorderLayout.EAST) { + gridBagLayout() + button(text : "Mark Neutral", constraints : gbc(gridx: 0, gridy: 0), markNeutralFromTrustedAction) + button(text : "Mark Distrusted", constraints : gbc(gridx: 0, gridy:1), markDistrustedAction) + } } - panel { label("buttons go here")} - panel { + panel (border : etchedBorder()){ borderLayout() panel (constraints : BorderLayout.NORTH) { label("Distrusted users") @@ -210,6 +215,11 @@ class MainFrameView { } } } + panel(constraints : BorderLayout.WEST) { + gridBagLayout() + button(text: "Mark Neutral", constraints: gbc(gridx: 0, gridy: 0), markNeutralFromDistrustedAction) + button(text: "Mark Trusted", constraints : gbc(gridx: 0, gridy : 1), markTrustedAction) + } } } }