diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 564adb9b..f8729710 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -89,12 +89,12 @@ class MainFrameController { group.model.results[row] } - private def selectedDownload() { + private int selectedDownload() { def selected = builder.getVariable("downloads-table").getSelectedRow() def sortEvt = mvcGroup.view.lastDownloadSortEvent if (sortEvt != null) selected = sortEvt.convertPreviousRowIndexToModel(selected) - model.downloads[selected].downloader + selected } @ControllerAction @@ -131,13 +131,13 @@ class MainFrameController { @ControllerAction void cancel() { - def downloader = selectedDownload() + def downloader = model.downloads[selectedDownload()].downloader downloader.cancel() } @ControllerAction void resume() { - def downloader = selectedDownload() + def downloader = model.downloads[selectedDownload()].downloader downloader.resume() } diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 66a242cb..a3e8ed24 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -111,7 +111,7 @@ class MainFrameView { downloadsTable = table(id : "downloads-table", autoCreateRowSorter : true) { tableModel(list: model.downloads) { closureColumn(header: "Name", preferredWidth: 350, type: String, read : {row -> row.downloader.file.getName()}) - closureColumn(header: "Status", preferredWidth: 50, type: String, read : {row -> row.downloader.getCurrentState()}) + closureColumn(header: "Status", preferredWidth: 50, type: String, read : {row -> row.downloader.getCurrentState().toString()}) closureColumn(header: "Progress", preferredWidth: 20, type: String, read: { row -> int pieces = row.downloader.nPieces int done = row.downloader.donePieces() @@ -263,7 +263,7 @@ class MainFrameView { def selectionModel = downloadsTable.getSelectionModel() selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) selectionModel.addListSelectionListener({ - int selectedRow = downloadsTable.getSelectedRow() + int selectedRow = selectedDownloaderRow() def downloader = model.downloads[selectedRow].downloader switch(downloader.getCurrentState()) { case Downloader.DownloadState.CONNECTING : @@ -288,6 +288,13 @@ class MainFrameView { downloadsTable.rowSorter.addRowSorterListener({evt -> lastDownloadSortEvent = evt}) } + int selectedDownloaderRow() { + int selected = builder.getVariable("downloads-table").getSelectedRow() + if (lastDownloadSortEvent != null) + selected = lastDownloadSortEvent.convertPreviousRowIndexToModel(selected) + selected + } + def showSearchWindow = { def cardsPanel = builder.getVariable("cards-panel") cardsPanel.getLayout().show(cardsPanel, "search window") diff --git a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy index a5c86e07..dc40c48e 100644 --- a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy @@ -39,7 +39,7 @@ class SearchTabView { closureColumn(header: "Sources", preferredWidth: 10, type : Integer, read : { row -> model.hashBucket[row.infohash].size()}) closureColumn(header: "Sender", preferredWidth: 170, type: String, read : {row -> row.sender.getHumanReadableName()}) closureColumn(header: "Trust", preferredWidth: 50, type: String, read : {row -> - model.core.trustService.getLevel(row.sender.destination) + model.core.trustService.getLevel(row.sender.destination).toString() }) } }