Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve pagination after actions which trigger a grid update #6546

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Refine.DatabaseImportController.prototype._getPreviewData = function(callback, n
result.rowModel = data;
callback(result);
},
"jsonp"
"json"
);
},
"json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ PerformEditsDialog.launch = function(logged_in_username, max_severity) {
tag: WikibaseManager.getSelectedWikibaseTagTemplate(),
maxEditsPerMinute: WikibaseManager.getSelectedWikibaseMaxEditsPerMinute()
},
{ includeEngine: true, cellsChanged: true, columnStatsChanged: true },
{ includeEngine: true, cellsChanged: true, columnStatsChanged: true, rowIdsPreserved: true, recordIdsPreserved: true },
{ onDone: function() { dismiss(); } }
);
};
Expand Down
6 changes: 4 additions & 2 deletions main/src/com/google/refine/browsing/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
import com.google.refine.browsing.util.ConjunctiveFilteredRows;
import com.google.refine.browsing.util.FilteredRecordsAsFilteredRows;
import com.google.refine.model.Project;
import com.google.refine.model.Record;
import com.google.refine.model.Row;

/**
Expand Down Expand Up @@ -105,7 +106,7 @@ public void accept(Project project, RowVisitor visitor) {
int c = project.rows.size();
for (int rowIndex = 0; rowIndex < c; rowIndex++) {
Row row = project.rows.get(rowIndex);
if (visitor.visit(project, rowIndex, row)) {
if (visitor.visit(project, rowIndex, rowIndex, row)) {
break;
}
}
Expand Down Expand Up @@ -150,7 +151,8 @@ public void accept(Project project, RecordVisitor visitor) {

int c = project.recordModel.getRecordCount();
for (int r = 0; r < c; r++) {
visitor.visit(project, project.recordModel.getRecord(r));
Record record = project.recordModel.getRecord(r);
visitor.visit(project, record.fromRowIndex, record);
}
} finally {
visitor.end(project);
Expand Down
20 changes: 20 additions & 0 deletions main/src/com/google/refine/browsing/RecordVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,29 @@ public interface RecordVisitor {

public void start(Project project); // called before any visit() call

/**
* @deprecated use {@link #visit(Project, int, Record)}
*/
@Deprecated
public boolean visit(
Project project,
Record record);

/**
* @param project
* project the record is part of
* @param sortedStartRowIndex
* zero-based sorted index of the first row in the record
* @param record
* the record to visit
* @return true to abort visitation early - no further visit calls will be made
*/
public default boolean visit(
Project project,
int sortedStartRowIndex,
Record record) {
return visit(project, record);
}

public void end(Project project); // called after all visit() calls
}
25 changes: 23 additions & 2 deletions main/src/com/google/refine/browsing/RowVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,39 @@ public interface RowVisitor {

/**
* @param project
* project
* project the row is part of
* @param rowIndex
* zero-based row index
* zero-based row index (unaffected by a temporary sort)
* @param row
* row
* @return true to abort visitation early - no further visit calls will be made
* @deprecated use {@link #visit(Project, int, int, Row)}
*/
@Deprecated
public boolean visit(
Project project,
int rowIndex,
Row row);

/**
* @param project
* project the row is part of
* @param rowIndex
* zero-based row index (unaffected by a temporary sort)
* @param sortedRowIndex
* zero-based row index in the sorted view (or equal to rowIndex if no temporary sorting is in place)
* @param row
* row
* @return true to abort visitation early - no further visit calls will be made
*/
public default boolean visit(
Project project,
int rowIndex,
int sortedRowIndex,
Row row) {
return visit(project, rowIndex, row);
}

/**
* Called after all visit() calls.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public boolean visit(Project project, int rowIndex, Row row) {
@Override
public boolean visit(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
visit(project, r, project.rows.get(r));
visit(project, r, r, project.rows.get(r));
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void accept(Project project, RecordVisitor visitor) {
for (int r = 0; r < c; r++) {
Record record = project.recordModel.getRecord(r);
if (matchRecord(project, record)) {
if (visitor.visit(project, record)) {
if (visitor.visit(project, record.fromRowIndex, record)) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void accept(Project project, RowVisitor visitor) {
}

protected boolean visitRow(Project project, RowVisitor visitor, int rowIndex, Row row) {
return visitor.visit(project, rowIndex, row);
return visitor.visit(project, rowIndex, rowIndex, row);
}

protected boolean matchRow(Project project, int rowIndex, Row row) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void end(Project project) {
@Override
public boolean visit(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
if (_rowVisitor.visit(project, r, project.rows.get(r))) {
if (_rowVisitor.visit(project, r, r, project.rows.get(r))) {
return true;
}
}
Expand Down