/** * Returns the Drop-Actions supported by the source-component * @return */ public int getSourceDropActions() { if(!this.isDrop) throw new IllegalStateException("getSourceDropActions called when isDrop = false"); return this.source.getTransferHandler().getSourceActions(this.source); }
protected static String getAddDragSourceString(SDragAndDropManager manager, SComponent dragSource) { String dragCode = manager.getCustomDragCode(dragSource); if (dragCode == null) { if (dragSource instanceof STextComponent) dragCode = "text"; else if (dragSource instanceof SList) dragCode = "list"; else if (dragSource instanceof STree) dragCode = "tree"; else if (dragSource instanceof STable) dragCode = "table"; else dragCode = "default"; } return "wingS.global.onHeadersLoaded(function() { wingS.sdnd.addDragSource('" + dragSource.getName() + "', " + dragSource.getTransferHandler().getSourceActions(dragSource) + ", '" + dragCode + "'); });"; }
/** * 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); } }