Search in sources :

Example 1 with LabelEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart in project statecharts by Yakindu.

the class TreeLayoutEditPolicy method showLayoutTargetFeedback.

@Override
protected void showLayoutTargetFeedback(Request request) {
    if (request instanceof ChangeBoundsRequest) {
        final ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
        if (!changeBoundsRequest.getEditParts().isEmpty() && !(changeBoundsRequest.getEditParts().get(0) instanceof LabelEditPart)) {
            final IGraphicalEditPart editPart = (IGraphicalEditPart) changeBoundsRequest.getEditParts().get(0);
            final List<IGraphicalEditPart> siblingList = TreeLayoutUtil.getSiblings(editPart);
            if (!siblingList.isEmpty()) {
                final int newTreePosition = TreeLayoutUtil.getNewTreeNodePosition(changeBoundsRequest.getLocation(), TreeLayoutUtil.getSiblings(editPart));
                Point point;
                if (newTreePosition == 0) {
                    // top end
                    point = getFeedBackFigurePoint(editPart.getFigure(), siblingList, 0, 0);
                } else if (newTreePosition == siblingList.size()) {
                    // Bottom end
                    point = getFeedBackFigurePoint(editPart.getFigure(), siblingList, siblingList.size(), siblingList.size());
                } else {
                    // Between siblings
                    point = getFeedBackFigurePoint(editPart.getFigure(), siblingList, newTreePosition - 1, newTreePosition);
                }
                final Rectangle bounds = getFeedbackFigureBounds();
                siblingList.get(0).getFigure().translateToAbsolute(bounds);
                bounds.setLocation(point);
                getFeedbackFigure().setBounds(bounds);
                getFeedbackFigure().translateToRelative(getFeedbackFigure().getBounds());
                getFeedbackLayer().add(getFeedbackFigure());
                getFeedbackLayer().repaint();
            }
        }
    }
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) LabelEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) Point(org.eclipse.draw2d.geometry.Point) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 LabelEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart)1 TreeLayoutConstraint (org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint)1