use of java.awt.datatransfer.Clipboard in project hale by halestudio.
the class MapTipManager method setMapKit.
/**
* @see MapPainter#setMapKit(BasicMapKit)
*/
@Override
public void setMapKit(BasicMapKit mapKit) {
this.mapKit = mapKit;
for (MapTipContainer c : mapTips) {
c.getMapTip().init(mapKit.getMainMap());
c.getMapTip().getPainter().setMapKit(mapKit);
}
mapKit.getMainMap().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
synchronized (this) {
if (lastTip != null && e.getKeyChar() == 'c') {
String text = lastTip.getLastText();
if (text != null) {
StringSelection stringSelection = new StringSelection(text);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, MapTipManager.this);
}
}
}
}
});
}
use of java.awt.datatransfer.Clipboard in project GregTech by GregTechCE.
the class ClipboardUtil method copyToClipboard.
public static void copyToClipboard(final String text) {
if (Desktop.isDesktopSupported()) {
final StringSelection selection = new StringSelection(text);
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, null);
}
}
use of java.awt.datatransfer.Clipboard in project proxyee-down by monkeyWie.
the class NativeController method copy.
@RequestMapping("copy")
public FullHttpResponse copy(Channel channel, FullHttpRequest request) throws Exception {
Map<String, Object> map = getJSONParams(request);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable selection = null;
if ("text".equalsIgnoreCase((String) map.get("type"))) {
selection = new StringSelection((String) map.get("data"));
}
clipboard.setContents(selection, null);
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
}
use of java.awt.datatransfer.Clipboard in project BoofCV by lessthanoptimal.
the class ApplicationLauncherApp method handleContextMenu.
/**
* Displays a context menu for a class leaf node
* Allows copying of the name and the path to the source
*/
private void handleContextMenu(JTree tree, int x, int y) {
TreePath path = tree.getPathForLocation(x, y);
tree.setSelectionPath(path);
var node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node == null)
return;
if (!node.isLeaf()) {
tree.setSelectionPath(null);
return;
}
final AppInfo info = (AppInfo) node.getUserObject();
var copyname = new JMenuItem("Copy Name");
copyname.addActionListener(e -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(info.app.getSimpleName()), null);
});
var copypath = new JMenuItem("Copy Path");
copypath.addActionListener(e -> {
String path1 = UtilIO.getSourcePath(info.app.getPackage().getName(), info.app.getSimpleName());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(path1), null);
});
var github = new JMenuItem("Go to Github");
github.addActionListener(e -> openInGitHub(info));
var submenu = new JPopupMenu();
submenu.add(copyname);
submenu.add(copypath);
submenu.add(github);
submenu.show(tree, x, y);
}
use of java.awt.datatransfer.Clipboard in project mzmine2 by mzmine.
the class ResultWindow method copyToClipboard.
/**
* Method sets value of clipboard to `content`
*
* @param content - Formula or SMILES string
* @param errorMessage - to print in a message if value of `content` is null
*/
private void copyToClipboard(String content, String errorMessage) {
if (content == null) {
MZmineCore.getDesktop().displayMessage(this, errorMessage);
return;
}
StringSelection stringSelection = new StringSelection(content);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
Aggregations