Search in sources :

Example 16 with QueryEvent

use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.

the class SQLTemplateMainTab method setEntity.

void setEntity(ObjEntity entity) {
    QueryDescriptor template = getQuery();
    if (template != null) {
        // in case of null entity, set root to DataMap
        Object root = entity != null ? entity : mediator.getCurrentDataMap();
        template.setRoot(root);
        mediator.fireQueryEvent(new QueryEvent(this, template));
    }
}
Also used : QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 17 with QueryEvent

use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.

the class SelectQueryMainTab 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 : SelectQueryDescriptor(org.apache.cayenne.map.SelectQueryDescriptor) QueryDescriptor(org.apache.cayenne.map.QueryDescriptor) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 18 with QueryEvent

use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.

the class SelectQueryMainTab method setQueryQualifier.

/**
 * Initializes Query qualifier from string.
 */
void setQueryQualifier(String text) {
    if (text != null && text.trim().length() == 0) {
        text = null;
    }
    Expression qualifier = createQualifier(text);
    // getQuery() is not null if we reached here
    getQuery().setQualifier((qualifier));
    mediator.fireQueryEvent(new QueryEvent(this, getQuery()));
}
Also used : Expression(org.apache.cayenne.exp.Expression) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 19 with QueryEvent

use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.

the class SelectQueryOrderingTab method removeOrdering.

void removeOrdering() {
    int selection = table.getSelectedRow();
    if (selection < 0) {
        return;
    }
    OrderingModel model = (OrderingModel) table.getModel();
    Ordering ordering = model.getOrdering(selection);
    selectQuery.removeOrdering(ordering);
    model.fireTableRowsDeleted(selection, selection);
    mediator.fireQueryEvent(new QueryEvent(SelectQueryOrderingTab.this, selectQuery));
}
Also used : Ordering(org.apache.cayenne.query.Ordering) QueryEvent(org.apache.cayenne.configuration.event.QueryEvent)

Example 20 with QueryEvent

use of org.apache.cayenne.configuration.event.QueryEvent in project cayenne by apache.

the class SelectQueryOrderingTab method addOrdering.

void addOrdering() {
    String orderingPath = getSelectedPath();
    if (orderingPath == null) {
        return;
    }
    // check if such ordering already exists
    for (Ordering ord : selectQuery.getOrderings()) {
        if (orderingPath.equals(ord.getSortSpecString())) {
            return;
        }
    }
    selectQuery.addOrdering(new Ordering(orderingPath, SortOrder.ASCENDING));
    int index = selectQuery.getOrderings().size() - 1;
    OrderingModel model = (OrderingModel) table.getModel();
    model.fireTableRowsInserted(index, index);
    mediator.fireQueryEvent(new QueryEvent(SelectQueryOrderingTab.this, selectQuery));
}
Also used : Ordering(org.apache.cayenne.query.Ordering) 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