private void pasteTermAtPoint(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 Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if (Arrays.asList(clipboard.getAvailableDataFlavors()).contains(TermSelection.termFlavor)) { try { clipboard.getData(DataFlavor.stringFlavor); log().debug("Made it past string flavor"); final Object data = clipboard.getData(TermSelection.termFlavor); // final IdentifiedObject obj = // this.getController().getOntologyController().getOBOSession().getObject(data.toString()); if (data instanceof TermTransferObject) { final OBOClass term = ((TermTransferObject) data) .getTerm(this.getController().getOntologyController().getOBOSession()); this.tableFormat.setColumnValue(phenotype, term, column); } else { log().error("The object on the clipboard was not an OBOClass"); } } catch (UnsupportedFlavorException e) { log().error("The clipboard didn't have the term flavor, although it said it did", e); } catch (IOException e) { log().error("Couldn't read from the clipboard", e); } } }
protected String getClipboardContent() throws IOException, UnsupportedFlavorException { try { return (String) myClipboard.getData(DataFlavor.stringFlavor); } catch (Exception e) { LOG.info(e); return null; } }
public void convertVssFileList(String[] args) throws Exception { String baseDir = "$/"; String inputStr = ""; Reader readerFileList = null; if (args.length > 1) { baseDir = args[1]; if (args.length > 2) { readerFileList = new FileReader(args[2]); } else { Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); inputStr = (String) clip.getData(DataFlavor.stringFlavor); } } else { Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); inputStr = (String) clip.getData(DataFlavor.stringFlavor); } System.out.println(VssUtil.convertFileList(baseDir, inputStr, readerFileList)); }
private void store() throws UnsupportedFlavorException, IOException { if (!usingCropper) { Clipboard clipBoard = Toolkit.getDefaultToolkit().getSystemClipboard(); BufferedImage image = (BufferedImage) clipBoard.getData(DataFlavor.imageFlavor); File file = new File(destinationFolder + "\\image_" + decFormat.format(count) + ".jpg"); ImageIO.write(image, "jpg", file); count++; } }
private ClipboardRespons read() { ClipboardRespons res = new ClipboardRespons(); try { String bRet = (String) clipboard.getData(DataFlavor.stringFlavor); bRet = bRet.replaceAll("\n", "\r\n"); res.setContent(bRet); res.setValid(true); } catch (Exception e) { res.setValid(false); } return res; }
private void listen() { String str = null; try { str = (String) clipboard.getData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException | IOException | IllegalStateException e) { // System.out.println("[EXCEPTION]" + e.getMessage()); str = last_str; } if (!Word.validateWord(str)) return; str = Word.regularWord(str); if (last_str.equals(str)) return; last_str = str; System.out.println(str); if (wordProcessor != null) wordProcessor.doClipboardChanged(str); }