From 3550fa43c93473b7a1084bd25efbea0d28b9fea2 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 2 Nov 2020 10:22:36 +0000 Subject: [PATCH] sequential download support --- .../muwire/gui/CollectionTabController.groovy | 6 ++-- .../com/muwire/gui/CollectionTabModel.groovy | 2 ++ .../com/muwire/gui/CollectionTabView.groovy | 28 +++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/gui/griffon-app/controllers/com/muwire/gui/CollectionTabController.groovy b/gui/griffon-app/controllers/com/muwire/gui/CollectionTabController.groovy index 4389b528..b4d760f1 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/CollectionTabController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/CollectionTabController.groovy @@ -37,7 +37,8 @@ class CollectionTabController { items : collection.getFiles(), host : model.host, infoHash : collection.getInfoHash(), - full : true + full : true, + sequential : view.isSequentialCollection() ) model.eventBus.publish(e) @@ -59,7 +60,8 @@ class CollectionTabController { items : new HashSet<>(items), host : model.host, infoHash : collection.getInfoHash(), - full : false + full : false, + sequential : view.isSequentialItem() ) model.eventBus.publish(e) diff --git a/gui/griffon-app/models/com/muwire/gui/CollectionTabModel.groovy b/gui/griffon-app/models/com/muwire/gui/CollectionTabModel.groovy index 726d3437..733a041c 100644 --- a/gui/griffon-app/models/com/muwire/gui/CollectionTabModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/CollectionTabModel.groovy @@ -46,6 +46,8 @@ class CollectionTabModel { @Observable boolean viewCommentButtonEnabled @Observable boolean downloadItemButtonEnabled @Observable boolean downloadCollectionButtonEnabled + @Observable boolean downloadSequentiallyCollection + @Observable boolean downloadSequentiallyItem void mvcGroupInit(Map args) { root = new DefaultMutableTreeNode() diff --git a/gui/griffon-app/views/com/muwire/gui/CollectionTabView.groovy b/gui/griffon-app/views/com/muwire/gui/CollectionTabView.groovy index 1ef660a3..f2fbd20b 100644 --- a/gui/griffon-app/views/com/muwire/gui/CollectionTabView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/CollectionTabView.groovy @@ -5,6 +5,7 @@ import griffon.core.artifact.GriffonView import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor +import javax.swing.JCheckBox import javax.swing.JLabel import javax.swing.JTable import javax.swing.JTextArea @@ -38,6 +39,8 @@ class CollectionTabView { JTable itemsTable def lastItemsTableSortEvent JTree itemsTree + JCheckBox downloadSequentiallyCollectionCheckbox + JCheckBox downloadSequentiallyItemCheckbox void initUI() { int rowHeight = application.context.get("row-height") @@ -62,7 +65,16 @@ class CollectionTabView { } } panel(constraints : BorderLayout.SOUTH) { - button(text : trans("COLLECTION_DOWNLOAD"), enabled : bind{model.downloadCollectionButtonEnabled}, downloadCollectionAction) + gridLayout(rows : 1, cols : 3) + panel{} + panel { + button(text : trans("COLLECTION_DOWNLOAD"), enabled : bind{model.downloadCollectionButtonEnabled}, downloadCollectionAction) + } + panel { + label(text : trans("DOWNLOAD_SEQUENTIALLY")) + downloadSequentiallyCollectionCheckbox = checkBox(selected : bind {model.downloadSequentiallyCollection}, + enabled : bind {model.downloadCollectionButtonEnabled}) + } } } panel { @@ -114,12 +126,24 @@ class CollectionTabView { button(text : trans("DOWNLOAD"), enabled : bind {model.downloadItemButtonEnabled}, downloadAction) button(text : trans("VIEW_COMMENT"), enabled : bind{model.viewCommentButtonEnabled}, viewCommentAction) } - panel {} + panel { + label(text : trans("DOWNLOAD_SEQUENTIALLY")) + downloadSequentiallyItemCheckbox = checkBox(selected : bind {model.downloadSequentiallyItem}, + enabled : bind {model.downloadItemButtonEnabled}) + } } } } } + boolean isSequentialCollection() { + downloadSequentiallyCollectionCheckbox.model.isSelected() + } + + boolean isSequentialItem() { + downloadSequentiallyItemCheckbox.model.isSelected() + } + void mvcGroupInit(Map args) { def mainFrameGroup = application.mvcGroupManager.findGroup("MainFrame") mainFrameGroup.model.collections.add(model.uuid.toString())