Search in sources :

Example 11 with QueryEvent

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));
}
Also used : QueryDisplayEvent(org.apache.cayenne.modeler.event.QueryDisplayEvent) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 12 with QueryEvent

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);
}
Also used : QueryEvent(org.apache.cayenne.configuration.event.QueryEvent) ProjectController(org.apache.cayenne.modeler.ProjectController)

Example 13 with QueryEvent

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.");
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) ValidationException(org.apache.cayenne.validation.ValidationException) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent) DataMap(org.apache.cayenne.map.DataMap)

Example 14 with QueryEvent

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));
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) ProcedureQueryDescriptor(org.apache.cayenne.map.ProcedureQueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 15 with QueryEvent

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));
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Aggregations

QueryEvent (org.apache.cayenne.configuration.event.QueryEvent)25 QueryDescriptor (org.apache.cayenne.map.QueryDescriptor)12 ProcedureQueryDescriptor (org.apache.cayenne.map.ProcedureQueryDescriptor)4 ValidationException (org.apache.cayenne.validation.ValidationException)4 DataMap (org.apache.cayenne.map.DataMap)3 QueryDisplayEvent (org.apache.cayenne.modeler.event.QueryDisplayEvent)3 ArrayList (java.util.ArrayList)2 DataChannelDescriptor (org.apache.cayenne.configuration.DataChannelDescriptor)2 EntityEvent (org.apache.cayenne.map.event.EntityEvent)2 ProjectController (org.apache.cayenne.modeler.ProjectController)2 Ordering (org.apache.cayenne.query.Ordering)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 EventObject (java.util.EventObject)1 BadLocationException (javax.swing.text.BadLocationException)1 Document (javax.swing.text.Document)1 ConfigurationNode (org.apache.cayenne.configuration.ConfigurationNode)1 DataMapEvent (org.apache.cayenne.configuration.event.DataMapEvent)1 DataNodeEvent (org.apache.cayenne.configuration.event.DataNodeEvent)1 DomainEvent (org.apache.cayenne.configuration.event.DomainEvent)1