use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class ProcedureQueryView method setQueryComment.
private void setQueryComment(String text) {
QueryDescriptor query = mediator.getCurrentQuery();
if (query == null) {
return;
}
ObjectInfo.putToMetaData(mediator.getApplication().getMetaData(), query, ObjectInfo.COMMENT, text);
mediator.fireQueryEvent(new QueryEvent(this, query));
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class ProcedureQueryView method initFromModel.
/**
* Updates the view from the current model state. Invoked when a currently displayed
* query is changed.
*/
void initFromModel() {
QueryDescriptor query = mediator.getCurrentQuery();
if (query == null || !QueryDescriptor.PROCEDURE_QUERY.equals(query.getType())) {
setVisible(false);
return;
}
properties.setEnabled(true);
name.setText(query.getName());
comment.setText(getQueryComment(query));
// init root choices and title label..
// - ProcedureQuery supports Procedure roots
// TODO: now we only allow roots from the current map,
// since query root is fully resolved during map loading,
// making it impossible to reference other DataMaps.
DataMap map = mediator.getCurrentDataMap();
Procedure[] roots = map.getProcedures().toArray(new Procedure[0]);
if (roots.length > 1) {
Arrays.sort(roots, Comparators.getDataMapChildrenComparator());
}
DefaultComboBoxModel<Procedure> model = new DefaultComboBoxModel<>(roots);
model.setSelectedItem(query.getRoot());
queryRoot.setModel(model);
properties.initFromModel(query);
setVisible(true);
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class ProcedureQueryView method initController.
private void initController() {
queryRoot.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
QueryDescriptor query = mediator.getCurrentQuery();
if (query != null) {
query.setRoot(queryRoot.getModel().getSelectedItem());
mediator.fireQueryEvent(new QueryEvent(this, query));
}
}
});
mediator.addQueryDisplayListener(new QueryDisplayListener() {
public void currentQueryChanged(QueryDisplayEvent e) {
initFromModel();
}
});
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class SelectPropertiesPanel method setQueryProperty.
void setQueryProperty(String property, String value) {
QueryDescriptor query = getQuery();
if (query != null) {
try {
Object old = query.getProperty(property);
if (Util.nullSafeEquals(value, old)) {
return;
}
query.setProperty(property, value);
mediator.fireQueryEvent(new QueryEvent(this, query));
} catch (Exception ex) {
logObj.warn("Error setting property: " + property, ex);
}
}
}
use of org.apache.cayenne.map.QueryDescriptor in project cayenne by apache.
the class SelectQueryOrderingTab method initFromModel.
protected void initFromModel() {
QueryDescriptor query = mediator.getCurrentQuery();
if (query == null || !QueryDescriptor.SELECT_QUERY.equals(query.getType())) {
processInvalidModel("Unknown query.");
return;
}
if (!(query.getRoot() instanceof Entity)) {
processInvalidModel("SelectQuery has no root set.");
return;
}
this.selectQuery = (SelectQueryDescriptor) query;
browser.setModel(createBrowserModel((Entity) selectQuery.getRoot()));
table.setModel(createTableModel());
// init column sizes
table.getColumnModel().getColumn(0).setPreferredWidth(250);
cardLayout.show(this, REAL_PANEL);
}
Aggregations