Merge pull request #3319 from Akarshit/gsoc-contrib

Progress bar added to Contrib Manager
This commit is contained in:
Ben Fry
2015-05-31 20:37:39 -04:00
3 changed files with 32 additions and 8 deletions

View File

@@ -125,6 +125,13 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
updateColors(); // XXX this is the place
}
}
// To make the scroll shift to the first element
// http://stackoverflow.com/questions/19400239/scrolling-to-the-top-jpanel-inside-a-jscrollpane
EventQueue.invokeLater(new Runnable() {
public void run() {
scrollRectToVisible(new Rectangle(0, 0, 1, 1));
}
});
}
});
}

View File

@@ -53,6 +53,7 @@ public class ContributionManagerDialog {
FilterField filterField;
JButton restartButton;
JButton retryConnectingButton;
JProgressBar progressBar;
// the calling editor, so updates can be applied
Editor editor;
@@ -167,6 +168,9 @@ public class ContributionManagerDialog {
downloadAndUpdateContributionListing();
}
});
progressBar = new JProgressBar();
progressBar.setVisible(true);
Toolkit.setIcon(dialog);
createComponents();
@@ -293,6 +297,7 @@ public class ContributionManagerDialog {
statusRestartPane.setOpaque(false);
statusRestartPane.add(status, BorderLayout.WEST);
statusRestartPane.add(progressBar, BorderLayout.LINE_END);
// Adding both of these to EAST shouldn't pose too much of a problem,
// since they can never get added together.
@@ -464,19 +469,28 @@ public class ContributionManagerDialog {
protected void downloadAndUpdateContributionListing() {
retryConnectingButton.setEnabled(false);
contribListing.downloadAvailableList(new ContribProgressMonitor() {
status.setMessage(Language.text("contrib.status.downloading_list"));
contribListing.downloadAvailableList(new ContribProgressBar(progressBar) {
@Override
public void startTask(String name, int maxValue) {
super.startTask(name, maxValue);
progressBar.setString(null);
}
@Override
public void setProgress(int value) {
super.setProgress(value);
int percent = 100 * value / this.max;
status.setMessage(Language.text("contrib.status.downloading_list") + " (" + percent + "%)");
// int percent = 100 * value / this.max;
progressBar.setValue(value);
progressBar.setStringPainted(true);
status.setMessage(Language.text("contrib.status.downloading_list"));
}
@Override
public void finished() {
super.finished();
public void finishedAction() {
progressBar.setVisible(false);
updateContributionListing();
updateCategoryChooser();
@@ -485,9 +499,11 @@ public class ContributionManagerDialog {
if (error) {
if (exception instanceof SocketTimeoutException) {
status.setErrorMessage(Language.text("contrib.errors.list_download.timeout"));
status.setErrorMessage(Language
.text("contrib.errors.list_download.timeout"));
} else {
status.setErrorMessage(Language.text("contrib.errors.list_download"));
status.setErrorMessage(Language
.text("contrib.errors.list_download"));
}
exception.printStackTrace();
retryConnectingButton.setVisible(true);

View File

@@ -423,6 +423,7 @@ contrib.errors.temporary_directory = Could not write to temporary directory.
contrib.errors.contrib_download.timeout = Connection timed out while downloading %s.
contrib.errors.no_internet_connection = You do not seem to be connected to the Internet.
contrib.status.downloading_list = Downloading contribution list...
contrib.status.connecting = Connecting...
contrib.status.done = Done.
contrib.all = All
contrib.undo = Undo