@Override public void exportDone(SComponent source, Transferable transferable, int action) { if(action == MOVE) { if(transferable instanceof TextTransferable) { ((TextTransferable)transferable).removeText(); } } super.exportDone(source, transferable, action); }
/** * Exports the data in componet to the given Clipboard * @param component * @param clipboard * @param action * @throws IllegalStateException */ public void exportToClipboard(SComponent component, Clipboard clipboard, int action) throws IllegalStateException { Transferable t = createTransferable(component); if( (action != COPY && action != MOVE) || (getSourceActions(component)&action) == 0 ) { exportDone(component, null, NONE); return; } if(t != null) { try { clipboard.setContents(t, null); exportDone(component, t, action); } catch(IllegalStateException e) { exportDone(component, t, NONE); throw e; } } }
/** * Exports component's data for a drag-operation - it is required for this method to call * the setTransferSupport Method in the SDragAndDropManager to set a TransferSupport, to be used for this * drag-operation * @param component * @param event * @param action */ public void exportAsDrag(SComponent component, SMouseEvent event, int action) { // (Swing) InputEvent -> (wingS) SMouseEvent int sourceActions = this.getSourceActions(component); // invalid action or requested action != actions allowed by source if((action != MOVE && action != COPY && action != LINK) || (sourceActions & action) == 0) { action = NONE; } if(action != NONE) { Transferable transferable = createTransferable(component, event); component.getSession().getSDragAndDropManager().setTransferSupport(new TransferSupport(component, transferable)); } else { exportDone(component, null, NONE); } }
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(); }