Search in sources :

Example 1 with MoveXSDElementAction

use of org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction in project webtools.sourceediting by eclipse.

the class XSDElementDragAndDropCommand method setup.

protected void setup() {
    canExecute = false;
    // Drop target is model group
    if (target instanceof ModelGroupEditPart) {
        parentEditPart = (ModelGroupEditPart) target;
        if (((GenericGroupFigure) parentEditPart.getFigure()).getIconFigure().getBounds().contains(location)) {
            xsdComponentToDrag = (XSDConcreteComponent) ((XSDElementDeclarationAdapter) itemToDrag.getModel()).getTarget();
            action = new MoveXSDElementAction(((ModelGroupEditPart) target).getXSDModelGroup(), 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();
        calculateModelGroupList();
        doDrop(targetEditPartSiblings, itemToDrag);
    }
}
Also used : ModelGroupEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart) GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) MoveXSDElementAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XSDElementDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 2 with MoveXSDElementAction

use of org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction in project webtools.sourceediting by eclipse.

the class XSDElementDragAndDropCommand method doDrop.

protected void doDrop(List siblings, GraphicalEditPart movingEditPart) {
    commonSetup(siblings, movingEditPart);
    // Can common this code up with XSDAttributeDragAndDropCommand...
    if ((previousRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDWildcard) && (nextRefComponent instanceof XSDElementDeclaration || nextRefComponent instanceof XSDWildcard)) {
        XSDModelGroup modelGroup = (XSDModelGroup) previousRefComponent.getContainer().getContainer();
        if (parentEditPart != null)
            modelGroup = ((ModelGroupEditPart) parentEditPart).getXSDModelGroup();
        action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
    } else if (previousRefComponent == null && (nextRefComponent instanceof XSDElementDeclaration || nextRefComponent instanceof XSDWildcard)) {
        if (closerSibling == ABOVE_IS_CLOSER) {
            if (leftSiblingEditPart == null) {
                action = new MoveXSDElementAction(topMostGroup.getXSDModelGroup(), xsdComponentToDrag, null, null, false);
            } else if (parentEditPart != null) {
                action = new MoveXSDElementAction(((ModelGroupEditPart) parentEditPart).getXSDModelGroup(), xsdComponentToDrag, previousRefComponent, nextRefComponent);
            }
        } else {
            XSDModelGroup modelGroup = (XSDModelGroup) nextRefComponent.getContainer().getContainer();
            action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
        }
    } else if ((previousRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDWildcard) && nextRefComponent == null) {
        XSDModelGroup modelGroup = (XSDModelGroup) previousRefComponent.getContainer().getContainer();
        if (parentEditPart != null)
            modelGroup = ((ModelGroupEditPart) parentEditPart).getXSDModelGroup();
        if (closerSibling == ABOVE_IS_CLOSER) {
            action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
        } else {
            if (rightSiblingEditPart == null) {
                action = new MoveXSDElementAction(topMostGroup.getXSDModelGroup(), xsdComponentToDrag, null, null, true);
            } else {
                action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
            }
        }
    }
    if (action != null)
        canExecute = action.canMove();
}
Also used : ModelGroupEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) MoveXSDElementAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDWildcard(org.eclipse.xsd.XSDWildcard)

Aggregations

MoveXSDElementAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction)2 ModelGroupEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)1 BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)1 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)1 GenericGroupFigure (org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)1 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)1 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)1 XSDWildcard (org.eclipse.xsd.XSDWildcard)1