Search in sources :

Example 1 with ResizableCompartmentFigure

use of org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure in project statecharts by Yakindu.

the class StateTextCompartmentEditPart method createFigure.

@Override
protected IFigure createFigure() {
    ResizableCompartmentFigure figure = (ResizableCompartmentFigure) super.createFigure();
    GridLayout gridLayout = new GridLayout(1, true);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    figure.getContentPane().setLayoutManager(gridLayout);
    figure.setBorder(null);
    figure.setToolTip((String) null);
    return figure;
}
Also used : GridLayout(org.eclipse.draw2d.GridLayout) ResizableCompartmentFigure(org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure)

Example 2 with ResizableCompartmentFigure

use of org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure in project elk by eclipse.

the class GmfDiagramLayoutConnector method buildLayoutGraphRecursively.

/**
 * Recursively builds a layout graph by analyzing the children of the given edit part.
 *
 * @param mapping
 *            the layout mapping
 * @param parentEditPart
 *            the parent edit part of the current elements
 * @param parentLayoutNode
 *            the corresponding KNode
 * @param currentEditPart
 *            the currently analyzed edit part
 */
protected void buildLayoutGraphRecursively(final LayoutMapping mapping, final IGraphicalEditPart parentEditPart, final ElkNode parentLayoutNode, final IGraphicalEditPart currentEditPart) {
    Maybe<ElkPadding> kinsets = new Maybe<ElkPadding>();
    // iterate through the children of the element
    for (Object obj : currentEditPart.getChildren()) {
        // check visibility of the child
        if (obj instanceof IGraphicalEditPart) {
            IFigure figure = ((IGraphicalEditPart) obj).getFigure();
            if (!figure.isVisible()) {
                continue;
            }
        }
        // process a port (border item)
        if (obj instanceof AbstractBorderItemEditPart) {
            AbstractBorderItemEditPart borderItem = (AbstractBorderItemEditPart) obj;
            if (editPartFilter.filter(borderItem)) {
                createPort(mapping, borderItem, parentEditPart, parentLayoutNode);
            }
        // process a compartment, which may contain other elements
        } else if (obj instanceof ResizableCompartmentEditPart && ((CompartmentEditPart) obj).getChildren().size() > 0) {
            CompartmentEditPart compartment = (CompartmentEditPart) obj;
            if (editPartFilter.filter(compartment)) {
                boolean compExp = true;
                IFigure compartmentFigure = compartment.getFigure();
                if (compartmentFigure instanceof ResizableCompartmentFigure) {
                    ResizableCompartmentFigure resizCompFigure = (ResizableCompartmentFigure) compartmentFigure;
                    // check whether the compartment is collapsed
                    compExp = resizCompFigure.isExpanded();
                }
                if (compExp) {
                    buildLayoutGraphRecursively(mapping, parentEditPart, parentLayoutNode, compartment);
                }
            }
        // process a node, which may be a parent of ports, compartments, or other nodes
        } else if (obj instanceof ShapeNodeEditPart) {
            ShapeNodeEditPart childNodeEditPart = (ShapeNodeEditPart) obj;
            if (editPartFilter.filter(childNodeEditPart)) {
                ElkNode node = createNode(mapping, childNodeEditPart, parentEditPart, parentLayoutNode, kinsets);
                // process the child as new current edit part
                buildLayoutGraphRecursively(mapping, childNodeEditPart, node, childNodeEditPart);
            }
        // process a label of the current node
        } else if (obj instanceof IGraphicalEditPart) {
            createNodeLabel(mapping, (IGraphicalEditPart) obj, parentEditPart, parentLayoutNode);
        }
    }
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ShapeNodeEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart) Maybe(org.eclipse.elk.core.util.Maybe) ResizableCompartmentFigure(org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure) ElkNode(org.eclipse.elk.graph.ElkNode) ResizableCompartmentEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart) ResizableCompartmentEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart) CompartmentEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart) AbstractBorderItemEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart) EObject(org.eclipse.emf.ecore.EObject) ElkPadding(org.eclipse.elk.core.math.ElkPadding) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ResizableCompartmentFigure (org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure)2 GridLayout (org.eclipse.draw2d.GridLayout)1 IFigure (org.eclipse.draw2d.IFigure)1 ElkPadding (org.eclipse.elk.core.math.ElkPadding)1 Maybe (org.eclipse.elk.core.util.Maybe)1 ElkNode (org.eclipse.elk.graph.ElkNode)1 EObject (org.eclipse.emf.ecore.EObject)1 AbstractBorderItemEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart)1 CompartmentEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 ResizableCompartmentEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.ResizableCompartmentEditPart)1 ShapeNodeEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart)1