diff options
| author | Jonathan Bauer | 2015-08-21 16:39:18 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2015-08-21 16:39:18 +0200 |
| commit | 063e4df5e0cbc8a0f22e12c199fd404a3ca4db65 (patch) | |
| tree | bb22525dfda4d44d25841ecd04dfe2cde6b8b16f | |
| parent | [client] setImageOwner ThriftActions'ed (diff) | |
| download | tutor-module-063e4df5e0cbc8a0f22e12c199fd404a3ca4db65.tar.gz tutor-module-063e4df5e0cbc8a0f22e12c199fd404a3ca4db65.tar.xz tutor-module-063e4df5e0cbc8a0f22e12c199fd404a3ca4db65.zip | |
[client] more ThriftActions & minor bugfix (saving button enabled even if no OS was preselected TODO fix properly)
3 files changed, 24 insertions, 25 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 80690c07..58ffb8c8 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 @@ -270,7 +270,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe * Push the changes of the image details to the satellite */ private void saveChanges() { - // first we build an ImageBaseWrite + // first build the ImageBaseWrite from the GUI fields final ImageBaseWrite ibw = new ImageBaseWrite( txtTitle.getText(), txtDescription.getText(), @@ -279,24 +279,13 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe chkIsTemplate.isSelected(), new ImagePermissions(chkCustomPermLink.isSelected(), chkCustomPermDownload.isSelected(), chkCustomPermEdit.isSelected(), chkCustomPermAdmin.isSelected()), image.shareMode); - - QuickTimer.scheduleOnce(new Task() { - @Override - public void fire() { - try { - // push to sat - ThriftManager.getSatClient().updateImageBase(Session.getSatelliteToken(), - image.getImageBaseId(), ibw); - } catch (TException e) { - ThriftError.showMessage(me, LOGGER, e, "Fail to update image details to satellite"); - return; - } - // no success message I'd say... - btnSaveChanges.setEnabled(false); - refresh(true); - callback.updated(); - } - }); + // now trigger the actual action + if (!ThriftActions.updateImageBase(JOptionPane.getFrameForComponent(me), image.getImageBaseId(), ibw)) + return; + // success + btnSaveChanges.setEnabled(false); + refresh(true); + callback.updated(); } /** * Triggers the download of the given image version @@ -472,8 +461,12 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe private void reactToChange() { OperatingSystem newOs = cboOperatingSystem.getItemAt(cboOperatingSystem.getSelectedIndex()); ShareMode newShareMode = cboShareMode.getItemAt(cboShareMode.getSelectedIndex()); - boolean changed = false; + // TODO remove this workaround + if (newOs == null) { + changed = false; + return; + } if (!txtTitle.getText().isEmpty() && !txtTitle.getText().equals(image.getImageName())) { changed = true; } else if (!txtDescription.getText().isEmpty() && !txtDescription.getText().equals(image.getDescription())) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/UpdateWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/UpdateWizard.java index 8eb6ca4e..a50891c2 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/UpdateWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/UpdateWizard.java @@ -30,7 +30,8 @@ public class UpdateWizard extends Wizard implements UiFeedback { @Override public void performFinish() { - ThriftActions.updateImageVersion(JOptionPane.getFrameForComponent(this), + // TODO use ret? + boolean ret = ThriftActions.updateImageVersion(JOptionPane.getFrameForComponent(this), uploadWizardState.transferInformation.getToken(), new ImageVersionWrite(uploadWizardState.isRestricted)); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java index 63558197..f2e1fb94 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -76,14 +76,17 @@ public class ThriftActions { * @param imageBaseId image's id we are writing meta information of * @param meta actual meta information as ImageBaseWrite */ - public static void updateImageBase(final Frame frame, final String imageBaseId, final ImageBaseWrite meta) { + public static boolean updateImageBase(final Frame frame, final String imageBaseId, final ImageBaseWrite meta) { try { ThriftManager.getSatClient().updateImageBase(Session.getSatelliteToken(), imageBaseId, meta); } catch (TException e) { ThriftError.showMessage(frame, LOGGER, e, "Konnte Metadaten des Images nicht übertragen"); + return false; } + return true; } + /** * GUI-BLOCKING * Pushes the given permission map as custom permission for the given imageBaseId @@ -142,6 +145,7 @@ public class ThriftActions { } return ti; } + /** * GUI-BLOCKING * Starts uploading the given diskFile using the transferInformation and hashGen @@ -202,7 +206,7 @@ public class ThriftActions { * @param transferInformation * @param versionInfo */ - public static void updateImageVersion(final Frame frame, + public static boolean updateImageVersion(final Frame frame, final String versionId, final ImageVersionWrite versionInfo){ try { ThriftManager.getSatClient().updateImageVersion(Session.getSatelliteToken(), @@ -211,9 +215,9 @@ public class ThriftActions { } catch (TException e) { Gui.showMessageBox(frame, "Konnte neue Version nicht erstellen!", MessageType.ERROR, LOGGER, e); - return; + return false; } - Gui.showMessageBox(frame, "Neue Version erfolgreich erstellt", MessageType.INFO, LOGGER, null); + return true; } /* ******************************************************************************* * @@ -229,6 +233,7 @@ public class ThriftActions { public interface DownloadCallback { void downloadInitialized(boolean success); } + /** * NON-BLOCKING * Initializes the download of the given imageVersionId saving it to the given |
