diff options
author | Simon Rettberg | 2016-04-18 15:18:59 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-04-18 15:18:59 +0200 |
commit | a183af9133e033dac3d1be3d3a141296713cb36e (patch) | |
tree | bc11129b87b1d40d67cf9ddf20e01066f97213e7 /dozentenmodul/src/main/java/org | |
parent | (WiP) Global image sync (diff) | |
download | tutor-module-a183af9133e033dac3d1be3d3a141296713cb36e.tar.gz tutor-module-a183af9133e033dac3d1be3d3a141296713cb36e.tar.xz tutor-module-a183af9133e033dac3d1be3d3a141296713cb36e.zip |
[*] Make uploading images to central server work
Diffstat (limited to 'dozentenmodul/src/main/java/org')
3 files changed, 39 insertions, 4 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 20f84b29..a3541c0a 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 @@ -60,6 +60,9 @@ import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.thrift.cache.UserCache; import org.openslx.dozmod.util.FormatHelper; import org.openslx.dozmod.util.MapHelper; +import org.openslx.thrifthelper.ThriftManager; +import org.openslx.util.QuickTimer; +import org.openslx.util.QuickTimer.Task; /** * Window for displaying and editing the details of an image. @@ -155,6 +158,12 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe refresh(true); } }); + btnUploadToMaster.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + uploadToMaster(); + } + }); btnShowLinkingLectures.addActionListener(new ActionListener() { @@ -398,7 +407,30 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe } else { btnSaveChanges.setEnabled(true); } + } + private void uploadToMaster() { + QuickTimer.scheduleOnce(new Task() { + @Override + public void fire() { + try { + String transferId = ThriftManager.getSatClient().publishImageVersion( + Session.getSatelliteToken(), image.latestVersionId); + /* + Gui.asyncExec(new Runnable() { + @Override + public void run() { + MainWindow.addUpload(transferId, ); + } + }); + */ + Gui.asyncMessageBox("Läuft: " + transferId, MessageType.INFO, null, null); + } catch (TException e1) { + ThriftError.showMessage(me, LOGGER, e1, + "Upload der VM auf den Master-Server fehlgeschlagen"); + } + } + }); } /** @@ -597,7 +629,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe lblLinkedLectureCount.setText(Integer.toString(lectureCount)); lblLinkedLectureCount.setForeground(lectureCount > 0 ? null : Color.RED); btnShowLinkingLectures.setEnabled(lectureCount > 0); - + // set the versions of the image to the table tblVersions.setData(image.getVersions(), true); mnuDelete.setEnabled(ImagePerms.canAdmin(image)); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java index 1fca5e07..5e84ea98 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java @@ -61,6 +61,7 @@ public abstract class ImageDetailsWindowLayout extends JDialog { protected final JButton btnSaveChanges; protected final JButton btnUpdateImage; + protected final JButton btnUploadToMaster; protected final JButton btnClose; protected final JButton btnShowLinkingLectures; @@ -208,6 +209,8 @@ public abstract class ImageDetailsWindowLayout extends JDialog { btnClose = new JButton("Schließen"); btnUpdateImage = new JButton("Neue VM-Version hochladen", Gui.getScaledIconResource("/img/upload-icon.png", "New VM", ICON_SIZE_Y, buttonPanel)); buttonPanel.add(btnUpdateImage); + btnUploadToMaster = new JButton("Landesweit veröffentlichen" /* TODO: Button image */); + buttonPanel.add(btnUploadToMaster); buttonPanel.add(Box.createGlue()); // user feedback slot lblError = new QLabel(""); 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 36486b8a..a6584bad 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/ThriftActions.java @@ -157,7 +157,7 @@ public class ThriftActions { long remoteVersion = -1; if (client != null) { try { - remoteVersion = client.getVersion(); + remoteVersion = client.getVersion(Version.VERSION); } catch (TTransportException e) { } catch (TException e) { remoteVersion = 1; // Assume something old @@ -799,8 +799,8 @@ public class ThriftActions { questionText += "\nWollen Sie diese Version samt Veranstaltungen löschen?\n"; } if (!matches) - questionText = "Wollen Sie die VM-Image-Version vom " + FormatHelper.shortDate(version.createTime) - + " Uhr wirklich löschen?"; + questionText = "Wollen Sie die VM-Image-Version vom " + + FormatHelper.shortDate(version.createTime) + " Uhr wirklich löschen?"; if (!userConfirmed(frame, questionText)) return; |