Search in sources :

Example 51 with StringSelection

use of java.awt.datatransfer.StringSelection in project otapij by FellowTraveler.

the class CashPurseTokenDetails method jButton2ActionPerformed.

//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton2ActionPerformed
    StringSelection fieldContent = new StringSelection(jTextArea1.getText());
    getToolkit().getSystemClipboard().setContents(fieldContent, CashPurseTokenDetails.this);
}
Also used : StringSelection(java.awt.datatransfer.StringSelection)

Example 52 with StringSelection

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

the class TextInputKeyProcessorTest method cmdVPastesAtCursorWithSelection.

@Test
public void cmdVPastesAtCursorWithSelection() {
    setupSingleLine("Here are four words").withCaretAt(0, 1).andSelectionAt(0, 4);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("oot"), model);
    processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_V, 0), model);
    assertEquals("Hoot are four words", model.getText());
    assertEquals(TextLocation.at(0, 4), model.getCaretLocation());
    assertEquals(TextLocation.at(0, 1), model.getSelectionLocation());
    assertEquals(false, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) StringSelection(java.awt.datatransfer.StringSelection) Test(org.junit.Test)

Example 53 with StringSelection

use of java.awt.datatransfer.StringSelection in project android by JetBrains.

the class AvdSummaryAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    AvdInfo info = getAvdInfo();
    if (info == null) {
        return;
    }
    HtmlBuilder htmlBuilder = new HtmlBuilder();
    htmlBuilder.openHtmlBody();
    htmlBuilder.addHtml("<br>Name: ").add(info.getName());
    htmlBuilder.addHtml("<br>CPU/ABI: ").add(AvdInfo.getPrettyAbiType(info));
    htmlBuilder.addHtml("<br>Path: ").add(info.getDataFolderPath());
    if (info.getStatus() != AvdInfo.AvdStatus.OK) {
        htmlBuilder.addHtml("<br>Error: ").add(info.getErrorMessage());
    } else {
        AndroidVersion version = info.getAndroidVersion();
        htmlBuilder.addHtml("<br>Target: ").add(String.format("%1$s (API level %2$s)", info.getTag(), version.getApiString()));
        // display some extra values.
        Map<String, String> properties = info.getProperties();
        String skin = properties.get(AvdManager.AVD_INI_SKIN_NAME);
        if (skin != null) {
            htmlBuilder.addHtml("<br>Skin: ").add(skin);
        }
        String sdcard = properties.get(AvdManager.AVD_INI_SDCARD_SIZE);
        if (sdcard == null) {
            sdcard = properties.get(AvdManager.AVD_INI_SDCARD_PATH);
        }
        if (sdcard != null) {
            htmlBuilder.addHtml("<br>SD Card: ").add(sdcard);
        }
        String snapshot = properties.get(AvdManager.AVD_INI_SNAPSHOT_PRESENT);
        if (snapshot != null) {
            htmlBuilder.addHtml("<br>Snapshot: ").add(snapshot);
        }
        // display other hardware
        HashMap<String, String> copy = new HashMap<String, String>(properties);
        // remove stuff we already displayed (or that we don't want to display)
        copy.remove(AvdManager.AVD_INI_ABI_TYPE);
        copy.remove(AvdManager.AVD_INI_CPU_ARCH);
        copy.remove(AvdManager.AVD_INI_SKIN_NAME);
        copy.remove(AvdManager.AVD_INI_SKIN_PATH);
        copy.remove(AvdManager.AVD_INI_SDCARD_SIZE);
        copy.remove(AvdManager.AVD_INI_SDCARD_PATH);
        copy.remove(AvdManager.AVD_INI_IMAGES_2);
        if (copy.size() > 0) {
            for (Map.Entry<String, String> entry : copy.entrySet()) {
                htmlBuilder.addHtml("<br>").add(entry.getKey()).add(": ").add(entry.getValue());
            }
        }
    }
    htmlBuilder.closeHtmlBody();
    String[] options = { "Copy to Clipboard and Close", "Close" };
    int i = Messages.showDialog((Project) null, htmlBuilder.getHtml(), "Details for " + info.getName(), options, 0, AllIcons.General.InformationDialog);
    if (i == 0) {
        CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.stripHtml(htmlBuilder.getHtml(), true)));
    }
}
Also used : HashMap(java.util.HashMap) HtmlBuilder(com.android.utils.HtmlBuilder) AvdInfo(com.android.sdklib.internal.avd.AvdInfo) AndroidVersion(com.android.sdklib.AndroidVersion) HashMap(java.util.HashMap) Map(java.util.Map) StringSelection(java.awt.datatransfer.StringSelection)

Example 54 with StringSelection

use of java.awt.datatransfer.StringSelection in project android by JetBrains.

the class TranslationsEditorTest method paste.

@Test
public void paste() {
    JTableFixture table = myTranslationsEditor.getTable();
    table.selectCell(TableCell.row(1).column(2));
    String data = "app_name\tapp_name_en\n" + "cancel\tcancel_en\n";
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(data), EmptyClipboardOwner.INSTANCE);
    KeyStroke keyStroke = getKeyStroke(table.target().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT), "paste");
    table.pressAndReleaseKey(KeyPressInfo.keyCode(keyStroke.getKeyCode()).modifiers(keyStroke.getModifiers()));
    assertEquals("app_name", table.valueAt(TableCell.row(1).column(2)));
    assertEquals("app_name_en", table.valueAt(TableCell.row(1).column(3)));
    assertEquals("cancel", table.valueAt(TableCell.row(2).column(2)));
    assertEquals("cancel_en", table.valueAt(TableCell.row(2).column(3)));
}
Also used : JTableFixture(org.fest.swing.fixture.JTableFixture) StringSelection(java.awt.datatransfer.StringSelection) Test(org.junit.Test)

Example 55 with StringSelection

use of java.awt.datatransfer.StringSelection in project android by JetBrains.

the class PTableTest method testPasteIntoSimpleItem.

public void testPasteIntoSimpleItem() {
    when(myCopyPasteManager.getContents()).thenReturn(new StringSelection("new value"));
    myTable.setRowSelectionInterval(0, 0);
    assertThat(myTable.isPastePossible(myContext)).isTrue();
    assertThat(myTable.isPasteEnabled(myContext)).isTrue();
    myTable.performPaste(myContext);
    assertThat(mySimpleItem.getValue()).isEqualTo("new value");
    assertHasOriginalValuesExceptFor(mySimpleItem);
}
Also used : 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