diff options
author | Simon Rettberg | 2015-08-19 14:08:35 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-08-19 14:08:35 +0200 |
commit | 8b48fab82405d9295f8f10ff7ef3db18124aff96 (patch) | |
tree | 66a77be898a898c5a0ba2ddce845412403f95ef0 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java | |
parent | [client] move thrift cache to its own package (diff) | |
download | tutor-module-8b48fab82405d9295f8f10ff7ef3db18124aff96.tar.gz tutor-module-8b48fab82405d9295f8f10ff7ef3db18124aff96.tar.xz tutor-module-8b48fab82405d9295f8f10ff7ef3db18124aff96.zip |
[client] Delay refresh of image list only for certain events
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java index 1fc9d1ce..ba5f0cf7 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java @@ -41,7 +41,7 @@ import org.openslx.util.QuickTimer.Task; /** * * @author Jonathan Bauer - * + * */ @SuppressWarnings("serial") public class ImageListWindow extends ImageListWindowLayout implements DownloadCallback { @@ -107,7 +107,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa performImageDownload(imageTable.getSelectedItem()); } if (e.getSource().equals(popupItemDelete)) { - + } } }); @@ -139,7 +139,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa ImageDetailsWindow.open((JFrame) SwingUtilities.getWindowAncestor(me), image.getImageBaseId(), new ImageUpdatedCallback() { public void updated() { - refreshList(true); + refreshList(true, 100); } }); } @@ -177,7 +177,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa @Override public void actionPerformed(ActionEvent e) { new ImageWizard(SwingUtilities.getWindowAncestor(me)).setVisible(true); - refreshList(true); + refreshList(true, 100); } }); newLectureButton.addActionListener(new ActionListener() { @@ -209,10 +209,11 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa updateAvailableOptions(null); } - /******************************************************************************** + + /******************************************************************************** + * + * General GUI and table helpers * - * General GUI and table helpers - * ********************************************************************************/ /** @@ -220,7 +221,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa * * @param forceRefresh true to force a refresh, false to use the cached list */ - private void refreshList(final boolean forceRefresh) { + private void refreshList(final boolean forceRefresh, int delay) { QuickTimer.scheduleOnce(new Task() { @Override public void fire() { @@ -232,12 +233,12 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa } }); } - }, 1000); - // TODO do this periodically with a large interval, say 10s? + }, delay); } /** - * Helper to return the selected image from the table or show an error to the user if none is selected + * Helper to return the selected image from the table or show an error to + * the user if none is selected * * @return the image selected in the table, null if there is no selection */ @@ -336,10 +337,11 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa popupItemNewLecture.setEnabled(link); popupItemDelete.setEnabled(admin); } - /******************************************************************************** + + /******************************************************************************** + * + * Helpers triggering the actual actions * - * Helpers triggering the actual actions - * ********************************************************************************/ /** @@ -365,15 +367,19 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa TransferHelper.initDownload(JOptionPane.getFrameForComponent(this), image.latestVersionId, image.imageName, image.virtId, image.fileSize, this); } + /** - * Callback when download initialized + * Callback when download initialized * * @param success true if downloading, false otherwise */ @Override public void downloadInitialized(boolean success) { - refreshList(!success); + if (!success) { + refreshList(true, 1000); + } } + /** * Deletes the latest version of the given image if it has one * @@ -390,6 +396,7 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa QuickTimer.scheduleOnce(new Task() { boolean success = false; Exception error = null; + @Override public void fire() { try { @@ -410,22 +417,26 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa } }); } + /** * Async callback when image was deleted * - * @param success true if the latest image version was deleted, false otherwise + * @param success true if the latest image version was deleted, false + * otherwise */ public void deletedLatestVersion(boolean success, Exception e) { if (e != null) { Gui.showMessageBox(me, "Fehler", MessageType.ERROR, LOGGER, e); } - refreshList(success); + if (success) { + refreshList(true, 1000); + } } - /******************************************************************************** + /******************************************************************************** + * + * CompositePage abstract methods implementation * - * CompositePage abstract methods implementation - * ********************************************************************************/ @Override public boolean requestHide() { @@ -434,6 +445,6 @@ public class ImageListWindow extends ImageListWindowLayout implements DownloadCa @Override public void requestShow() { - refreshList(false); + refreshList(false, 1); } } |