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