Search in sources :

Example 1 with AbstractImageEditPart

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);
            }
        });
    }
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ShapeNodeEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart) ILayoutNode(org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNode) AbstractBorderItemEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart) AbstractImageEditPart(org.eclipse.gmf.runtime.diagram.ui.render.editparts.AbstractImageEditPart)

Aggregations

AbstractBorderItemEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 ShapeNodeEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart)1 AbstractImageEditPart (org.eclipse.gmf.runtime.diagram.ui.render.editparts.AbstractImageEditPart)1 ILayoutNode (org.eclipse.gmf.runtime.diagram.ui.services.layout.ILayoutNode)1