コード例 #1
0
ファイル: OWLVizView.java プロジェクト: protegeproject/owlviz
  public void drop(DropTargetDropEvent dtde) {
    logger.info("Drop: " + dtde);
    if (dtde.isDataFlavorSupported(OWLObjectDataFlavor.OWL_OBJECT_DATA_FLAVOR)) {
      try {
        List<OWLObject> objects =
            (List<OWLObject>)
                dtde.getTransferable().getTransferData(OWLObjectDataFlavor.OWL_OBJECT_DATA_FLAVOR);
        List<OWLClass> clses = new ArrayList<OWLClass>();
        for (OWLObject obj : objects) {
          if (obj instanceof OWLClass) {
            clses.add((OWLClass) obj);
          }
        }

        if (!clses.isEmpty()) {
          getAssertedGraphComponent().getVisualisedObjectManager().showObjects(clses.toArray());
          dtde.dropComplete(true);
        }
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
コード例 #2
0
  public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
      try {
        content =
            (java.util.List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        repaint();
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      dtde.dropComplete(true);

      boolean listsAreEqual = true;

      for (int i = 0; i < content.size(); i++) {
        if (!FileListTransferable.files[i].getName().equals(content.get(i).getName())) {
          listsAreEqual = false;
        }
      }

      if (listsAreEqual) {
        System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL);
        System.exit(0);
      }
    }
    dtde.rejectDrop();
    System.err.println(InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED);
    System.exit(1);
  }
コード例 #3
0
 private void processDrop(DropData dropData, DropTargetDropEvent dropTargetDropEvent) {
   putEntryAtPoint(dropData.whatToDrop, dropData.whereInTable);
   _widget.addEntry(dropData.whatToDrop);
   _underlyingTable.setRowSelectionInterval(dropData.whereInTable.x, dropData.whereInTable.x);
   _underlyingTable.setColumnSelectionInterval(dropData.whereInTable.y, dropData.whereInTable.y);
   dropTargetDropEvent.acceptDrop(dropTargetDropEvent.getDropAction());
   dropTargetDropEvent.dropComplete(true);
 }
コード例 #4
0
ファイル: JDropListener.java プロジェクト: lmop/jbidwatcher
  private void acceptDrop(DropTargetDropEvent dtde) {
    int dragaction = dtde.getDropAction();

    if (dragaction != 0) {
      dtde.acceptDrop(dragaction);
    } else {
      dtde.acceptDrop(ALL_ACTIONS);
    }
  }
コード例 #5
0
    public void drop(DropTargetDropEvent event) {
      if (!isDropAcceptable(event)) {
        event.rejectDrop();
        return;
      }

      event.acceptDrop(DnDConstants.ACTION_COPY);

      Transferable transferable = event.getTransferable();

      MessageCollection messages = new MessageCollection();
      try {
        List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);

        for (File file : files) {
          try {
            ResourceLocator locator = new ResourceLocator(file.getAbsolutePath());
            IGV.getInstance().load(locator, panel);
          } catch (DataLoadException de) {
            messages.append(de.getMessage());
          }
        }
        String obj = transferable.getTransferData(DataFlavor.stringFlavor).toString();
        if (HttpUtils.isRemoteURL(obj)) {
          IGV.getInstance().load(new ResourceLocator(obj), panel);
        }
        if (messages != null && !messages.isEmpty()) {
          log.error(messages.getFormattedMessage());
          MessageUtils.showMessage(messages.getFormattedMessage());
        }
      } catch (Exception e) {
        String obj = null;
        try {
          obj = transferable.getTransferData(DataFlavor.stringFlavor).toString();
          if (HttpUtils.isRemoteURL(obj)) {
            IGV.getInstance().load(new ResourceLocator(obj), panel);
          }
        } catch (Exception e1) {
          log.error(e1);
          if (messages != null && !messages.isEmpty()) {
            MessageUtils.showMessage(messages.getFormattedMessage());
          }
        }
      }
      IGV.getMainFrame().repaint();
      event.dropComplete(true);
    }
コード例 #6
0
 public boolean isDropAcceptable(DropTargetDropEvent event) { // usually, you
   // check the
   // available
   // data flavors
   // here
   // in this program, we accept all flavors
   return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0;
 }
コード例 #7
0
 protected Point getTableLocationForEvent(DropTargetDropEvent dropTargetDropEvent) {
   Point dropTargetPoint = dropTargetDropEvent.getLocation();
   int column = _underlyingTable.columnAtPoint(dropTargetPoint);
   int row = _underlyingTable.rowAtPoint(dropTargetPoint);
   if ((row < 0) || (column < 0)) {
     return null;
   }
   return new Point(row, column);
 }
コード例 #8
0
 public void drop(DropTargetDropEvent dropTargetDropEvent) {
   DropData dropData = convertEventIntoDropData(dropTargetDropEvent);
   if (null == dropData) {
     dropTargetDropEvent.rejectDrop();
   } else {
     int dropAction = dropTargetDropEvent.getDropAction();
     if (DnDConstants.ACTION_MOVE == dropAction) {
       _widget.removeEntry(dropData.whatToDrop);
       processDrop(dropData, dropTargetDropEvent);
     }
     if (DnDConstants.ACTION_COPY == dropAction) {
       dropData.whatToDrop =
           RecursiveCopy.recursivelyCopyInstance(
               dropData.whatToDrop, Constants.RECURSIVE_COPY_DEPTH_FOR_DND);
       processDrop(dropData, dropTargetDropEvent);
     }
   }
   _widget.setIsCurrentlyDragging(false);
   return;
 }
コード例 #9
0
ファイル: MainPanel.java プロジェクト: mhcrnl/java-swing-tips
 @Override
 public void drop(DropTargetDropEvent dtde) {
   try {
     if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
       dtde.acceptDrop(DnDConstants.ACTION_COPY);
       Transferable t = dtde.getTransferable();
       List list = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
       for (Object o : list) {
         if (o instanceof File) {
           File f = (File) o;
           System.out.println(f.getAbsolutePath());
         }
       }
       dtde.dropComplete(true);
       return;
     }
   } catch (UnsupportedFlavorException | IOException ex) {
     ex.printStackTrace();
   }
   dtde.rejectDrop();
 }
コード例 #10
0
    public void drop(DropTargetDropEvent e) {
      if (dragSource != null) {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge =
            graph.insertEdge(
                null,
                null,
                null,
                dragSource.cell,
                JTableRenderer.this.cell,
                "sourceRow=" + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
      } else {
        e.rejectDrop();
      }
    }
コード例 #11
0
 private DropData convertEventIntoDropData(DropTargetDropEvent dropTargetDropEvent) {
   Transferable transferable = dropTargetDropEvent.getTransferable();
   Point tableLocation = getTableLocationForEvent(dropTargetDropEvent);
   if (null != _underlyingTable.getValueAt(tableLocation.x, tableLocation.y)) {
     return null;
   }
   Instance entry;
   try {
     entry = (Instance) transferable.getTransferData(_flavor);
   } catch (Exception e) {
     return null;
   }
   if ((null == entry) || !entry.hasType(_entryCls)) {
     return null;
   }
   return new DropData(tableLocation, entry);
 }
コード例 #12
0
ファイル: JDropListener.java プロジェクト: lmop/jbidwatcher
  public void drop(DropTargetDropEvent dtde) {
    Transferable t = dtde.getTransferable();
    StringBuffer dropData = null;
    DataFlavor dtf;

    JConfig.log().logVerboseDebug("Dropping!");

    if (t.getTransferDataFlavors().length == 0) {
      Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
      Transferable t2 = sysClip.getContents(null);
      DataFlavor[] dfa2;
      int j;

      JConfig.log().logDebug("Dropped 0 data flavors, trying clipboard.");
      dfa2 = null;

      if (t2 != null) {
        JConfig.log().logVerboseDebug("t2 is not null: " + t2);
        dfa2 = t2.getTransferDataFlavors();
        JConfig.log().logVerboseDebug("Back from getTransferDataFlavors()!");
      } else {
        JConfig.log().logVerboseDebug("t2 is null!");
      }

      if (JConfig.queryConfiguration("debug.uber", "false").equals("true")) {
        if (dfa2 != null) {
          if (dfa2.length == 0) {
            JConfig.log().logVerboseDebug("Length is still zero!");
          }
          for (j = 0; j < dfa2.length; j++) {
            JConfig.log()
                .logVerboseDebug("Flavah " + j + " == " + dfa2[j].getHumanPresentableName());
            JConfig.log().logVerboseDebug("Flavah/mime " + j + " == " + dfa2[j].getMimeType());
          }
        } else {
          JConfig.log().logVerboseDebug("Flavahs supported: none!\n");
        }
      }
    }

    if (JConfig.queryConfiguration("debug.uber", "false").equals("true") && JConfig.debugging)
      dumpFlavorsOld(t);

    dtf = testAllFlavors(t);
    if (dtf != null) {
      JConfig.log().logVerboseDebug("Accepting!");
      acceptDrop(dtde);

      dropData = getTransferData(t);
      dtde.dropComplete(true);
      dtde.getDropTargetContext().dropComplete(true);
      if (dropData != null) {
        if (handler != null) {
          handler.receiveDropString(dropData);
        }
      }
    } else {
      JConfig.log().logVerboseDebug("Rejecting!");
      dtde.rejectDrop();
      handler.receiveDropString(dropData);
    }
  }