move buttons onto search result tab
This commit is contained in:
@@ -59,6 +59,7 @@ class MainFrameController {
|
|||||||
Map<String, Object> params = new HashMap<>()
|
Map<String, Object> params = new HashMap<>()
|
||||||
params["search-terms"] = search
|
params["search-terms"] = search
|
||||||
params["uuid"] = uuid.toString()
|
params["uuid"] = uuid.toString()
|
||||||
|
params["core"] = core
|
||||||
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
||||||
model.results[uuid.toString()] = group
|
model.results[uuid.toString()] = group
|
||||||
|
|
||||||
@@ -96,6 +97,7 @@ class MainFrameController {
|
|||||||
Map<String, Object> params = new HashMap<>()
|
Map<String, Object> params = new HashMap<>()
|
||||||
params["search-terms"] = tabTitle
|
params["search-terms"] = tabTitle
|
||||||
params["uuid"] = uuid.toString()
|
params["uuid"] = uuid.toString()
|
||||||
|
params["core"] = core
|
||||||
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
||||||
model.results[uuid.toString()] = group
|
model.results[uuid.toString()] = group
|
||||||
|
|
||||||
@@ -106,20 +108,6 @@ class MainFrameController {
|
|||||||
originator : core.me))
|
originator : core.me))
|
||||||
}
|
}
|
||||||
|
|
||||||
private def selectedResult() {
|
|
||||||
def selected = builder.getVariable("result-tabs").getSelectedComponent()
|
|
||||||
def group = selected.getClientProperty("mvc-group")
|
|
||||||
def table = selected.getClientProperty("results-table")
|
|
||||||
int row = table.getSelectedRow()
|
|
||||||
if (row == -1)
|
|
||||||
return
|
|
||||||
def sortEvt = group.view.lastSortEvent
|
|
||||||
if (sortEvt != null) {
|
|
||||||
row = group.view.resultsTable.rowSorter.convertRowIndexToModel(row)
|
|
||||||
}
|
|
||||||
group.model.results[row]
|
|
||||||
}
|
|
||||||
|
|
||||||
private int selectedDownload() {
|
private int selectedDownload() {
|
||||||
def downloadsTable = builder.getVariable("downloads-table")
|
def downloadsTable = builder.getVariable("downloads-table")
|
||||||
def selected = downloadsTable.getSelectedRow()
|
def selected = downloadsTable.getSelectedRow()
|
||||||
@@ -129,42 +117,6 @@ class MainFrameController {
|
|||||||
selected
|
selected
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
|
||||||
void download() {
|
|
||||||
def result = selectedResult()
|
|
||||||
if (result == null)
|
|
||||||
return
|
|
||||||
|
|
||||||
if (!model.canDownload(result.infohash))
|
|
||||||
return
|
|
||||||
|
|
||||||
def file = new File(application.context.get("muwire-settings").downloadLocation, result.name)
|
|
||||||
|
|
||||||
def selected = builder.getVariable("result-tabs").getSelectedComponent()
|
|
||||||
def group = selected.getClientProperty("mvc-group")
|
|
||||||
|
|
||||||
def resultsBucket = group.model.hashBucket[result.infohash]
|
|
||||||
def sources = group.model.sourcesBucket[result.infohash]
|
|
||||||
|
|
||||||
core.eventBus.publish(new UIDownloadEvent(result : resultsBucket, sources: sources, target : file))
|
|
||||||
}
|
|
||||||
|
|
||||||
@ControllerAction
|
|
||||||
void trust() {
|
|
||||||
def result = selectedResult()
|
|
||||||
if (result == null)
|
|
||||||
return // TODO disable button
|
|
||||||
core.eventBus.publish( new TrustEvent(persona : result.sender, level : TrustLevel.TRUSTED))
|
|
||||||
}
|
|
||||||
|
|
||||||
@ControllerAction
|
|
||||||
void distrust() {
|
|
||||||
def result = selectedResult()
|
|
||||||
if (result == null)
|
|
||||||
return // TODO disable button
|
|
||||||
core.eventBus.publish( new TrustEvent(persona : result.sender, level : TrustLevel.DISTRUSTED))
|
|
||||||
}
|
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void trustPersonaFromSearch() {
|
void trustPersonaFromSearch() {
|
||||||
int selected = builder.getVariable("searches-table").getSelectedRow()
|
int selected = builder.getVariable("searches-table").getSelectedRow()
|
||||||
|
@@ -6,6 +6,63 @@ import griffon.inject.MVCMember
|
|||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.download.UIDownloadEvent
|
||||||
|
import com.muwire.core.trust.TrustEvent
|
||||||
|
import com.muwire.core.trust.TrustLevel
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class SearchTabController {
|
class SearchTabController {
|
||||||
|
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
SearchTabModel model
|
||||||
|
@MVCMember @Nonnull
|
||||||
|
SearchTabView view
|
||||||
|
|
||||||
|
Core core
|
||||||
|
|
||||||
|
private def selectedResult() {
|
||||||
|
int row = view.resultsTable.getSelectedRow()
|
||||||
|
if (row == -1)
|
||||||
|
return
|
||||||
|
def sortEvt = view.lastSortEvent
|
||||||
|
if (sortEvt != null) {
|
||||||
|
row = view.resultsTable.rowSorter.convertRowIndexToModel(row)
|
||||||
|
}
|
||||||
|
model.results[row]
|
||||||
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void download() {
|
||||||
|
def result = selectedResult()
|
||||||
|
if (result == null)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!mvcGroup.parentGroup.model.canDownload(result.infohash))
|
||||||
|
return
|
||||||
|
|
||||||
|
def file = new File(application.context.get("muwire-settings").downloadLocation, result.name)
|
||||||
|
|
||||||
|
def resultsBucket = model.hashBucket[result.infohash]
|
||||||
|
def sources = model.sourcesBucket[result.infohash]
|
||||||
|
|
||||||
|
core.eventBus.publish(new UIDownloadEvent(result : resultsBucket, sources: sources, target : file))
|
||||||
|
mvcGroup.parentGroup.view.showDownloadsWindow.call()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void trust() {
|
||||||
|
def result = selectedResult()
|
||||||
|
if (result == null)
|
||||||
|
return
|
||||||
|
core.eventBus.publish( new TrustEvent(persona : result.sender, level : TrustLevel.TRUSTED))
|
||||||
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void distrust() {
|
||||||
|
def result = selectedResult()
|
||||||
|
if (result == null)
|
||||||
|
return
|
||||||
|
core.eventBus.publish( new TrustEvent(persona : result.sender, level : TrustLevel.DISTRUSTED))
|
||||||
|
}
|
||||||
}
|
}
|
@@ -76,8 +76,6 @@ class MainFrameModel {
|
|||||||
@Observable String me
|
@Observable String me
|
||||||
@Observable int loadedFiles
|
@Observable int loadedFiles
|
||||||
@Observable File hashingFile
|
@Observable File hashingFile
|
||||||
@Observable boolean downloadActionEnabled
|
|
||||||
@Observable boolean trustButtonsEnabled
|
|
||||||
@Observable boolean cancelButtonEnabled
|
@Observable boolean cancelButtonEnabled
|
||||||
@Observable boolean retryButtonEnabled
|
@Observable boolean retryButtonEnabled
|
||||||
@Observable boolean pauseButtonEnabled
|
@Observable boolean pauseButtonEnabled
|
||||||
|
@@ -18,6 +18,9 @@ class SearchTabModel {
|
|||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
FactoryBuilderSupport builder
|
FactoryBuilderSupport builder
|
||||||
|
|
||||||
|
@Observable boolean downloadActionEnabled
|
||||||
|
@Observable boolean trustButtonsEnabled
|
||||||
|
|
||||||
Core core
|
Core core
|
||||||
UISettings uiSettings
|
UISettings uiSettings
|
||||||
String uuid
|
String uuid
|
||||||
|
@@ -119,11 +119,6 @@ class MainFrameView {
|
|||||||
panel (constraints : "search window") {
|
panel (constraints : "search window") {
|
||||||
borderLayout()
|
borderLayout()
|
||||||
tabbedPane(id : "result-tabs", constraints: BorderLayout.CENTER)
|
tabbedPane(id : "result-tabs", constraints: BorderLayout.CENTER)
|
||||||
panel(constraints : BorderLayout.SOUTH) {
|
|
||||||
button(text : "Download", enabled : bind {model.downloadActionEnabled}, downloadAction)
|
|
||||||
button(text : "Trust", enabled: bind {model.trustButtonsEnabled }, trustAction)
|
|
||||||
button(text : "Distrust", enabled : bind {model.trustButtonsEnabled}, distrustAction)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
panel (constraints: "downloads window") {
|
panel (constraints: "downloads window") {
|
||||||
gridLayout(rows : 2, cols: 1)
|
gridLayout(rows : 2, cols: 1)
|
||||||
|
@@ -43,7 +43,9 @@ class SearchTabView {
|
|||||||
void initUI() {
|
void initUI() {
|
||||||
builder.with {
|
builder.with {
|
||||||
def resultsTable
|
def resultsTable
|
||||||
def pane = scrollPane {
|
def pane = panel {
|
||||||
|
borderLayout()
|
||||||
|
scrollPane (constraints : BorderLayout.CENTER) {
|
||||||
resultsTable = table(id : "results-table", autoCreateRowSorter : true) {
|
resultsTable = table(id : "results-table", autoCreateRowSorter : true) {
|
||||||
tableModel(list: model.results) {
|
tableModel(list: model.results) {
|
||||||
closureColumn(header: "Name", preferredWidth: 350, type: String, read : {row -> row.name.replace('<','_')})
|
closureColumn(header: "Name", preferredWidth: 350, type: String, read : {row -> row.name.replace('<','_')})
|
||||||
@@ -57,6 +59,12 @@ class SearchTabView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
panel(constraints : BorderLayout.SOUTH) {
|
||||||
|
button(text : "Download", enabled : bind {model.downloadActionEnabled}, downloadAction)
|
||||||
|
button(text : "Trust", enabled: bind {model.trustButtonsEnabled }, trustAction)
|
||||||
|
button(text : "Distrust", enabled : bind {model.trustButtonsEnabled}, distrustAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.pane = pane
|
this.pane = pane
|
||||||
this.pane.putClientProperty("mvc-group", mvcGroup)
|
this.pane.putClientProperty("mvc-group", mvcGroup)
|
||||||
@@ -72,8 +80,8 @@ class SearchTabView {
|
|||||||
return
|
return
|
||||||
if (lastSortEvent != null)
|
if (lastSortEvent != null)
|
||||||
row = resultsTable.rowSorter.convertRowIndexToModel(row)
|
row = resultsTable.rowSorter.convertRowIndexToModel(row)
|
||||||
mvcGroup.parentGroup.model.trustButtonsEnabled = true
|
model.trustButtonsEnabled = true
|
||||||
mvcGroup.parentGroup.model.downloadActionEnabled = mvcGroup.parentGroup.model.canDownload(model.results[row].infohash)
|
model.downloadActionEnabled = mvcGroup.parentGroup.model.canDownload(model.results[row].infohash)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,14 +139,14 @@ class SearchTabView {
|
|||||||
def closeTab = {
|
def closeTab = {
|
||||||
int index = parent.indexOfTab(searchTerms)
|
int index = parent.indexOfTab(searchTerms)
|
||||||
parent.removeTabAt(index)
|
parent.removeTabAt(index)
|
||||||
mvcGroup.parentGroup.model.trustButtonsEnabled = false
|
model.trustButtonsEnabled = false
|
||||||
mvcGroup.parentGroup.model.downloadActionEnabled = false
|
model.downloadActionEnabled = false
|
||||||
mvcGroup.destroy()
|
mvcGroup.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
def showPopupMenu(MouseEvent e) {
|
def showPopupMenu(MouseEvent e) {
|
||||||
JPopupMenu menu = new JPopupMenu()
|
JPopupMenu menu = new JPopupMenu()
|
||||||
if (mvcGroup.parentGroup.model.downloadActionEnabled) {
|
if (model.downloadActionEnabled) {
|
||||||
JMenuItem download = new JMenuItem("Download")
|
JMenuItem download = new JMenuItem("Download")
|
||||||
download.addActionListener({mvcGroup.parentGroup.controller.download()})
|
download.addActionListener({mvcGroup.parentGroup.controller.download()})
|
||||||
menu.add(download)
|
menu.add(download)
|
||||||
|
Reference in New Issue
Block a user