incoming searches monitor

This commit is contained in:
Zlatin Balevsky
2019-06-01 13:44:46 +01:00
parent 9dac1891b2
commit 1996681677
2 changed files with 41 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ import com.muwire.core.download.DownloadStartedEvent
import com.muwire.core.files.FileHashedEvent import com.muwire.core.files.FileHashedEvent
import com.muwire.core.files.FileLoadedEvent import com.muwire.core.files.FileLoadedEvent
import com.muwire.core.files.FileSharedEvent import com.muwire.core.files.FileSharedEvent
import com.muwire.core.search.QueryEvent
import com.muwire.core.search.UIResultEvent import com.muwire.core.search.UIResultEvent
import com.muwire.core.trust.TrustEvent import com.muwire.core.trust.TrustEvent
import com.muwire.core.trust.TrustService import com.muwire.core.trust.TrustService
@@ -42,6 +43,7 @@ class MainFrameModel {
def uploads = [] def uploads = []
def shared = [] def shared = []
def connectionList = [] def connectionList = []
def searches = new LinkedList()
@Observable int connections @Observable int connections
@Observable String me @Observable String me
@@ -65,6 +67,7 @@ class MainFrameModel {
core.eventBus.register(UploadEvent.class, this) core.eventBus.register(UploadEvent.class, this)
core.eventBus.register(UploadFinishedEvent.class, this) core.eventBus.register(UploadFinishedEvent.class, this)
core.eventBus.register(TrustEvent.class, this) core.eventBus.register(TrustEvent.class, this)
core.eventBus.register(QueryEvent.class, this)
}) })
Timer timer = new Timer("download-pumper", true) Timer timer = new Timer("download-pumper", true)
timer.schedule({ timer.schedule({
@@ -153,4 +156,22 @@ class MainFrameModel {
table.model.fireTableDataChanged() table.model.fireTableDataChanged()
} }
} }
void onQueryEvent(QueryEvent e) {
StringBuilder sb = new StringBuilder()
e.searchEvent.searchTerms?.each {
sb.append(it)
sb.append(" ")
}
def search = sb.toString()
if (search.trim().size() == 0)
return
runInsideUIAsync {
searches.addFirst(search)
while(searches.size() > 200)
searches.removeLast()
JTable table = builder.getVariable("searches-table")
table.model.fireTableDataChanged()
}
}
} }

View File

@@ -134,6 +134,8 @@ class MainFrameView {
} }
} }
panel (constraints: "monitor window") { panel (constraints: "monitor window") {
gridLayout(rows : 1, cols : 2)
panel {
borderLayout() borderLayout()
label("Connections", constraints : BorderLayout.NORTH) label("Connections", constraints : BorderLayout.NORTH)
scrollPane(constraints : BorderLayout.CENTER) { scrollPane(constraints : BorderLayout.CENTER) {
@@ -144,6 +146,18 @@ class MainFrameView {
} }
} }
} }
panel {
borderLayout()
label("Incoming searches", constraints : BorderLayout.NORTH)
scrollPane(constraints : BorderLayout.CENTER) {
table(id : "searches-table") {
tableModel(list : model.searches) {
closureColumn(header : "Keywords", type : String, read : { it })
}
}
}
}
}
} }
panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) { panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) {
borderLayout() borderLayout()