use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.
the class CreateQueryAction method fireQueryEvent.
/**
* Fires events when a query was added
*/
public static void fireQueryEvent(Object src, ProjectController mediator, DataChannelDescriptor domain, DataMap dataMap, QueryDescriptor query) {
mediator.fireQueryEvent(new QueryEvent(src, query, MapEvent.ADD, dataMap));
mediator.fireQueryDisplayEvent(new QueryDisplayEvent(src, query, dataMap, domain));
}
use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.
the class RemoveAction method removeQuery.
/**
* Removes current Query from its DataMap and fires "remove" QueryEvent.
*/
public void removeQuery(DataMap map, QueryDescriptor query) {
ProjectController mediator = getProjectController();
QueryEvent e = new QueryEvent(Application.getFrame(), query, MapEvent.REMOVE, map);
e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode());
map.removeQueryDescriptor(query.getName());
mediator.fireQueryEvent(e);
}
use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.
the class ProcedureQueryView method setQueryName.
/**
* Initializes Query name from string.
*/
void setQueryName(String newName) {
if (newName != null && newName.trim().length() == 0) {
newName = null;
}
QueryDescriptor query = mediator.getCurrentQuery();
if (query == null) {
return;
}
if (Util.nullSafeEquals(newName, query.getName())) {
return;
}
if (newName == null) {
throw new ValidationException("Query name is required.");
}
DataMap map = mediator.getCurrentDataMap();
if (map.getQueryDescriptor(newName) == null) {
// completely new name, set new name for entity
QueryEvent e = new QueryEvent(this, query, query.getName(), map);
ProjectUtil.setQueryName(map, query, newName);
mediator.fireQueryEvent(e);
} else {
// there is a query with the same name
throw new ValidationException("There is another query named '" + newName + "'. Use a different name.");
}
}
use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.
the class ProcedureQueryView method setEntity.
void setEntity(ObjEntity entity) {
QueryDescriptor query = mediator.getCurrentQuery();
if (query != null && QueryDescriptor.PROCEDURE_QUERY.equals(query.getType())) {
((ProcedureQueryDescriptor) query).setResultEntityName(entity != null ? entity.getName() : null);
mediator.fireQueryEvent(new QueryEvent(this, query));
}
}
use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.
the class SQLTemplateMainTab method setQueryComment.
private void setQueryComment(String text) {
QueryDescriptor query = getQuery();
if (query == null) {
return;
}
ObjectInfo.putToMetaData(mediator.getApplication().getMetaData(), query, ObjectInfo.COMMENT, text);
mediator.fireQueryEvent(new QueryEvent(this, query));
}
Aggregations