hook up trust buttons

pull/4/head
Zlatin Balevsky 2019-05-31 16:07:00 +01:00
parent 3c9883785a
commit e7c463a3be
2 changed files with 23 additions and 5 deletions

View File

@ -13,6 +13,8 @@ import com.muwire.core.download.DownloadStartedEvent
import com.muwire.core.download.UIDownloadEvent import com.muwire.core.download.UIDownloadEvent
import com.muwire.core.search.QueryEvent import com.muwire.core.search.QueryEvent
import com.muwire.core.search.SearchEvent import com.muwire.core.search.SearchEvent
import com.muwire.core.trust.TrustEvent
import com.muwire.core.trust.TrustLevel
@ArtifactProviderFor(GriffonController) @ArtifactProviderFor(GriffonController)
class MainFrameController { class MainFrameController {
@ -33,15 +35,31 @@ class MainFrameController {
replyTo: core.me.destination, receivedOn: core.me.destination)) replyTo: core.me.destination, receivedOn: core.me.destination))
} }
@ControllerAction private def selectedResult() {
void download() {
def resultsTable = builder.getVariable("results-table") def resultsTable = builder.getVariable("results-table")
int row = resultsTable.getSelectedRow() int row = resultsTable.getSelectedRow()
def result = model.results[row] model.results[row]
}
@ControllerAction
void download() {
def result = selectedResult()
def file = new File(application.context.get("muwire-settings").downloadLocation, result.name) def file = new File(application.context.get("muwire-settings").downloadLocation, result.name)
core.eventBus.publish(new UIDownloadEvent(result : result, target : file)) core.eventBus.publish(new UIDownloadEvent(result : result, target : file))
} }
@ControllerAction
void trust() {
def result = selectedResult()
core.eventBus.publish( new TrustEvent(destination : result.sender.destination, level : TrustLevel.TRUSTED))
}
@ControllerAction
void distrust() {
def result = selectedResult()
core.eventBus.publish( new TrustEvent(destination : result.sender.destination, level : TrustLevel.DISTRUSTED))
}
void mvcGroupInit(Map<String, String> args) { void mvcGroupInit(Map<String, String> args) {
application.addPropertyChangeListener("core", {e-> application.addPropertyChangeListener("core", {e->
core = e.getNewValue() core = e.getNewValue()

View File

@ -75,8 +75,8 @@ class MainFrameView {
} }
panel(constraints : BorderLayout.SOUTH) { panel(constraints : BorderLayout.SOUTH) {
button(text : "Download", downloadAction) button(text : "Download", downloadAction)
button(text : "Trust") button(text : "Trust", trustAction)
button(text : "Distrust") button(text : "Distrust", distrustAction)
} }
} }
panel (constraints : JSplitPane.BOTTOM) { panel (constraints : JSplitPane.BOTTOM) {