use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class ObjEntityTab method setQualifier.
void setQualifier(String text) {
if (text != null && text.trim().length() == 0) {
text = null;
}
ObjEntity entity = mediator.getCurrentObjEntity();
if (entity != null) {
ExpressionConvertor convertor = new ExpressionConvertor();
try {
String oldQualifier = convertor.valueAsString(entity.getDeclaredQualifier());
if (!Util.nullSafeEquals(oldQualifier, text)) {
Expression exp = (Expression) convertor.stringAsValue(text);
entity.setDeclaredQualifier(exp);
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
} catch (IllegalArgumentException ex) {
// unparsable qualifier
throw new ValidationException(ex.getMessage());
}
}
}
use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class ObjEntityTab method setClassName.
void setClassName(String className) {
if (className != null && className.trim().length() == 0) {
className = null;
}
ObjEntity entity = mediator.getCurrentObjEntity();
// "ent" may be null if we quit editing by changing tree selection
if (entity != null && !Util.nullSafeEquals(entity.getClassName(), className)) {
entity.setClassName(className);
mediator.fireObjEntityEvent(new EntityEvent(this, entity));
}
}
use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class LockingUpdateController method updateAction.
public void updateAction() {
int defaultLockType = dataMap.getDefaultLockType();
boolean on = defaultLockType == ObjEntity.LOCK_TYPE_OPTIMISTIC;
boolean updateEntities = view.getEntities().isSelected();
boolean updateAttributes = view.getAttributes().isSelected();
boolean updateRelationships = view.getRelationships().isSelected();
ProjectController parent = (ProjectController) getParent();
for (ObjEntity entity : dataMap.getObjEntities()) {
if (updateEntities && defaultLockType != entity.getDeclaredLockType()) {
entity.setDeclaredLockType(defaultLockType);
parent.fireObjEntityEvent(new EntityEvent(this, entity));
}
if (updateAttributes) {
for (ObjAttribute a : entity.getAttributes()) {
if (a.isUsedForLocking() != on) {
a.setUsedForLocking(on);
parent.fireObjAttributeEvent(new AttributeEvent(this, a, entity));
}
}
}
if (updateRelationships) {
for (ObjRelationship r : entity.getRelationships()) {
if (r.isUsedForLocking() != on) {
r.setUsedForLocking(on);
parent.fireObjRelationshipEvent(new RelationshipEvent(this, r, entity));
}
}
}
}
if (view != null) {
view.dispose();
}
}
use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class SchemaUpdateController method updateSchema.
protected void updateSchema() {
boolean doAll = isAllEntities();
String defaultSchema = dataMap.getDefaultSchema();
// set schema for DbEntities
for (DbEntity entity : dataMap.getDbEntities()) {
if (doAll || Util.isEmptyString(entity.getSchema())) {
if (!Util.nullSafeEquals(defaultSchema, entity.getSchema())) {
entity.setSchema(defaultSchema);
// any way to batch events, a big change will flood the app with
// entity events..?
mediator.fireDbEntityEvent(new EntityEvent(this, entity));
}
}
}
// set schema for procedures...
for (Procedure procedure : dataMap.getProcedures()) {
if (doAll || Util.isEmptyString(procedure.getSchema())) {
if (!Util.nullSafeEquals(defaultSchema, procedure.getSchema())) {
procedure.setSchema(defaultSchema);
// any way to batch events, a big change will flood the app with
// procedure events..?
mediator.fireProcedureEvent(new ProcedureEvent(this, procedure));
}
}
}
view.dispose();
}
use of org.apache.cayenne.map.event.EntityEvent in project cayenne by apache.
the class ObjAttributeInfoDialog method changeAttributeObject.
private void changeAttributeObject() {
if (attributeSaved instanceof EmbeddedAttribute && embeddableModel.isAttributeOverrideChange()) {
Map<String, String> overrides = ((EmbeddedAttribute) attributeSaved).getAttributeOverrides();
Map<String, String> currentOverrAttr = getCurrentOverrideAttribute();
compareAndSetOverrideInEmbeddedAttribute(attributeSaved, overrides, currentOverrAttr);
}
if (attributeSaved instanceof EmbeddedAttribute) {
attributeSaved.setDbAttributePath(null);
model.setUpdatedValueAt(attributeSaved.getDbAttributePath(), row, 3);
}
model.getEntity().removeAttribute(attribute.getName());
model.getEntity().addAttribute(attributeSaved);
mediator.fireObjEntityEvent(new EntityEvent(this, model.getEntity(), MapEvent.CHANGE));
EntityDisplayEvent event = new EntityDisplayEvent(this, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireObjEntityDisplayEvent(event);
mediator.fireObjAttributeEvent(new AttributeEvent(this, attributeSaved, model.getEntity(), MapEvent.CHANGE));
AttributeDisplayEvent eventAttr = new AttributeDisplayEvent(this, attributeSaved, mediator.getCurrentObjEntity(), mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode());
mediator.fireObjAttributeDisplayEvent(eventAttr);
}
Aggregations