mirror of https://github.com/zlatinb/muwire
button for publishing, column in the shared files table
parent
17cd60afe3
commit
8798ea38e8
|
@ -505,6 +505,24 @@ class MainFrameController {
|
||||||
clipboard.setContents(selection, null)
|
clipboard.setContents(selection, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void publish() {
|
||||||
|
def selectedFiles = view.selectedSharedFiles()
|
||||||
|
if (selectedFiles == null || selectedFiles.isEmpty())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (model.publishButtonText == "Unpublish") {
|
||||||
|
selectedFiles.each {
|
||||||
|
it.unpublish()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
long now = System.currentTimeMillis()
|
||||||
|
selectedFiles.stream().filter({!it.isPublished()}).forEach({it.publish(now)})
|
||||||
|
}
|
||||||
|
// TODO: issue event to core
|
||||||
|
view.refreshSharedFiles()
|
||||||
|
}
|
||||||
|
|
||||||
void startChat(Persona p) {
|
void startChat(Persona p) {
|
||||||
if (!mvcGroup.getChildrenGroups().containsKey(p.getHumanReadableName())) {
|
if (!mvcGroup.getChildrenGroups().containsKey(p.getHumanReadableName())) {
|
||||||
def params = [:]
|
def params = [:]
|
||||||
|
|
|
@ -103,6 +103,8 @@ class MainFrameModel {
|
||||||
@Observable boolean previewButtonEnabled
|
@Observable boolean previewButtonEnabled
|
||||||
@Observable String resumeButtonText
|
@Observable String resumeButtonText
|
||||||
@Observable boolean addCommentButtonEnabled
|
@Observable boolean addCommentButtonEnabled
|
||||||
|
@Observable boolean publishButtonEnabled
|
||||||
|
@Observable String publishButtonText
|
||||||
@Observable boolean subscribeButtonEnabled
|
@Observable boolean subscribeButtonEnabled
|
||||||
@Observable boolean markNeutralFromTrustedButtonEnabled
|
@Observable boolean markNeutralFromTrustedButtonEnabled
|
||||||
@Observable boolean markDistrustedButtonEnabled
|
@Observable boolean markDistrustedButtonEnabled
|
||||||
|
@ -253,6 +255,7 @@ class MainFrameModel {
|
||||||
distrusted.addAll(core.trustService.bad.values())
|
distrusted.addAll(core.trustService.bad.values())
|
||||||
|
|
||||||
resumeButtonText = "Retry"
|
resumeButtonText = "Retry"
|
||||||
|
publishButtonText = "Publish"
|
||||||
|
|
||||||
searchesPaneButtonEnabled = false
|
searchesPaneButtonEnabled = false
|
||||||
downloadsPaneButtonEnabled = true
|
downloadsPaneButtonEnabled = true
|
||||||
|
|
|
@ -292,6 +292,7 @@ class MainFrameView {
|
||||||
Core core = application.context.get("core")
|
Core core = application.context.get("core")
|
||||||
core.certificateManager.hasLocalCertificate(new InfoHash(it.getRoot()))
|
core.certificateManager.hasLocalCertificate(new InfoHash(it.getRoot()))
|
||||||
})
|
})
|
||||||
|
closureColumn(header : "Published", preferredWidth : 50, type : Boolean, read : {row -> row.isPublished()})
|
||||||
closureColumn(header : "Search Hits", preferredWidth: 50, type : Integer, read : {it.getHits()})
|
closureColumn(header : "Search Hits", preferredWidth: 50, type : Integer, read : {it.getHits()})
|
||||||
closureColumn(header : "Downloaders", preferredWidth: 50, type : Integer, read : {it.getDownloaders().size()})
|
closureColumn(header : "Downloaders", preferredWidth: 50, type : Integer, read : {it.getDownloaders().size()})
|
||||||
}
|
}
|
||||||
|
@ -316,9 +317,11 @@ class MainFrameView {
|
||||||
radioButton(text : "Table", selected : false, buttonGroup : sharedViewType, actionPerformed : showSharedFilesTable)
|
radioButton(text : "Table", selected : false, buttonGroup : sharedViewType, actionPerformed : showSharedFilesTable)
|
||||||
}
|
}
|
||||||
panel {
|
panel {
|
||||||
button(text : "Share", actionPerformed : shareFiles)
|
gridBagLayout()
|
||||||
button(text : "Add Comment", enabled : bind {model.addCommentButtonEnabled}, addCommentAction)
|
button(text : "Share", constraints : gbc(gridx: 0), actionPerformed : shareFiles)
|
||||||
button(text : "Certify", enabled : bind {model.addCommentButtonEnabled}, issueCertificateAction)
|
button(text : "Add Comment", enabled : bind {model.addCommentButtonEnabled}, constraints : gbc(gridx: 1), addCommentAction)
|
||||||
|
button(text : "Certify", enabled : bind {model.addCommentButtonEnabled}, constraints : gbc(gridx: 2), issueCertificateAction)
|
||||||
|
button(text : bind {model.publishButtonText}, enabled : bind {model.publishButtonEnabled}, constraints : gbc(gridx:3), publishAction)
|
||||||
}
|
}
|
||||||
panel {
|
panel {
|
||||||
panel {
|
panel {
|
||||||
|
@ -682,14 +685,30 @@ class MainFrameView {
|
||||||
if (selectedFiles == null || selectedFiles.isEmpty())
|
if (selectedFiles == null || selectedFiles.isEmpty())
|
||||||
return
|
return
|
||||||
model.addCommentButtonEnabled = true
|
model.addCommentButtonEnabled = true
|
||||||
|
model.publishButtonEnabled = true
|
||||||
|
boolean unpublish = true
|
||||||
|
selectedFiles.each {
|
||||||
|
unpublish &= it.isPublished()
|
||||||
|
}
|
||||||
|
model.publishButtonText = unpublish ? "Unpublish" : "Publish"
|
||||||
})
|
})
|
||||||
|
|
||||||
def sharedFilesTree = builder.getVariable("shared-files-tree")
|
def sharedFilesTree = builder.getVariable("shared-files-tree")
|
||||||
sharedFilesTree.addMouseListener(sharedFilesMouseListener)
|
sharedFilesTree.addMouseListener(sharedFilesMouseListener)
|
||||||
|
|
||||||
sharedFilesTree.addTreeSelectionListener({
|
sharedFilesTree.addTreeSelectionListener({
|
||||||
def selectedNode = sharedFilesTree.getLastSelectedPathComponent()
|
def selectedNode = sharedFilesTree.getLastSelectedPathComponent()
|
||||||
model.addCommentButtonEnabled = selectedNode != null
|
model.addCommentButtonEnabled = selectedNode != null
|
||||||
|
model.publishButtonEnabled = selectedNode != null
|
||||||
|
|
||||||
|
def selectedFiles = selectedSharedFiles()
|
||||||
|
if (selectedFiles == null || selectedFiles.isEmpty())
|
||||||
|
return
|
||||||
|
boolean unpublish = true
|
||||||
|
selectedFiles.each {
|
||||||
|
unpublish &= it.isPublished()
|
||||||
|
}
|
||||||
|
model.publishButtonText = unpublish ? "Unpublish" : "Publish"
|
||||||
})
|
})
|
||||||
|
|
||||||
sharedFilesTree.addTreeExpansionListener(expansionListener)
|
sharedFilesTree.addTreeExpansionListener(expansionListener)
|
||||||
|
|
Loading…
Reference in New Issue