fixed name of ClientP2PGUI and updated javadoc for GUI

pull/108/head
js 5 years ago
parent 4b06939257
commit 6331f9f144

@ -1,12 +1,5 @@
package gui; 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.JFrame;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@ -14,6 +7,7 @@ package gui;
* @author Louis Royer * @author Louis Royer
* @author Flavien Haas * @author Flavien Haas
* @author JS Auge * @author JS Auge
*@version 1.0
*/ */
public class ArgumentsGen extends javax.swing.JPanel { 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. * 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") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() { private void initComponents() {
@ -162,6 +155,8 @@ public class ArgumentsGen extends javax.swing.JPanel {
// TODO add your handling code here: // 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) { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String hostnameServer = jTextField2.getText(); String hostnameServer = jTextField2.getText();
String portServerStr = jTextField1.getText(); String portServerStr = jTextField1.getText();
@ -175,7 +170,7 @@ public class ArgumentsGen extends javax.swing.JPanel {
System.out.println("protocol: " + protocolClient); System.out.println("protocol: " + protocolClient);
int portServer = Integer.parseInt(portServerStr); int portServer = Integer.parseInt(portServerStr);
int portTracker = Integer.parseInt(portTrackerStr); 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(); c.connect();
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
topFrame.dispose(); topFrame.dispose();

@ -37,7 +37,6 @@ public class ClientInterfaceGUI extends ClientInterface {
/** Constructor with clientManagement, logger and scanner. /** Constructor with clientManagement, logger and scanner.
* @param clientManagement ClientManagement used * @param clientManagement ClientManagement used
* @param logger Logger used * @param logger Logger used
* @param scanner Scanner used to read input
*/ */
Logger loggerC; Logger loggerC;
@ -60,10 +59,10 @@ public class ClientInterfaceGUI extends ClientInterface {
int optionSearch = 0; int optionSearch = 0;
String searchInput = ""; String searchInput = "";
String[] list = clientManagement.listDirectory(); String[] list = clientManagement.listDirectory();
System.out.println("running ClientInterfaceGUI and creating window"); //System.out.println("running ClientInterfaceGUI and creating window");
for(String listItem: list){ //for(String listItem: list){
System.out.println(listItem); //System.out.println(listItem);
} //}
JFrame win = new JFrame(); JFrame win = new JFrame();
win.setTitle("Client"); win.setTitle("Client");
win.setSize(550, 250); win.setSize(550, 250);

@ -14,14 +14,14 @@ import tools.HostItem;
import tools.ServerPortRange; import tools.ServerPortRange;
import tools.TrackerPortRange; import tools.TrackerPortRange;
/** Client + Server implementation. /** Client + Server implementation in GUI
* @author Louis Royer * @author Louis Royer
* @author Flavien Haas * @author Flavien Haas
* @author JS Auge * @author JS Auge
* @version 1.0 * @version 1.0
*/ */
public class ClientP2Pgui { public class ClientP2PGUI {
private String logDir = "logs/"; private String logDir = "logs/";
private String partsDir = ".parts/"; private String partsDir = ".parts/";
private Logger loggerServer; private Logger loggerServer;
@ -54,8 +54,9 @@ public class ClientP2Pgui {
* @param portServer port to bind * @param portServer port to bind
* @param hostnameTracker hostname of tracker * @param hostnameTracker hostname of tracker
* @param portTracker port 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.hostnameServer = hostnameServer;
this.hostnameTracker = hostnameTracker; 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()); 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(){ public void connect(){
System.out.println("using hostname : " + hostnameServer); System.out.println("using hostname : " + hostnameServer);
System.out.println("using port : " + portServer); System.out.println("using port : " + portServer);
System.out.println("tracker hostname : " + hostnameTracker); System.out.println("tracker hostname : " + hostnameTracker);

@ -17,10 +17,10 @@ package gui;
* @author Louis Royer * @author Louis Royer
* @author Flavien Haas * @author Flavien Haas
* @author JS Auge * @author JS Auge
* @version 1.0
*/ */
public class DownloadSelectionGen extends javax.swing.JPanel { public class DownloadSelectionGen extends javax.swing.JPanel {
// Variables declaration - do not modify
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2; private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
@ -30,9 +30,11 @@ public class DownloadSelectionGen extends javax.swing.JPanel {
private String[] listFilesToDownload; private String[] listFilesToDownload;
private ClientManagement clientManagement; private ClientManagement clientManagement;
private Logger logger; private Logger logger;
// End of variables declaration
/** /**
* @param listFilesToDownload list of files to display
* @param clientManagement clientManagement
* @param logger logger
* Creates new form ArgumentsGen * Creates new form ArgumentsGen
*/ */
public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger) { 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. * 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") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">
@ -116,6 +116,8 @@ public class DownloadSelectionGen extends javax.swing.JPanel {
); );
}// </editor-fold> }// </editor-fold>
/** Actions to initiate when button "Download" is pressed */
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String fileSelected = jList1.getSelectedValue(); String fileSelected = jList1.getSelectedValue();
System.out.println("File to download: " + fileSelected); System.out.println("File to download: " + fileSelected);
@ -123,6 +125,7 @@ public class DownloadSelectionGen extends javax.swing.JPanel {
//DownloadFileGUI.download(); //DownloadFileGUI.download();
} }
/** Actions to initiate when button "Back" is initiate */
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
ArgumentsGen a = new ArgumentsGen(); ArgumentsGen a = new ArgumentsGen();
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);

@ -11,6 +11,7 @@ package gui;
* @author Louis Royer * @author Louis Royer
* @author Flavien Haas * @author Flavien Haas
* @author JS Auge * @author JS Auge
* @version 1.0
*/ */
public class ErrorFrame extends javax.swing.JFrame { public class ErrorFrame extends javax.swing.JFrame {
@ -18,9 +19,13 @@ public class ErrorFrame extends javax.swing.JFrame {
private javax.swing.JToggleButton jToggleButton1; private javax.swing.JToggleButton jToggleButton1;
private String message; private String message;
private static final long serialVersionUID = 13L; 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) { public ErrorFrame(String message) {
this.message = message; this.message = message;
initComponents(); initComponents();
@ -29,8 +34,6 @@ public class ErrorFrame extends javax.swing.JFrame {
/** /**
* This method is called from within the constructor to initialize the form. * 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") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">
@ -79,6 +82,8 @@ public class ErrorFrame extends javax.swing.JFrame {
pack(); pack();
}// </editor-fold> }// </editor-fold>
/**force exit the program when the button "Close" is pressed*/
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(1); System.exit(1);
} }

@ -2,6 +2,14 @@ package gui;
import javax.swing.JFrame; 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 class Gui{
public static void main(String[] args) { public static void main(String[] args) {

@ -2,6 +2,15 @@ package gui;
import javax.swing.JFrame; 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{ public class MainWindow extends JFrame{
private static final long serialVersionUID = 13L; private static final long serialVersionUID = 13L;
@ -13,11 +22,7 @@ public class MainWindow extends JFrame{
fenetre.setLocationRelativeTo(null); fenetre.setLocationRelativeTo(null);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.add(new ArgumentsGen()); 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); fenetre.setVisible(true);
//ErrorFrame erreur = new ErrorFrame("ceci est une erreur");
} }
} }

Loading…
Cancel
Save