use of org.apache.cayenne.map.event.EmbeddableEvent 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);
}
}
use of org.apache.cayenne.map.event.EmbeddableEvent in project cayenne by apache.
the class CreateEmbeddableAction method fireEmbeddableEvent.
static void fireEmbeddableEvent(Object src, ProjectController mediator, DataMap dataMap, Embeddable embeddable) {
mediator.fireEmbeddableEvent(new EmbeddableEvent(src, embeddable, MapEvent.ADD), dataMap);
EmbeddableDisplayEvent displayEvent = new EmbeddableDisplayEvent(src, embeddable, dataMap, (DataChannelDescriptor) mediator.getProject().getRootNode());
displayEvent.setMainTabFocus(true);
mediator.fireEmbeddableDisplayEvent(displayEvent);
}
use of org.apache.cayenne.map.event.EmbeddableEvent in project cayenne by apache.
the class EmbeddableTab method setComment.
void setComment(String comment) {
Embeddable embeddable = mediator.getCurrentEmbeddable();
if (embeddable == null) {
return;
}
ObjectInfo.putToMetaData(mediator.getApplication().getMetaData(), embeddable, ObjectInfo.COMMENT, comment);
mediator.fireEmbeddableEvent(new EmbeddableEvent(this, embeddable), mediator.getCurrentDataMap());
}
use of org.apache.cayenne.map.event.EmbeddableEvent in project cayenne by apache.
the class PackageUpdateController method updatePackage.
protected void updatePackage() {
boolean doAll = isAllEntities();
Map<String, String> oldNameEmbeddableToNewName = new HashMap<>();
// Create local copy to escape ConcurrentModificationException
Collection<Embeddable> embeddables = new ArrayList<>(dataMap.getEmbeddables());
for (Embeddable embeddable : embeddables) {
String oldName = embeddable.getClassName();
String[] tokens = oldName.split("\\.");
String className = tokens[tokens.length - 1];
if (doAll || Util.isEmptyString(oldName) || oldName.indexOf('.') < 0) {
EmbeddableEvent e = new EmbeddableEvent(this, embeddable, embeddable.getClassName());
String newClassName = getNameWithDefaultPackage(className);
oldNameEmbeddableToNewName.put(oldName, newClassName);
embeddable.setClassName(newClassName);
mediator.fireEmbeddableEvent(e, mediator.getCurrentDataMap());
}
}
for (ObjEntity entity : dataMap.getObjEntities()) {
String oldName = getClassName(entity);
if (doAll || Util.isEmptyString(oldName) || oldName.indexOf('.') < 0) {
String className = extractClassName(Util.isEmptyString(oldName) ? entity.getName() : oldName);
setClassName(entity, getNameWithDefaultPackage(className));
}
for (ObjAttribute attribute : entity.getAttributes()) {
if (attribute instanceof EmbeddedAttribute) {
if (oldNameEmbeddableToNewName.size() > 0 && oldNameEmbeddableToNewName.containsKey(attribute.getType())) {
attribute.setType(oldNameEmbeddableToNewName.get(attribute.getType()));
AttributeEvent ev = new AttributeEvent(this, attribute, entity);
mediator.fireObjAttributeEvent(ev);
}
}
}
}
view.dispose();
}
use of org.apache.cayenne.map.event.EmbeddableEvent in project cayenne by apache.
the class RemoveAction method removeEmbeddable.
public void removeEmbeddable(DataMap map, Embeddable embeddable) {
ProjectController mediator = getProjectController();
EmbeddableEvent e = new EmbeddableEvent(Application.getFrame(), embeddable, MapEvent.REMOVE);
e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
map.removeEmbeddable(embeddable.getClassName());
mediator.fireEmbeddableEvent(e, map);
}
Aggregations