@Override
  public boolean canImport(TransferSupport support) {
    if (!support.isDataFlavorSupported(DominoTransferable.getFlavor())) return false;
    if (!(support.getComponent() instanceof DominoDisplay)) return false;

    return true;
  }
Ejemplo n.º 2
0
  /* (non-Javadoc)
   * @see javax.swing.TransferHandler#importData(javax.swing.TransferHandler.TransferSupport)
   */
  @Override
  public boolean importData(TransferSupport support) {
    try {
      if (support.getComponent() instanceof JTree) {
        JTree tree = (JTree) support.getComponent();
        Point dropPoint = support.getDropLocation().getDropPoint();
        TreePath path = tree.getPathForLocation(dropPoint.x, dropPoint.y);
        Object node = path.getLastPathComponent();
        if (support.isDataFlavorSupported(ProcessVar.PvDataFlavors[0])) {
          ProcessVar tVar = (ProcessVar) ((PvTreeNode) node).getUserObject();
          ProcessVar chldPv =
              (ProcessVar) support.getTransferable().getTransferData(ProcessVar.PvDataFlavors[0]);

          Object chldKey = chldPv.getKeyValue();
          tVar.put(chldKey, chldPv, PvChangeEvent.PV_ADDED);
          DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
          model.nodeStructureChanged((TreeNode) model.getRoot());
          return true;
        }
      }
    } catch (UnsupportedFlavorException e) {
      ProcessVar.log.error(this.toString() + ":" + e.getMessage());
    } catch (IOException e) {
      ProcessVar.log.error(this.toString() + ":" + e.getMessage());
    }
    // anything else is handled by superclass
    return super.importData(support);
  }
Ejemplo n.º 3
0
 /**
  * Checks whether a callback has been registered for any of the data flavors supported by this
  * drop event.
  *
  * @param support The TransferSupport describing the drop event.
  * @return Whether or not a callback for any of the support's data flavors has been registered.
  */
 @Override
 public boolean canImport(final TransferSupport support) {
   for (DataFlavor flavor : _callbackMapping.keySet()) {
     final LinkedList<DropHandlerCallback> callbackLinkedList = _callbackMapping.get(flavor);
     if (callbackLinkedList.size() > 0 && support.isDataFlavorSupported(flavor)) return true;
   }
   return false;
 }
    public boolean canImport(TransferSupport support) {
      if (!inDrag || !support.isDataFlavorSupported(DATA_FLAVOUR)) {
        return false;
      }

      JList.DropLocation dl = (JList.DropLocation) support.getDropLocation();
      if (dl.getIndex() == -1) {
        return false;
      } else {
        return true;
      }
    }
 private boolean isDataFlavorValid(TransferSupport support) {
   // only support string flavor, or a file list (if a file has been dragged into the tree)
   return support.isDataFlavorSupported(DataFlavor.stringFlavor)
       || support.isDataFlavorSupported(DataFlavor.javaFileListFlavor);
 }
Ejemplo n.º 6
0
 /* (non-Javadoc)
  * @see javax.swing.TransferHandler#canImport(javax.swing.TransferHandler.TransferSupport)
  */
 @Override
 public boolean canImport(TransferSupport support) {
   return support != null && support.isDataFlavorSupported(ProcessVar.PvDataFlavors[0]);
 }