Search in sources :

Example 6 with Embeddable

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

the class CreateAttributeAction method performAction.

/**
 * Creates ObjAttribute, DbAttribute depending on context.
 */
@Override
public void performAction(ActionEvent e) {
    ProjectController mediator = getProjectController();
    if (getProjectController().getCurrentEmbeddable() != null) {
        Embeddable embeddable = mediator.getCurrentEmbeddable();
        EmbeddableAttribute attr = new EmbeddableAttribute();
        attr.setName(NameBuilder.builder(attr, embeddable).name());
        createEmbAttribute(embeddable, attr);
        application.getUndoManager().addEdit(new CreateEmbAttributeUndoableEdit(embeddable, new EmbeddableAttribute[] { attr }));
    }
    if (getProjectController().getCurrentObjEntity() != null) {
        ObjEntity objEntity = mediator.getCurrentObjEntity();
        ObjAttribute attr = new ObjAttribute();
        attr.setName(NameBuilder.builder(attr, objEntity).name());
        createObjAttribute(mediator.getCurrentDataMap(), objEntity, attr);
        application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), objEntity, attr));
    } else if (getProjectController().getCurrentDbEntity() != null) {
        DbEntity dbEntity = getProjectController().getCurrentDbEntity();
        DbAttribute attr = new DbAttribute();
        attr.setName(NameBuilder.builder(attr, dbEntity).name());
        attr.setType(TypesMapping.NOT_DEFINED);
        attr.setEntity(dbEntity);
        createDbAttribute(mediator.getCurrentDataMap(), dbEntity, attr);
        application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), dbEntity, attr));
    }
}
Also used : CreateEmbAttributeUndoableEdit(org.apache.cayenne.modeler.undo.CreateEmbAttributeUndoableEdit) ObjEntity(org.apache.cayenne.map.ObjEntity) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ObjAttribute(org.apache.cayenne.map.ObjAttribute) DbEntity(org.apache.cayenne.map.DbEntity) CreateAttributeUndoableEdit(org.apache.cayenne.modeler.undo.CreateAttributeUndoableEdit) DbAttribute(org.apache.cayenne.map.DbAttribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) ProjectController(org.apache.cayenne.modeler.ProjectController) Embeddable(org.apache.cayenne.map.Embeddable)

Example 7 with Embeddable

use of org.apache.cayenne.map.Embeddable 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 8 with Embeddable

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

the class RemoveAction method removeLastPathComponent.

/**
 * Removes an object, depending on its type
 */
private UndoableEdit removeLastPathComponent(ConfigurationNode object, ConfigurationNode parentObject) {
    UndoableEdit undo = null;
    if (object instanceof DataMap) {
        if (parentObject != null && parentObject instanceof DataNodeDescriptor) {
            undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) parentObject, (DataMap) object);
            removeDataMapFromDataNode((DataNodeDescriptor) parentObject, (DataMap) object);
        } else {
            // Not under Data Node, remove completely
            undo = new RemoveUndoableEdit(application, (DataMap) object);
            removeDataMap((DataMap) object);
        }
    } else if (object instanceof DataNodeDescriptor) {
        undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) object);
        removeDataNode((DataNodeDescriptor) object);
    } else if (object instanceof DbEntity) {
        undo = new RemoveUndoableEdit(((DbEntity) object).getDataMap(), (DbEntity) object);
        removeDbEntity(((DbEntity) object).getDataMap(), (DbEntity) object);
    } else if (object instanceof ObjEntity) {
        undo = new RemoveUndoableEdit(((ObjEntity) object).getDataMap(), (ObjEntity) object);
        removeObjEntity(((ObjEntity) object).getDataMap(), (ObjEntity) object);
    } else if (object instanceof QueryDescriptor) {
        undo = new RemoveUndoableEdit(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
        removeQuery(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
    } else if (object instanceof Procedure) {
        undo = new RemoveUndoableEdit(((Procedure) object).getDataMap(), (Procedure) object);
        removeProcedure(((Procedure) object).getDataMap(), (Procedure) object);
    } else if (object instanceof Embeddable) {
        undo = new RemoveUndoableEdit(((Embeddable) object).getDataMap(), (Embeddable) object);
        removeEmbeddable(((Embeddable) object).getDataMap(), (Embeddable) object);
    }
    return undo;
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) RemoveAttributeUndoableEdit(org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit) RemoveCallbackMethodUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit) UndoableEdit(javax.swing.undo.UndoableEdit) RemoveRelationshipUndoableEdit(org.apache.cayenne.modeler.undo.RemoveRelationshipUndoableEdit) RemoveUndoableEdit(org.apache.cayenne.modeler.undo.RemoveUndoableEdit) RemoveCompoundUndoableEdit(org.apache.cayenne.modeler.undo.RemoveCompoundUndoableEdit) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) Procedure(org.apache.cayenne.map.Procedure) RemoveUndoableEdit(org.apache.cayenne.modeler.undo.RemoveUndoableEdit) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Example 9 with Embeddable

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

the class CodeGeneratorControllerBase method getItemName.

public JLabel getItemName(Object obj) {
    String className;
    Icon icon = null;
    if (obj instanceof Embeddable) {
        className = ((Embeddable) obj).getClassName();
        icon = CellRenderers.iconForObject(new Embeddable());
    } else {
        className = ((ObjEntity) obj).getName();
        icon = CellRenderers.iconForObject(new ObjEntity());
    }
    JLabel labelIcon = new JLabel();
    labelIcon.setIcon(icon);
    labelIcon.setVisible(true);
    labelIcon.setText(className);
    return labelIcon;
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) JLabel(javax.swing.JLabel) Icon(javax.swing.Icon) Embeddable(org.apache.cayenne.map.Embeddable)

Example 10 with Embeddable

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

the class EmbeddableDisplayEventType method fireLastDisplayEvent.

@Override
public void fireLastDisplayEvent() {
    DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
    if (!dataChannel.getName().equals(preferences.getDomain())) {
        return;
    }
    DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
    if (dataMap == null) {
        return;
    }
    Embeddable embeddable = dataMap.getEmbeddable(preferences.getEmbeddable());
    if (embeddable == null) {
        return;
    }
    EmbeddableDisplayEvent embeddableDisplayEvent = new EmbeddableDisplayEvent(this, embeddable, dataMap, dataChannel);
    controller.fireEmbeddableDisplayEvent(embeddableDisplayEvent);
}
Also used : DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) EmbeddableDisplayEvent(org.apache.cayenne.modeler.event.EmbeddableDisplayEvent) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable)

Aggregations

Embeddable (org.apache.cayenne.map.Embeddable)33 DataMap (org.apache.cayenne.map.DataMap)14 ObjEntity (org.apache.cayenne.map.ObjEntity)14 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)11 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)11 DbEntity (org.apache.cayenne.map.DbEntity)8 ArrayList (java.util.ArrayList)7 ObjAttribute (org.apache.cayenne.map.ObjAttribute)7 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)6 DbAttribute (org.apache.cayenne.map.DbAttribute)5 Procedure (org.apache.cayenne.map.Procedure)5 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)4 ObjRelationship (org.apache.cayenne.map.ObjRelationship)4 ProjectController (org.apache.cayenne.modeler.ProjectController)4 HashMap (java.util.HashMap)3 DbRelationship (org.apache.cayenne.map.DbRelationship)3 EmbeddableDisplayEvent (org.apache.cayenne.modeler.event.EmbeddableDisplayEvent)3 RemoveAttributeUndoableEdit (org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit)3 File (java.io.File)2 LinkedList (java.util.LinkedList)2