use of org.eclipse.gmf.runtime.diagram.ui.render.editparts.AbstractImageEditPart in project elk by eclipse.
the class ElkLayoutProvider method canLayoutNodes.
/**
* {@inheritDoc}<br>
* <br>
* This method returns <code>true</code> only for {@link IGraphicalEditPart IGraphicalEditParts}
* whose figures are visible and that contain at least a {@link ShapeNodeEditPart}, which is not
* an {@link AbstractBorderItemEditPart} or an {@link AbstractImageEditPart}.<br>
* <br>
* In short, returns only true if the provided edit part contains children that can be layouted.
*/
@SuppressWarnings("rawtypes")
public boolean canLayoutNodes(final List layoutNodes, final boolean shouldOffsetFromBoundingBox, final IAdaptable layoutHint) {
Object o = layoutHint.getAdapter(IGraphicalEditPart.class);
if (!(o instanceof IGraphicalEditPart)) {
return false;
}
final IGraphicalEditPart parent = (IGraphicalEditPart) o;
// computing layout on the element wouldn't make sense otherwise
if (layoutNodes.isEmpty()) {
return Iterables.any((List<?>) parent.getChildren(), new Predicate<Object>() {
public boolean apply(final Object o) {
return o instanceof ShapeNodeEditPart && !(o instanceof AbstractBorderItemEditPart) && !(o instanceof AbstractImageEditPart);
}
});
} else {
return Iterables.any((List<?>) layoutNodes, new Predicate<Object>() {
public boolean apply(final Object o) {
ILayoutNode layoutNode = (ILayoutNode) o;
IGraphicalEditPart editPart = findEditPart(parent, layoutNode.getNode());
return editPart instanceof ShapeNodeEditPart && !(editPart instanceof AbstractBorderItemEditPart) && !(editPart instanceof AbstractImageEditPart);
}
});
}
}
Aggregations