From 6331f9f1442917aa4f6189d02acc7de7e55f611c Mon Sep 17 00:00:00 2001 From: js Date: Sat, 11 Apr 2020 10:48:03 +0200 Subject: [PATCH] fixed name of ClientP2PGUI and updated javadoc for GUI --- src/gui/ArgumentsGen.java | 15 +++++---------- src/gui/ClientInterfaceGUI.java | 9 ++++----- src/gui/{ClientP2Pgui.java => ClientP2PGUI.java} | 9 +++++---- src/gui/DownloadSelectionGen.java | 11 +++++++---- src/gui/ErrorFrame.java | 11 ++++++++--- src/gui/Gui.java | 8 ++++++++ src/gui/MainWindow.java | 13 +++++++++---- 7 files changed, 46 insertions(+), 30 deletions(-) rename src/gui/{ClientP2Pgui.java => ClientP2PGUI.java} (95%) diff --git a/src/gui/ArgumentsGen.java b/src/gui/ArgumentsGen.java index ec06267..7e70511 100644 --- a/src/gui/ArgumentsGen.java +++ b/src/gui/ArgumentsGen.java @@ -1,12 +1,5 @@ package gui; - -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - import javax.swing.JFrame; import javax.swing.SwingUtilities; @@ -14,6 +7,7 @@ package gui; * @author Louis Royer * @author Flavien Haas * @author JS Auge +*@version 1.0 */ public class ArgumentsGen extends javax.swing.JPanel { @@ -41,9 +35,8 @@ public class ArgumentsGen extends javax.swing.JPanel { /** * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. */ + @SuppressWarnings("unchecked") // private void initComponents() { @@ -162,6 +155,8 @@ public class ArgumentsGen extends javax.swing.JPanel { // TODO add your handling code here: } + +/** Actions when click on connect: creat a clientP2Pgui with the infos from textfields*/ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String hostnameServer = jTextField2.getText(); String portServerStr = jTextField1.getText(); @@ -175,7 +170,7 @@ public class ArgumentsGen extends javax.swing.JPanel { System.out.println("protocol: " + protocolClient); int portServer = Integer.parseInt(portServerStr); int portTracker = Integer.parseInt(portTrackerStr); - ClientP2Pgui c = new ClientP2Pgui(hostnameServer, portServer, hostnameTracker, portTracker, protocolClient); + ClientP2PGUI c = new ClientP2PGUI(hostnameServer, portServer, hostnameTracker, portTracker, protocolClient); c.connect(); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); topFrame.dispose(); diff --git a/src/gui/ClientInterfaceGUI.java b/src/gui/ClientInterfaceGUI.java index 0d713da..76f819b 100644 --- a/src/gui/ClientInterfaceGUI.java +++ b/src/gui/ClientInterfaceGUI.java @@ -37,7 +37,6 @@ public class ClientInterfaceGUI extends ClientInterface { /** Constructor with clientManagement, logger and scanner. * @param clientManagement ClientManagement used * @param logger Logger used - * @param scanner Scanner used to read input */ Logger loggerC; @@ -60,10 +59,10 @@ public class ClientInterfaceGUI extends ClientInterface { int optionSearch = 0; String searchInput = ""; String[] list = clientManagement.listDirectory(); - System.out.println("running ClientInterfaceGUI and creating window"); - for(String listItem: list){ - System.out.println(listItem); - } + //System.out.println("running ClientInterfaceGUI and creating window"); + //for(String listItem: list){ + //System.out.println(listItem); + //} JFrame win = new JFrame(); win.setTitle("Client"); win.setSize(550, 250); diff --git a/src/gui/ClientP2Pgui.java b/src/gui/ClientP2PGUI.java similarity index 95% rename from src/gui/ClientP2Pgui.java rename to src/gui/ClientP2PGUI.java index 3c1eea1..10b377e 100644 --- a/src/gui/ClientP2Pgui.java +++ b/src/gui/ClientP2PGUI.java @@ -14,14 +14,14 @@ import tools.HostItem; import tools.ServerPortRange; import tools.TrackerPortRange; -/** Client + Server implementation. +/** Client + Server implementation in GUI * @author Louis Royer * @author Flavien Haas * @author JS Auge * @version 1.0 */ -public class ClientP2Pgui { +public class ClientP2PGUI { private String logDir = "logs/"; private String partsDir = ".parts/"; private Logger loggerServer; @@ -54,8 +54,9 @@ public class ClientP2Pgui { * @param portServer port to bind * @param hostnameTracker hostname of tracker * @param portTracker port of tracker + * @param protocolP2P protocol used */ - public ClientP2Pgui(String hostnameServer, int portServer, String hostnameTracker, int portTracker, String protocolP2P) { + public ClientP2PGUI(String hostnameServer, int portServer, String hostnameTracker, int portTracker, String protocolP2P) { this.hostnameServer = hostnameServer; this.hostnameTracker = hostnameTracker; @@ -76,9 +77,9 @@ public class ClientP2Pgui { System.out.println("Server will listen on port " + portServer + " and serve files from " + directories.getDataHomeDirectory()); } +/**Initiate a connection using fields from ArgumentsGen*/ public void connect(){ - System.out.println("using hostname : " + hostnameServer); System.out.println("using port : " + portServer); System.out.println("tracker hostname : " + hostnameTracker); diff --git a/src/gui/DownloadSelectionGen.java b/src/gui/DownloadSelectionGen.java index 95a861c..c9c8d8b 100644 --- a/src/gui/DownloadSelectionGen.java +++ b/src/gui/DownloadSelectionGen.java @@ -17,10 +17,10 @@ package gui; * @author Louis Royer * @author Flavien Haas * @author JS Auge +* @version 1.0 */ public class DownloadSelectionGen extends javax.swing.JPanel { - // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel1; @@ -30,9 +30,11 @@ public class DownloadSelectionGen extends javax.swing.JPanel { private String[] listFilesToDownload; private ClientManagement clientManagement; private Logger logger; - // End of variables declaration /** + * @param listFilesToDownload list of files to display + * @param clientManagement clientManagement + * @param logger logger * Creates new form ArgumentsGen */ public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger) { @@ -44,8 +46,6 @@ public class DownloadSelectionGen extends javax.swing.JPanel { /** * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // @@ -116,6 +116,8 @@ public class DownloadSelectionGen extends javax.swing.JPanel { ); }// + + /** Actions to initiate when button "Download" is pressed */ private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { String fileSelected = jList1.getSelectedValue(); System.out.println("File to download: " + fileSelected); @@ -123,6 +125,7 @@ public class DownloadSelectionGen extends javax.swing.JPanel { //DownloadFileGUI.download(); } + /** Actions to initiate when button "Back" is initiate */ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { ArgumentsGen a = new ArgumentsGen(); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); diff --git a/src/gui/ErrorFrame.java b/src/gui/ErrorFrame.java index 4f23ce2..be94d56 100644 --- a/src/gui/ErrorFrame.java +++ b/src/gui/ErrorFrame.java @@ -11,6 +11,7 @@ package gui; * @author Louis Royer * @author Flavien Haas * @author JS Auge + * @version 1.0 */ public class ErrorFrame extends javax.swing.JFrame { @@ -18,9 +19,13 @@ public class ErrorFrame extends javax.swing.JFrame { private javax.swing.JToggleButton jToggleButton1; private String message; private static final long serialVersionUID = 13L; - // End of variables declaration + /** + * @param message error message that will be displayed + * Create new Errorframe, used to display an error and stop the program when needed + */ + public ErrorFrame(String message) { this.message = message; initComponents(); @@ -29,8 +34,6 @@ public class ErrorFrame extends javax.swing.JFrame { /** * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // @@ -79,6 +82,8 @@ public class ErrorFrame extends javax.swing.JFrame { pack(); }// + + /**force exit the program when the button "Close" is pressed*/ private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(1); } diff --git a/src/gui/Gui.java b/src/gui/Gui.java index 748e215..1272a84 100644 --- a/src/gui/Gui.java +++ b/src/gui/Gui.java @@ -2,6 +2,14 @@ package gui; import javax.swing.JFrame; +/** Class to download file +* @author Louis Royer +* @author Flavien Haas +* @author JS Auge +* @version 1.0 +* Class used to create the Graphical interface +*/ + public class Gui{ public static void main(String[] args) { diff --git a/src/gui/MainWindow.java b/src/gui/MainWindow.java index 5ee4428..fd3dbe7 100644 --- a/src/gui/MainWindow.java +++ b/src/gui/MainWindow.java @@ -2,6 +2,15 @@ package gui; import javax.swing.JFrame; +/** Class to download file +* @author Louis Royer +* @author Flavien Haas +* @author JS Auge +* @version 1.0 +* Class used to create the main window of the GUI +*/ + + public class MainWindow extends JFrame{ private static final long serialVersionUID = 13L; @@ -13,11 +22,7 @@ public class MainWindow extends JFrame{ fenetre.setLocationRelativeTo(null); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.add(new ArgumentsGen()); - //String[] listTest = {"test", "test2", "test3", "test4", "test5", "test6", "test7", "fichier1", - // "fichier2", "fichier3", "fichier4"}; - //fenetre.add(new DownloadSelectionGen(listTest)); fenetre.setVisible(true); - //ErrorFrame erreur = new ErrorFrame("ceci est une erreur"); } }