public void track(DnDInfo info) { DropAgent curAgent = dropAgent; // Re-use the same dropAgent until it returns 'false' from track if (dropAgent != null) dropAgent = dropAgent.track(dragElement, info) ? dropAgent : null; // If we don't have a drop agent currently try to get one if (dropAgent == null) { if (curAgent != null) curAgent.dragLeave(dragElement, info); dropAgent = dndManager.getDropAgent(dragElement, info); if (dropAgent != null) dropAgent.dragEnter(dragElement, info); else { dndManager.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_NO)); } } }
@Override public void dragEnter(MUIElement dragElement, DnDInfo info) { super.dragEnter(dragElement, info); clientBounds = dropCTF.getClientArea(); clientBounds = Display.getCurrent().map(dropCTF, null, clientBounds); ctfBounds = dropCTF.getBounds(); ctfBounds = Display.getCurrent().map(dropCTF.getParent(), null, ctfBounds); // Find the root of the dropStack's sash structure outerRelTo = dropStack.getParent(); if (outerRelTo instanceof MPartSashContainer) { while (outerRelTo != null && !(outerRelTo.getWidget() instanceof Composite)) outerRelTo = outerRelTo.getParent(); } // If the stack is in an MArea or a Perspective then allow 'outer' docking if (outerRelTo instanceof MArea) { // If the relTo is in the MArea then use its 'curSharedRef' outerRelTo = outerRelTo.getCurSharedRef(); } else if (outerRelTo instanceof MPartSashContainer) { MUIElement relToParent = outerRelTo.getParent(); if (relToParent instanceof MArea) { outerRelTo = relToParent.getCurSharedRef(); } else if (relToParent instanceof MPerspective) { outerRelTo = relToParent.getParent(); // PerspectiveStack } else { outerRelTo = null; } } else { outerRelTo = null; } if (outerRelTo != null) { Composite outerComposite = (Composite) outerRelTo.getWidget(); ocBounds = outerComposite.getBounds(); ocBounds = Display.getCurrent().map(outerComposite.getParent(), null, ocBounds); } else { ocBounds = null; } getDockLocation(info); showFeedback(curDockLocation); }
/** * Start a drag operation on the given element. * * @param element The element to drag */ public void dragStart(DnDInfo info) { // cache a placeholder where the element started (NOTE: this also prevents the parent from // being auto-removed by going 'empty' if (dragElement.getParent() != null) { if (dragElement instanceof MStackElement) dragPH = AdvancedFactoryImpl.eINSTANCE.createPlaceholder(); else if (dragElement instanceof MPartStack) dragPH = BasicFactoryImpl.eINSTANCE.createPartSashContainer(); else if (dragElement instanceof MTrimElement) dragPH = MenuFactoryImpl.eINSTANCE.createToolControl(); dragPH.setElementId(DRAG_PLACEHOLDER_ID); dragPH.setToBeRendered(false); List<MUIElement> kids = dragElement.getParent().getChildren(); kids.add(kids.indexOf(dragElement), dragPH); } dropAgent = dndManager.getDropAgent(dragElement, info); if (dropAgent != null) dropAgent.dragEnter(dragElement, info); }