Search in sources :

Example 46 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class RemoveAttributeAction method performAction.

@Override
public void performAction(ActionEvent e, boolean allowAsking) {
    ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);
    ProjectController mediator = getProjectController();
    EmbeddableAttribute[] embAttrs = getProjectController().getCurrentEmbAttributes();
    ObjAttribute[] objAttrs = getProjectController().getCurrentObjAttributes();
    DbAttribute[] dbAttrs = getProjectController().getCurrentDbAttributes();
    if (embAttrs != null && embAttrs.length > 0) {
        if ((embAttrs.length == 1 && dialog.shouldDelete("Embeddable Attribute", embAttrs[0].getName())) || (embAttrs.length > 1 && dialog.shouldDelete("selected EmbAttributes"))) {
            Embeddable embeddable = mediator.getCurrentEmbeddable();
            application.getUndoManager().addEdit(new RemoveAttributeUndoableEdit(embeddable, embAttrs));
            removeEmbeddableAttributes(embeddable, embAttrs);
        }
    } else if (objAttrs != null && objAttrs.length > 0) {
        if ((objAttrs.length == 1 && dialog.shouldDelete("ObjAttribute", objAttrs[0].getName())) || (objAttrs.length > 1 && dialog.shouldDelete("selected ObjAttributes"))) {
            ObjEntity entity = mediator.getCurrentObjEntity();
            application.getUndoManager().addEdit(new RemoveAttributeUndoableEdit(entity, objAttrs));
            removeObjAttributes(entity, objAttrs);
        }
    } else if (dbAttrs != null && dbAttrs.length > 0) {
        if ((dbAttrs.length == 1 && dialog.shouldDelete("DbAttribute", dbAttrs[0].getName())) || (dbAttrs.length > 1 && dialog.shouldDelete("selected DbAttributes"))) {
            DbEntity entity = mediator.getCurrentDbEntity();
            application.getUndoManager().addEdit(new RemoveAttributeUndoableEdit(entity, dbAttrs));
            removeDbAttributes(mediator.getCurrentDataMap(), entity, dbAttrs);
        }
    }
}
Also used : RemoveAttributeUndoableEdit(org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit) ObjEntity(org.apache.cayenne.map.ObjEntity) ObjAttribute(org.apache.cayenne.map.ObjAttribute) DbEntity(org.apache.cayenne.map.DbEntity) DbAttribute(org.apache.cayenne.map.DbAttribute) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) ProjectController(org.apache.cayenne.modeler.ProjectController) ConfirmRemoveDialog(org.apache.cayenne.modeler.dialog.ConfirmRemoveDialog) Embeddable(org.apache.cayenne.map.Embeddable)

Example 47 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class RemoveAttributeAction method removeObjAttributes.

public void removeObjAttributes(ObjEntity entity, ObjAttribute[] attribs) {
    ProjectController mediator = getProjectController();
    for (ObjAttribute attrib : attribs) {
        entity.removeAttribute(attrib.getName());
        AttributeEvent e = new AttributeEvent(Application.getFrame(), attrib, entity, MapEvent.REMOVE);
        mediator.fireObjAttributeEvent(e);
        Collection<ObjEntity> objEntities = ProjectUtil.getCollectionOfChildren((ObjEntity) e.getEntity());
        for (ObjEntity objEntity : objEntities) {
            objEntity.removeAttributeOverride(e.getAttribute().getName());
        }
    }
}
Also used : ObjEntity(org.apache.cayenne.map.ObjEntity) ObjAttribute(org.apache.cayenne.map.ObjAttribute) ProjectController(org.apache.cayenne.modeler.ProjectController) AttributeEvent(org.apache.cayenne.map.event.AttributeEvent) EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent)

Example 48 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class RemoveAttributeAction method removeEmbeddableAttributes.

public void removeEmbeddableAttributes(Embeddable embeddable, EmbeddableAttribute[] attrs) {
    ProjectController mediator = getProjectController();
    for (EmbeddableAttribute attrib : attrs) {
        embeddable.removeAttribute(attrib.getName());
        EmbeddableAttributeEvent e = new EmbeddableAttributeEvent(Application.getFrame(), attrib, embeddable, MapEvent.REMOVE);
        mediator.fireEmbeddableAttributeEvent(e);
    }
}
Also used : EmbeddableAttributeEvent(org.apache.cayenne.map.event.EmbeddableAttributeEvent) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 49 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class RemoveCallbackMethodAction method removeCallbackMethod.

public void removeCallbackMethod(CallbackType callbackType, String method) {
    ProjectController mediator = getProjectController();
    getCallbackMap().getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(method);
    CallbackMethodEvent e = new CallbackMethodEvent(this, null, method, MapEvent.REMOVE);
    mediator.fireCallbackMethodEvent(e);
}
Also used : CallbackMethodEvent(org.apache.cayenne.modeler.event.CallbackMethodEvent) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 50 with ProjectController

use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.

the class RemoveRelationshipAction method removeObjRelationships.

public void removeObjRelationships(ObjEntity entity, ObjRelationship[] rels) {
    ProjectController mediator = getProjectController();
    for (ObjRelationship rel : rels) {
        entity.removeRelationship(rel.getName());
        RelationshipEvent e = new RelationshipEvent(Application.getFrame(), rel, entity, MapEvent.REMOVE);
        mediator.fireObjRelationshipEvent(e);
    }
}
Also used : ObjRelationship(org.apache.cayenne.map.ObjRelationship) ProjectController(org.apache.cayenne.modeler.ProjectController) RelationshipEvent(org.apache.cayenne.map.event.RelationshipEvent)

Aggregations

ProjectController (org.apache.cayenne.modeler.ProjectController)59 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)12 ObjEntity (org.apache.cayenne.map.ObjEntity)10 DbEntity (org.apache.cayenne.map.DbEntity)8 DataMap (org.apache.cayenne.map.DataMap)7 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)6 EntityEvent (org.apache.cayenne.map.event.EntityEvent)6 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)5 ObjAttribute (org.apache.cayenne.map.ObjAttribute)5 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)5 ArrayList (java.util.ArrayList)4 DbAttribute (org.apache.cayenne.map.DbAttribute)4 DbRelationship (org.apache.cayenne.map.DbRelationship)4 Embeddable (org.apache.cayenne.map.Embeddable)4 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)4 ObjRelationship (org.apache.cayenne.map.ObjRelationship)4 RelationshipEvent (org.apache.cayenne.map.event.RelationshipEvent)4 ComponentAdapter (java.awt.event.ComponentAdapter)3 ComponentEvent (java.awt.event.ComponentEvent)3 EntityMergeSupport (org.apache.cayenne.dbsync.merge.context.EntityMergeSupport)3