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