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);
}
}
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();
}
}
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;
}
Aggregations