diff options
author | Stephan Schwaer | 2015-08-10 17:14:52 +0200 |
---|---|---|
committer | Stephan Schwaer | 2015-08-10 17:14:52 +0200 |
commit | 970b756032307d867a0e7929feddb4f38f20b2dc (patch) | |
tree | 15602bad0269c51620ffa771770ee329e2a861c6 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java | |
parent | [cient] improved lecture creation page and sorted versions list for combo in ... (diff) | |
download | tutor-module-970b756032307d867a0e7929feddb4f38f20b2dc.tar.gz tutor-module-970b756032307d867a0e7929feddb4f38f20b2dc.tar.xz tutor-module-970b756032307d867a0e7929feddb4f38f20b2dc.zip |
[client] Seperated filechooser from ImageUploadPage and also added it as directory chooser to download buttons.
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 | 43 |
1 files changed, 37 insertions, 6 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 0914bac7..ba8f2d36 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 @@ -5,8 +5,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileNotFoundException; import java.util.List; +import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.RowFilter; @@ -20,8 +23,11 @@ import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.bwlp.thrift.iface.TNotFoundException; +import org.openslx.bwlp.thrift.iface.TransferInformation; +import org.openslx.dozmod.filetransfer.DownloadTask; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.MainWindow; +import org.openslx.dozmod.gui.helper.FileChooser; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.PopupMenu; import org.openslx.dozmod.gui.window.layout.ImageListWindowLayout; @@ -42,13 +48,13 @@ public class ImageListWindow extends ImageListWindowLayout { private JMenuItem popupItemNewLecture = new JMenuItem("Neue Veranstaltung"); private JMenuItem popupItemDelete = new JMenuItem("Löschen"); private JMenuItem popupItemDownload = new JMenuItem("Download"); - + public ImageListWindow() { super(); // filter the objects in the table depending on the search field searchTextField.getDocument().addDocumentListener(new DocumentListener() { - + @Override public void removeUpdate(DocumentEvent e) { changedUpdate(e); @@ -80,7 +86,7 @@ public class ImageListWindow extends ImageListWindowLayout { LOGGER.debug("New lecture clicked"); } if (e.getSource().equals(popupItemDownload)) { - // Download + performImageDownload(); LOGGER.debug("Download image clicked"); } if (e.getSource().equals(popupItemDelete)) { @@ -95,7 +101,7 @@ public class ImageListWindow extends ImageListWindowLayout { pop.addMenuItem(popupItemDownload); pop.addSeparator(); pop.addMenuItem(popupItemDelete); - + imageTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -140,7 +146,7 @@ public class ImageListWindow extends ImageListWindowLayout { downloadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO open download popup + performImageDownload(); } }); @@ -177,7 +183,7 @@ public class ImageListWindow extends ImageListWindowLayout { MainWindow.showPage(MainMenuWindow.class); } }); - + } private void refreshList(final boolean forceRefresh) { @@ -214,4 +220,29 @@ public class ImageListWindow extends ImageListWindowLayout { public void requestShow() { refreshList(false); } + + private void performImageDownload() { + FileChooser fc = new FileChooser(false); + int action = fc.showOpenDialog(me); + File file = fc.getSelectedFile(); + if (action != JFileChooser.APPROVE_OPTION || file == null) + return; + TransferInformation transInf = null; + try { + transInf = ThriftManager.getSatClient().requestDownload(Session.getSatelliteToken(), imageTable.getSelectedItem().latestVersionId); + } catch ( TException e) { + LOGGER.error("Failed to get transfer information: ", e); + return; + } + if (transInf == null) + return; + + // TODO fix filename/path and consider multiplatform + try { + DownloadTask dlTask = new DownloadTask(Session.getSatelliteAddress(), transInf.getPlainPort(), transInf.getToken(), new File(file.getAbsolutePath() + "/HanneloreKraft"), imageTable.getSelectedItem().getFileSize(), null); + } catch (FileNotFoundException e) { + LOGGER.error("Failed to get download: ", e); + } + LOGGER.info(file.getAbsolutePath()); + } } |