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