Skip to content
Permalink
Browse files

Merge remote-tracking branch 'origin/devel' into devel

  • Loading branch information...
serge-rider committed Nov 8, 2019
2 parents 51e8cca + 704db03 commit fdcbf5f386748ac4f1ed0c0ee0a47151c2862563
@@ -134,4 +134,7 @@ public boolean matches(DBSAttributeBase attr, boolean matchByName) {
(attribute instanceof DBDAttributeBinding && ((DBDAttributeBinding) attribute).matches(attr, matchByName));
}

public boolean equalVisibility(DBDAttributeConstraint constraint) {
return isVisible() == constraint.isVisible() && getVisualPosition() == constraint.getVisualPosition();
}
}
@@ -262,6 +262,19 @@ public boolean equalFilters(DBDDataFilter source, boolean compareOrders) {
CommonUtils.equalObjects(this.where, source.where);
}

public boolean equalVisibility(DBDDataFilter dataFilter) {
if (dataFilter.constraints.size() != constraints.size()) {
return false;
}
for (int i = 0; i < dataFilter.constraints.size(); i++) {
if (!constraints.get(i).equalVisibility(dataFilter.constraints.get(i))) {
return false;
}

}
return true;
}

public boolean hasNameDuplicates(String name) {
int count = 0;
for (DBDAttributeConstraint c : constraints) {
@@ -275,4 +288,5 @@ public boolean hasNameDuplicates(String name) {
public void serialize(Map<String, Object> state) {

}

}
@@ -154,7 +154,7 @@ private static Expression getOrderConstraintExpression(DBPDataSource dataSource,
Expression orderExpr;
String attrName = DBUtils.getQuotedIdentifier(dataSource, co.getAttributeName());
if (forceNumeric || attrName.isEmpty()) {
orderExpr = new LongValue(co.getOrderPosition() + 1);
orderExpr = new LongValue(co.getOrderPosition());
} else if (CommonUtils.isJavaIdentifier(attrName)) {
// Use column table only if there are multiple source tables (joins)
Table orderTable = CommonUtils.isEmpty(select.getJoins()) ? null : getConstraintTable(select, co);
@@ -52,7 +52,10 @@
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Copy results in external format
@@ -156,6 +159,7 @@ protected IStatus run(DBRProgressMonitor monitor) {
DBDDataFilter dataFilter = resultSet.getModel().getDataFilter();
DatabaseTransferProducer producer = new DatabaseTransferProducer(dataContainer, dataFilter);
DatabaseProducerSettings producerSettings = new DatabaseProducerSettings();
producerSettings.setOpenNewConnections(false);
producerSettings.setExtractType(DatabaseProducerSettings.ExtractType.SINGLE_QUERY);
producerSettings.setQueryRowCount(false);
producerSettings.setSelectedRowsOnly(!CommonUtils.isEmpty(options.getSelectedRows()));
@@ -110,8 +110,8 @@

import java.lang.reflect.InvocationTargetException;
import java.text.DecimalFormat;
import java.util.List;
import java.util.*;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

/**
@@ -3516,9 +3516,10 @@ private void afterDataRead() {

if (!scroll) {
if (dataFilter != null) {
boolean visibilityChanged = !model.getDataFilter().equalVisibility(dataFilter);
model.updateDataFilter(dataFilter, true);
// New data filter may have different columns visibility
redrawData(true, false);
redrawData(visibilityChanged, false);
}
}
if (getStatistics() == null || !getStatistics().isEmpty()) {
@@ -255,60 +255,66 @@ public void scrollToRow(@NotNull RowPosition position)
ResultSetRow curRow = controller.getCurrentRow();
ResultSetModel model = controller.getModel();

switch (position) {
case FIRST:
if (recordMode) {
if (model.getRowCount() > 0) {
controller.setCurrentRow(model.getRow(0));
spreadsheet.setRedraw(false);
try {
int hScrollPos = spreadsheet.getHorizontalScrollBarProxy().getSelection();

switch (position) {
case FIRST:
if (recordMode) {
if (model.getRowCount() > 0) {
controller.setCurrentRow(model.getRow(0));
} else {
controller.setCurrentRow(null);
}
} else {
controller.setCurrentRow(null);
spreadsheet.shiftCursor(0, -spreadsheet.getItemCount(), false);
}
} else {
spreadsheet.shiftCursor(0, -spreadsheet.getItemCount(), false);
}
break;
case PREVIOUS:
if (recordMode && curRow != null && curRow.getVisualNumber() > 0) {
controller.setCurrentRow(model.getRow(curRow.getVisualNumber() - 1));
} else {
spreadsheet.shiftCursor(0, -1, false);
}
break;
case NEXT:
if (recordMode && curRow != null && curRow.getVisualNumber() < model.getRowCount() - 1) {
controller.setCurrentRow(model.getRow(curRow.getVisualNumber() + 1));
} else {
spreadsheet.shiftCursor(0, 1, false);
}
break;
case LAST:
if (recordMode && model.getRowCount() > 0) {
controller.setCurrentRow(model.getRow(model.getRowCount() - 1));
} else {
spreadsheet.shiftCursor(0, spreadsheet.getItemCount(), false);
}
break;
case CURRENT:
if (curRow != null) {
GridPos curPos = spreadsheet.getCursorPosition();
GridCell newCell = spreadsheet.posToCell(new GridPos(curPos.col, curRow.getVisualNumber()));
if (newCell != null) {
spreadsheet.setCursor(newCell, false, true);
break;
case PREVIOUS:
if (recordMode && curRow != null && curRow.getVisualNumber() > 0) {
controller.setCurrentRow(model.getRow(curRow.getVisualNumber() - 1));
} else {
spreadsheet.shiftCursor(0, -1, false);
}
}
break;
}
if (controller.isRecordMode()) {
// Update focus cell
restoreState(curAttribute);
}
// Update controls
controller.updateEditControls();
controller.updateStatusMessage();
break;
case NEXT:
if (recordMode && curRow != null && curRow.getVisualNumber() < model.getRowCount() - 1) {
controller.setCurrentRow(model.getRow(curRow.getVisualNumber() + 1));
} else {
spreadsheet.shiftCursor(0, 1, false);
}
break;
case LAST:
if (recordMode && model.getRowCount() > 0) {
controller.setCurrentRow(model.getRow(model.getRowCount() - 1));
} else {
spreadsheet.shiftCursor(0, spreadsheet.getItemCount(), false);
}
break;
case CURRENT:
if (curRow != null) {
GridPos curPos = spreadsheet.getCursorPosition();
GridCell newCell = spreadsheet.posToCell(new GridPos(curPos.col, curRow.getVisualNumber()));
if (newCell != null) {
spreadsheet.setCursor(newCell, false, true);
}
}
break;
}

spreadsheet.getHorizontalScrollBarProxy().setSelection(hScrollPos);

if (recordMode) {
// Refresh meta if we are in record mode
refreshData(true, false, true);
// Update controls
controller.updateEditControls();
controller.updateStatusMessage();

if (recordMode) {
// Refresh meta if we are in record mode
refreshData(true, false, true);
}
} finally {
spreadsheet.setRedraw(true);
}
}

@@ -378,14 +384,14 @@ public void restoreState(Object state) {
}
ViewState viewState = (ViewState) state;
this.curAttribute = controller.getModel().getAttributeBinding(viewState.focusedAttribute);
ResultSetRow curRow = controller.getCurrentRow();
/*ResultSetRow curRow = controller.getCurrentRow();
if (curRow != null && this.curAttribute != null) {
GridCell cell = controller.isRecordMode() ?
new GridCell(curRow, this.curAttribute) :
new GridCell(this.curAttribute, curRow);
//spreadsheet.selectCell(cell);
//spreadsheet.setCursor(cell, false, false);
}
spreadsheet.setCursor(cell, false, false);
}*/
spreadsheet.getHorizontalScrollBarProxy().setSelection(viewState.hScrollSelection);
}

0 comments on commit fdcbf5f

Please sign in to comment.
You can’t perform that action at this time.