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);
     }
   }
 }
Exemple #2
0
 public boolean canPaste() {
   Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
   for (DataFlavor df : clipboard.getAvailableDataFlavors()) {
     if (df.equals(PrimitiveIdTransferable.PRIMITIVE_ID_LIST_FLAVOR)) return true;
   }
   // FIXME: check whether there are selected objects in the JOSM copy/paste buffer
   return false;
 }