use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class XSDAttributeDragAndDropCommand method setup.
protected void setup() {
canExecute = false;
// Drop target is attribute group ref
if (target instanceof AttributeGroupDefinitionEditPart) {
parentEditPart = (AttributeGroupDefinitionEditPart) target;
if (((GenericGroupFigure) parentEditPart.getFigure()).getIconFigure().getBounds().contains(location)) {
xsdComponentToDrag = (XSDConcreteComponent) ((XSDAttributeDeclarationAdapter) itemToDrag.getModel()).getTarget();
action = new MoveXSDAttributeAction(((AttributeGroupDefinitionEditPart) parentEditPart).getXSDAttributeGroupDefinition(), xsdComponentToDrag, null, null);
canExecute = action.canMove();
}
} else if (target instanceof BaseFieldEditPart) {
targetSpacesList = new ArrayList();
// Calculate the list of all sibling field edit parts;
List targetEditPartSiblings = calculateFieldEditParts();
calculateAttributeGroupList();
// Get 'left' and 'right' siblings
doDrop(targetEditPartSiblings, itemToDrag);
}
}
use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart in project webtools.sourceediting by eclipse.
the class BaseDragAndDropCommand method commonSetup.
protected void commonSetup(List siblings, GraphicalEditPart movingEditPart) {
closerSibling = ABOVE_IS_CLOSER;
int pointerYLocation = location.y;
int index;
for (index = 0; index < siblings.size(); index++) {
GraphicalEditPart sibling = (GraphicalEditPart) siblings.get(index);
if (sibling instanceof BaseFieldEditPart) {
int siblingYLocation = getZoomedBounds(sibling.getFigure().getBounds()).getCenter().y;
if (siblingYLocation > pointerYLocation) {
rightSiblingEditPart = sibling;
if (index > 0) {
leftSiblingEditPart = (GraphicalEditPart) siblings.get(index - 1);
}
if (leftSiblingEditPart != null && Math.abs(getZoomedBounds(leftSiblingEditPart.getFigure().getBounds()).getCenter().y - pointerYLocation) > Math.abs(siblingYLocation - pointerYLocation)) {
closerSibling = BELOW_IS_CLOSER;
}
break;
}
}
}
boolean isHandled = handleFirstAndLastDropTargets(index, siblings);
if (!isHandled)
handleOtherTargets(index);
calculateLeftAndRightXSDComponents();
xsdComponentToDrag = (XSDConcreteComponent) ((XSDBaseAdapter) itemToDrag.getModel()).getTarget();
}
Aggregations