private MUIElement getInsertionElement(MUIElement dragElement, DnDInfo info) { Composite trimComp = (Composite) trimBar.getWidget(); // If we're over the trim bar itself drop at the end // May need to take margins into account if (info.curCtrl == trimComp) return null; TrimBarLayout tbl = (TrimBarLayout) trimComp.getLayout(); Point trimPos = trimComp.getDisplay().map(null, trimComp, info.cursorPos); Control trimCtrl = tbl.ctrlFromPoint(trimPos); if (trimCtrl == null) return null; if (trimCtrl == dragElement.getWidget()) return dragElement; // Are we closer to the 'end' of the trim control ? // If so insert before the next control (if any) MUIElement trimElement = (MUIElement) trimCtrl.getData(AbstractPartRenderer.OWNING_ME); if (isAfter(trimCtrl, info)) { MElementContainer<MUIElement> trimParent = trimElement.getParent(); int trimIndex = trimParent.getChildren().indexOf(trimElement); if (trimIndex == trimParent.getChildren().size() - 1) return null; return trimParent.getChildren().get(trimIndex + 1); } return trimElement; }
private MUIElement getInsertionElement(MUIElement dragElement, DnDInfo info) { Composite trimComp = (Composite) trimBar.getWidget(); // If we're over the trim bar itself drop at the end // May need to take margins into account if (info.curCtrl == trimComp) { return null; } TrimBarLayout tbl = (TrimBarLayout) trimComp.getLayout(); Point trimPos = trimComp.getDisplay().map(null, trimComp, info.cursorPos); Control trimCtrl = tbl.ctrlFromPoint(trimComp, trimPos); if (trimCtrl == null || dragElement.getWidget() == null) { return null; } if (trimCtrl == dragElement.getWidget()) { return dragElement; } // Are we closer to the 'end' of the trim control ? // If so insert before the next control (if any) MUIElement trimElement = (MUIElement) trimCtrl.getData(AbstractPartRenderer.OWNING_ME); if (isAfter(trimCtrl, info) && trimElement != null) { MElementContainer<MUIElement> trimParent = trimElement.getParent(); int trimIndex = trimParent.getChildren().indexOf(trimElement); if (trimIndex == trimParent.getChildren().size() - 1) { return null; } return trimParent.getChildren().get(trimIndex + 1); } return trimElement; }