connection monitor

pull/4/head
Zlatin Balevsky 2019-06-01 13:32:40 +01:00
parent 1255ac936b
commit 9dac1891b2
2 changed files with 28 additions and 0 deletions

View File

@ -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()
}
}

View File

@ -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")