@Override public void actionPerformed(ActionEvent ae) { try { String action = ae.getActionCommand(); switch (action) { case "sign": String message = messageField.getText(); if (message.length() == 0) { UIRes.showErrorMessage(this, "Error", "You must enter the message text to sign"); } else { int index = nameField.getSelectedIndex(); ECKey key = BTCLoader.keys.get(index); String signature = key.signMessage(message); signatureField.setText(signature); } break; case "copy": String signature = signatureField.getText(); StringSelection sel = new StringSelection(signature); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(sel, null); break; case "done": setVisible(false); dispose(); break; } } catch (ECException exc) { ErrorLog.get().logException("Unable to sign message", exc); } catch (Exception exc) { ErrorLog.get().logException("Exception while processing action event", exc); } }
/* (non-Javadoc) * @see org.jdesktop.swingworker.SwingWorker#doInBackground() */ @Override protected Void doInBackground() throws Exception { if (errorInfo != null) { Throwable t = errorInfo.getErrorException(); String osMessage = "An error occurred on " + System.getProperty("os.name") + " version " + System.getProperty("os.version"); StringBuffer message = new StringBuffer(); message.append("System Info : ").append(osMessage).append(NEW_LINE_CHAR); message.append("Message : ").append(t.toString()).append(NEW_LINE_CHAR); message.append("Level : ").append(errorInfo.getErrorLevel()).append(NEW_LINE_CHAR); message.append("Stack Trace : ").append(NEW_LINE_CHAR); message.append(stackTraceToString(t)); // copy error message to system clipboard StringSelection stringSelection = new StringSelection(message.toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, null); // open errorReportingURL OpenBrowserAction openBrowserAction = new OpenBrowserAction(errorReportingURL); openBrowserAction.actionPerformed(null); } return null; }
@Override public void actionPerformed(ActionEvent e) { StringSelection text = new StringSelection(getText()); sb.setLength(0); Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(text, null); }
@Override public void export(DependencyGraph<CoffeeIdentifier> graph) { List<CoffeeIdentifier> identifiers; try { identifiers = GraphUtils.topologicalSort(graph); } catch (CyclicDependencyException e) { throw new RuntimeException(e); } List<CoffeeIdentifier> trimmed = trimDuplicateFiles(identifiers); StringBuilder builder = new StringBuilder(); for (CoffeeIdentifier identifier : trimmed) { try { String path = identifier.getFile().getCanonicalPath(); builder.append(path); if (multiLine) { builder.append("\n"); } else { builder.append(" "); } } catch (IOException e) { e.printStackTrace(); } } Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(builder.toString()), null); }
private static void copySVNURL(String fileName) { File file = new File(fileName); SVNClientManager clientManager = SVNClientManager.newInstance(); SVNStatusClient statusClient = clientManager.getStatusClient(); SVNStatus status = null; try { status = statusClient.doStatus(file, false); } catch (SVNException e) { logger.error("SVN Status was not possible", e); String message = "Some error with SVN. Probably the file selected is not in SVN."; String title = "Error"; JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE); System.exit(ERROR_END); } if (status != null) { SVNURL fileSVNUrl = status.getRemoteURL(); logger.info("SVN URL " + fileSVNUrl); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection stringSelection = new StringSelection(fileSVNUrl.toString()); clpbrd.setContents(stringSelection, null); String message = "Remote SVN URL has been coppied to the clipboard"; String title = "Success!"; JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE); } else { String message = "File " + fileName + " cannot be found in SVN"; String title = "File not found in Repository"; JOptionPane.showMessageDialog(null, message, title, JOptionPane.WARNING_MESSAGE); } }
private void copyBtnActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_copyBtnActionPerformed StringSelection stringSelection = new StringSelection(logArea.getText()); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); } // GEN-LAST:event_copyBtnActionPerformed
public static void copyAndNotify(String value) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable = new StringSelection(value); clipboard.setContents(transferable, null); System.out.println("copied password to clipboard, exiting in 10 seconds"); try { for (int i = 0; i < 10; i++) { System.out.print("."); Thread.sleep(1000); } } catch (InterruptedException e) { } clipboard.setContents(new StringSelection(""), null); }
private static void openweb() throws InterruptedException, AWTException { Robot robot = new Robot(); Thread.sleep(5000); String url = "http://www.freeproxylists.net/zh/?page="; Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); for (int i = 2; i <= 50; ++i) { String tUrl = url + Integer.toString(i); Transferable t = new StringSelection(tUrl); cb.setContents(t, null); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_T); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_T); Thread.sleep(1000); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_V); robot.keyRelease(KeyEvent.VK_CONTROL); robot.keyRelease(KeyEvent.VK_V); Thread.sleep(1000); robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER); Thread.sleep(1000); } }
public void actionPerformed(ActionEvent arg0) { StringSelection data = new StringSelection(xlist.toString()); try { clipboard.setContents(data, data); } catch (IllegalStateException e) { System.out.println("Error copying to clipboard, seems it's busy?"); } }
@Override public void execute(final GUI gui) { final int pre = gui.context.marked.pres[0]; final byte[] txt = ViewData.path(gui.context.data(), pre); // copy path to clipboard final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); clip.setContents(new StringSelection(Token.string(txt)), null); }
public void actionPerformed(ActionEvent e) { String output = radioStatistics(true, true, false); logger.info("PowerTracker output:\n\n" + output); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection stringSelection = new StringSelection(output); clipboard.setContents(stringSelection, null); }
public void actionPerformed(ActionEvent e) { final Toolkit tk = Toolkit.getDefaultToolkit(); final StringSelection st = new StringSelection(txt); final Clipboard cp = tk.getSystemClipboard(); cp.setContents(st, null); ti.inject(""); }
private void copyToClipboard(java.awt.event.ActionEvent evt) { String myString = passwordField.getText(); if (myString.isEmpty()) { return; } StringSelection stringSelection = new StringSelection(myString); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); }
/** * Copies the given text to the system clipboard. * * @param text the text to copy */ public static void copyToClipboard(final String text) { StringSelection selection = new StringSelection(text == null ? "" : text); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if (clipboard != null) { clipboard.setContents(selection, selection); } else { BeamLogManager.getSystemLogger().severe("failed to obtain clipboard instance"); } }
/** * Copies the given image to the system clipboard. * * @param image the image to copy */ public static void copyToClipboard(final Image image) { ImageSelection selection = new ImageSelection(image); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if (clipboard != null) { clipboard.setContents(selection, null); } else { BeamLogManager.getSystemLogger().severe("failed to obtain clipboard instance"); } }
public static void copyToClipboard(String text) { StringSelection selection = new StringSelection(text); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); ClipboardOwner owner = new ClipboardOwner() { public void lostOwnership(Clipboard clipboard, Transferable contents) {} }; clipboard.setContents(selection, owner); }
/** copies the content of the selection to the clipboard */ public void copyContent() { StringSelection selection; Clipboard clipboard; selection = getTable().getStringSelection(); if (selection == null) return; clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); }
/** * Simulate a paste from the user's clipboard into the indicated row * * @param rowIndex row to enter text * @param text text to be entered * @return new EditorPage */ public EditorPage pasteIntoRowAtIndex(final long rowIndex, final String text) { log.info("Paste at {} the text {}", rowIndex, text); WebElement we = readyElement(By.id(String.format(TARGET_ID_FMT, rowIndex, Plurals.SourceSingular.index()))); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(text), null); we.click(); we.sendKeys(Keys.LEFT_CONTROL + "v"); return new EditorPage(getDriver()); }
@Override public void actionPerformed(ActionEvent evt) { TreePath path = resultTree.getSelectionPath(); DefaultMutableTreeNode operNode = (DefaultMutableTreeNode) path.getLastPathComponent(); ToStringNodes toStringNodes = new ToStringNodes(); traverseNodes(operNode, toStringNodes); StringSelection selection = new StringSelection(toStringNodes.nodesString.toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, null); }
private void copyOverviewToClipboard() throws InsufficientDataException { String overview = generateOverviewText(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents( new StringSelection(overview), new ClipboardOwner() { @Override public void lostOwnership(Clipboard c, Transferable t) {} }); }
/** * the command has been executed, so extract extract the needed information from the application * context. */ public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); ITextSelection content = (ITextSelection) window .getActivePage() .getActiveEditor() .getEditorSite() .getSelectionProvider() .getSelection(); String texto = content.getText(); Toolkit toolkit = Toolkit.getDefaultToolkit(); Clipboard clipboard = toolkit.getSystemClipboard(); String sqlFormatado = formatSQL(texto); StringSelection textoFormatado = new StringSelection(sqlFormatado); clipboard.setContents(textoFormatado, null); if (isBlank(texto)) { MessageDialog.openInformation(window.getShell(), "SQLCopy", "Você não selecionou nada!"); } else { if (isConvertToJava( texto)) { // Realizar a substituição do texto selecionado apenas quando estiver // convertendo um SQL para Java. IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); ITextEditor editor = (ITextEditor) part; IDocumentProvider prov = editor.getDocumentProvider(); IDocument doc = prov.getDocument(editor.getEditorInput()); ISelection sel = editor.getSelectionProvider().getSelection(); if (sel instanceof TextSelection) { final TextSelection textSel = (TextSelection) sel; try { // IRegion region = doc.getLineInformationOfOffset(textSel.getOffset()); // doc.replace( textSel.getOffset(), textSel.getLength(), // identingCode(region.getLength(), sqlFormatado)); doc.replace(textSel.getOffset(), textSel.getLength(), sqlFormatado); } catch (BadLocationException e) { e.printStackTrace(); } } } // MessageDialog.openInformation( // window.getShell(), // "SQLCopy", // sqlFormatado.toString()); CustomMessageDialog dialog = new CustomMessageDialog(window.getShell(), sqlFormatado.toString()); dialog.open(); } return null; }
public static void copyToClipboard(String contents[]) { Toolkit kit = Toolkit.getDefaultToolkit(); final Clipboard clipboard = kit.getSystemClipboard(); String allContent = ""; for (int i = 0; i < contents.length; i++) { String content = contents[i]; allContent += content; } StringSelection stsel = new StringSelection(allContent); clipboard.setContents(stsel, stsel); }
@Override public void mouseReleased(MouseEvent e) { String selectedText = jTextArea.getSelectedText(); StringSelection stringSelection = new StringSelection(selectedText); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(stringSelection, null); if (e.isPopupTrigger()) { doPop(e); } }
@Override public void actionPerformed(ActionEvent ae) { if (ae.getSource().equals(openItem)) { File f = null; if (null == (f = SpeedyGrader.getInstance().getFilesLoc())) { f = new File(System.getProperty("user.home")); } JFileChooser chooser = new JFileChooser(f); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int ret = chooser.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { newFolderSelected(chooser.getSelectedFile()); } } else if (ae.getSource().equals(inputItem)) { new InputDialog(); } else if (ae.getSource().equals(saveItem)) { for (EditorPanel ep : editorPanels) { ep.save(); } SpeedyGrader.getInstance().startComplieAndRun(); } else if (ae.getSource().equals(refreshItem)) { newFolderSelected(null); } else if (ae.getSource().equals(githubItem)) { String url = "https://github.com/MitchellSlavik/SpeedyGrader"; Desktop d = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; if (d != null && d.isSupported(Action.BROWSE)) { try { d.browse(URI.create(url)); } catch (IOException e) { e.printStackTrace(); } } else { JOptionPane.showMessageDialog( this, "We were unable to open a web browser. The url has been copied to your clipboard.", "Unable to preform operation", JOptionPane.ERROR_MESSAGE); StringSelection selection = new StringSelection(url); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); } } else if (ae.getSource().equals(aboutItem)) { new AboutDialog(); } else if (ae.getSource().equals(installItem)) { new InstallDialog(); } else if (ae.getSource().equals(upgradeItem)) { new AutoUpdater(); } else if (ae.getSource().equals(editorSplitToggle)) { splitEditorPane.setOrientation( editorSplitToggle.isSelected() ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT); this.validate(); this.repaint(); } }
/** * クエリ実行結果の転送処理。<br> * クエリ実行結果はクリップボードに転送する。<br> */ @Override public void transfer() { if (!getEvidenceMode()) { return; } Toolkit toolkit = Toolkit.getDefaultToolkit(); Clipboard clip = toolkit.getSystemClipboard(); StringSelection stringSelection = new StringSelection(getTransferData()); clip.setContents(stringSelection, stringSelection); }
private ClipboardRespons write(String value) { ClipboardRespons res = new ClipboardRespons(); try { clipboard.setContents(new StringSelection(value), null); res.setValid(true); } catch (Exception e) { res.setValid(false); } return res; }
protected void selected(CharPos start, CharPos end) { StringBuilder buf = new StringBuilder(); synchronized (msgs) { boolean sel = false; for (Message msg : msgs) { if (!(msg.text() instanceof RichText)) continue; RichText rt = (RichText) msg.text(); RichText.Part part = null; if (sel) { part = rt.parts; } else if (msg == start.msg) { sel = true; for (part = rt.parts; part != null; part = part.next) { if (part == start.part) break; } } if (sel) { for (; part != null; part = part.next) { if (!(part instanceof RichText.TextPart)) continue; RichText.TextPart tp = (RichText.TextPart) part; CharacterIterator iter = tp.ti(); int sch; if (tp == start.part) sch = tp.start + start.ch.getInsertionIndex(); else sch = tp.start; int ech; if (tp == end.part) ech = tp.start + end.ch.getInsertionIndex(); else ech = tp.end; for (int i = sch; i < ech; i++) buf.append(iter.setIndex(i)); if (part == end.part) { sel = false; break; } buf.append(' '); } if (sel) buf.append('\n'); } if (msg == end.msg) break; } } Clipboard cl; if ((cl = java.awt.Toolkit.getDefaultToolkit().getSystemSelection()) == null) cl = java.awt.Toolkit.getDefaultToolkit().getSystemClipboard(); try { final CharPos ownsel = selstart; cl.setContents( new StringSelection(buf.toString()), new ClipboardOwner() { public void lostOwnership(Clipboard cl, Transferable tr) { if (selstart == ownsel) selstart = selend = null; } }); } catch (IllegalStateException e) { } }
/** * Copies the selected text to the clipboard. * * @return true if text was copied */ final boolean copy() { final String txt = text.copy(); if (txt.isEmpty()) { text.noMark(); return false; } // copy selection to clipboard final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); clip.setContents(new StringSelection(txt), null); return true; }
public SFFileTreePopup() { JMenuItem menuItem = new JMenuItem("Copy Path"); menuItem.addActionListener( (ActionEvent arg0) -> { if (file != null && file.exists() && file.isFile()) { Clipboard clipboard = getToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(file.getAbsolutePath()), null); } }); this.add(menuItem); }
private void copyTermAtPoint(Point p) { final int column = this.phenotypesTable.getTableHeader().columnAtPoint(p); final int row = this.phenotypesTable.rowAtPoint(p); if (!this.tableFormat.getColumnClass(column).equals(OBOObject.class)) return; final Phenotype phenotype = this.getController().getPhenotypesForCurrentStateSelection().get(row); final OBOClass term = (OBOClass) (this.tableFormat.getColumnValue(phenotype, column)); final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); final TermSelection termSelection = new TermSelection(term); log().debug("Putting term on clipboard: " + term); clipboard.setContents(termSelection, null); }