mirror of https://github.com/zlatinb/muwire
add ability to copy full id from results table
parent
a28a7e66a1
commit
c46da44592
|
@ -207,4 +207,12 @@ class SearchTabController {
|
|||
params.core = model.core
|
||||
mvcGroup.parentGroup.createMVCGroup("new-message", UUID.randomUUID().toString(), params)
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void copyFullID() {
|
||||
Persona sender = view.selectedSender()
|
||||
if (sender == null)
|
||||
return
|
||||
CopyPasteSupport.copyToClipboard(sender.toBase64())
|
||||
}
|
||||
}
|
|
@ -258,7 +258,7 @@ RESULTS=Results
|
|||
FEED=Feed
|
||||
NEUTRAL=Neutral
|
||||
DISTRUST=Distrust
|
||||
COPY_FULL_ID=Copy full ID
|
||||
COPY_FULL_ID=Copy Full ID
|
||||
|
||||
# results table (group by sender)
|
||||
DIRECT_SOURCES=Direct Sources
|
||||
|
|
|
@ -318,6 +318,25 @@ class SearchTabView {
|
|||
parent.setTabComponentAt(index, tabPanel)
|
||||
mvcGroup.parentGroup.view.showSearchWindow.call()
|
||||
|
||||
|
||||
// senders popup menu
|
||||
JPopupMenu popupMenu = new JPopupMenu()
|
||||
JMenuItem copyFullIDItem = new JMenuItem(trans("COPY_FULL_ID"))
|
||||
copyFullIDItem.addActionListener({mvcGroup.controller.copyFullID()})
|
||||
popupMenu.add(copyFullIDItem)
|
||||
|
||||
def mouseListener = new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger() || e.button == MouseEvent.BUTTON3)
|
||||
popupMenu.show(e.getComponent(), e.getX(), e.getY())
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger() || e.button == MouseEvent.BUTTON3)
|
||||
popupMenu.show(e.getComponent(), e.getX(), e.getY())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def centerRenderer = new DefaultTableCellRenderer()
|
||||
centerRenderer.setHorizontalAlignment(JLabel.CENTER)
|
||||
resultsTable.setDefaultRenderer(Integer.class,centerRenderer)
|
||||
|
@ -360,6 +379,7 @@ class SearchTabView {
|
|||
})
|
||||
|
||||
// senders table
|
||||
sendersTable.addMouseListener(mouseListener)
|
||||
sendersTable.setDefaultRenderer(Integer.class, centerRenderer)
|
||||
sendersTable.rowSorter.addRowSorterListener({evt -> lastSendersSortEvent = evt})
|
||||
sendersTable.rowSorter.setSortsOnUpdates(true)
|
||||
|
@ -390,6 +410,7 @@ class SearchTabView {
|
|||
}
|
||||
})
|
||||
|
||||
|
||||
// results table 2
|
||||
resultsTable2.setDefaultRenderer(Integer.class,centerRenderer)
|
||||
resultsTable2.columnModel.getColumn(1).setCellRenderer(new SizeRenderer())
|
||||
|
@ -430,6 +451,7 @@ class SearchTabView {
|
|||
// TODO: add download right-click action
|
||||
|
||||
// senders table 2
|
||||
sendersTable2.addMouseListener(mouseListener)
|
||||
sendersTable2.setDefaultRenderer(Integer.class, centerRenderer)
|
||||
sendersTable2.rowSorter.addRowSorterListener({ evt -> lastSenders2SortEvent = evt})
|
||||
sendersTable2.rowSorter.setSortsOnUpdates(true)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.muwire.gui;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
|
||||
public class CopyPasteSupport {
|
||||
|
||||
|
@ -14,4 +16,9 @@ public class CopyPasteSupport {
|
|||
throw new RuntimeException(impossible);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyToClipboard(String str) {
|
||||
StringSelection selection = new StringSelection(str);
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue