copy path to clipboard
This commit is contained in:
parent
c373b1aa18
commit
4f539660c9
@ -21,6 +21,13 @@ public class ClipboardService {
|
|||||||
clipboard.setContents(transferable, null);
|
clipboard.setContents(transferable, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void copyTextToClipboard(String text) {
|
||||||
|
if (text == null || text.isEmpty()) return;
|
||||||
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
StringSelection selection = new StringSelection(text);
|
||||||
|
clipboard.setContents(selection, null);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static List<File> getFilesFromClipboard() {
|
public static List<File> getFilesFromClipboard() {
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package cz.kamma.kfmanager.ui;
|
|||||||
import cz.kamma.kfmanager.MainApp;
|
import cz.kamma.kfmanager.MainApp;
|
||||||
import cz.kamma.kfmanager.config.AppConfig;
|
import cz.kamma.kfmanager.config.AppConfig;
|
||||||
import cz.kamma.kfmanager.model.FileItem;
|
import cz.kamma.kfmanager.model.FileItem;
|
||||||
|
import cz.kamma.kfmanager.service.ClipboardService;
|
||||||
import cz.kamma.kfmanager.service.FileOperations;
|
import cz.kamma.kfmanager.service.FileOperations;
|
||||||
import cz.kamma.kfmanager.service.FileOperationQueue;
|
import cz.kamma.kfmanager.service.FileOperationQueue;
|
||||||
|
|
||||||
@ -294,6 +295,19 @@ public class MainWindow extends JFrame {
|
|||||||
|
|
||||||
cmdLabel = new JLabel();
|
cmdLabel = new JLabel();
|
||||||
cmdLabel.setFont(new Font("Monospaced", Font.BOLD, 12));
|
cmdLabel.setFont(new Font("Monospaced", Font.BOLD, 12));
|
||||||
|
|
||||||
|
// Add context menu to cmdLabel
|
||||||
|
JPopupMenu cmdPopupMenu = new JPopupMenu();
|
||||||
|
JMenuItem copyPathItem = new JMenuItem("Copy path");
|
||||||
|
copyPathItem.addActionListener(e -> {
|
||||||
|
String path = cmdLabel.getToolTipText();
|
||||||
|
if (path != null && !path.isEmpty()) {
|
||||||
|
ClipboardService.copyTextToClipboard(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cmdPopupMenu.add(copyPathItem);
|
||||||
|
cmdLabel.setComponentPopupMenu(cmdPopupMenu);
|
||||||
|
|
||||||
cmdPanel.add(cmdLabel, BorderLayout.WEST);
|
cmdPanel.add(cmdLabel, BorderLayout.WEST);
|
||||||
updateCommandLinePrompt();
|
updateCommandLinePrompt();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user