mirror of https://github.com/zlatinb/muwire
event for downloading collections
parent
65e96eacc2
commit
00c1f9590a
|
@ -0,0 +1,12 @@
|
||||||
|
package com.muwire.core.collections
|
||||||
|
|
||||||
|
import com.muwire.core.Event
|
||||||
|
import com.muwire.core.Persona
|
||||||
|
|
||||||
|
class UIDownloadCollectionEvent extends Event {
|
||||||
|
|
||||||
|
FileCollection collection
|
||||||
|
Set<FileCollectionItem> items
|
||||||
|
boolean full
|
||||||
|
Persona host
|
||||||
|
}
|
|
@ -6,7 +6,9 @@ import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
|
import com.muwire.core.collections.FileCollection
|
||||||
import com.muwire.core.collections.FileCollectionItem
|
import com.muwire.core.collections.FileCollectionItem
|
||||||
|
import com.muwire.core.collections.UIDownloadCollectionEvent
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class CollectionTabController {
|
class CollectionTabController {
|
||||||
|
@ -15,14 +17,46 @@ class CollectionTabController {
|
||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
CollectionTabView view
|
CollectionTabView view
|
||||||
|
|
||||||
|
private FileCollection selectedCollection() {
|
||||||
|
int row = view.selectedCollection()
|
||||||
|
if (row < 0)
|
||||||
|
return null
|
||||||
|
|
||||||
|
return model.collections.get(row)
|
||||||
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void downloadCollection() {
|
void downloadCollection() {
|
||||||
|
FileCollection collection = selectedCollection()
|
||||||
|
if (collection == null)
|
||||||
|
return
|
||||||
|
|
||||||
|
UIDownloadCollectionEvent e = new UIDownloadCollectionEvent(
|
||||||
|
collection : collection,
|
||||||
|
items : collection.getFiles(),
|
||||||
|
full : true,
|
||||||
|
host : model.host
|
||||||
|
)
|
||||||
|
model.eventBus.publish(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void download() {
|
void download() {
|
||||||
|
FileCollection collection = selectedCollection()
|
||||||
|
if (collection == null)
|
||||||
|
return
|
||||||
|
|
||||||
|
List<FileCollectionItem> items = view.selectedItems()
|
||||||
|
if (items.isEmpty())
|
||||||
|
return
|
||||||
|
|
||||||
|
UIDownloadCollectionEvent e = new UIDownloadCollectionEvent(
|
||||||
|
collection : collection,
|
||||||
|
items : new HashSet<>(items),
|
||||||
|
full : false,
|
||||||
|
host : model.host
|
||||||
|
)
|
||||||
|
model.eventBus.publish(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
|
|
Loading…
Reference in New Issue