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);
}
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());
}
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)));
}
}
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)));
}
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);
}
Aggregations