mirror of https://github.com/zlatinb/muwire
connection monitor
parent
1255ac936b
commit
9dac1891b2
|
@ -27,6 +27,7 @@ import griffon.core.mvc.MVCGroup
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.transform.FXObservable
|
import griffon.transform.FXObservable
|
||||||
import griffon.transform.Observable
|
import griffon.transform.Observable
|
||||||
|
import net.i2p.data.Destination
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonModel)
|
@ArtifactProviderFor(GriffonModel)
|
||||||
|
@ -40,6 +41,7 @@ class MainFrameModel {
|
||||||
def downloads = []
|
def downloads = []
|
||||||
def uploads = []
|
def uploads = []
|
||||||
def shared = []
|
def shared = []
|
||||||
|
def connectionList = []
|
||||||
|
|
||||||
@Observable int connections
|
@Observable int connections
|
||||||
@Observable String me
|
@Observable String me
|
||||||
|
@ -85,14 +87,23 @@ class MainFrameModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConnectionEvent(ConnectionEvent e) {
|
void onConnectionEvent(ConnectionEvent e) {
|
||||||
|
if (e.getStatus() != ConnectionAttemptStatus.SUCCESSFUL)
|
||||||
|
return
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
connections = core.connectionManager.getConnections().size()
|
connections = core.connectionManager.getConnections().size()
|
||||||
|
|
||||||
|
connectionList.add(e.endpoint.destination)
|
||||||
|
JTable table = builder.getVariable("connections-table")
|
||||||
|
table.model.fireTableDataChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDisconnectionEvent(DisconnectionEvent e) {
|
void onDisconnectionEvent(DisconnectionEvent e) {
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
connections = core.connectionManager.getConnections().size()
|
connections = core.connectionManager.getConnections().size()
|
||||||
|
connectionList.remove(e.destination)
|
||||||
|
JTable table = builder.getVariable("connections-table")
|
||||||
|
table.model.fireTableDataChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ class MainFrameView {
|
||||||
gridLayout(rows:1, cols: 2)
|
gridLayout(rows:1, cols: 2)
|
||||||
button(text: "Searches", actionPerformed : showSearchWindow)
|
button(text: "Searches", actionPerformed : showSearchWindow)
|
||||||
button(text: "Uploads", actionPerformed : showUploadsWindow)
|
button(text: "Uploads", actionPerformed : showUploadsWindow)
|
||||||
|
button(text: "Monitor", actionPerformed : showMonitorWindow)
|
||||||
}
|
}
|
||||||
panel(constraints: BorderLayout.CENTER) {
|
panel(constraints: BorderLayout.CENTER) {
|
||||||
borderLayout()
|
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) {
|
panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
|
@ -156,6 +168,11 @@ class MainFrameView {
|
||||||
cardsPanel.getLayout().show(cardsPanel, "uploads window")
|
cardsPanel.getLayout().show(cardsPanel, "uploads window")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def showMonitorWindow = {
|
||||||
|
def cardsPanel = builder.getVariable("cards-panel")
|
||||||
|
cardsPanel.getLayout().show(cardsPanel,"monitor window")
|
||||||
|
}
|
||||||
|
|
||||||
def shareFiles = {
|
def shareFiles = {
|
||||||
def chooser = new JFileChooser()
|
def chooser = new JFileChooser()
|
||||||
chooser.setDialogTitle("Select file or directory to share")
|
chooser.setDialogTitle("Select file or directory to share")
|
||||||
|
|
Loading…
Reference in New Issue