if (Util.nullSafeEquals(newName, entity.getName())) {
return;
}
if (newName == null) {
throw new ValidationException("Entity name is required.");
}
else if (entity.getDataMap().getObjEntity(newName) == null) {
// completely new name, set new name for entity
EntityEvent e = new EntityEvent(this, entity, entity.getName());
entity.setName(newName);
mediator.fireObjEntityEvent(e);
// suggest to update class name
ClassNameUpdater nameUpdater = new ClassNameUpdater(Application
.getInstance()
.getFrameController(), entity);
if (nameUpdater.doNameUpdate()) {
className.setText(entity.getClassName());
clientClassName.setText(entity.getClientClassName());
}
}
else {
// there is an entity with the same name
throw new ValidationException("There is another entity with name '"
+ newName
+ "'.");
}
}