diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index 4cf5a926..779d8f04 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -49,7 +49,8 @@ class MainFrameController { def group = selected.getClientProperty("mvc-group") def table = selected.getClientProperty("results-table") int row = table.getSelectedRow() - + if (row == -1) + return group.model.results[row] } diff --git a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy index 6eef7bea..51d3ec65 100644 --- a/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/MainFrameModel.groovy @@ -37,11 +37,13 @@ class MainFrameModel { @Observable boolean coreInitialized = false def results = new ConcurrentHashMap<>() - @Observable def downloads = [] - @Observable def uploads = [] - @Observable def shared = [] + def downloads = [] + def uploads = [] + def shared = [] + @Observable int connections @Observable String me + @Observable boolean searchButtonsEnabled private final Set infoHashes = new HashSet<>() diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index ea00a12f..81f40c46 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -69,9 +69,9 @@ class MainFrameView { borderLayout() tabbedPane(id : "result-tabs", constraints: BorderLayout.CENTER) panel(constraints : BorderLayout.SOUTH) { - button(text : "Download", downloadAction) - button(text : "Trust", trustAction) - button(text : "Distrust", distrustAction) + button(text : "Download", enabled : bind {model.searchButtonsEnabled}, downloadAction) + button(text : "Trust", enabled: bind {model.searchButtonsEnabled }, trustAction) + button(text : "Distrust", enabled : bind {model.searchButtonsEnabled}, distrustAction) } } panel (constraints : JSplitPane.BOTTOM) { diff --git a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy index 1594b290..df261825 100644 --- a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy @@ -4,6 +4,8 @@ import griffon.core.artifact.GriffonView import griffon.core.mvc.MVCGroup import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor + +import javax.swing.ListSelectionModel import javax.swing.SwingConstants import java.awt.BorderLayout @@ -39,6 +41,12 @@ class SearchTabView { this.pane = pane this.pane.putClientProperty("mvc-group", mvcGroup) this.pane.putClientProperty("results-table",resultsTable) + + def selectionModel = resultsTable.getSelectionModel() + selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) + selectionModel.addListSelectionListener( { + mvcGroup.parentGroup.model.searchButtonsEnabled = true + }) } } @@ -66,6 +74,7 @@ class SearchTabView { def closeTab = { int index = parent.indexOfTab(searchTerms) parent.removeTabAt(index) + mvcGroup.parentGroup.model.searchButtonsEnabled = false mvcGroup.destroy() } } \ No newline at end of file