Search in sources :

Example 61 with Clipboard

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;
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException)

Example 62 with Clipboard

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;
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 63 with Clipboard

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;
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 64 with Clipboard

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);
}
Also used : Toolkit(java.awt.Toolkit) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 65 with Clipboard

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);
}
Also used : Toolkit(java.awt.Toolkit) Clipboard(java.awt.datatransfer.Clipboard) IOException(java.io.IOException) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)181 StringSelection (java.awt.datatransfer.StringSelection)117 Transferable (java.awt.datatransfer.Transferable)44 IOException (java.io.IOException)30 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)16 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 ActionEvent (java.awt.event.ActionEvent)11 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)8 JButton (javax.swing.JButton)8 JScrollPane (javax.swing.JScrollPane)8 JMenuItem (javax.swing.JMenuItem)7 JPanel (javax.swing.JPanel)7 JTextArea (javax.swing.JTextArea)7 Foundation (org.concord.energy3d.model.Foundation)7 HousePart (org.concord.energy3d.model.HousePart)7 FlameReader (org.jwildfire.create.tina.io.FlameReader)7 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)7 Point (java.awt.Point)6