Search in sources :

Example 11 with StringSelection

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

the class PaymentOutboxDetailsDialog method jButton2ActionPerformed.

// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton2ActionPerformed
    StringSelection fieldContent = new StringSelection(jTextArea1.getText());
    getToolkit().getSystemClipboard().setContents(fieldContent, this);
}
Also used : StringSelection(java.awt.datatransfer.StringSelection)

Example 12 with StringSelection

use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.

the class TestTreeView method performCopy.

@Override
public void performCopy(@NotNull DataContext dataContext) {
    final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
    final String fqn;
    if (element != null) {
        fqn = CopyReferenceAction.elementToFqn(element);
    } else {
        AbstractTestProxy selectedTest = getSelectedTest();
        fqn = selectedTest instanceof TestProxyRoot ? ((TestProxyRoot) selectedTest).getRootLocation() : selectedTest != null ? selectedTest.getLocationUrl() : null;
    }
    CopyPasteManager.getInstance().setContents(new StringSelection(fqn));
}
Also used : PsiElement(com.intellij.psi.PsiElement) StringSelection(java.awt.datatransfer.StringSelection)

Example 13 with StringSelection

use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.

the class StatusPanel method createCopyAction.

private Action createCopyAction() {
    ActionManager actionManager = ActionManager.getInstance();
    if (actionManager == null)
        return null;
    AnAction action = actionManager.getAction(IdeActions.ACTION_COPY);
    if (action == null)
        return null;
    return new AbstractAction(action.getTemplatePresentation().getText(), action.getTemplatePresentation().getIcon()) {

        @Override
        public void actionPerformed(ActionEvent e) {
            StringSelection content = new StringSelection(getText());
            ClipboardSynchronizer.getInstance().setContent(content, content);
        }

        @Override
        public boolean isEnabled() {
            return !getText().isEmpty();
        }
    };
}
Also used : ActionManager(com.intellij.openapi.actionSystem.ActionManager) ActionEvent(java.awt.event.ActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) StringSelection(java.awt.datatransfer.StringSelection)

Example 14 with StringSelection

use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.

the class ChangesBrowserNodeCopyProvider method performCopy.

public void performCopy(@NotNull DataContext dataContext) {
    List<TreePath> paths = ContainerUtil.sorted(Arrays.asList(ObjectUtils.assertNotNull(myTree.getSelectionPaths())), TreeUtil.getDisplayOrderComparator(myTree));
    CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(paths, new Function<TreePath, String>() {

        @Override
        public String fun(TreePath path) {
            Object node = path.getLastPathComponent();
            if (node instanceof ChangesBrowserNode) {
                return ((ChangesBrowserNode) node).getTextPresentation();
            } else {
                return node.toString();
            }
        }
    }, "\n")));
}
Also used : TreePath(javax.swing.tree.TreePath) StringSelection(java.awt.datatransfer.StringSelection)

Example 15 with StringSelection

use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.

the class DetailsPanel method performCopy.

@Override
public void performCopy(@NotNull DataContext dataContext) {
    String selectedText = getSelectedText();
    if (selectedText == null || selectedText.isEmpty())
        selectedText = StringUtil.removeHtmlTags(getText());
    CopyPasteManager.getInstance().setContents(new StringSelection(selectedText));
}
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