diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 46da4371..4cf5a926 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -45,14 +45,19 @@ class MainFrameController { } private def selectedResult() { - def resultsTable = builder.getVariable("results-table") - int row = resultsTable.getSelectedRow() - model.results[row] + def selected = builder.getVariable("result-tabs").getSelectedComponent() + def group = selected.getClientProperty("mvc-group") + def table = selected.getClientProperty("results-table") + int row = table.getSelectedRow() + + group.model.results[row] } @ControllerAction void download() { def result = selectedResult() + if (result == null) + return // TODO disable button def file = new File(application.context.get("muwire-settings").downloadLocation, result.name) core.eventBus.publish(new UIDownloadEvent(result : result, target : file)) } @@ -60,12 +65,16 @@ class MainFrameController { @ControllerAction void trust() { def result = selectedResult() + if (result == null) + return // TODO disable button core.eventBus.publish( new TrustEvent(destination : result.sender.destination, level : TrustLevel.TRUSTED)) } @ControllerAction void distrust() { def result = selectedResult() + if (result == null) + return // TODO disable button core.eventBus.publish( new TrustEvent(destination : result.sender.destination, level : TrustLevel.DISTRUSTED)) } diff --git a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy index 2d62f8fa..1594b290 100644 --- a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy @@ -23,8 +23,9 @@ class SearchTabView { void initUI() { builder.with { + def resultsTable def pane = scrollPane { - table(id : "results-table") { + resultsTable = table(id : "results-table") { tableModel(list: model.results) { closureColumn(header: "Name", type: String, read : {row -> row.name}) closureColumn(header: "Size", preferredWidth: 150, type: Long, read : {row -> row.size}) @@ -36,6 +37,8 @@ class SearchTabView { } } this.pane = pane + this.pane.putClientProperty("mvc-group", mvcGroup) + this.pane.putClientProperty("results-table",resultsTable) } }