Search in sources :

Example 51 with Clipboard

use of java.awt.datatransfer.Clipboard in project google-cloud-intellij by GoogleCloudPlatform.

the class CopyToClipboardActionListener method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(new StringSelection(text), null);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 52 with Clipboard

use of java.awt.datatransfer.Clipboard in project WorldPainter by Captain-Chaos.

the class ErrorDialog method copyToClipboard.

private void copyToClipboard() {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    StringSelection data = new StringSelection(body);
    clipboard.setContents(data, data);
    JOptionPane.showMessageDialog(this, "The information has been copied to the clipboard. Please paste\nit in a new email and send it to worldpainter@pepsoft.org.", "Information Copied", JOptionPane.INFORMATION_MESSAGE);
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 53 with Clipboard

use of java.awt.datatransfer.Clipboard in project basicv2 by EgonOlsen71.

the class ShellTextComponent method getClipBoardString.

private static String getClipBoardString() throws Exception {
    Clipboard clipboard = getDefaultToolkit().getSystemClipboard();
    Transferable clipData = clipboard.getContents(clipboard);
    if (clipData != null) {
        if (clipData.isDataFlavorSupported(stringFlavor)) {
            return (String) (clipData.getTransferData(stringFlavor));
        }
    }
    throw new Exception("no clpboard data");
}
Also used : Transferable(java.awt.datatransfer.Transferable) Clipboard(java.awt.datatransfer.Clipboard)

Example 54 with Clipboard

use of java.awt.datatransfer.Clipboard in project zencash-swing-wallet-ui by ZencashOfficial.

the class IPFSWrapper method shareFileViaIPFS.

// Returns null or [name](link)
public String shareFileViaIPFS() throws IOException, InterruptedException {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Share file via IPFS...");
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    int result = fileChooser.showOpenDialog(this.parentFrame);
    if (result != JFileChooser.APPROVE_OPTION) {
        return null;
    }
    File f = fileChooser.getSelectedFile();
    Cursor oldCursor = this.parentFrame.getCursor();
    try {
        this.parentFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        Log.info("Sharing file: {0}", f.getCanonicalPath());
        if (!this.ensureIPFSIsRunning()) {
            return null;
        }
        String ipfs = this.getIPFSFullExecutablePath();
        String pathParameter = ZCashClientCaller.wrapStringParameter(f.getCanonicalPath());
        CommandExecutor exec = new CommandExecutor(new String[] { ipfs, "add", "--quieter", pathParameter });
        String strResponse = exec.execute().trim();
        Log.info("IPFS hash of added file is: " + strResponse);
        // TODO: add via HTTP to some public writable IPFS gateway
        // this.uploadIPFSDataViaPost(f, "http://localhost:8080/ipfs/");
        this.parentFrame.setCursor(oldCursor);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(new StringSelection("http://localhost:8080/ipfs/" + strResponse), null);
        JOptionPane.showMessageDialog(this.parentFrame, "The file " + f.getName() + " has been shared successfully via IPFS. It may be\n" + "reached by other users (who have a local IPFS server running) via IPFS link: \n" + "http://localhost:8080/ipfs/" + strResponse + "\n\n" + "The link has been added to the messaging text box and also copied to the clipboard.\n", "File shared successfully", JOptionPane.INFORMATION_MESSAGE);
        return "[" + f.getName() + "](" + "http://localhost:8080/ipfs/" + strResponse + ")";
    } catch (Exception wce) {
        Log.error("Unexpected error: ", wce);
        JOptionPane.showMessageDialog(this.parentFrame, "An unexpected error occurred while sharing file via IPFS!" + "\n" + wce.getMessage().replace(",", ",\n"), "Error in importing wallet private keys...", JOptionPane.ERROR_MESSAGE);
        return null;
    } finally {
        this.parentFrame.setCursor(oldCursor);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) CommandExecutor(com.vaklinov.zcashui.CommandExecutor) Clipboard(java.awt.datatransfer.Clipboard) Cursor(java.awt.Cursor) File(java.io.File) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ProtocolException(java.net.ProtocolException) StringSelection(java.awt.datatransfer.StringSelection)

Example 55 with Clipboard

use of java.awt.datatransfer.Clipboard in project zencash-swing-wallet-ui by ZencashOfficial.

the class SendCashPanel method reportCompleteOperationToTheUser.

private void reportCompleteOperationToTheUser(String amount, String sourceAddress, String destinationAddress) throws InterruptedException, WalletCallException, IOException, URISyntaxException {
    if (clientCaller.isCompletedOperationSuccessful(operationStatusID)) {
        operationStatusLabel.setText(langUtil.getString("send.cash.panel.operation.status.success.label"));
        String TXID = clientCaller.getSuccessfulOperationTXID(operationStatusID);
        Object[] options = langUtil.getString("send.cash.panel.operation.complete.report").split(":");
        int option = JOptionPane.showOptionDialog(SendCashPanel.this.getRootPane().getParent(), langUtil.getString("send.cash.panel.operation.complete.report.success.text", amount, sourceAddress, destinationAddress, TXID), langUtil.getString("send.cash.panel.operation.complete.report.success.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
        if (option == 1) {
            // Copy the transaction ID to clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            clipboard.setContents(new StringSelection(TXID), null);
        } else if (option == 2) {
            // Open block explorer
            Log.info("Transaction ID for block explorer is: " + TXID);
            // TODO: code duplication with transactions table
            String urlPrefix = "https://explorer.zensystem.io/tx/";
            if (installationObserver.isOnTestNet()) {
                urlPrefix = "https://explorer-testnet.zen-solutions.io/tx/";
            }
            Desktop.getDesktop().browse(new URL(urlPrefix + TXID).toURI());
        }
        // Call the backup tracker - to remind the user
        this.backupTracker.handleNewTransaction();
    } else {
        String errorMessage = clientCaller.getOperationFinalErrorMessage(operationStatusID);
        operationStatusLabel.setText(langUtil.getString("send.cash.panel.operation.status.error.label", errorMessage));
        JOptionPane.showMessageDialog(SendCashPanel.this.getRootPane().getParent(), langUtil.getString("send.cash.panel.option.pane.error.report.text", errorMessage), langUtil.getString("send.cash.panel.option.pane.error.report.title"), JOptionPane.ERROR_MESSAGE);
    }
}
Also used : Clipboard(java.awt.datatransfer.Clipboard) URL(java.net.URL) 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