fix paging issue

This commit is contained in:
Branislav Stojkovic
2016-11-12 18:53:33 +01:00
parent 97d7d51fae
commit 32053fb2a8
@@ -163,14 +163,21 @@ public class ResultsScrollPanel extends JScrollPane {
addProjectToDisplay(project); addProjectToDisplay(project);
this.currentLocation++; this.currentLocation++;
} }
armed = true; getResultsPanel().invalidate();
getResultsPanel().revalidate();
// Reset scrollbar position, for some reason it jumps to the last added element
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
old.translate(0, -16);
getViewport().setViewPosition(old); getViewport().setViewPosition(old);
LOG.info("Paging mechanism is armed");
armed = true;
} }
}); });
if (searchSession != null && searchSession.hasMoreData()) { if (searchSession != null && searchSession.hasMoreData()) {
getLoadMoreLabel().setText("Querying the cloud for more results..."); getLoadMoreLabel().setText("Querying the cloud for more results...");
getLoadMoreLabel().setIcon(spinnerIcon); getLoadMoreLabel().setIcon(spinnerIcon);
@@ -403,9 +410,9 @@ public class ResultsScrollPanel extends JScrollPane {
@Override @Override
public ProjectEntity doInBackground() throws Exception { public ProjectEntity doInBackground() throws Exception {
CloudPresenter.Instance.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(), CloudPresenter.Instance.uploadProject(dialog.getName(), dialog.getCategory(), dialog
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile, .getDescription(), dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(),
file, project.getId()); thumbnailFile, file, project.getId());
return CloudPresenter.Instance.fetchUserUploads(project.getId()).get(0); return CloudPresenter.Instance.fetchUserUploads(project.getId()).get(0);
} }
@@ -600,6 +607,7 @@ public class ResultsScrollPanel extends JScrollPane {
super.paint(g); super.paint(g);
if (armed && searchSession != null && searchSession.hasMoreData()) { if (armed && searchSession != null && searchSession.hasMoreData()) {
// disarm immediately so we don't trigger successive requests to the provider // disarm immediately so we don't trigger successive requests to the provider
LOG.info("Paging mechanism is disarmed");
armed = false; armed = false;
SwingWorker<List<ProjectEntity>, Void> worker = new SwingWorker<List<ProjectEntity>, Void>() { SwingWorker<List<ProjectEntity>, Void> worker = new SwingWorker<List<ProjectEntity>, Void>() {