Search in sources :

Example 1 with XSDBaseAttributeAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAttributeAdapter in project webtools.sourceediting by eclipse.

the class DragAndDropEditPolicy method getCommand.

public org.eclipse.gef.commands.Command getCommand(Request request) {
    BaseDragAndDropCommand command = null;
    if (request instanceof ChangeBoundsRequest) {
        ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
        Point location = changeBoundsRequest.getLocation();
        GraphicalEditPart target = (GraphicalEditPart) viewer.findObjectAt(location);
        location = getPointerLocation(changeBoundsRequest.getLocation());
        ((GraphicalEditPart) viewer.getRootEditPart()).getFigure().translateToRelative(location);
        List list = changeBoundsRequest.getEditParts();
        // allow drag and drop of only one selected object
        if (list.size() == 1) {
            Object itemToDrag = list.get(0);
            if (itemToDrag instanceof XSDBaseFieldEditPart) {
                XSDBaseFieldEditPart selected = (XSDBaseFieldEditPart) itemToDrag;
                if (selected.getModel() instanceof XSDElementDeclarationAdapter) {
                    command = new XSDElementDragAndDropCommand(viewer, (ChangeBoundsRequest) request, target, selected, location);
                    selectionHandlesEditPolicy.setDragAndDropCommand(command);
                } else if (selected.getModel() instanceof XSDBaseAttributeAdapter) {
                    command = new XSDAttributeDragAndDropCommand(viewer, (ChangeBoundsRequest) request, target, selected, location);
                    selectionHandlesEditPolicy.setDragAndDropCommand(command);
                }
            }
        }
    }
    return command;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) XSDElementDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.XSDElementDragAndDropCommand) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) XSDBaseAttributeAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAttributeAdapter) BaseDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point) XSDAttributeDragAndDropCommand(org.eclipse.wst.xsd.ui.internal.commands.XSDAttributeDragAndDropCommand) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) XSDElementDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)

Aggregations

List (java.util.List)1 Point (org.eclipse.draw2d.geometry.Point)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1 XSDBaseAttributeAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAttributeAdapter)1 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)1 BaseDragAndDropCommand (org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand)1 XSDAttributeDragAndDropCommand (org.eclipse.wst.xsd.ui.internal.commands.XSDAttributeDragAndDropCommand)1 XSDElementDragAndDropCommand (org.eclipse.wst.xsd.ui.internal.commands.XSDElementDragAndDropCommand)1 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)1