Search in sources :

Example 1 with AttributeGroupDefinitionEditPart

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

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

the class XSDAttributeDragAndDropCommand method calculateAttributeGroupList.

// Attribute Group related helper method
protected void calculateAttributeGroupList() {
    EditPart editPart = target;
    while (editPart != null) {
        if (editPart instanceof ComplexTypeEditPart) {
            List list = editPart.getChildren();
            for (Iterator i = list.iterator(); i.hasNext(); ) {
                Object child = i.next();
                if (child instanceof CompartmentEditPart) {
                    List compartmentList = ((CompartmentEditPart) child).getChildren();
                    for (Iterator it = compartmentList.iterator(); it.hasNext(); ) {
                        Object obj = it.next();
                        if (obj instanceof XSDAttributesForAnnotationEditPart) {
                            XSDAttributesForAnnotationEditPart groups = (XSDAttributesForAnnotationEditPart) obj;
                            List groupList = groups.getChildren();
                            for (Iterator iter = groupList.iterator(); iter.hasNext(); ) {
                                Object groupChild = iter.next();
                                if (groupChild instanceof TargetConnectionSpacingFigureEditPart) {
                                    targetSpacesList.add(groupChild);
                                } else if (groupChild instanceof AttributeGroupDefinitionEditPart) {
                                    getAttributeGroupEditParts((AttributeGroupDefinitionEditPart) groupChild);
                                }
                            }
                        }
                    }
                }
            }
        }
        editPart = editPart.getParent();
    }
}
Also used : ComplexTypeEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ComplexTypeEditPart) AttributeGroupDefinitionEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart) TargetConnectionSpacingFigureEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.TargetConnectionSpacingFigureEditPart) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) ComplexTypeEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ComplexTypeEditPart) CompartmentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CompartmentEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart) AttributeGroupDefinitionEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart) EditPart(org.eclipse.gef.EditPart) XSDAttributesForAnnotationEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDAttributesForAnnotationEditPart) Iterator(java.util.Iterator) CompartmentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CompartmentEditPart) ArrayList(java.util.ArrayList) List(java.util.List) TargetConnectionSpacingFigureEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.TargetConnectionSpacingFigureEditPart) XSDAttributesForAnnotationEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDAttributesForAnnotationEditPart)

Example 3 with AttributeGroupDefinitionEditPart

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

the class XSDAttributeDragAndDropCommand method getAttributeGroupEditParts.

// Attribute Group related helper method
protected List getAttributeGroupEditParts(AttributeGroupDefinitionEditPart attributeGroupEditPart) {
    List groupList = new ArrayList();
    List list = attributeGroupEditPart.getChildren();
    for (Iterator i = list.iterator(); i.hasNext(); ) {
        Object object = i.next();
        if (object instanceof TargetConnectionSpacingFigureEditPart) {
            targetSpacesList.add(object);
        } else if (object instanceof AttributeGroupDefinitionEditPart) {
            AttributeGroupDefinitionEditPart groupRef = (AttributeGroupDefinitionEditPart) object;
            List groupRefChildren = groupRef.getChildren();
            for (Iterator it = groupRefChildren.iterator(); it.hasNext(); ) {
                Object o = it.next();
                if (o instanceof TargetConnectionSpacingFigureEditPart) {
                    targetSpacesList.add(o);
                } else if (o instanceof AttributeGroupDefinitionEditPart) {
                    AttributeGroupDefinitionEditPart aGroup = (AttributeGroupDefinitionEditPart) o;
                    groupList.add(aGroup);
                    groupList.addAll(getAttributeGroupEditParts(aGroup));
                }
            }
        }
    }
    return groupList;
}
Also used : AttributeGroupDefinitionEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart) 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)

Aggregations

ArrayList (java.util.ArrayList)3 List (java.util.List)3 AttributeGroupDefinitionEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.AttributeGroupDefinitionEditPart)3 Iterator (java.util.Iterator)2 BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)2 TargetConnectionSpacingFigureEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.TargetConnectionSpacingFigureEditPart)2 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)2 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 MoveXSDAttributeAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction)1 XSDAttributeDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter)1 CompartmentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CompartmentEditPart)1 ComplexTypeEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.ComplexTypeEditPart)1 XSDAttributesForAnnotationEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDAttributesForAnnotationEditPart)1 GenericGroupFigure (org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)1