Search in sources :

Example 1 with MoveXSDAttributeAction

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

the class XSDAttributeDragAndDropCommand method doDrop.

protected void doDrop(List siblings, GraphicalEditPart movingEditPart) {
    commonSetup(siblings, movingEditPart);
    if ((previousRefComponent instanceof XSDAttributeDeclaration || previousRefComponent instanceof XSDWildcard) && (nextRefComponent instanceof XSDAttributeDeclaration || nextRefComponent instanceof XSDWildcard)) {
        XSDConcreteComponent parent = previousRefComponent.getContainer().getContainer();
        if (closerSibling == BELOW_IS_CLOSER) {
            parent = nextRefComponent.getContainer().getContainer();
        }
        action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
    } else if (previousRefComponent == null && (nextRefComponent instanceof XSDAttributeDeclaration || nextRefComponent instanceof XSDWildcard)) {
        XSDConcreteComponent parent = nextRefComponent.getContainer().getContainer();
        if (closerSibling == ABOVE_IS_CLOSER) {
            if (leftSiblingEditPart == null) {
                action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
            } else if (parentEditPart != null) {
                action = new MoveXSDAttributeAction(parentEditPart.getXSDConcreteComponent(), xsdComponentToDrag, previousRefComponent, nextRefComponent);
            }
        } else {
            action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
        }
    } else if (previousRefComponent instanceof XSDAttributeDeclaration && nextRefComponent == null) {
        XSDConcreteComponent parent = previousRefComponent.getContainer().getContainer();
        if (closerSibling == ABOVE_IS_CLOSER) {
            action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
        } else {
            if (rightSiblingEditPart == null) {
                action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
            } else {
                action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
            }
        }
    }
    if (action != null)
        canExecute = action.canMove();
}
Also used : MoveXSDAttributeAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 2 with MoveXSDAttributeAction

use of org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction 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)

Aggregations

MoveXSDAttributeAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 XSDAttributeDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter)1 BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)1 AttributeGroupDefinitionEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart)1 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)1 GenericGroupFigure (org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)1 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1 XSDWildcard (org.eclipse.xsd.XSDWildcard)1