diff --git a/src/gui/DownloadFileGUI.java b/src/gui/DownloadFileGUI.java index a66849a..384c8bc 100644 --- a/src/gui/DownloadFileGUI.java +++ b/src/gui/DownloadFileGUI.java @@ -44,11 +44,35 @@ public class DownloadFileGUI extends JPanel{ public void download() { try { - //clientManagement.download(fileToDownload); - + System.out.println("Downloading " + fileToDownload + " ... "); + clientManagement.download(fileToDownload); ErrorFrame erreur = new ErrorFrame("File " + fileToDownload + " sucessfully downloaded"); } catch (NumberFormatException e) { ErrorFrame erreur = new ErrorFrame("File " + fileToDownload + " unsucessfully downloaded, wrong number"); + } catch (InternalError e) { + ErrorFrame err = new ErrorFrame("Client internal error"); + } catch (UnknownHostException e) { + ErrorFrame err = new ErrorFrame("Server host is unknown"); + } catch (IOException e) { + ErrorFrame err = new ErrorFrame("Request cannot be send or response cannot be received"); + } catch (TransmissionError e) { + ErrorFrame err = new ErrorFrame("Message received is too big"); + } catch (ProtocolError e) { + ErrorFrame err = new ErrorFrame("Cannot decode server’s response"); + } catch (VersionError e) { + ErrorFrame err = new ErrorFrame("Server’s response use bad version of the protocol"); + } catch (SizeError e) { + ErrorFrame err = new ErrorFrame("Cannot handle this packets because of internal representation limitations of numbers on the client"); + } catch (InternalRemoteError e) { + ErrorFrame err = new ErrorFrame("Server internal error"); + } catch (ProtocolRemoteError e) { + ErrorFrame err = new ErrorFrame("Server cannot decode client’s request"); + } catch (VersionRemoteError e) { + ErrorFrame err = new ErrorFrame("Server cannot decode this version of the protocol"); + } catch (NotFound e) { + ErrorFrame err = new ErrorFrame("Server has not this file in directory"); + } catch (EmptyFile e) { + ErrorFrame err = new ErrorFrame("File is empty"); } } diff --git a/src/gui/DownloadSelectionGen.java b/src/gui/DownloadSelectionGen.java index c9c8d8b..4785687 100644 --- a/src/gui/DownloadSelectionGen.java +++ b/src/gui/DownloadSelectionGen.java @@ -121,8 +121,8 @@ public class DownloadSelectionGen extends javax.swing.JPanel { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String fileSelected = jList1.getSelectedValue(); System.out.println("File to download: " + fileSelected); - //DownloadFileGUI interface = new DownloadFileGUI(fileSelected, clientManagement, logger, scanner); - //DownloadFileGUI.download(); + DownloadFileGUI dl = new DownloadFileGUI(fileSelected, clientManagement, logger); + dl.download(); } /** Actions to initiate when button "Back" is initiate */