Search in sources :

Example 71 with Clipboard

use of java.awt.datatransfer.Clipboard in project jadx by skylot.

the class UiUtils method setClipboardString.

public static void setClipboardString(String text) {
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable transferable = new StringSelection(text);
        clipboard.setContents(transferable, null);
        LOG.debug("String '{}' copied to clipboard", text);
    } catch (Exception e) {
        LOG.error("Failed copy string '{}' to clipboard", text, e);
    }
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) StringSelection(java.awt.datatransfer.StringSelection)

Example 72 with Clipboard

use of java.awt.datatransfer.Clipboard in project jadx by skylot.

the class VarTreePopupMenu method addItems.

private void addItems() {
    JMenuItem copyValItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_copy_value")) {

        private static final long serialVersionUID = -1111111202103171118L;

        @Override
        public void actionPerformed(ActionEvent e) {
            String val = valNode.getValue();
            if (val != null) {
                if (val.startsWith("\"") && val.endsWith("\"")) {
                    val = val.substring(1, val.length() - 1);
                }
                StringSelection stringSelection = new StringSelection(val);
                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                clipboard.setContents(stringSelection, null);
            }
        }
    });
    JMenuItem setValItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_set_value")) {

        private static final long serialVersionUID = -1111111202103171119L;

        @Override
        public void actionPerformed(ActionEvent e) {
            (new SetValueDialog(mainWindow, valNode)).setVisible(true);
        }
    });
    JMenuItem zeroItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_change_to_zero")) {

        private static final long serialVersionUID = -1111111202103171120L;

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                mainWindow.getDebuggerPanel().getDbgController().modifyRegValue(valNode, ArgType.INT, 0);
            } catch (Exception e) {
                LOG.error("Change to zero failed", e);
                UiUtils.showMessageBox(mainWindow, e.getMessage());
            }
        }
    });
    JMenuItem oneItem = new JMenuItem(new AbstractAction(NLS.str("debugger.popup_change_to_one")) {

        private static final long serialVersionUID = -1111111202103171121L;

        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                mainWindow.getDebuggerPanel().getDbgController().modifyRegValue(valNode, ArgType.INT, 1);
            } catch (Exception e) {
                LOG.error("Change to one failed", e);
                UiUtils.showMessageBox(mainWindow, e.getMessage());
            }
        }
    });
    this.add(copyValItem);
    this.add(new Separator());
    this.add(setValItem);
    this.add(zeroItem);
    this.add(oneItem);
    this.add(zeroItem);
}
Also used : ActionEvent(java.awt.event.ActionEvent) SetValueDialog(jadx.gui.ui.dialog.SetValueDialog) Clipboard(java.awt.datatransfer.Clipboard) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) StringSelection(java.awt.datatransfer.StringSelection)

Example 73 with Clipboard

use of java.awt.datatransfer.Clipboard in project jmeter by apache.

the class GuiUtils method getPastedText.

/**
 * Get pasted text from clipboard
 *
 * @return String Pasted text
 * @throws UnsupportedFlavorException
 *             if the clipboard data can not be get as a {@link String}
 * @throws IOException
 *             if the clipboard data is no longer available
 */
public static String getPastedText() throws UnsupportedFlavorException, IOException {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    Transferable trans = clipboard.getContents(null);
    DataFlavor[] flavourList = trans.getTransferDataFlavors();
    Collection<DataFlavor> flavours = new ArrayList<>(flavourList.length);
    if (Collections.addAll(flavours, flavourList) && flavours.contains(DataFlavor.stringFlavor)) {
        return (String) trans.getTransferData(DataFlavor.stringFlavor);
    } else {
        return null;
    }
}
Also used : Transferable(java.awt.datatransfer.Transferable) ArrayList(java.util.ArrayList) Clipboard(java.awt.datatransfer.Clipboard) DataFlavor(java.awt.datatransfer.DataFlavor)

Example 74 with Clipboard

use of java.awt.datatransfer.Clipboard in project jmeter by apache.

the class GuiUtils method copyTextToClipboard.

/**
 * Copy text to clipboard
 * @param text Text to copy
 */
public static final void copyTextToClipboard(String text) {
    Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection stringSelection = new StringSelection(text);
    clpbrd.setContents(stringSelection, null);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 75 with Clipboard

use of java.awt.datatransfer.Clipboard in project vectalign by bonnyfone.

the class Utils method copyToClipboard.

public static void copyToClipboard(String data) {
    Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
    clpbrd.setContents(new StringSelection(data), null);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Aggregations

Clipboard (java.awt.datatransfer.Clipboard)181 StringSelection (java.awt.datatransfer.StringSelection)117 Transferable (java.awt.datatransfer.Transferable)44 IOException (java.io.IOException)30 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)16 JDialog (javax.swing.JDialog)12 JOptionPane (javax.swing.JOptionPane)12 ActionEvent (java.awt.event.ActionEvent)11 Flame (org.jwildfire.create.tina.base.Flame)10 ActionListener (java.awt.event.ActionListener)8 JButton (javax.swing.JButton)8 JScrollPane (javax.swing.JScrollPane)8 JMenuItem (javax.swing.JMenuItem)7 JPanel (javax.swing.JPanel)7 JTextArea (javax.swing.JTextArea)7 Foundation (org.concord.energy3d.model.Foundation)7 HousePart (org.concord.energy3d.model.HousePart)7 FlameReader (org.jwildfire.create.tina.io.FlameReader)7 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)7 Point (java.awt.Point)6