mirror of
https://github.com/mitb-archive/filebot
synced 2024-08-13 17:03:45 -04:00
SwingUI.copyToClipboard(String text)
This commit is contained in:
parent
8b3e2825be
commit
e3fbd3825f
@ -16,9 +16,7 @@ import static net.filebot.util.ui.SwingUI.*;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -364,7 +362,7 @@ public class RenamePanel extends JComponent {
|
|||||||
installAction(this, WHEN_IN_FOCUSED_WINDOW, getKeyStroke(VK_F7, 0), newAction("Copy Debug Information", evt -> {
|
installAction(this, WHEN_IN_FOCUSED_WINDOW, getKeyStroke(VK_F7, 0), newAction("Copy Debug Information", evt -> {
|
||||||
try {
|
try {
|
||||||
withWaitCursor(evt.getSource(), () -> {
|
withWaitCursor(evt.getSource(), () -> {
|
||||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(getDebugInfo()), null);
|
copyToClipboard(getDebugInfo());
|
||||||
log.info("Match model has been copied to clipboard");
|
log.info("Match model has been copied to clipboard");
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -13,7 +13,9 @@ import java.awt.Frame;
|
|||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.awt.dnd.DnDConstants;
|
import java.awt.dnd.DnDConstants;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
@ -62,6 +64,10 @@ public final class SwingUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void copyToClipboard(String text) {
|
||||||
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkEventDispatchThread() {
|
public static void checkEventDispatchThread() {
|
||||||
if (!SwingUtilities.isEventDispatchThread()) {
|
if (!SwingUtilities.isEventDispatchThread()) {
|
||||||
throw new IllegalStateException("Method must be accessed from the Swing Event Dispatch Thread, but was called on Thread \"" + Thread.currentThread().getName() + "\"");
|
throw new IllegalStateException("Method must be accessed from the Swing Event Dispatch Thread, but was called on Thread \"" + Thread.currentThread().getName() + "\"");
|
||||||
|
@ -10,9 +10,7 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@ -75,7 +73,7 @@ public class MessageNotification extends NotificationWindow {
|
|||||||
|
|
||||||
// copy message to clipboard
|
// copy message to clipboard
|
||||||
getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
getGlassPane().addMouseListener(mouseClicked(evt -> Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null)));
|
getGlassPane().addMouseListener(mouseClicked(evt -> copyToClipboard(text)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user