use of java.awt.datatransfer.Clipboard in project netbeans-mmd-plugin by raydac.
the class TextEditor method doPaste.
@Override
public boolean doPaste() {
boolean result = false;
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String text = null;
try {
if (Utils.isDataFlavorAvailable(clipboard, DataFlavor.stringFlavor)) {
text = clipboard.getData(DataFlavor.stringFlavor).toString();
}
} catch (Exception ex) {
// NOI18N
LOGGER.warn("Can't get data from clipboard : " + ex.getMessage());
}
if (text != null) {
this.editor.replaceSelection(text);
result = true;
}
return result;
}
use of java.awt.datatransfer.Clipboard in project netbeans-mmd-plugin by raydac.
the class TextEditor method doCopy.
@Override
public boolean doCopy() {
boolean result = false;
final String selected = this.editor.getSelectedText();
if (selected != null && !selected.isEmpty()) {
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(selected), null);
}
return result;
}
use of java.awt.datatransfer.Clipboard in project netbeans-mmd-plugin by raydac.
the class TextEditor method doCut.
@Override
public boolean doCut() {
boolean result = false;
final String selected = this.editor.getSelectedText();
if (selected != null && !selected.isEmpty()) {
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(selected), null);
// NOI18N
this.editor.replaceSelection("");
}
return result;
}
use of java.awt.datatransfer.Clipboard in project azure-tools-for-java by Microsoft.
the class RedisPropertyView method copyToSystemClipboard.
private void copyToSystemClipboard(String key) {
StringSelection stringSelection = new StringSelection(key);
Toolkit toolKit = Toolkit.getDefaultToolkit();
if (toolKit == null) {
onError(COPY_FAIL);
return;
}
Clipboard clipboard = toolKit.getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
use of java.awt.datatransfer.Clipboard in project azure-tools-for-java by Microsoft.
the class Utils method copyToSystemClipboard.
public static void copyToSystemClipboard(String key) throws Exception {
StringSelection stringSelection = new StringSelection(key);
Toolkit toolKit = Toolkit.getDefaultToolkit();
if (toolKit == null) {
throw new Exception("Cannot copy to system clipboard.");
}
Clipboard clipboard = toolKit.getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
Aggregations