This commit is contained in:
Zlatin Balevsky
2019-05-31 01:24:21 +01:00
parent d9aeb030d4
commit d7cb534813
3 changed files with 29 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ public class Downloader {
private final int pieceSize
private final I2PConnector connector
private final Destination destination
private final int nPieces
private Endpoint endpoint
private volatile DownloadSession currentSession
@@ -35,6 +36,7 @@ public class Downloader {
nPieces = length / pieceSize
else
nPieces = length / pieceSize + 1
this.nPieces = nPieces
pieces = new Pieces(nPieces, Constants.DOWNLOAD_SEQUENTIAL_RATIO)
currentState = DownloadState.CONNECTING

View File

@@ -13,6 +13,9 @@ class MainFrameModel {
@Inject @Nonnull GriffonApplication application
@Observable boolean coreInitialized = false
@Observable def results
@Observable def downloads
void mvcGroupInit(Map<String, Object> args) {
application.addPropertyChangeListener("core", {e ->
coreInitialized = (e.getNewValue() != null)

View File

@@ -58,11 +58,19 @@ class MainFrameView {
cardLayout()
panel (constraints : "search window") {
borderLayout()
splitPane( orientation : JSplitPane.VERTICAL_SPLIT, dividerLocation : -1,
splitPane( orientation : JSplitPane.VERTICAL_SPLIT, dividerLocation : 500,
continuousLayout : true, constraints : BorderLayout.CENTER) {
panel (constraints : JSplitPane.TOP, preferredSize : [1020, 500]) {
panel (constraints : JSplitPane.TOP) {
borderLayout()
label(text : "results go here", constraints : BorderLayout.CENTER)
scrollPane (constraints : BorderLayout.CENTER){
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})
closureColumn(header: "Sender", type: String, read : {row -> row.sender.getHumanReadableName()})
}
}
}
panel(constraints : BorderLayout.SOUTH) {
button(text : "Download")
button(text : "Trust")
@@ -71,7 +79,19 @@ class MainFrameView {
}
panel (constraints : JSplitPane.BOTTOM) {
borderLayout()
label(text : "downloads go here", constraints : BorderLayout.CENTER)
scrollPane (constraints : BorderLayout.CENTER) {
table() {
tableModel(list: model.downloads) {
closureColumn(header: "Name", type: String, read : {row -> row.downloader.file.getName()})
closureColumn(header: "Status", type: String, read : {row -> row.downloader.getCurrentState()})
closureColumn(header: "Progress", type: String, read: { row ->
int pieces = row.downloader.nPieces
int done = row.downloader.donePieces()
"$pieces/$done pieces"
})
}
}
}
}
}
}