use of org.apache.cayenne.configuration.event.DataMapEvent in project cayenne by apache.
the class DataMapView method setDataMapName.
void setDataMapName(String newName) {
if (newName == null || newName.trim().length() == 0) {
throw new ValidationException("Enter name for DataMap");
}
DataMap map = eventController.getCurrentDataMap();
// search for matching map name across domains, as currently they have to be
// unique globally
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
DataMap matchingMap = dataChannelDescriptor.getDataMap(newName);
if (matchingMap != null && !matchingMap.equals(map)) {
// there is an entity with the same name
throw new ValidationException("There is another DataMap named '" + newName + "'. Use a different name.");
}
String oldName = map.getName();
if (Util.nullSafeEquals(newName, oldName)) {
return;
}
// completely new name, set new name for domain
DataMapDefaults pref = eventController.getDataMapPreferences("");
DataMapEvent e = new DataMapEvent(this, map, map.getName());
ProjectUtil.setDataMapName((DataChannelDescriptor) eventController.getProject().getRootNode(), map, newName);
pref.copyPreferences(newName);
eventController.fireDataMapEvent(e);
}
use of org.apache.cayenne.configuration.event.DataMapEvent in project cayenne by apache.
the class DataMapView method updateComment.
void updateComment(String comment) {
DataMap dataMap = eventController.getCurrentDataMap();
if (dataMap == null) {
return;
}
ObjectInfo.putToMetaData(eventController.getApplication().getMetaData(), dataMap, ObjectInfo.COMMENT, comment);
eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
use of org.apache.cayenne.configuration.event.DataMapEvent in project cayenne by apache.
the class DataMapView method setClientSupport.
void setClientSupport(boolean flag) {
DataMap dataMap = eventController.getCurrentDataMap();
if (dataMap == null) {
return;
}
if (dataMap.isClientSupported() != flag) {
dataMap.setClientSupported(flag);
toggleClientProperties(flag);
eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
}
use of org.apache.cayenne.configuration.event.DataMapEvent in project cayenne by apache.
the class DataMapView method setDefaultSchema.
void setDefaultSchema(String newSchema) {
DataMap dataMap = eventController.getCurrentDataMap();
if (dataMap == null) {
return;
}
if (newSchema != null && newSchema.trim().length() == 0) {
newSchema = null;
}
String oldSchema = dataMap.getDefaultSchema();
if (Util.nullSafeEquals(newSchema, oldSchema)) {
return;
}
dataMap.setDefaultSchema(newSchema);
eventController.fireDataMapEvent(new DataMapEvent(this, dataMap));
}
use of org.apache.cayenne.configuration.event.DataMapEvent in project cayenne by apache.
the class ProjectController method removeFromHistory.
private void removeFromHistory(EventObject e) {
int count = controllerStateHistory.size();
List<ControllerState> removeList = new ArrayList<>();
for (int i = 0; i < count; i++) {
ControllerState cs = controllerStateHistory.get(i);
if (cs == null || cs.event == null) {
continue;
}
EventObject csEvent = cs.event;
if (e instanceof EntityEvent && csEvent instanceof EntityDisplayEvent) {
if (((EntityEvent) e).getEntity() == ((EntityDisplayEvent) csEvent).getEntity()) {
removeList.add(cs);
}
} else if (e instanceof EmbeddableEvent && csEvent instanceof EmbeddableDisplayEvent) {
if (((EmbeddableEvent) e).getEmbeddable() == ((EmbeddableDisplayEvent) csEvent).getEmbeddable()) {
removeList.add(cs);
}
} else if (e instanceof ProcedureEvent && csEvent instanceof ProcedureDisplayEvent) {
if (((ProcedureEvent) e).getProcedure() == ((ProcedureDisplayEvent) csEvent).getProcedure()) {
removeList.add(cs);
}
} else if (e instanceof QueryEvent && csEvent instanceof QueryDisplayEvent) {
if (((QueryEvent) e).getQuery() == ((QueryDisplayEvent) csEvent).getQuery()) {
removeList.add(cs);
}
} else if (e instanceof DataMapEvent && csEvent instanceof DataMapDisplayEvent) {
if (((DataMapEvent) e).getDataMap() == ((DataMapDisplayEvent) csEvent).getDataMap()) {
removeList.add(cs);
}
} else if (e instanceof DataNodeEvent && csEvent instanceof DataNodeDisplayEvent) {
if (((DataNodeEvent) e).getDataNode() == ((DataNodeDisplayEvent) csEvent).getDataNode()) {
removeList.add(cs);
}
} else if (e instanceof DomainEvent && csEvent instanceof DomainDisplayEvent) {
if (((DomainEvent) e).getDomain() == ((DomainDisplayEvent) csEvent).getDomain()) {
removeList.add(cs);
}
}
}
for (ControllerState o : removeList) {
controllerStateHistory.remove(o);
}
}
Aggregations