use of java.awt.datatransfer.Clipboard in project jadx by skylot.
the class UiUtils method setClipboardString.
public static void setClipboardString(String text) {
try {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable transferable = new StringSelection(text);
clipboard.setContents(transferable, null);
LOG.debug("String '{}' copied to clipboard", text);
} catch (Exception e) {
LOG.error("Failed copy string '{}' to clipboard", text, e);
}
}
use of java.awt.datatransfer.Clipboard in project jadx by skylot.
the class VarTreePopupMenu method addItems.
private void addItems() {
JMenuItem copyValItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_copy_value")) {
private static final long serialVersionUID = -1111111202103171118L;
@Override
public void actionPerformed(ActionEvent e) {
String val = valNode.getValue();
if (val != null) {
if (val.startsWith("\"") && val.endsWith("\"")) {
val = val.substring(1, val.length() - 1);
}
StringSelection stringSelection = new StringSelection(val);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
}
});
JMenuItem setValItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_set_value")) {
private static final long serialVersionUID = -1111111202103171119L;
@Override
public void actionPerformed(ActionEvent e) {
(new SetValueDialog(mainWindow, valNode)).setVisible(true);
}
});
JMenuItem zeroItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_change_to_zero")) {
private static final long serialVersionUID = -1111111202103171120L;
@Override
public void actionPerformed(ActionEvent event) {
try {
mainWindow.getDebuggerPanel().getDbgController().modifyRegValue(valNode, ArgType.INT, 0);
} catch (Exception e) {
LOG.error("Change to zero failed", e);
UiUtils.showMessageBox(mainWindow, e.getMessage());
}
}
});
JMenuItem oneItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_change_to_one")) {
private static final long serialVersionUID = -1111111202103171121L;
@Override
public void actionPerformed(ActionEvent event) {
try {
mainWindow.getDebuggerPanel().getDbgController().modifyRegValue(valNode, ArgType.INT, 1);
} catch (Exception e) {
LOG.error("Change to one failed", e);
UiUtils.showMessageBox(mainWindow, e.getMessage());
}
}
});
this.add(copyValItem);
this.add(new Separator());
this.add(setValItem);
this.add(zeroItem);
this.add(oneItem);
this.add(zeroItem);
}
use of java.awt.datatransfer.Clipboard in project jmeter by apache.
the class GuiUtils method getPastedText.
/**
* Get pasted text from clipboard
*
* @return String Pasted text
* @throws UnsupportedFlavorException
* if the clipboard data can not be get as a {@link String}
* @throws IOException
* if the clipboard data is no longer available
*/
public static String getPastedText() throws UnsupportedFlavorException, IOException {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable trans = clipboard.getContents(null);
DataFlavor[] flavourList = trans.getTransferDataFlavors();
Collection<DataFlavor> flavours = new ArrayList<>(flavourList.length);
if (Collections.addAll(flavours, flavourList) && flavours.contains(DataFlavor.stringFlavor)) {
return (String) trans.getTransferData(DataFlavor.stringFlavor);
} else {
return null;
}
}
use of java.awt.datatransfer.Clipboard in project jmeter by apache.
the class GuiUtils method copyTextToClipboard.
/**
* Copy text to clipboard
* @param text Text to copy
*/
public static final void copyTextToClipboard(String text) {
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(text);
clpbrd.setContents(stringSelection, null);
}
use of java.awt.datatransfer.Clipboard in project vectalign by bonnyfone.
the class Utils method copyToClipboard.
public static void copyToClipboard(String data) {
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
clpbrd.setContents(new StringSelection(data), null);
}
Aggregations