Search in sources :

Example 1 with ModelGroupEditPart

use of org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart 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 ModelGroupEditPart

use of org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart in project webtools.sourceediting by eclipse.

the class XSDElementDragAndDropCommand method getModelGroupEditParts.

// Model Group related helper method
protected List getModelGroupEditParts(ModelGroupEditPart modelGroupEditPart) {
    List modelGroupList = new ArrayList();
    List list = modelGroupEditPart.getChildren();
    for (Iterator i = list.iterator(); i.hasNext(); ) {
        Object object = i.next();
        if (object instanceof TargetConnectionSpacingFigureEditPart) {
            targetSpacesList.add(object);
        } else if (object instanceof ModelGroupDefinitionReferenceEditPart) {
            ModelGroupDefinitionReferenceEditPart groupRef = (ModelGroupDefinitionReferenceEditPart) object;
            List groupRefChildren = groupRef.getChildren();
            for (Iterator it = groupRefChildren.iterator(); it.hasNext(); ) {
                Object o = it.next();
                if (o instanceof ModelGroupEditPart) {
                    getModelGroupEditParts((ModelGroupEditPart) o);
                }
            }
        } else if (object instanceof ModelGroupEditPart) {
            getModelGroupEditParts((ModelGroupEditPart) object);
        }
    }
    return modelGroupList;
}
Also used : ModelGroupDefinitionReferenceEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupDefinitionReferenceEditPart) ModelGroupEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TargetConnectionSpacingFigureEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.TargetConnectionSpacingFigureEditPart)

Example 3 with ModelGroupEditPart

use of org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart 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

ModelGroupEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MoveXSDElementAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction)2 Iterator (java.util.Iterator)1 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)1 BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)1 ModelGroupDefinitionReferenceEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupDefinitionReferenceEditPart)1 TargetConnectionSpacingFigureEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.TargetConnectionSpacingFigureEditPart)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