Search in sources :

Example 1 with Attribute

use of org.apache.cayenne.map.Attribute in project cayenne by apache.

the class SQLTemplatePrefetchTab method createBrowserModel.

protected TreeModel createBrowserModel(Entity entity) {
    EntityTreeModel treeModel = new EntityTreeModel(entity);
    treeModel.setFilter(new EntityTreeFilter() {

        public boolean attributeMatch(Object node, Attribute attr) {
            return false;
        }

        public boolean relationshipMatch(Object node, Relationship rel) {
            return true;
        }
    });
    return treeModel;
}
Also used : EntityTreeFilter(org.apache.cayenne.modeler.util.EntityTreeFilter) EntityTreeModel(org.apache.cayenne.modeler.util.EntityTreeModel) Attribute(org.apache.cayenne.map.Attribute) Relationship(org.apache.cayenne.map.Relationship)

Example 2 with Attribute

use of org.apache.cayenne.map.Attribute in project cayenne by apache.

the class SelectQueryPrefetchTab method createBrowserModel.

protected TreeModel createBrowserModel(Entity entity) {
    EntityTreeModel treeModel = new EntityTreeModel(entity);
    treeModel.setFilter(new EntityTreeFilter() {

        public boolean attributeMatch(Object node, Attribute attr) {
            return false;
        }

        public boolean relationshipMatch(Object node, Relationship rel) {
            return true;
        }
    });
    return treeModel;
}
Also used : EntityTreeFilter(org.apache.cayenne.modeler.util.EntityTreeFilter) EntityTreeModel(org.apache.cayenne.modeler.util.EntityTreeModel) Attribute(org.apache.cayenne.map.Attribute) Relationship(org.apache.cayenne.map.Relationship)

Example 3 with Attribute

use of org.apache.cayenne.map.Attribute in project cayenne by apache.

the class EntityCellMetadata method createLabel.

/**
 * Creates label for this cell
 */
String createLabel() {
    Entity entity = fetchEntity();
    StringBuilder label = new StringBuilder("<html><center><u><b>").append(entity.getName()).append("</b></u></center>");
    for (Attribute attr : entity.getAttributes()) {
        if (isPrimary(attr)) {
            label.append("<br><i>").append(attr.getName()).append("</i>");
        }
    }
    for (Attribute attr : entity.getAttributes()) {
        if (!isPrimary(attr)) {
            label.append("<br>").append(attr.getName());
        }
    }
    return label.toString();
}
Also used : Entity(org.apache.cayenne.map.Entity) Attribute(org.apache.cayenne.map.Attribute)

Example 4 with Attribute

use of org.apache.cayenne.map.Attribute in project cayenne by apache.

the class FindAction method jumpToResult.

/**
 * Navigate to search result
 * Used also in {@link org.apache.cayenne.modeler.graph.action.EntityDisplayAction}
 */
public static void jumpToResult(FindAction.SearchResultEntry searchResultEntry) {
    EditorView editor = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
    DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
    if (searchResultEntry.getObject() instanceof Entity) {
        jumpToEntityResult((Entity) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof QueryDescriptor) {
        jumpToQueryResult((QueryDescriptor) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof Embeddable) {
        jumpToEmbeddableResult((Embeddable) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof EmbeddableAttribute) {
        jumpToEmbeddableAttributeResult((EmbeddableAttribute) searchResultEntry.getObject(), editor, domain);
    } else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject() instanceof Relationship) {
        jumpToAttributeResult(searchResultEntry, editor, domain);
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DetectedDbEntity(org.apache.cayenne.map.DetectedDbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EJBQLQueryDescriptor(org.apache.cayenne.map.EJBQLQueryDescriptor) SelectQueryDescriptor(org.apache.cayenne.map.SelectQueryDescriptor) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttribute(org.apache.cayenne.map.ObjAttribute) Attribute(org.apache.cayenne.map.Attribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Relationship(org.apache.cayenne.map.Relationship) DbRelationship(org.apache.cayenne.map.DbRelationship) ObjRelationship(org.apache.cayenne.map.ObjRelationship) EditorView(org.apache.cayenne.modeler.editor.EditorView) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) CayenneModelerFrame(org.apache.cayenne.modeler.CayenneModelerFrame) Embeddable(org.apache.cayenne.map.Embeddable)

Example 5 with Attribute

use of org.apache.cayenne.map.Attribute in project cayenne by apache.

the class FindAction method jumpToAttributeResult.

private static void jumpToAttributeResult(SearchResultEntry searchResultEntry, EditorView editor, DataChannelDescriptor domain) {
    DataMap map;
    Entity entity;
    if (searchResultEntry.getObject() instanceof Attribute) {
        map = ((Attribute) searchResultEntry.getObject()).getEntity().getDataMap();
        entity = ((Attribute) searchResultEntry.getObject()).getEntity();
    } else {
        map = ((Relationship) searchResultEntry.getObject()).getSourceEntity().getDataMap();
        entity = ((Relationship) searchResultEntry.getObject()).getSourceEntity();
    }
    buildAndSelectTreePath(map, entity, editor);
    if (searchResultEntry.getObject() instanceof Attribute) {
        AttributeDisplayEvent event = new AttributeDisplayEvent(editor.getProjectTreeView(), (Attribute) searchResultEntry.getObject(), entity, map, domain);
        event.setMainTabFocus(true);
        if (searchResultEntry.getObject() instanceof DbAttribute) {
            editor.getDbDetailView().currentDbAttributeChanged(event);
        } else {
            editor.getObjDetailView().currentObjAttributeChanged(event);
        }
    } else if (searchResultEntry.getObject() instanceof Relationship) {
        RelationshipDisplayEvent event = new RelationshipDisplayEvent(editor.getProjectTreeView(), (Relationship) searchResultEntry.getObject(), entity, map, domain);
        event.setMainTabFocus(true);
        if (searchResultEntry.getObject() instanceof DbRelationship) {
            editor.getDbDetailView().currentDbRelationshipChanged(event);
        } else {
            editor.getObjDetailView().currentObjRelationshipChanged(event);
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) DetectedDbEntity(org.apache.cayenne.map.DetectedDbEntity) Entity(org.apache.cayenne.map.Entity) DbEntity(org.apache.cayenne.map.DbEntity) EmbeddableAttributeDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent) AttributeDisplayEvent(org.apache.cayenne.modeler.event.AttributeDisplayEvent) DbAttribute(org.apache.cayenne.map.DbAttribute) ObjAttribute(org.apache.cayenne.map.ObjAttribute) Attribute(org.apache.cayenne.map.Attribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) Relationship(org.apache.cayenne.map.Relationship) DbRelationship(org.apache.cayenne.map.DbRelationship) ObjRelationship(org.apache.cayenne.map.ObjRelationship) DbRelationship(org.apache.cayenne.map.DbRelationship) DbAttribute(org.apache.cayenne.map.DbAttribute) DataMap(org.apache.cayenne.map.DataMap) RelationshipDisplayEvent(org.apache.cayenne.modeler.event.RelationshipDisplayEvent)

Aggregations

Attribute (org.apache.cayenne.map.Attribute)9 Entity (org.apache.cayenne.map.Entity)5 Relationship (org.apache.cayenne.map.Relationship)5 ObjEntity (org.apache.cayenne.map.ObjEntity)4 DbAttribute (org.apache.cayenne.map.DbAttribute)3 DbEntity (org.apache.cayenne.map.DbEntity)3 ArrayList (java.util.ArrayList)2 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)2 DataMap (org.apache.cayenne.map.DataMap)2 DbRelationship (org.apache.cayenne.map.DbRelationship)2 DetectedDbEntity (org.apache.cayenne.map.DetectedDbEntity)2 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)2 ObjAttribute (org.apache.cayenne.map.ObjAttribute)2 ObjRelationship (org.apache.cayenne.map.ObjRelationship)2 AttributeDisplayEvent (org.apache.cayenne.modeler.event.AttributeDisplayEvent)2 EntityTreeFilter (org.apache.cayenne.modeler.util.EntityTreeFilter)2 EntityTreeModel (org.apache.cayenne.modeler.util.EntityTreeModel)2 ConfigurationNode (org.apache.cayenne.configuration.ConfigurationNode)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 EJBQLQueryDescriptor (org.apache.cayenne.map.EJBQLQueryDescriptor)1