mirror of https://github.com/zlatinb/muwire
hook up downloads to the table
parent
7e4bf5d85d
commit
deae9a3977
|
@ -9,6 +9,8 @@ import javax.annotation.Nonnull
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.download.DownloadStartedEvent
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -31,7 +33,18 @@ class MainFrameController {
|
||||||
replyTo: core.me.destination, receivedOn: core.me.destination))
|
replyTo: core.me.destination, receivedOn: core.me.destination))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void download() {
|
||||||
|
def resultsTable = builder.getVariable("results-table")
|
||||||
|
int row = resultsTable.getSelectedRow()
|
||||||
|
def result = model.results[row]
|
||||||
|
def file = new File(System.getProperty("user.home"), result.name) // TODO: move elsewhere
|
||||||
|
core.eventBus.publish(new UIDownloadEvent(result : result, target : file))
|
||||||
|
}
|
||||||
|
|
||||||
void mvcGroupInit(Map<String, String> args) {
|
void mvcGroupInit(Map<String, String> args) {
|
||||||
application.addPropertyChangeListener("core", {e-> core = e.getNewValue()})
|
application.addPropertyChangeListener("core", {e->
|
||||||
|
core = e.getNewValue()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import javax.inject.Inject
|
||||||
import javax.swing.JTable
|
import javax.swing.JTable
|
||||||
|
|
||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.download.DownloadStartedEvent
|
||||||
import com.muwire.core.search.UIResultEvent
|
import com.muwire.core.search.UIResultEvent
|
||||||
|
|
||||||
import griffon.core.GriffonApplication
|
import griffon.core.GriffonApplication
|
||||||
|
@ -31,6 +32,7 @@ class MainFrameModel {
|
||||||
coreInitialized = (e.getNewValue() != null)
|
coreInitialized = (e.getNewValue() != null)
|
||||||
core = e.getNewValue()
|
core = e.getNewValue()
|
||||||
core.eventBus.register(UIResultEvent.class, this)
|
core.eventBus.register(UIResultEvent.class, this)
|
||||||
|
core.eventBus.register(DownloadStartedEvent.class, this)
|
||||||
})
|
})
|
||||||
Timer timer = new Timer("download-pumper", true)
|
Timer timer = new Timer("download-pumper", true)
|
||||||
timer.schedule({
|
timer.schedule({
|
||||||
|
@ -47,4 +49,10 @@ class MainFrameModel {
|
||||||
table.model.fireTableDataChanged()
|
table.model.fireTableDataChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onDownloadStartedEvent(DownloadStartedEvent e) {
|
||||||
|
runInsideUIAsync {
|
||||||
|
downloads << e
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -73,7 +73,7 @@ class MainFrameView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel(constraints : BorderLayout.SOUTH) {
|
panel(constraints : BorderLayout.SOUTH) {
|
||||||
button(text : "Download")
|
button(text : "Download", downloadAction)
|
||||||
button(text : "Trust")
|
button(text : "Trust")
|
||||||
button(text : "Distrust")
|
button(text : "Distrust")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue