Search in sources :

Example 6 with BaseFieldEditPart

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);
    }
}
Also used : MoveXSDAttributeAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction) GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) XSDAttributeDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter) AttributeGroupDefinitionEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 7 with BaseFieldEditPart

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();
}
Also used : XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Point(org.eclipse.draw2d.geometry.Point) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Aggregations

BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)7 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Point (org.eclipse.draw2d.geometry.Point)2 ContentOutline (org.eclipse.ui.views.contentoutline.ContentOutline)2 GenericGroupFigure (org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)2 Iterator (java.util.Iterator)1 Label (org.eclipse.draw2d.Label)1 PointList (org.eclipse.draw2d.geometry.PointList)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 Text (org.eclipse.swt.widgets.Text)1 MoveXSDAttributeAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction)1 MoveXSDElementAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction)1 XSDAttributeDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)1 IAutoDirectEdit (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IAutoDirectEdit)1 IFieldFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)1