Search in sources :

Example 1 with RemoveAttributeAction

use of org.apache.cayenne.modeler.action.RemoveAttributeAction in project cayenne by apache.

the class CreateAttributeUndoableEdit method undo.

@Override
public void undo() throws CannotUndoException {
    RemoveAttributeAction action = actionManager.getAction(RemoveAttributeAction.class);
    if (objEntity != null) {
        action.removeObjAttributes(objEntity, new ObjAttribute[] { objAttr });
        controller.fireObjEntityDisplayEvent(new EntityDisplayEvent(this, objEntity, dataMap, domain));
    }
    if (dbEntity != null) {
        action.removeDbAttributes(dataMap, dbEntity, new DbAttribute[] { dbAttr });
        controller.fireDbEntityDisplayEvent(new EntityDisplayEvent(this, dbEntity, dataMap, domain));
    }
}
Also used : EntityDisplayEvent(org.apache.cayenne.modeler.event.EntityDisplayEvent) RemoveAttributeAction(org.apache.cayenne.modeler.action.RemoveAttributeAction)

Example 2 with RemoveAttributeAction

use of org.apache.cayenne.modeler.action.RemoveAttributeAction in project cayenne by apache.

the class CreateEmbAttributeUndoableEdit method undo.

@Override
public void undo() throws CannotUndoException {
    RemoveAttributeAction action = actionManager.getAction(RemoveAttributeAction.class);
    action.removeEmbeddableAttributes(embeddable, attrs);
}
Also used : RemoveAttributeAction(org.apache.cayenne.modeler.action.RemoveAttributeAction)

Example 3 with RemoveAttributeAction

use of org.apache.cayenne.modeler.action.RemoveAttributeAction in project cayenne by apache.

the class PasteUndoableEdit method undo.

@Override
public void undo() throws CannotUndoException {
    RemoveAttributeAction rAttributeAction = actionManager.getAction(RemoveAttributeAction.class);
    RemoveAction rAction = actionManager.getAction(RemoveAction.class);
    RemoveRelationshipAction rRelationShipAction = actionManager.getAction(RemoveRelationshipAction.class);
    RemoveCallbackMethodAction rCallbackMethodAction = actionManager.getAction(RemoveCallbackMethodAction.class);
    RemoveProcedureParameterAction rProcedureParamAction = actionManager.getAction(RemoveProcedureParameterAction.class);
    if (content instanceof DataMap) {
        if (where instanceof DataChannelDescriptor) {
            rAction.removeDataMap((DataMap) content);
        } else if (where instanceof DataNodeDescriptor) {
            rAction.removeDataMapFromDataNode((DataNodeDescriptor) where, (DataMap) content);
        }
    } else if (where instanceof DataMap) {
        if (content instanceof DbEntity) {
            rAction.removeDbEntity(map, (DbEntity) content);
        } else if (content instanceof ObjEntity) {
            rAction.removeObjEntity(map, (ObjEntity) content);
        } else if (content instanceof Embeddable) {
            rAction.removeEmbeddable(map, (Embeddable) content);
        } else if (content instanceof QueryDescriptor) {
            rAction.removeQuery(map, (QueryDescriptor) content);
        } else if (content instanceof Procedure) {
            rAction.removeProcedure(map, (Procedure) content);
        }
    } else if (where instanceof DbEntity) {
        if (content instanceof DbEntity) {
            rAction.removeDbEntity(map, (DbEntity) content);
        } else if (content instanceof DbAttribute) {
            rAttributeAction.removeDbAttributes(map, (DbEntity) where, new DbAttribute[] { (DbAttribute) content });
        } else if (content instanceof DbRelationship) {
            rRelationShipAction.removeDbRelationships((DbEntity) where, new DbRelationship[] { (DbRelationship) content });
        }
    } else if (where instanceof ObjEntity) {
        if (content instanceof ObjEntity) {
            rAction.removeObjEntity(map, (ObjEntity) content);
        } else if (content instanceof ObjAttribute) {
            rAttributeAction.removeObjAttributes((ObjEntity) where, new ObjAttribute[] { (ObjAttribute) content });
        } else if (content instanceof ObjRelationship) {
            rRelationShipAction.removeObjRelationships((ObjEntity) where, new ObjRelationship[] { (ObjRelationship) content });
        } else if (content instanceof ObjCallbackMethod) {
            ObjCallbackMethod[] methods = new ObjCallbackMethod[] { (ObjCallbackMethod) content };
            for (ObjCallbackMethod callbackMethod : methods) {
                rCallbackMethodAction.removeCallbackMethod(methods[0].getCallbackType(), callbackMethod.getName());
            }
        }
    } else if (where instanceof Procedure) {
        final Procedure procedure = (Procedure) where;
        if (content instanceof ProcedureParameter) {
            rProcedureParamAction.removeProcedureParameters(procedure, new ProcedureParameter[] { (ProcedureParameter) content });
        }
    } else if (where instanceof Embeddable) {
        if (content instanceof Embeddable) {
            rAction.removeEmbeddable(map, (Embeddable) content);
        } else if (content instanceof EmbeddableAttribute) {
            rAttributeAction.removeEmbeddableAttributes((Embeddable) where, new EmbeddableAttribute[] { (EmbeddableAttribute) content });
        }
    }
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) DataChannelDescriptor(org.apache.cayenne.configuration.DataChannelDescriptor) ObjRelationship(org.apache.cayenne.map.ObjRelationship) ObjAttribute(org.apache.cayenne.map.ObjAttribute) DbAttribute(org.apache.cayenne.map.DbAttribute) DataNodeDescriptor(org.apache.cayenne.configuration.DataNodeDescriptor) DataMap(org.apache.cayenne.map.DataMap) Embeddable(org.apache.cayenne.map.Embeddable) RemoveProcedureParameterAction(org.apache.cayenne.modeler.action.RemoveProcedureParameterAction) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ObjEntity(org.apache.cayenne.map.ObjEntity) DbEntity(org.apache.cayenne.map.DbEntity) DbRelationship(org.apache.cayenne.map.DbRelationship) RemoveCallbackMethodAction(org.apache.cayenne.modeler.action.RemoveCallbackMethodAction) Procedure(org.apache.cayenne.map.Procedure) RemoveRelationshipAction(org.apache.cayenne.modeler.action.RemoveRelationshipAction) EmbeddableAttribute(org.apache.cayenne.map.EmbeddableAttribute) RemoveAction(org.apache.cayenne.modeler.action.RemoveAction) ObjCallbackMethod(org.apache.cayenne.modeler.editor.ObjCallbackMethod) RemoveAttributeAction(org.apache.cayenne.modeler.action.RemoveAttributeAction)

Example 4 with RemoveAttributeAction

use of org.apache.cayenne.modeler.action.RemoveAttributeAction in project cayenne by apache.

the class RemoveAttributeUndoableEdit method redo.

@Override
public void redo() throws CannotRedoException {
    RemoveAttributeAction action = actionManager.getAction(RemoveAttributeAction.class);
    if (objEntity != null) {
        action.removeObjAttributes(objEntity, objAttributes);
        focusObjEntity();
    }
    if (dbEntity != null) {
        action.removeDbAttributes(dbEntity.getDataMap(), dbEntity, dbAttributes);
        focusDBEntity();
    }
    if (embeddable != null) {
        action.removeEmbeddableAttributes(embeddable, embeddableAttrs);
        focusEmbeddable();
    }
}
Also used : RemoveAttributeAction(org.apache.cayenne.modeler.action.RemoveAttributeAction)

Aggregations

RemoveAttributeAction (org.apache.cayenne.modeler.action.RemoveAttributeAction)4 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)1 DataNodeDescriptor (org.apache.cayenne.configuration.DataNodeDescriptor)1 DataMap (org.apache.cayenne.map.DataMap)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 DbEntity (org.apache.cayenne.map.DbEntity)1 DbRelationship (org.apache.cayenne.map.DbRelationship)1 Embeddable (org.apache.cayenne.map.Embeddable)1 EmbeddableAttribute (org.apache.cayenne.map.EmbeddableAttribute)1 ObjAttribute (org.apache.cayenne.map.ObjAttribute)1 ObjEntity (org.apache.cayenne.map.ObjEntity)1 ObjRelationship (org.apache.cayenne.map.ObjRelationship)1 Procedure (org.apache.cayenne.map.Procedure)1 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)1 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)1 RemoveAction (org.apache.cayenne.modeler.action.RemoveAction)1 RemoveCallbackMethodAction (org.apache.cayenne.modeler.action.RemoveCallbackMethodAction)1 RemoveProcedureParameterAction (org.apache.cayenne.modeler.action.RemoveProcedureParameterAction)1 RemoveRelationshipAction (org.apache.cayenne.modeler.action.RemoveRelationshipAction)1 ObjCallbackMethod (org.apache.cayenne.modeler.editor.ObjCallbackMethod)1