/** * Sets a drop action programmatically - it must be supported by the source component and a valid action * @param dropAction */ public void setDropAction(int dropAction) { if(!this.isDrop) throw new IllegalStateException("isDrop was false when setDropAction was called"); int action = dropAction & getSourceDropActions(); if(action != COPY && action != MOVE && action != LINK) { throw new IllegalArgumentException("unsupported drop action " + dropAction); } this.dropAction = dropAction; }
if ((transferSupport.getSourceDropActions() & action) == 0) {
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(); }