Search in sources :

Example 1 with CloneCommand

use of org.csstudio.opibuilder.commands.CloneCommand in project yamcs-studio by yamcs.

the class WidgetXYLayoutEditPolicy method getCloneCommand.

@SuppressWarnings("deprecation")
@Override
protected Command getCloneCommand(ChangeBoundsRequest request) {
    CloneCommand clone = new CloneCommand((AbstractContainerModel) getHost().getModel());
    for (AbstractBaseEditPart part : sortSelectedWidgets(request.getEditParts())) {
        clone.addPart((AbstractWidgetModel) part.getModel(), (Rectangle) getConstraintForClone(part, request));
    }
    // Attach to horizontal guide, if one is given
    Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE);
    if (guidePos != null) {
        int hAlignment = ((Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_ANCHOR)).intValue();
        clone.setGuide(findGuideAt(guidePos.intValue(), true), hAlignment, true);
    }
    // Attach to vertical guide, if one is given
    guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE);
    if (guidePos != null) {
        int vAlignment = ((Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_ANCHOR)).intValue();
        clone.setGuide(findGuideAt(guidePos.intValue(), false), vAlignment, false);
    }
    return clone;
}
Also used : CloneCommand(org.csstudio.opibuilder.commands.CloneCommand) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart)

Aggregations

CloneCommand (org.csstudio.opibuilder.commands.CloneCommand)1 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)1