/* * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) */ @Override public void dragSetData(DragSourceEvent event) { IDocument doc = fViewer.getDocument(); try { event.data = doc.get(fSelectionPosition.offset, fSelectionPosition.length); } catch (BadLocationException e) { event.detail = DND.DROP_NONE; event.doit = false; } }
/** All selection must be named model objects. */ @Override public void dragStart(DragSourceEvent event) { // Workaround for 1GEUS9V DragSource dragSource = (DragSource) event.widget; Control control = dragSource.getControl(); if (control != control.getDisplay().getFocusControl()) { event.doit = false; return; } event.doit = canDrag(); }
/** Returns the data to be transferred in a drag and drop operation. */ @Override public void dragSetData(DragSourceEvent event) { if (event.doit == false) return; if (ModelDataTransfer.getInstance().isSupportedType(event.dataType)) { event.data = getSelectedModelObjects(); fDragData = event.data; return; } if (TextTransfer.getInstance().isSupportedType(event.dataType)) { event.data = createTextualRepresentation((IStructuredSelection) fSelectionProvider.getSelection()); fDragData = null; return; } }
/* * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData */ @Override public void dragSetData(DragSourceEvent event) { if (EditorInputTransfer.getInstance().isSupportedType(event.dataType) && fEditorInputDatas.size() > 0) { event.data = fEditorInputDatas.toArray(new EditorInputData[fEditorInputDatas.size()]); } }
public void dragSetData(DragSourceEvent event) { IStructuredSelection selection = (IStructuredSelection) provider.getSelection(); Iterator<?> iterator = selection.iterator(); if (PluginTransfer.getInstance().isSupportedType(event.dataType)) { try { List<Reachable> objectURIs = new ArrayList<Reachable>(); while (iterator.hasNext()) { Object next = iterator.next(); ReachableObject fromObject; try { fromObject = manager.getHandlerFromObject(next).getFromObject(next); if (fromObject.getReachable() != null) { objectURIs.add(fromObject.getReachable()); } } catch (IReachableHandlerException e) { e.printStackTrace(); } } ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream buffered; buffered = new ObjectOutputStream(bos); buffered.writeObject(objectURIs.toArray()); byte[] data = bos.toByteArray(); bos.close(); buffered.close(); event.data = new PluginTransferData(PLUGIN_TRANSFER_ACTION_ID, data); } catch (IOException e) { e.printStackTrace(); } } }
/* * @see org.eclipse.swt.dnd.DragSourceListener#dragStart */ @Override public void dragStart(DragSourceEvent event) { fEditorInputDatas = new ArrayList<EditorInputData>(); ISelection selection = fProvider.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext(); ) { Object element = iter.next(); IEditorInput editorInput = EditorUtility.getEditorInput(element); if (editorInput != null && editorInput.getPersistable() != null) { try { String editorId = EditorUtility.getEditorID(editorInput); // see org.eclipse.ui.internal.ide.EditorAreaDropAdapter.openNonExternalEditor(..): IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc = editorReg.findEditor(editorId); if (editorDesc != null && !editorDesc.isOpenExternal()) { fEditorInputDatas.add( EditorInputTransfer.createEditorInputData(editorId, editorInput)); } } catch (PartInitException e) { JavaPlugin.log(e); } } } } event.doit = fEditorInputDatas.size() > 0; }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") public void dragSetData(DragSourceEvent event) { List<ProcessVariable> pvs = new ArrayList<ProcessVariable>(); List<AbstractEditPart> controllers = getViewer().getSelectedEditParts(); for (AbstractEditPart c : controllers) { // if (c instanceof ProcessVariable) { // pvs.add((ProcessVariable) c); // } } if (!pvs.isEmpty()) { event.doit = true; event.data = pvs; } else { event.doit = false; } }
/* * (non-Javadoc) * * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, * org.eclipse.jface.viewers.IStructuredSelection) */ public boolean setDragData(DragSourceEvent anEvent, IStructuredSelection aSelection) { IResource[] resources = getSelectedResources(aSelection); if (resources.length > 0) { if (ResourceTransfer.getInstance().isSupportedType(anEvent.dataType)) { anEvent.data = resources; if (Policy.DEBUG_DND) { System.out.println( "ResourceDragAdapterAssistant.dragSetData set ResourceTransfer"); //$NON-NLS-1$ } return true; } if (FileTransfer.getInstance().isSupportedType(anEvent.dataType)) { // Get the path of each file and set as the drag data final int length = resources.length; int actualLength = 0; String[] fileNames = new String[length]; for (int i = 0; i < length; i++) { IPath location = resources[i].getLocation(); // location may be null. See bug 29491. if (location != null) { fileNames[actualLength++] = location.toOSString(); } } if (actualLength > 0) { // was one or more of the locations null? if (actualLength < length) { String[] tempFileNames = fileNames; fileNames = new String[actualLength]; for (int i = 0; i < actualLength; i++) fileNames[i] = tempFileNames[i]; } anEvent.data = fileNames; if (Policy.DEBUG_DND) System.out.println( "ResourceDragAdapterAssistant.dragSetData set FileTransfer"); //$NON-NLS-1$ return true; } } } return false; }
/* * @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) */ @Override public void dragSetData(DragSourceEvent event) { if (TextTransfer.getInstance().isSupportedType(event.dataType)) { List<XViewerColumn> selCols = getVisibleTableSelection(); Collection<String> ids = new ArrayList<String>(selCols.size()); for (XViewerColumn xCol : selCols) { ids.add(xCol.getId()); } event.data = CollectionsUtil.toString(ids, null, ", ", null); } }
/* * (non-Javadoc) * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent) */ public void dragStart(DragSourceEvent event) { TableItem[] selection = fViewer.getTable().getSelection(); if (selection.length > 0) { for (TableItem item : selection) { Object data = item.getData(); if (data instanceof IWaypoint) fWayPoints.add((IWaypoint) data); } } else { event.doit = false; } }
public void dragStart(DragSourceEvent event) { TreeItem[] items = tree.getSelection(); if (items.length == 0) { event.doit = false; } else { boolean isHasChildren = false; for (TreeItem treeItem : items) { if (treeItem.getItemCount() > 0) { isHasChildren = true; break; } } if (isHasChildren) { event.doit = false; } else { LocalDraggedData draggedData = new LocalDraggedData(); for (TreeItem treeItem : items) { draggedData.add(treeItem.getData()); } LocalDataTransfer.getInstance().setLocalDraggedData(draggedData); } } }
/* * @see org.eclipse.swt.dnd.DragSourceAdapter#dragStart(org.eclipse.swt.dnd.DragSourceEvent) */ @Override public void dragStart(DragSourceEvent event) { Point linkSize = link.computeSize(SWT.DEFAULT, SWT.DEFAULT); GC gc = new GC(link); /* Erst altes Image disposen falls nötig */ dispose(); /* Neues Bild erzeugen und als DragSourceEffect festlegen */ image = new Image(link.getDisplay(), linkSize.x, linkSize.y); gc.copyArea(image, 0, 0); // Kopiert das UI des Widgets in das Bild gc.dispose(); event.image = image; }
/* (non-Javadoc) * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) */ public void dragSetData(DragSourceEvent event) { if (!getTransfer().isSupportedType(event.dataType)) return; List meemNodes = getMeemNodes(); NamedMeem[] namedMeems = new NamedMeem[meemNodes.size()]; for (int i = 0; i < namedMeems.length; i++) { MeemNode meemNode = (MeemNode) meemNodes.get(i); ConfigurationHandlerProxy config = meemNode.getProxy().getConfigurationHandler(); String identifier = meemNode.getText(); if (identifier.length() == 0) { Object identifierValue = config.getValue(ConfigurationHandlerProxy.ID_MEEM_IDENTIFIER); if (identifierValue instanceof String) { identifier = (String) identifierValue; } } namedMeems[i] = new NamedMeem(identifier, meemNode.getMeemPath()); } event.data = namedMeems; }
/* * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent) */ @Override public void dragStart(DragSourceEvent event) { if (!fIsEnabled) { event.doit = false; return; } // convert screen coordinates to widget offest int offset = getOffsetAtLocation(event.x, event.y, false); // convert further to a document offset offset = getDocumentOffset(offset); Point selection = fViewer.getSelectedRange(); if (selection != null && offset >= selection.x && offset < selection.x + selection.y) { fSelectionPosition = new Position(selection.x, selection.y); if (fViewer instanceof ITextViewerExtension) { ((ITextViewerExtension) fViewer).getRewriteTarget().beginCompoundChange(); } IDocument doc = fViewer.getDocument(); try { // add the drag selection position // the position is used to delete the selection on a DROP_MOVE // and it can be used by the drop target to determine if it should // allow the drop (e.g. if drop location overlaps selection) doc.addPositionCategory(DRAG_SELECTION_CATEGORY); fPositionUpdater = new DefaultPositionUpdater(DRAG_SELECTION_CATEGORY); doc.addPositionUpdater(fPositionUpdater); doc.addPosition(DRAG_SELECTION_CATEGORY, fSelectionPosition); } catch (BadLocationException e) { // should not happen } catch (BadPositionCategoryException e) { // cannot happen } event.doit = true; // this has no effect? event.detail = DND.DROP_COPY; if (isDocumentEditable()) { event.detail |= DND.DROP_MOVE; } } else { event.doit = false; event.detail = DND.DROP_NONE; } }
@Override public void dragStart(DragSourceEvent event) { if (visibleColTable.getViewer().getSelection().isEmpty()) { event.doit = false; } }
/* * (non-Javadoc) * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent) */ public void dragSetData(DragSourceEvent event) { if (fWayPoints.size() > 0) event.data = fWayPoints.toArray(new IWaypoint[0]); }
/** This is called to transfer the data. */ public void dragSetData(DragSourceEvent event) { if (LocalTransfer.getInstance().isSupportedType(event.dataType)) { event.data = selection; } }
public void dragSetData(DragSourceEvent event) { List resources = convertSelection(); event.data = resources.toArray(new IResource[resources.size()]); }
public void dragStart(DragSourceEvent event) { event.doit = convertSelection().size() > 0; }