Search in sources :

Example 1 with AttributeMap

use of org.jgraph.graph.AttributeMap in project cayenne by apache.

the class BaseGraphBuilder method updateEntityCell.

/**
 * Updates specified entity on the graph
 */
protected void updateEntityCell(Entity e) {
    DefaultGraphCell cell = entityCells.get(e.getName());
    if (cell != null) {
        GraphConstants.setValue(cell.getAttributes(), getCellMetadata(e));
        GraphConstants.setResize(cell.getAttributes(), true);
        Map<DefaultGraphCell, AttributeMap> nested = new HashMap<>();
        nested.put(cell, cell.getAttributes());
        edit(nested);
    }
}
Also used : DefaultGraphCell(org.jgraph.graph.DefaultGraphCell) AttributeMap(org.jgraph.graph.AttributeMap) HashMap(java.util.HashMap)

Example 2 with AttributeMap

use of org.jgraph.graph.AttributeMap in project cayenne by apache.

the class BaseGraphBuilder method updateRelationshipCell.

protected void updateRelationshipCell(Relationship rel) {
    if (rel.getSourceEntity() != null && rel.getTargetEntity() != null) {
        DefaultEdge edge = relCells.get(getQualifiedName(rel));
        if (edge != null) {
            updateRelationshipLabels(edge, rel, rel.getReverseRelationship());
            Map<DefaultEdge, AttributeMap> nested = new HashMap<>();
            nested.put(edge, edge.getAttributes());
            edit(nested);
        } else {
            insertRelationshipCell(rel);
        }
    }
}
Also used : AttributeMap(org.jgraph.graph.AttributeMap) HashMap(java.util.HashMap) DefaultEdge(org.jgraph.graph.DefaultEdge)

Example 3 with AttributeMap

use of org.jgraph.graph.AttributeMap in project cayenne by apache.

the class ObjGraphBuilder method objEntityChanged.

public void objEntityChanged(EntityEvent e) {
    remapEntity(e);
    updateEntityCell(e.getEntity());
    // maybe super entity was changed
    ObjEntity entity = (ObjEntity) e.getEntity();
    DefaultEdge inheritanceEdge = inheritanceEdges.get(entity);
    if (inheritanceEdge != null) {
        if (entity.getSuperEntity() == null) {
            graph.getGraphLayoutCache().remove(new Object[] { inheritanceEdge });
            inheritanceEdges.remove(entity);
        } else {
            inheritanceEdge.setTarget(entityCells.get(entity.getSuperEntity().getName()).getChildAt(0));
            Map<DefaultEdge, AttributeMap> nested = new HashMap<>();
            nested.put(inheritanceEdge, inheritanceEdge.getAttributes());
            graph.getGraphLayoutCache().edit(nested);
        }
    } else {
        if (entity.getSuperEntity() != null) {
            DefaultEdge edge = createInheritanceEdge(entity);
            graph.getGraphLayoutCache().insert(edge);
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) AttributeMap(org.jgraph.graph.AttributeMap) HashMap(java.util.HashMap) DefaultEdge(org.jgraph.graph.DefaultEdge)

Aggregations

HashMap (java.util.HashMap)3 AttributeMap (org.jgraph.graph.AttributeMap)3 DefaultEdge (org.jgraph.graph.DefaultEdge)2 ObjEntity (org.apache.cayenne.map.ObjEntity)1 DefaultGraphCell (org.jgraph.graph.DefaultGraphCell)1