shared file details panel
This commit is contained in:
@@ -377,6 +377,19 @@ class MainFrameController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void showFileDetails() {
|
||||||
|
def selected = view.selectedSharedFiles()
|
||||||
|
if (selected.size() != 1) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Please select only one file to view it's details")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
def params = [:]
|
||||||
|
params['sf'] = selected[0]
|
||||||
|
params['core'] = core
|
||||||
|
mvcGroup.createMVCGroup("shared-file", params)
|
||||||
|
}
|
||||||
|
|
||||||
void saveMuWireSettings() {
|
void saveMuWireSettings() {
|
||||||
core.saveMuSettings()
|
core.saveMuSettings()
|
||||||
}
|
}
|
||||||
|
@@ -8,11 +8,4 @@ import javax.annotation.Nonnull
|
|||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class SharedFileController {
|
class SharedFileController {
|
||||||
@MVCMember @Nonnull
|
|
||||||
SharedFileModel model
|
|
||||||
|
|
||||||
@ControllerAction
|
|
||||||
void click() {
|
|
||||||
model.clickCount++
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -1,10 +1,24 @@
|
|||||||
package com.muwire.gui
|
package com.muwire.gui
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.SharedFile
|
||||||
|
|
||||||
import griffon.core.artifact.GriffonModel
|
import griffon.core.artifact.GriffonModel
|
||||||
import griffon.transform.Observable
|
import griffon.transform.Observable
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonModel)
|
@ArtifactProviderFor(GriffonModel)
|
||||||
class SharedFileModel {
|
class SharedFileModel {
|
||||||
@Observable int clickCount = 0
|
SharedFile sf
|
||||||
|
Core core
|
||||||
|
|
||||||
|
def searchers = []
|
||||||
|
def downloaders = []
|
||||||
|
def certificates = []
|
||||||
|
|
||||||
|
public void mvcGroupInit(Map<String,String> args) {
|
||||||
|
searchers.addAll(sf.searches)
|
||||||
|
downloaders.addAll(sf.downloaders)
|
||||||
|
certificates.addAll(core.certificateManager.byInfoHash.get(sf.infoHash))
|
||||||
|
}
|
||||||
}
|
}
|
@@ -611,6 +611,9 @@ class MainFrameView {
|
|||||||
JMenuItem certifySelectedFiles = new JMenuItem("Certify selected files")
|
JMenuItem certifySelectedFiles = new JMenuItem("Certify selected files")
|
||||||
certifySelectedFiles.addActionListener({mvcGroup.controller.issueCertificate()})
|
certifySelectedFiles.addActionListener({mvcGroup.controller.issueCertificate()})
|
||||||
sharedFilesMenu.add(certifySelectedFiles)
|
sharedFilesMenu.add(certifySelectedFiles)
|
||||||
|
JMenuItem showFileDetails = new JMenuItem("Show file details")
|
||||||
|
showFileDetails.addActionListener({mvcGroup.controller.showFileDetails()})
|
||||||
|
sharedFilesMenu.add(showFileDetails)
|
||||||
|
|
||||||
def sharedFilesMouseListener = new MouseAdapter() {
|
def sharedFilesMouseListener = new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
|
@@ -3,7 +3,15 @@ package com.muwire.gui
|
|||||||
import griffon.core.artifact.GriffonView
|
import griffon.core.artifact.GriffonView
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
|
||||||
|
import javax.swing.JDialog
|
||||||
|
import javax.swing.JTabbedPane
|
||||||
import javax.swing.SwingConstants
|
import javax.swing.SwingConstants
|
||||||
|
|
||||||
|
import java.awt.BorderLayout
|
||||||
|
import java.awt.event.WindowAdapter
|
||||||
|
import java.awt.event.WindowEvent
|
||||||
|
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonView)
|
@ArtifactProviderFor(GriffonView)
|
||||||
@@ -13,19 +21,82 @@ class SharedFileView {
|
|||||||
@MVCMember @Nonnull
|
@MVCMember @Nonnull
|
||||||
SharedFileModel model
|
SharedFileModel model
|
||||||
|
|
||||||
|
def mainFrame
|
||||||
|
def dialog
|
||||||
|
def panel
|
||||||
|
def searchersPanel
|
||||||
|
def downloadersPanel
|
||||||
|
def certificatesTable
|
||||||
|
def certificatesPanel
|
||||||
|
|
||||||
void initUI() {
|
void initUI() {
|
||||||
builder.with {
|
mainFrame = application.windowManager.findWindow("main-frame")
|
||||||
application(size: [320, 160], id: 'shared-file',
|
int rowHeight = application.context.get("row-height")
|
||||||
title: application.configuration['application.title'],
|
dialog = new JDialog(mainFrame,"Details for "+model.sf.getFile().getName(),true)
|
||||||
iconImage: imageIcon('/griffon-icon-48x48.png').image,
|
dialog.setResizable(true)
|
||||||
iconImages: [imageIcon('/griffon-icon-48x48.png').image,
|
|
||||||
imageIcon('/griffon-icon-32x32.png').image,
|
searchersPanel = builder.panel {
|
||||||
imageIcon('/griffon-icon-16x16.png').image]) {
|
borderLayout()
|
||||||
gridLayout(rows: 2, cols: 1)
|
scrollPane(constraints : BorderLayout.CENTER) {
|
||||||
label(id: 'clickLabel', text: bind { model.clickCount },
|
table(autoCreateRowSorter : true, rowHeight : rowHeight) {
|
||||||
horizontalAlignment: SwingConstants.CENTER)
|
tableModel(list : model.searchers) {
|
||||||
button(id: 'clickButton', clickAction)
|
closureColumn(header : "Searcher", type : String, read : {it.searcher.getHumanReadableName()})
|
||||||
|
closureColumn(header : "Query", type : String, read : {it.query})
|
||||||
|
closureColumn(header : "Timestamp", type : String, read : {
|
||||||
|
Date d = new Date(it.timestamp)
|
||||||
|
d.toString()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadersPanel = builder.panel {
|
||||||
|
borderLayout()
|
||||||
|
scrollPane(constraints : BorderLayout.CENTER) {
|
||||||
|
table(autoCreateRowSorter : true, rowHeight : rowHeight) {
|
||||||
|
tableModel(list : model.downloaders) {
|
||||||
|
closureColumn(header : "Downloader", type : String, read : {it})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
certificatesPanel = builder.panel {
|
||||||
|
borderLayout()
|
||||||
|
scrollPane(constraints : BorderLayout.CENTER) {
|
||||||
|
certificatesTable = table(autoCreateRowSorter : true, rowHeight : rowHeight) {
|
||||||
|
tableModel(list : model.certificates) {
|
||||||
|
closureColumn(header : "Issuer", type:String, read : {it.issuer.getHumanReadableName()})
|
||||||
|
closureColumn(header : "File Name", type : String, read : {it.name.name})
|
||||||
|
closureColumn(header : "Comment", type : Boolean, read : {it.comment != null})
|
||||||
|
closureColumn(header : "Timestamp", type : String, read : {
|
||||||
|
Date d = new Date(it.timestamp)
|
||||||
|
d.toString()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mvcGroupInit(Map<String,String> args) {
|
||||||
|
def tabbedPane = new JTabbedPane()
|
||||||
|
tabbedPane.addTab("Search Hits", searchersPanel)
|
||||||
|
tabbedPane.addTab("Downloaders", downloadersPanel)
|
||||||
|
tabbedPane.addTab("Certificates", certificatesPanel)
|
||||||
|
|
||||||
|
dialog.with {
|
||||||
|
getContentPane().add(tabbedPane)
|
||||||
|
pack()
|
||||||
|
setLocationRelativeTo(mainFrame)
|
||||||
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
|
||||||
|
addWindowListener(new WindowAdapter() {
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
mvcGroup.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user