use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.
the class ResultSetFilterPanel method setCustomDataFilter.
private void setCustomDataFilter() {
DBCExecutionContext context = viewer.getExecutionContext();
if (context == null) {
return;
}
String condition = filtersText.getText();
StringBuilder currentCondition = new StringBuilder();
SQLUtils.appendConditionString(viewer.getModel().getDataFilter(), context.getDataSource(), null, currentCondition, true);
if (currentCondition.toString().trim().equals(condition.trim())) {
// The same
return;
}
DBDDataFilter newFilter = new DBDDataFilter(viewer.getModel().getDataFilter());
for (DBDAttributeConstraint ac : newFilter.getConstraints()) {
ac.setCriteria(null);
}
newFilter.setWhere(condition);
viewer.setDataFilter(newFilter, true);
// viewer.getControl().setFocus();
}
use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.
the class FilterByAttributeAction method run.
@Override
public void run() {
Object value = type.getValue(resultSetViewer, attribute, operator, false);
if (operator.getArgumentCount() != 0 && value == null) {
return;
}
DBDDataFilter filter = new DBDDataFilter(resultSetViewer.getModel().getDataFilter());
DBDAttributeConstraint constraint = filter.getConstraint(attribute);
if (constraint != null) {
constraint.setOperator(operator);
constraint.setValue(value);
resultSetViewer.setDataFilter(filter, true);
}
}
use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.
the class FilterResetAttributeAction method run.
@Override
public void run() {
DBDDataFilter dataFilter = new DBDDataFilter(resultSetViewer.getModel().getDataFilter());
DBDAttributeConstraint constraint = dataFilter.getConstraint(attribute);
if (constraint != null) {
constraint.setCriteria(null);
resultSetViewer.setDataFilter(dataFilter, true);
}
}
use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.
the class FilterSettingsDialog method swapColumns.
private void swapColumns(int curIndex, int newIndex) {
final DBDAttributeConstraint c1 = getBindingConstraint((DBDAttributeBinding) columnsViewer.getTree().getItem(curIndex).getData());
final DBDAttributeConstraint c2 = getBindingConstraint((DBDAttributeBinding) columnsViewer.getTree().getItem(newIndex).getData());
final int vp2 = c2.getVisualPosition();
c2.setVisualPosition(c1.getVisualPosition());
c1.setVisualPosition(vp2);
refreshData();
moveTopButton.setEnabled(newIndex > 0);
moveUpButton.setEnabled(newIndex > 0);
moveDownButton.setEnabled(newIndex < getItemsCount() - 1);
moveBottomButton.setEnabled(newIndex < getItemsCount() - 1);
}
use of org.jkiss.dbeaver.model.data.DBDAttributeConstraint in project dbeaver by serge-rider.
the class FilterSettingsDialog method okPressed.
@Override
protected void okPressed() {
treeEditor.okPressed();
boolean hasVisibleColumns = false;
for (DBDAttributeConstraint constraint : dataFilter.getConstraints()) {
// constraint.setVisualPosition(this.constraints.indexOf(constraint));
if (constraint.isVisible()) {
hasVisibleColumns = true;
}
}
if (!hasVisibleColumns) {
UIUtils.showMessageBox(getShell(), "Bad filter", "You have to set at least one column visible", SWT.ICON_WARNING);
return;
}
if (!CommonUtils.isEmpty(orderText.getText())) {
dataFilter.setOrder(orderText.getText());
} else {
dataFilter.setOrder(null);
}
if (!CommonUtils.isEmpty(whereText.getText())) {
dataFilter.setWhere(whereText.getText());
} else {
dataFilter.setWhere(null);
}
boolean filtersChanged = true;
if (dataFilter.equalFilters(resultSetViewer.getModel().getDataFilter(), true)) {
// Only attribute visibility was changed
filtersChanged = false;
}
resultSetViewer.setDataFilter(dataFilter, filtersChanged);
super.okPressed();
}
Aggregations