diff options
author | Jonathan Bauer | 2015-08-21 13:32:45 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-08-21 13:32:45 +0200 |
commit | 7b1c316bd9bd8abcbfb8792a1ee939b378d6da82 (patch) | |
tree | 0a85890bdc1a5b4aa7384337f498bbf9d3976a41 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java | |
parent | [client] support deletion of image base in ThriftActions (diff) | |
download | tutor-module-7b1c316bd9bd8abcbfb8792a1ee939b378d6da82.tar.gz tutor-module-7b1c316bd9bd8abcbfb8792a1ee939b378d6da82.tar.xz tutor-module-7b1c316bd9bd8abcbfb8792a1ee939b378d6da82.zip |
[client] ThriftActions for Image Metadata (details + permissions) and use these in imageDetailsWindow
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index 3ca4a90f..bf8fd2ba 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -42,6 +42,7 @@ import org.openslx.dozmod.permissions.ImagePerms; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.ThriftActions.DeleteCallback; +import org.openslx.dozmod.thrift.ThriftActions.MetadataCallback; import org.openslx.dozmod.thrift.ThriftError; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.thrift.cache.UserCache; @@ -220,39 +221,37 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe * @param imageBaseId the id of the image to be displayed */ public void setImage(final String imageBaseId) { - QuickTimer.scheduleOnce(new Task() { - @Override - public void fire() { - Exception error = null; - try { - synchronized (me) { - if (image != null) - return; - image = ThriftManager.getSatClient().getImageDetails(Session.getSatelliteToken(), - imageBaseId); - permissionMap = ThriftManager.getSatClient().getImagePermissions(Session.getSatelliteToken(), imageBaseId); + synchronized (me) { + if (image != null) + return; + // Just prime the cache... + MetaDataCache.getOperatingSystems(); + MetaDataCache.getVirtualizers(); + final MetadataCallback callback = new MetadataCallback() { + @Override + public void fetchedImageDetails(ImageDetailsRead details) { + LOGGER.debug("detail cb: " + details); + if (details != null) { + image = details; + if (permissionMap != null) + fill(); + // TODO else still show what we have? } - } catch (Exception e) { - error = e; } - // Just prime the cache... - MetaDataCache.getOperatingSystems(); - MetaDataCache.getVirtualizers(); - final Exception e = error; - Gui.asyncExec(new Runnable() { - @Override - public void run() { - if (e != null || image == null) { - Gui.showMessageBox(null, "Konnte Daten des Images nicht abrufen", - MessageType.ERROR, LOGGER, e); - dispose(); - } else { + @Override + public void fetchedImagePermissions(Map<String, ImagePermissions> permissions) { + LOGGER.debug("perms cb: " + permissions); + if (permissions != null) { + permissionMap = permissions; + if (image != null) fill(); - } } - }); - } - }); + } + }; + final Frame parentFrame = JOptionPane.getFrameForComponent(me); + ThriftActions.getImageDetails(parentFrame, imageBaseId, callback); + ThriftActions.getImagePermissions(parentFrame, imageBaseId, callback); + } } /** |