add right-click and show-in-library option for uploads
This commit is contained in:
@@ -20,6 +20,7 @@ import javax.swing.JOptionPane
|
|||||||
import javax.swing.JTable
|
import javax.swing.JTable
|
||||||
|
|
||||||
import com.muwire.core.Core
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.InfoHash
|
||||||
import com.muwire.core.Persona
|
import com.muwire.core.Persona
|
||||||
import com.muwire.core.SharedFile
|
import com.muwire.core.SharedFile
|
||||||
import com.muwire.core.SplitPattern
|
import com.muwire.core.SplitPattern
|
||||||
@@ -39,6 +40,8 @@ import com.muwire.core.trust.RemoteTrustList
|
|||||||
import com.muwire.core.trust.TrustEvent
|
import com.muwire.core.trust.TrustEvent
|
||||||
import com.muwire.core.trust.TrustLevel
|
import com.muwire.core.trust.TrustLevel
|
||||||
import com.muwire.core.trust.TrustSubscriptionEvent
|
import com.muwire.core.trust.TrustSubscriptionEvent
|
||||||
|
import com.muwire.core.upload.HashListUploader
|
||||||
|
import com.muwire.core.upload.Uploader
|
||||||
|
|
||||||
@ArtifactProviderFor(GriffonController)
|
@ArtifactProviderFor(GriffonController)
|
||||||
class MainFrameController {
|
class MainFrameController {
|
||||||
@@ -329,6 +332,28 @@ class MainFrameController {
|
|||||||
model.uploads.removeAll { it.finished }
|
model.uploads.removeAll { it.finished }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ControllerAction
|
||||||
|
void showInLibrary() {
|
||||||
|
Uploader uploader = view.selectedUploader()
|
||||||
|
if (uploader == null)
|
||||||
|
return
|
||||||
|
SharedFile sf = null
|
||||||
|
if (uploader instanceof HashListUploader) {
|
||||||
|
InfoHash infoHash = uploader.infoHash
|
||||||
|
Set<SharedFile> sfs = core.fileManager.rootToFiles.get(infoHash)
|
||||||
|
if (sfs != null && !sfs.isEmpty())
|
||||||
|
sf = sfs.first()
|
||||||
|
} else {
|
||||||
|
File f = uploader.file
|
||||||
|
sf = core.fileManager.fileToSharedFile.get(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sf == null)
|
||||||
|
return // can happen if user un-shared
|
||||||
|
|
||||||
|
view.focusOnSharedFile(sf)
|
||||||
|
}
|
||||||
|
|
||||||
@ControllerAction
|
@ControllerAction
|
||||||
void restoreSession() {
|
void restoreSession() {
|
||||||
model.sessionRestored = true
|
model.sessionRestored = true
|
||||||
|
@@ -176,8 +176,7 @@ class MainFrameModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.getVariable("uploads-table")?.model.fireTableDataChanged()
|
updateTablePreservingSelection("uploads-table")
|
||||||
|
|
||||||
updateTablePreservingSelection("downloads-table")
|
updateTablePreservingSelection("downloads-table")
|
||||||
updateTablePreservingSelection("trusted-table")
|
updateTablePreservingSelection("trusted-table")
|
||||||
updateTablePreservingSelection("distrusted-table")
|
updateTablePreservingSelection("distrusted-table")
|
||||||
@@ -409,8 +408,7 @@ class MainFrameModel {
|
|||||||
wrapper.finished = false
|
wrapper.finished = false
|
||||||
} else
|
} else
|
||||||
uploads << new UploaderWrapper(uploader : e.uploader)
|
uploads << new UploaderWrapper(uploader : e.uploader)
|
||||||
JTable table = builder.getVariable("uploads-table")
|
updateTablePreservingSelection("uploads-table")
|
||||||
table.model.fireTableDataChanged()
|
|
||||||
view.refreshSharedFiles()
|
view.refreshSharedFiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,8 +427,7 @@ class MainFrameModel {
|
|||||||
} else {
|
} else {
|
||||||
wrapper.finished = true
|
wrapper.finished = true
|
||||||
}
|
}
|
||||||
JTable table = builder.getVariable("uploads-table")
|
updateTablePreservingSelection("uploads-table")
|
||||||
table.model.fireTableDataChanged()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ import java.awt.FlowLayout
|
|||||||
import java.awt.GridBagConstraints
|
import java.awt.GridBagConstraints
|
||||||
import java.awt.GridBagLayout
|
import java.awt.GridBagLayout
|
||||||
import java.awt.Insets
|
import java.awt.Insets
|
||||||
|
import java.awt.Rectangle
|
||||||
import java.awt.Toolkit
|
import java.awt.Toolkit
|
||||||
import java.awt.datatransfer.DataFlavor
|
import java.awt.datatransfer.DataFlavor
|
||||||
import java.awt.datatransfer.StringSelection
|
import java.awt.datatransfer.StringSelection
|
||||||
@@ -70,6 +71,7 @@ class MainFrameView {
|
|||||||
|
|
||||||
def downloadsTable
|
def downloadsTable
|
||||||
def lastDownloadSortEvent
|
def lastDownloadSortEvent
|
||||||
|
def lastUploadsSortEvent
|
||||||
def lastSharedSortEvent
|
def lastSharedSortEvent
|
||||||
def trustTablesSortEvents = [:]
|
def trustTablesSortEvents = [:]
|
||||||
def expansionListener = new TreeExpansions()
|
def expansionListener = new TreeExpansions()
|
||||||
@@ -320,7 +322,7 @@ class MainFrameView {
|
|||||||
label("Uploads")
|
label("Uploads")
|
||||||
}
|
}
|
||||||
scrollPane (constraints : BorderLayout.CENTER) {
|
scrollPane (constraints : BorderLayout.CENTER) {
|
||||||
table(id : "uploads-table", rowHeight : rowHeight) {
|
table(id : "uploads-table", autoCreateRowSorter: true, rowHeight : rowHeight) {
|
||||||
tableModel(list : model.uploads) {
|
tableModel(list : model.uploads) {
|
||||||
closureColumn(header : "Name", type : String, read : {row -> row.uploader.getName() })
|
closureColumn(header : "Name", type : String, read : {row -> row.uploader.getName() })
|
||||||
closureColumn(header : "Progress", type : String, read : { row ->
|
closureColumn(header : "Progress", type : String, read : { row ->
|
||||||
@@ -650,6 +652,29 @@ class MainFrameView {
|
|||||||
|
|
||||||
sharedFilesTree.addTreeExpansionListener(expansionListener)
|
sharedFilesTree.addTreeExpansionListener(expansionListener)
|
||||||
|
|
||||||
|
// uploadsTable
|
||||||
|
def uploadsTable = builder.getVariable("uploads-table")
|
||||||
|
|
||||||
|
uploadsTable.rowSorter.addRowSorterListener({evt -> lastUploadsSortEvent = evt})
|
||||||
|
uploadsTable.rowSorter.setSortsOnUpdates(true)
|
||||||
|
|
||||||
|
selectionModel = uploadsTable.getSelectionModel()
|
||||||
|
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
|
||||||
|
JPopupMenu uploadsTableMenu = new JPopupMenu()
|
||||||
|
JMenuItem showInLibrary = new JMenuItem("Show in library")
|
||||||
|
showInLibrary.addActionListener({mvcGroup.controller.showInLibrary()})
|
||||||
|
uploadsTableMenu.add(showInLibrary)
|
||||||
|
uploadsTable.addMouseListener(new MouseAdapter() {
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger())
|
||||||
|
showPopupMenu(uploadsTableMenu, e)
|
||||||
|
}
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger())
|
||||||
|
showPopupMenu(uploadsTableMenu, e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// searches table
|
// searches table
|
||||||
def searchesTable = builder.getVariable("searches-table")
|
def searchesTable = builder.getVariable("searches-table")
|
||||||
JPopupMenu searchTableMenu = new JPopupMenu()
|
JPopupMenu searchTableMenu = new JPopupMenu()
|
||||||
@@ -902,6 +927,36 @@ class MainFrameView {
|
|||||||
showPopupMenu(menu, e)
|
showPopupMenu(menu, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def selectedUploader() {
|
||||||
|
def uploadsTable = builder.getVariable("uploads-table")
|
||||||
|
int selectedRow = uploadsTable.getSelectedRow()
|
||||||
|
if (selectedRow < 0)
|
||||||
|
return null
|
||||||
|
if (lastUploadsSortEvent != null)
|
||||||
|
selectedRow = uploadsTable.rowSorter.convertRowIndexToModel(selectedRow)
|
||||||
|
model.uploads[selectedRow].uploader
|
||||||
|
}
|
||||||
|
|
||||||
|
void focusOnSharedFile(SharedFile sf) {
|
||||||
|
if(model.treeVisible) {
|
||||||
|
def tree = builder.getVariable("shared-files-tree")
|
||||||
|
def node = model.fileToNode.get(sf)
|
||||||
|
if (node == null)
|
||||||
|
return
|
||||||
|
def path = new TreePath(node.getPath())
|
||||||
|
tree.setSelectionPath(path)
|
||||||
|
tree.scrollPathToVisible(path)
|
||||||
|
} else {
|
||||||
|
def table = builder.getVariable("shared-files-table")
|
||||||
|
int row = model.shared.indexOf(sf)
|
||||||
|
if (row < 0)
|
||||||
|
return
|
||||||
|
table.setRowSelectionInterval(row, row)
|
||||||
|
|
||||||
|
table.scrollRectToVisible(new Rectangle(table.getCellRect(row, 0, true)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void showRestoreOrEmpty() {
|
void showRestoreOrEmpty() {
|
||||||
def searchWindow = builder.getVariable("search window")
|
def searchWindow = builder.getVariable("search window")
|
||||||
String id
|
String id
|
||||||
|
Reference in New Issue
Block a user