use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.
the class CreateProcedureAction method fireProcedureEvent.
/**
* Fires events when a procedure was added
*/
static void fireProcedureEvent(Object src, ProjectController mediator, DataMap dataMap, Procedure procedure) {
mediator.fireProcedureEvent(new ProcedureEvent(src, procedure, MapEvent.ADD));
mediator.fireProcedureDisplayEvent(new ProcedureDisplayEvent(src, procedure, mediator.getCurrentDataMap(), (DataChannelDescriptor) mediator.getProject().getRootNode()));
}
use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.
the class CatalogUpdateController method updateCatalog.
protected void updateCatalog() {
boolean doAll = isAllEntities();
String defaultCatalog = dataMap.getDefaultCatalog();
// set catalog for DbEntities
for (DbEntity entity : dataMap.getDbEntities()) {
if (doAll || Util.isEmptyString(entity.getCatalog())) {
if (!Util.nullSafeEquals(defaultCatalog, entity.getCatalog())) {
entity.setCatalog(defaultCatalog);
// any way to batch events, a big change will flood the app
// with entity events..?
mediator.fireDbEntityEvent(new EntityEvent(this, entity));
}
}
}
// set catalog for procedures...
for (Procedure procedure : dataMap.getProcedures()) {
if (doAll || Util.isEmptyString(procedure.getCatalog())) {
if (!Util.nullSafeEquals(defaultCatalog, procedure.getCatalog())) {
procedure.setCatalog(defaultCatalog);
// 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.configuration.event.ProcedureEvent 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.configuration.event.ProcedureEvent in project cayenne by apache.
the class ProcedureTab method setComment.
void setComment(String comment) {
Procedure procedure = eventController.getCurrentProcedure();
if (procedure == null) {
return;
}
ObjectInfo.putToMetaData(eventController.getApplication().getMetaData(), procedure, ObjectInfo.COMMENT, comment);
eventController.fireProcedureEvent(new ProcedureEvent(this, procedure));
}
use of org.apache.cayenne.configuration.event.ProcedureEvent in project cayenne by apache.
the class ProcedureTab method setCatalog.
void setCatalog(String text) {
if (text != null && text.trim().length() == 0) {
text = null;
}
Procedure procedure = eventController.getCurrentProcedure();
if (procedure != null && !Util.nullSafeEquals(procedure.getCatalog(), text)) {
procedure.setCatalog(text);
eventController.fireProcedureEvent(new ProcedureEvent(this, procedure));
}
}
Aggregations