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);
}
}
}
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());
}
}
}
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);
}
}
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);
}
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);
}
}
Aggregations