From 9dac1891b2920c71449ccfd69b7d2795a910b4b5 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 1 Jun 2019 13:32:40 +0100 Subject: [PATCH] connection monitor --- .../models/com/muwire/gui/MainFrameModel.groovy | 11 +++++++++++ .../views/com/muwire/gui/MainFrameView.groovy | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index c8a5be7b..d2f9a16b 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -27,6 +27,7 @@ import griffon.core.mvc.MVCGroup import griffon.inject.MVCMember import griffon.transform.FXObservable import griffon.transform.Observable +import net.i2p.data.Destination import griffon.metadata.ArtifactProviderFor @ArtifactProviderFor(GriffonModel) @@ -40,6 +41,7 @@ class MainFrameModel { def downloads = [] def uploads = [] def shared = [] + def connectionList = [] @Observable int connections @Observable String me @@ -85,14 +87,23 @@ class MainFrameModel { } void onConnectionEvent(ConnectionEvent e) { + if (e.getStatus() != ConnectionAttemptStatus.SUCCESSFUL) + return runInsideUIAsync { connections = core.connectionManager.getConnections().size() + + connectionList.add(e.endpoint.destination) + JTable table = builder.getVariable("connections-table") + table.model.fireTableDataChanged() } } void onDisconnectionEvent(DisconnectionEvent e) { runInsideUIAsync { connections = core.connectionManager.getConnections().size() + connectionList.remove(e.destination) + JTable table = builder.getVariable("connections-table") + table.model.fireTableDataChanged() } } diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 81f40c46..09d775c6 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -48,6 +48,7 @@ class MainFrameView { gridLayout(rows:1, cols: 2) button(text: "Searches", actionPerformed : showSearchWindow) button(text: "Uploads", actionPerformed : showUploadsWindow) + button(text: "Monitor", actionPerformed : showMonitorWindow) } panel(constraints: BorderLayout.CENTER) { borderLayout() @@ -132,6 +133,17 @@ class MainFrameView { } } } + panel (constraints: "monitor window") { + borderLayout() + label("Connections", constraints : BorderLayout.NORTH) + scrollPane(constraints : BorderLayout.CENTER) { + table(id : "connections-table") { + tableModel(list : model.connectionList) { + closureColumn(header : "Destination", type: String, read : { row -> row.toBase32() }) + } + } + } + } } panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) { borderLayout() @@ -156,6 +168,11 @@ class MainFrameView { cardsPanel.getLayout().show(cardsPanel, "uploads window") } + def showMonitorWindow = { + def cardsPanel = builder.getVariable("cards-panel") + cardsPanel.getLayout().show(cardsPanel,"monitor window") + } + def shareFiles = { def chooser = new JFileChooser() chooser.setDialogTitle("Select file or directory to share")