/* (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); }
/* (non-Javadoc) * @see javax.swing.TransferHandler#exportDone(javax.swing.JComponent, java.awt.datatransfer.Transferable, int) */ @Override protected void exportDone(JComponent c, Transferable t, int action) { try { if (action == MOVE) { ProcessVar pv = (ProcessVar) t.getTransferData(ProcessVar.PvDataFlavors[0]); pv.firePvChanged( new PvChangeEvent(pv, pv.getKeyAttribute(), pv, PvChangeEvent.PV_ELIMINATED)); } } catch (UnsupportedFlavorException e) { ProcessVar.log.error(this.toString() + ":" + e.getMessage()); } catch (IOException e) { ProcessVar.log.error(this.toString() + ":" + e.getMessage()); } }