Search in sources :

Example 96 with StringSelection

use of java.awt.datatransfer.StringSelection in project tigervnc by TigerVNC.

the class CConn method serverCutText.

public void serverCutText(String str, int len) {
    StringSelection buffer;
    if (!acceptClipboard.getValue())
        return;
    ClipboardDialog.serverCutText(str);
}
Also used : StringSelection(java.awt.datatransfer.StringSelection)

Example 97 with StringSelection

use of java.awt.datatransfer.StringSelection in project cayenne by apache.

the class LogConsole method copy.

/**
 * Copies selected text from the console to system buffer
 */
public void copy() {
    String selectedText = view.getLogView().getSelectedText();
    // If nothing is selected, we copy the whole text
    if (Util.isEmptyString(selectedText)) {
        Document doc = view.getLogView().getDocument();
        try {
            selectedText = doc.getText(0, doc.getLength());
        } catch (BadLocationException e) {
            return;
        }
    }
    Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection data = new StringSelection(selectedText);
    sysClip.setContents(data, data);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 98 with StringSelection

use of java.awt.datatransfer.StringSelection in project suite by stupidsing.

the class ClipboardUtil method setClipboardText.

public void setClipboardText(String text) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(new StringSelection(text), null);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 99 with StringSelection

use of java.awt.datatransfer.StringSelection in project Payara by payara.

the class ErrorDisplayDialog method showText.

/**
 * Manages the dialog box to display whatever error information has already
 * been formatted.
 *
 * @param text message to display
 * @param rb ResourceBundle containing the i18n strings
 */
private static void showText(final String text, final ResourceBundle rb) {
    ErrorDisplayDialog.rb = rb;
    /*
         *The JOptionPane class will accept other Components as elements of
         *the dialog box.  Build a JTextArea containing the stack trace.  Do not
         *let the user edit the text.  
         */
    JTextArea stackTraceArea = new JTextArea();
    stackTraceArea.setEditable(false);
    stackTraceArea.setRows(16);
    stackTraceArea.setText(text);
    /*
         *Place the text area inside a scroll pane.
         */
    JScrollPane sp = new JScrollPane(stackTraceArea);
    /*
         *Build a check box for the user to click to copy the error information
         *to the platform's clipboard.
         */
    JCheckBox copyToClipboardCB = new JCheckBox(getString("jwsacc.errorDialog.copyToClipboardLabel"));
    /*
         *Display the dialog box that also contains the text area's scroll
         *pane and the checkbox and then wait for the user to close it.
         */
    boolean copyToClipboard = showDialog(getString("jwsacc.errorDialog.mainMessage.1") + LINE_SEP + getString("jwsacc.errorDialog.mainMessage.2"), sp, copyToClipboardCB);
    if (copyToClipboard) {
        Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
        StringSelection ss = new StringSelection(stackTraceArea.getText());
        try {
            cb.setContents(ss, null);
        } catch (Throwable e) {
            /*
                 *If we cannot copy the text to the clipboard, tell the user that
                 *and suggest that he or she manually copy it.
                 */
            showDialog(getString("jwsacc.errorDialog.errorCopyingMessage.1") + LINE_SEP + getString("jwsacc.errorDialog.errorCopyingMessage.2"), sp, null);
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JCheckBox(javax.swing.JCheckBox) JTextArea(javax.swing.JTextArea) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

StringSelection (java.awt.datatransfer.StringSelection)99 Clipboard (java.awt.datatransfer.Clipboard)28 ActionEvent (java.awt.event.ActionEvent)11 Transferable (java.awt.datatransfer.Transferable)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 JTextArea (javax.swing.JTextArea)7 Test (org.junit.Test)7 JPanel (javax.swing.JPanel)6 ActionListener (java.awt.event.ActionListener)5 JScrollPane (javax.swing.JScrollPane)5 Editor (com.intellij.openapi.editor.Editor)4 Project (com.intellij.openapi.project.Project)4 PsiFile (com.intellij.psi.PsiFile)4 ClipboardOwner (java.awt.datatransfer.ClipboardOwner)4 JMenuItem (javax.swing.JMenuItem)4 BibEntry (org.jabref.model.entry.BibEntry)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 PsiElement (com.intellij.psi.PsiElement)3 BorderLayout (java.awt.BorderLayout)3