Search in sources :

Example 1 with StringSelection

use of java.awt.datatransfer.StringSelection in project processing by processing.

the class ColorSelector method run.

public void run() {
    if (selector == null) {
        synchronized (ColorSelector.class) {
            if (selector == null) {
                selector = new ColorChooser(base.getActiveEditor(), false, Color.WHITE, Language.text("menu.edit.copy"), new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        Clipboard c = Toolkit.getSystemClipboard();
                        c.setContents(new StringSelection(selector.getHexColor()), null);
                    }
                });
            }
        }
    }
    selector.show();
}
Also used : ColorChooser(processing.app.ui.ColorChooser) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 2 with StringSelection

use of java.awt.datatransfer.StringSelection in project hid-serial by rayshobby.

the class GClip method copyString.

/**
	 * Copy a string to the clipboard. If the Clipboard has not been created
	 * then create it.
	 * @return true for a successful copy to clipboard
	 */
private boolean copyString(String chars) {
    if (clipboard == null)
        makeClipboardObject();
    if (clipboard != null) {
        StringSelection fieldContent = new StringSelection(chars);
        clipboard.setContents(fieldContent, this);
        return true;
    }
    return false;
}
Also used : StringSelection(java.awt.datatransfer.StringSelection)

Example 3 with StringSelection

use of java.awt.datatransfer.StringSelection in project limelight by slagyr.

the class TextModelTest method canMakeUseOfTheClipboard.

@Test
public void canMakeUseOfTheClipboard() {
    assumeTrue(TestUtil.notHeadless());
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("This Text"), model);
    String clipboard = model.getClipboardContents();
    assertEquals("This Text", clipboard);
}
Also used : StringSelection(java.awt.datatransfer.StringSelection) Test(org.junit.Test)

Example 4 with StringSelection

use of java.awt.datatransfer.StringSelection in project limelight by slagyr.

the class TextModelTest method reportsChangeWhenTextIsPasted.

@Test
public void reportsChangeWhenTextIsPasted() throws Exception {
    assumeTrue(TestUtil.notHeadless());
    model.setText("blah");
    model.resetChangeFlag();
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("yum"), model);
    model.pasteClipboard();
    assertEquals(true, model.hasChanged());
}
Also used : StringSelection(java.awt.datatransfer.StringSelection) Test(org.junit.Test)

Example 5 with StringSelection

use of java.awt.datatransfer.StringSelection in project limelight by slagyr.

the class TextInputKeyProcessorTest method cmdVPastesAtCursor.

@Test
public void cmdVPastesAtCursor() {
    setupSingleLine("Bob");
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(" Dole"), model);
    processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_V, 0), model);
    assertEquals(model.getEndLocation(), model.getCaretLocation());
    assertEquals("Bob Dole", model.getText());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) StringSelection(java.awt.datatransfer.StringSelection) Test(org.junit.Test)

Aggregations

StringSelection (java.awt.datatransfer.StringSelection)92 Clipboard (java.awt.datatransfer.Clipboard)23 ActionEvent (java.awt.event.ActionEvent)11 Transferable (java.awt.datatransfer.Transferable)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 JPanel (javax.swing.JPanel)6 JTextArea (javax.swing.JTextArea)6 ActionListener (java.awt.event.ActionListener)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 JScrollPane (javax.swing.JScrollPane)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