private boolean dragStart(SComponent source, STransferHandler sourceTH, SComponent target, int action, SMouseEvent mouseEvent) { SCursor cursor = getSession().getCursor(); // clean transfersupport (in case a old dragging was aborted for any reason and didn't clean up) this.transferSupport = null; // Look for a CustomDragHandler if (sourceTH instanceof CustomDragHandler) { if(((CustomDragHandler) sourceTH).dragStart(source, target, action, mouseEvent)) { return true; } } // This call must and usually will set the TransferSupport sourceTH.exportAsDrag(source, mouseEvent, action); if (this.transferSupport == null) { // abort drag operation return false; } // Start drag operation // Get the Visual Representation Label and use it SLabel label = sourceTH.getVisualRepresentationLabel(getTransferSupport().getTransferable()); if (label != null) { cursor.setLabel(label); } // Show it cursor.setShowCursor(true); return true; }
private void drop(SComponent source, STransferHandler sourceTH, SComponent target, STransferHandler targetTH, int action, SMouseEvent mouseEvent) { // check for the custom drop-handler if (targetTH instanceof CustomDropHandler) { if (((CustomDropHandler) targetTH).drop(source, target, action, mouseEvent)) { return; } } transferSupport.setIsDrop(target, source, mouseEvent, action); if ((transferSupport.getSourceDropActions() & action) == 0) { // if dropping isn't allowed with the requested action resetDndStatus(); return; } // Import the data and call exportDone on the source-TH if (targetTH != null && targetTH.canImport(transferSupport)) { targetTH.importData(transferSupport); sourceTH.exportDone(source, transferSupport.getTransferable(), action); } resetDndStatus(); }
/** * Imports the data specified in TransferSupport into the component specified in TransferSupport * @param support * @return */ public boolean importData(STransferHandler.TransferSupport support) { return importData(support.getComponent(), support.getTransferable()); }