use of org.apache.cayenne.map.event.AttributeEvent 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.map.event.AttributeEvent 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.map.event.AttributeEvent in project cayenne by apache.
the class CreateAttributeAction method fireObjAttributeEvent.
/**
* Fires events when an obj attribute was added
*/
static void fireObjAttributeEvent(Object src, ProjectController mediator, DataMap map, ObjEntity objEntity, ObjAttribute attr) {
mediator.fireObjAttributeEvent(new AttributeEvent(src, attr, objEntity, MapEvent.ADD));
DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
AttributeDisplayEvent ade = new AttributeDisplayEvent(src, attr, objEntity, map, domain);
mediator.fireObjAttributeDisplayEvent(ade);
}
use of org.apache.cayenne.map.event.AttributeEvent in project cayenne by apache.
the class AttributeEventTest method testAttribute.
@Test
public void testAttribute() throws Exception {
Object src = new Object();
Attribute a = new DbAttribute();
a.setName("xyz");
AttributeEvent e = new AttributeEvent(src, null, null);
e.setAttribute(a);
assertSame(a, e.getAttribute());
}
Aggregations