use of org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit in project cayenne by apache.
the class RemoveAction method removeDbAttributes.
private void removeDbAttributes(ProjectController mediator, ConfirmRemoveDialog dialog, DbAttribute[] dbAttrs) {
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));
for (DbAttribute attrib : dbAttrs) {
entity.removeAttribute(attrib.getName());
AttributeEvent e = new AttributeEvent(Application.getFrame(), attrib, entity, MapEvent.REMOVE);
mediator.fireDbAttributeEvent(e);
}
ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());
}
}
}
use of org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit in project cayenne by apache.
the class RemoveAction method removeObjAttributes.
private void removeObjAttributes(ProjectController mediator, ConfirmRemoveDialog dialog, ObjAttribute[] objAttrs) {
if (objAttrs != null && objAttrs.length > 0) {
if ((objAttrs.length == 1 && dialog.shouldDelete("DbAttribute", objAttrs[0].getName())) || (objAttrs.length > 1 && dialog.shouldDelete("selected DbAttributes"))) {
ObjEntity entity = mediator.getCurrentObjEntity();
application.getUndoManager().addEdit(new RemoveAttributeUndoableEdit(entity, objAttrs));
for (ObjAttribute attrib : objAttrs) {
entity.removeAttribute(attrib.getName());
AttributeEvent e = new AttributeEvent(Application.getFrame(), attrib, entity, MapEvent.REMOVE);
mediator.fireObjAttributeEvent(e);
}
ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());
}
}
}
use of org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit in project cayenne by apache.
the class RemoveAction method removeEmbAttributes.
private void removeEmbAttributes(ProjectController mediator, ConfirmRemoveDialog dialog, EmbeddableAttribute[] embAttrs) {
if (embAttrs != null && embAttrs.length > 0) {
if ((embAttrs.length == 1 && dialog.shouldDelete("DbAttribute", embAttrs[0].getName())) || (embAttrs.length > 1 && dialog.shouldDelete("selected DbAttributes"))) {
Embeddable embeddable = mediator.getCurrentEmbeddable();
application.getUndoManager().addEdit(new RemoveAttributeUndoableEdit(embeddable, embAttrs));
for (EmbeddableAttribute attrib : embAttrs) {
embeddable.removeAttribute(attrib.getName());
EmbeddableAttributeEvent e = new EmbeddableAttributeEvent(Application.getFrame(), attrib, embeddable, MapEvent.REMOVE);
mediator.fireEmbeddableAttributeEvent(e);
}
ProjectUtil.cleanObjMappings(mediator.getCurrentDataMap());
}
}
}
use of org.apache.cayenne.modeler.undo.RemoveAttributeUndoableEdit 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);
}
}
}
Aggregations