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