From 839dc50e5b6bba6c6d82fd1e59380db5efe982bf Mon Sep 17 00:00:00 2001 From: RichardSimmons Date: Mon, 17 Dec 2018 21:14:44 -0500 Subject: [PATCH 001/145] Issue 422 Dialog box error This commit fixes a logistical error in the salutation message that prevented a dialog message to appear when no name was entered. --- .../cs/raiderplanner/controller/AccountController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/AccountController.java b/src/edu/wright/cs/raiderplanner/controller/AccountController.java index 982c2b92..15199d24 100644 --- a/src/edu/wright/cs/raiderplanner/controller/AccountController.java +++ b/src/edu/wright/cs/raiderplanner/controller/AccountController.java @@ -170,6 +170,7 @@ public void handleSubmit() { String invalidMessage = ""; boolean validSuccess = true; boolean validName = true; + if (!validateNumber()) { invalidMessage += "Please enter a valid W Number\n"; validSuccess = false; @@ -182,10 +183,7 @@ public void handleSubmit() { invalidMessage += "Please enter a valid email\n"; validSuccess = false; } - if (!validateSalutation()) { - invalidMessage += "Please enter a valid salutation\n"; - validSuccess = false; - } + if (this.fullName.getText().trim().isEmpty()) { if (!this.handleEmptyName()) { validName = false; From 23eab4d9f4793b465271c99e48e2bb8c4b51ee78 Mon Sep 17 00:00:00 2001 From: RichardSimmons Date: Tue, 18 Dec 2018 16:50:29 -0500 Subject: [PATCH 002/145] Update AccountController.java --- .../wright/cs/raiderplanner/controller/AccountController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/AccountController.java b/src/edu/wright/cs/raiderplanner/controller/AccountController.java index 15199d24..2d8d9444 100644 --- a/src/edu/wright/cs/raiderplanner/controller/AccountController.java +++ b/src/edu/wright/cs/raiderplanner/controller/AccountController.java @@ -183,7 +183,6 @@ public void handleSubmit() { invalidMessage += "Please enter a valid email\n"; validSuccess = false; } - if (this.fullName.getText().trim().isEmpty()) { if (!this.handleEmptyName()) { validName = false; @@ -202,7 +201,6 @@ public void handleSubmit() { invalidInputAlert.showAndWait(); } } - /** * Handle Quit button. */ From d815b2fb6f8adc738df448027133e804ffdc355e Mon Sep 17 00:00:00 2001 From: RichardSimmons Date: Tue, 18 Dec 2018 16:51:12 -0500 Subject: [PATCH 003/145] Remove Trailing Whitespaces --- .../wright/cs/raiderplanner/controller/AccountController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/AccountController.java b/src/edu/wright/cs/raiderplanner/controller/AccountController.java index 2d8d9444..728edf75 100644 --- a/src/edu/wright/cs/raiderplanner/controller/AccountController.java +++ b/src/edu/wright/cs/raiderplanner/controller/AccountController.java @@ -170,7 +170,6 @@ public void handleSubmit() { String invalidMessage = ""; boolean validSuccess = true; boolean validName = true; - if (!validateNumber()) { invalidMessage += "Please enter a valid W Number\n"; validSuccess = false; From 3cdf29d62778b7c94e7e6047c9cd07ea86b32eb1 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 28 Jan 2019 14:11:16 -0500 Subject: [PATCH 004/145] Created Server Stub --- .../wright/cs/raiderserver/ServerMain.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/edu/wright/cs/raiderserver/ServerMain.java diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java new file mode 100644 index 00000000..56aabefc --- /dev/null +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2019 + * + * + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package edu.wright.cs.raiderserver; + +/** + * @author lukeg + * + */ +public class ServerMain { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + System.out.println("Hello Server"); + } + +} From 7190de1059247d13bf1b97e279d36e4d841eb716 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Tue, 29 Jan 2019 21:22:20 -0500 Subject: [PATCH 005/145] Load file iff is not null --- .settings/org.eclipse.buildship.core.prefs | 4 ++-- .../wright/cs/raiderplanner/controller/MenuController.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index e8895216..408b507c 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -1,2 +1,2 @@ -connection.project.dir= -eclipse.preferences.version=1 +connection.project.dir= +eclipse.preferences.version=1 diff --git a/src/edu/wright/cs/raiderplanner/controller/MenuController.java b/src/edu/wright/cs/raiderplanner/controller/MenuController.java index 20fcbe8b..1aeac029 100644 --- a/src/edu/wright/cs/raiderplanner/controller/MenuController.java +++ b/src/edu/wright/cs/raiderplanner/controller/MenuController.java @@ -576,8 +576,10 @@ public void openProfile() { } else { UiManager.reportError("File does not exist."); } + + MainController.loadFile(plannerFile); } - MainController.loadFile(plannerFile); + try { MainController.ui.reloadMainMenu(); } catch (Exception e) { From bc879f880c6081892a88eb4a30659c05ce8fd10f Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Wed, 30 Jan 2019 21:51:35 -0500 Subject: [PATCH 006/145] Change planner file only if chosen file not null --- src/edu/wright/cs/raiderplanner/controller/MenuController.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/MenuController.java b/src/edu/wright/cs/raiderplanner/controller/MenuController.java index 1aeac029..a8435be3 100644 --- a/src/edu/wright/cs/raiderplanner/controller/MenuController.java +++ b/src/edu/wright/cs/raiderplanner/controller/MenuController.java @@ -560,8 +560,8 @@ public void createNewProfile() { public void openProfile() { MainController.save(); File plannerFile = MainController.ui.loadPlannerFileDialog(); - MainController.setPlannerFile(plannerFile); if (plannerFile != null) { + MainController.setPlannerFile(plannerFile); if (plannerFile.exists()) { if (plannerFile.canRead()) { if (plannerFile.canWrite()) { @@ -576,7 +576,6 @@ public void openProfile() { } else { UiManager.reportError("File does not exist."); } - MainController.loadFile(plannerFile); } From f1e72eac9c7629feae8dbfad7a07c1fdc863e90b Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Wed, 30 Jan 2019 22:01:04 -0500 Subject: [PATCH 007/145] Prevent reloading main menu if null file chosen Whenever someone loads a new profile, the main menu is reloaded to update the view for that profile. When the main menu is reloaded, the notifications tray opens. If someone did not actually choose a new profile, the only discernable change to the view is seeing the notifications tray open. It is best to not reload the main menu to prevent the notifications tray from being opened. --- .../cs/raiderplanner/controller/MenuController.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/MenuController.java b/src/edu/wright/cs/raiderplanner/controller/MenuController.java index a8435be3..e28a6aa9 100644 --- a/src/edu/wright/cs/raiderplanner/controller/MenuController.java +++ b/src/edu/wright/cs/raiderplanner/controller/MenuController.java @@ -577,14 +577,15 @@ public void openProfile() { UiManager.reportError("File does not exist."); } MainController.loadFile(plannerFile); + + try { + MainController.ui.reloadMainMenu(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - try { - MainController.ui.reloadMainMenu(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } } /** From 7cc9a67f5b37b4cc10a81df1caf409babacdcb4d Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Thu, 31 Jan 2019 20:56:26 -0500 Subject: [PATCH 008/145] Create server-side socket connection --- src/edu/wright/cs/raiderserver/ServerMain.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 56aabefc..51a93a9b 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -21,6 +21,9 @@ package edu.wright.cs.raiderserver; +import java.io.IOException; +import java.net.ServerSocket; + /** * @author lukeg * @@ -31,8 +34,14 @@ public class ServerMain { * @param args */ public static void main(String[] args) { - // TODO Auto-generated method stub - System.out.println("Hello Server"); + int port = 8080; + + try { + ServerSocket ss = new ServerSocket(port); + } catch (IOException exc) { + System.err.println("A problem has occurred. Aborted."); + System.exit(1); + } } } From 87bf188ed05702f7c76c880915945724ec093492 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Thu, 31 Jan 2019 21:13:11 -0500 Subject: [PATCH 009/145] Create client server connection --- .../raiderplanner/controller/ChatController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index 23d4d8df..b008ccae 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -32,6 +32,7 @@ import javafx.scene.layout.HBox; import javafx.scene.paint.Color; +import java.net.Socket; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -97,4 +98,17 @@ public static void sendButtonAction(String userName) { } }); } + + /** + * This will create the client connection to the socket server to pass messages between users. + */ + public static void createClientSocketConnection() { + int port = 8080; + + try { + Socket sock = new Socket("localhost", port); + } catch (IOException exc) { + System.err.println("Connection error! Aborted."); + } + } } From 570710d374c466738438b4edfe4f2c1116978256 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Thu, 31 Jan 2019 21:20:38 -0500 Subject: [PATCH 010/145] Listen for incoming connections on chat server --- .../raiderplanner/controller/ChatController.java | 1 + src/edu/wright/cs/raiderserver/ServerMain.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index b008ccae..78f06788 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -32,6 +32,7 @@ import javafx.scene.layout.HBox; import javafx.scene.paint.Color; +import java.io.IOException; import java.net.Socket; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 51a93a9b..4bc9b78a 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -23,21 +23,32 @@ import java.io.IOException; import java.net.ServerSocket; +import java.net.Socket; /** + * This class creates the chat server. * @author lukeg - * */ public class ServerMain { /** - * @param args + * This starts the socket server listening for connections. */ public static void main(String[] args) { int port = 8080; try { + // Create the socket server ServerSocket ss = new ServerSocket(port); + + // Listen for new connections + while (true) { + try { + Socket incomingConn = ss.accept(); + } catch (IOException exc) { + System.err.println("Incoming connection failed!"); + } + } } catch (IOException exc) { System.err.println("A problem has occurred. Aborted."); System.exit(1); From 4a5a4d9626580469f6edd287a2937780cab12ba2 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Thu, 31 Jan 2019 21:51:08 -0500 Subject: [PATCH 011/145] Complete server framework --- .../controller/ChatController.java | 21 ++++++++ .../wright/cs/raiderserver/ServerMain.java | 51 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index 78f06788..ceeb3be2 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -108,8 +108,29 @@ public static void createClientSocketConnection() { try { Socket sock = new Socket("localhost", port); + new Thread(new ServerThread(sock)).start(); } catch (IOException exc) { System.err.println("Connection error! Aborted."); } } } + +class ServerThread implements Runnable { + + private Socket sock; + + public ServerThread(Socket sock) { + this.sock = sock; + } + + /* (non-Javadoc) + * @see java.lang.Runnable#run() + */ + @Override + public void run() { + // TODO Auto-generated method stub + + } + +} + diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 4bc9b78a..da46a737 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -21,9 +21,13 @@ package edu.wright.cs.raiderserver; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; +import java.util.ArrayList; /** * This class creates the chat server. @@ -42,9 +46,13 @@ public static void main(String[] args) { ServerSocket ss = new ServerSocket(port); // Listen for new connections + ArrayList clients = new ArrayList(); while (true) { try { Socket incomingConn = ss.accept(); + ClientThread newClient = new ClientThread(incomingConn); + new Thread(newClient).start(); + clients.add(newClient); } catch (IOException exc) { System.err.println("Incoming connection failed!"); } @@ -56,3 +64,46 @@ public static void main(String[] args) { } } + +/** + * This class implements a client manager thread. + * @author ajhs2 + */ +class ClientThread extends ServerMain implements Runnable { + + private Socket sock; + private BufferedReader in; + private PrintWriter out; + + public ClientThread(Socket sock) { + this.sock = sock; + } + + /* (non-Javadoc) + * @see java.lang.Runnable#run() + */ + @Override + public void run() { + try { + out = new PrintWriter(sock.getOutputStream(), true); + in = new BufferedReader(new InputStreamReader(sock.getInputStream())); + + while (!sock.isClosed()) { + String input = in.readLine(); + if (input != null) { + for (ClientThread c : clients) { + c.getWriter().write(input); + } + } + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public PrintWriter getWriter() { + return out; + } + +} From 4e558d484da082e4e45697aaaa430020d5f88e02 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Fri, 1 Feb 2019 17:01:58 -0500 Subject: [PATCH 012/145] Use simpler server code as baseline The new code is now based on a simpler tutorial than the one used previously. See tutorial at https://way2java.com/networking/chat-program-two-way-communication/ --- .../wright/cs/raiderserver/ServerMain.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index da46a737..f83f26d7 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -23,11 +23,14 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; +import java.util.Scanner; /** * This class creates the chat server. @@ -46,16 +49,29 @@ public static void main(String[] args) { ServerSocket ss = new ServerSocket(port); // Listen for new connections - ArrayList clients = new ArrayList(); + Socket incomingConn = ss.accept(); + + // Get message to send to client + Scanner in = new Scanner(System.in); + OutputStream out = incomingConn.getOutputStream(); + PrintWriter pw = new PrintWriter(out, true); + + // Receive new messages + InputStream is = incomingConn.getInputStream(); + Scanner receive = new Scanner(System.in); + + String outgoing, incoming; while (true) { - try { - Socket incomingConn = ss.accept(); - ClientThread newClient = new ClientThread(incomingConn); - new Thread(newClient).start(); - clients.add(newClient); - } catch (IOException exc) { - System.err.println("Incoming connection failed!"); + // Get any incoming messages + incoming = receive.nextLine(); + if (incoming != null) { + System.out.println(incoming); } + + // Send any outgoing messages + outgoing = in.nextLine(); + pw.println(outgoing); + pw.flush(); } } catch (IOException exc) { System.err.println("A problem has occurred. Aborted."); From 92bd356700395c386a9f45274e9400149e1ab6f7 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Fri, 1 Feb 2019 17:11:10 -0500 Subject: [PATCH 013/145] Use simple client code for base Client based on new simple example at https://way2java.com/networking/chat-program-two-way-communication/ --- .../controller/ChatController.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index ceeb3be2..c3ff9923 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -33,9 +33,13 @@ import javafx.scene.paint.Color; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; import java.net.Socket; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Scanner; /** * This is a class to handle the code for the chat feature. @@ -107,8 +111,31 @@ public static void createClientSocketConnection() { int port = 8080; try { + // Connect to server Socket sock = new Socket("localhost", port); - new Thread(new ServerThread(sock)).start(); + + // Handle input + Scanner in = new Scanner(System.in); + OutputStream os = sock.getOutputStream(); + PrintWriter pw = new PrintWriter(os, true); + + // Recieve from server + InputStream is = sock.getInputStream(); + Scanner recieve = new Scanner(is); + + String incoming, outgoing; + while (true) { + // Handle sending messages out + outgoing = in.nextLine(); + pw.println(outgoing); + pw.flush(); + + // Handle getting messages back + incoming = recieve.nextLine(); + if (incoming != null) { + System.out.println(incoming); + } + } } catch (IOException exc) { System.err.println("Connection error! Aborted."); } From a652e8a42fe7d2a693f38200e286ed57bad9ce00 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Fri, 1 Feb 2019 17:36:38 -0500 Subject: [PATCH 014/145] Eliminate unneeded threading code Threading code was from previous example and is no longer needed. --- .../controller/ChatController.java | 119 ++++++++++-------- .../wright/cs/raiderserver/ServerMain.java | 86 ++++++------- 2 files changed, 108 insertions(+), 97 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index c3ff9923..8c8fe23e 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -32,8 +32,10 @@ import javafx.scene.layout.HBox; import javafx.scene.paint.Color; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.net.Socket; @@ -47,62 +49,62 @@ */ public class ChatController { //chat variables - private static final GridPane userMessagePane = new GridPane(); - private static final HBox spacingBox = new HBox(); - private static TextField tfMessageToSend = new TextField(); - private static TextArea msgArea = new TextArea(); - private static final Button sendButton = new Button("Send"); - - /** - * Default Constructor. - */ - public ChatController() { - } +// private static final GridPane userMessagePane = new GridPane(); +// private static final HBox spacingBox = new HBox(); +// private static TextField tfMessageToSend = new TextField(); +// private static TextArea msgArea = new TextArea(); +// private static final Button sendButton = new Button("Send"); +// +// /** +// * Default Constructor. +// */ +// public ChatController() { +// } /** * This will prevent the message area from being edited and set the size for all the buttons * This method will also create padding between the text and message areas and the send button. */ - public static void createUserMessagePane() { - msgArea.setEditable(false); - tfMessageToSend.setPrefWidth(800); - userMessagePane.setPadding(new Insets(10, 10, 10, 10)); - sendButton.setBackground(new Background(new BackgroundFill(Color.AQUAMARINE, null, null))); - spacingBox.setPadding(new Insets(0, 5, 0, 5)); - userMessagePane.add(tfMessageToSend, 0, 0); - userMessagePane.add(spacingBox, 1, 0); - userMessagePane.add(sendButton, 2, 0); - sendButton.setMinWidth(100); - sendButton.setDefaultButton(true); - } - - /** - * This will load the msg_area which is where the user will see messages from other users and - * him or herself. This will also load the text field where the user will be able to send his or - * her own message to peers. - */ - public static void createMainPane() { - MenuController.getMainPane().setCenter(msgArea); - MenuController.getMainPane().setBottom(userMessagePane); - } - - /** - * This will take in the action of when the send button is pressed. If a user sends a message, - * the line of text will append to the chat log so the user can see what they sent. It follows - * the format of USER: sentence time/date. - * The text box with the user input will be set back to blank after a message is sent. - */ - public static void sendButtonAction(String userName) { - sendButton.setOnAction((ActionEvent exception1) -> { - DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); - LocalDateTime time = LocalDateTime.now(); - if (!(tfMessageToSend.getText().equals(""))) { - msgArea.appendText(userName + ": " + tfMessageToSend.getText()); - msgArea.appendText("\t\t\t" + date.format(time) + "\n"); - tfMessageToSend.setText(""); - } - }); - } +// public static void createUserMessagePane() { +// msgArea.setEditable(false); +// tfMessageToSend.setPrefWidth(800); +// userMessagePane.setPadding(new Insets(10, 10, 10, 10)); +// sendButton.setBackground(new Background(new BackgroundFill(Color.AQUAMARINE, null, null))); +// spacingBox.setPadding(new Insets(0, 5, 0, 5)); +// userMessagePane.add(tfMessageToSend, 0, 0); +// userMessagePane.add(spacingBox, 1, 0); +// userMessagePane.add(sendButton, 2, 0); +// sendButton.setMinWidth(100); +// sendButton.setDefaultButton(true); +// } +// +// /** +// * This will load the msg_area which is where the user will see messages from other users and +// * him or herself. This will also load the text field where the user will be able to send his or +// * her own message to peers. +// */ +// public static void createMainPane() { +// MenuController.getMainPane().setCenter(msgArea); +// MenuController.getMainPane().setBottom(userMessagePane); +// } +// +// /** +// * This will take in the action of when the send button is pressed. If a user sends a message, +// * the line of text will append to the chat log so the user can see what they sent. It follows +// * the format of USER: sentence time/date. +// * The text box with the user input will be set back to blank after a message is sent. +// */ +// public static void sendButtonAction(String userName) { +// sendButton.setOnAction((ActionEvent exception1) -> { +// DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); +// LocalDateTime time = LocalDateTime.now(); +// if (!(tfMessageToSend.getText().equals(""))) { +// msgArea.appendText(userName + ": " + tfMessageToSend.getText()); +// msgArea.appendText("\t\t\t" + date.format(time) + "\n"); +// tfMessageToSend.setText(""); +// } +// }); +// } /** * This will create the client connection to the socket server to pass messages between users. @@ -113,25 +115,26 @@ public static void createClientSocketConnection() { try { // Connect to server Socket sock = new Socket("localhost", port); + System.out.println("Client ready!"); // Handle input - Scanner in = new Scanner(System.in); + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); OutputStream os = sock.getOutputStream(); PrintWriter pw = new PrintWriter(os, true); // Recieve from server InputStream is = sock.getInputStream(); - Scanner recieve = new Scanner(is); + BufferedReader recieve = new BufferedReader(new InputStreamReader(is)); String incoming, outgoing; while (true) { // Handle sending messages out - outgoing = in.nextLine(); + outgoing = in.readLine(); pw.println(outgoing); pw.flush(); // Handle getting messages back - incoming = recieve.nextLine(); + incoming = recieve.readLine(); if (incoming != null) { System.out.println(incoming); } @@ -140,8 +143,14 @@ public static void createClientSocketConnection() { System.err.println("Connection error! Aborted."); } } + + public static void main(String[] arga) { + createClientSocketConnection(); + } } + + class ServerThread implements Runnable { private Socket sock; diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index f83f26d7..9e44214e 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -50,31 +50,33 @@ public static void main(String[] args) { // Listen for new connections Socket incomingConn = ss.accept(); + System.out.println("Server ready!"); // Get message to send to client - Scanner in = new Scanner(System.in); + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); OutputStream out = incomingConn.getOutputStream(); PrintWriter pw = new PrintWriter(out, true); // Receive new messages InputStream is = incomingConn.getInputStream(); - Scanner receive = new Scanner(System.in); + BufferedReader receive = new BufferedReader(new InputStreamReader(is)); String outgoing, incoming; while (true) { // Get any incoming messages - incoming = receive.nextLine(); + incoming = receive.readLine(); if (incoming != null) { System.out.println(incoming); } // Send any outgoing messages - outgoing = in.nextLine(); + outgoing = in.readLine(); pw.println(outgoing); pw.flush(); } } catch (IOException exc) { System.err.println("A problem has occurred. Aborted."); + exc.printStackTrace(); System.exit(1); } } @@ -85,41 +87,41 @@ public static void main(String[] args) { * This class implements a client manager thread. * @author ajhs2 */ -class ClientThread extends ServerMain implements Runnable { - - private Socket sock; - private BufferedReader in; - private PrintWriter out; - - public ClientThread(Socket sock) { - this.sock = sock; - } - - /* (non-Javadoc) - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - try { - out = new PrintWriter(sock.getOutputStream(), true); - in = new BufferedReader(new InputStreamReader(sock.getInputStream())); - - while (!sock.isClosed()) { - String input = in.readLine(); - if (input != null) { - for (ClientThread c : clients) { - c.getWriter().write(input); - } - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public PrintWriter getWriter() { - return out; - } - -} +//class ClientThread extends ServerMain implements Runnable { +// +// private Socket sock; +// private BufferedReader in; +// private PrintWriter out; +// +// public ClientThread(Socket sock) { +// this.sock = sock; +// } +// +// /* (non-Javadoc) +// * @see java.lang.Runnable#run() +// */ +// @Override +// public void run() { +// try { +// out = new PrintWriter(sock.getOutputStream(), true); +// in = new BufferedReader(new InputStreamReader(sock.getInputStream())); +// +// while (!sock.isClosed()) { +// String input = in.readLine(); +// if (input != null) { +// for (ClientThread c : clients) { +// c.getWriter().write(input); +// } +// } +// } +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public PrintWriter getWriter() { +// return out; +// } +// +//} From 4317b05966dc9fbec4b338431d64f493f2ff3572 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 19:12:24 -0500 Subject: [PATCH 015/145] Switch input reading to Scanner object --- .../cs/raiderplanner/controller/ChatController.java | 12 ++++++------ src/edu/wright/cs/raiderserver/ServerMain.java | 13 +++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index 8c8fe23e..d36fed69 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -118,25 +118,25 @@ public static void createClientSocketConnection() { System.out.println("Client ready!"); // Handle input - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + Scanner in = new Scanner(System.in); OutputStream os = sock.getOutputStream(); PrintWriter pw = new PrintWriter(os, true); // Recieve from server InputStream is = sock.getInputStream(); - BufferedReader recieve = new BufferedReader(new InputStreamReader(is)); + Scanner recieve = new Scanner(is); String incoming, outgoing; while (true) { // Handle sending messages out - outgoing = in.readLine(); + outgoing = in.nextLine(); pw.println(outgoing); pw.flush(); // Handle getting messages back - incoming = recieve.readLine(); - if (incoming != null) { - System.out.println(incoming); + //incoming = recieve.readLine(); + if (recieve.hasNext()) { + System.out.println(recieve.nextLine()); } } } catch (IOException exc) { diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 9e44214e..540ef370 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -53,24 +53,25 @@ public static void main(String[] args) { System.out.println("Server ready!"); // Get message to send to client - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + Scanner in = new Scanner(System.in); OutputStream out = incomingConn.getOutputStream(); PrintWriter pw = new PrintWriter(out, true); // Receive new messages InputStream is = incomingConn.getInputStream(); - BufferedReader receive = new BufferedReader(new InputStreamReader(is)); + Scanner receive = new Scanner(is); + // Handle I/O String outgoing, incoming; while (true) { // Get any incoming messages - incoming = receive.readLine(); - if (incoming != null) { - System.out.println(incoming); + //incoming = receive.readLine(); + if (receive.hasNext()) { + System.out.println(receive.nextLine()); } // Send any outgoing messages - outgoing = in.readLine(); + outgoing = in.nextLine(); pw.println(outgoing); pw.flush(); } From 122982f3d6b34df6640154c69bb23a2ba9688374 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 19:29:18 -0500 Subject: [PATCH 016/145] Recieve incoming messages on separate threads Thread out reciept of messages so that we can get more than one message at a time. Otherwise, we must get a message, send a message, one message at a time. --- .../controller/ChatController.java | 26 +++++++++++-------- .../wright/cs/raiderserver/ServerMain.java | 24 +++++++++-------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index d36fed69..665f9eb0 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -126,18 +126,22 @@ public static void createClientSocketConnection() { InputStream is = sock.getInputStream(); Scanner recieve = new Scanner(is); - String incoming, outgoing; - while (true) { - // Handle sending messages out - outgoing = in.nextLine(); - pw.println(outgoing); - pw.flush(); - - // Handle getting messages back - //incoming = recieve.readLine(); - if (recieve.hasNext()) { - System.out.println(recieve.nextLine()); + // Handle I/O... + + // Spawn new background thread to handle receipt + // TODO: Hook into GUI + new Thread(() -> { + while (true) { + if (recieve.hasNext()) { + System.out.println(recieve.nextLine()); + } } + }).start(); + + // Get keyboard input on this thread + while (true) { + pw.println(in.nextLine()); + pw.flush(); } } catch (IOException exc) { System.err.println("Connection error! Aborted."); diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 540ef370..9ef46ef4 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -61,18 +61,20 @@ public static void main(String[] args) { InputStream is = incomingConn.getInputStream(); Scanner receive = new Scanner(is); - // Handle I/O - String outgoing, incoming; - while (true) { - // Get any incoming messages - //incoming = receive.readLine(); - if (receive.hasNext()) { - System.out.println(receive.nextLine()); + // Handle I/O... + + // Spawn new background thread to handle receipt + new Thread(() -> { + while (true) { + if (receive.hasNext()) { + System.out.println(receive.nextLine()); + } } - - // Send any outgoing messages - outgoing = in.nextLine(); - pw.println(outgoing); + }).start(); + + // Get keyboard input on this thread + while (true) { + pw.println(in.nextLine()); pw.flush(); } } catch (IOException exc) { From e1714287b1b2aff6b908f427998f4b8ef7382875 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 20:03:52 -0500 Subject: [PATCH 017/145] Remove unneeded client/server threads --- .../controller/ChatController.java | 22 ---------- .../wright/cs/raiderserver/ServerMain.java | 43 ------------------- 2 files changed, 65 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index 665f9eb0..cd97e477 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -152,25 +152,3 @@ public static void main(String[] arga) { createClientSocketConnection(); } } - - - -class ServerThread implements Runnable { - - private Socket sock; - - public ServerThread(Socket sock) { - this.sock = sock; - } - - /* (non-Javadoc) - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - // TODO Auto-generated method stub - - } - -} - diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 9ef46ef4..1614d814 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -85,46 +85,3 @@ public static void main(String[] args) { } } - -/** - * This class implements a client manager thread. - * @author ajhs2 - */ -//class ClientThread extends ServerMain implements Runnable { -// -// private Socket sock; -// private BufferedReader in; -// private PrintWriter out; -// -// public ClientThread(Socket sock) { -// this.sock = sock; -// } -// -// /* (non-Javadoc) -// * @see java.lang.Runnable#run() -// */ -// @Override -// public void run() { -// try { -// out = new PrintWriter(sock.getOutputStream(), true); -// in = new BufferedReader(new InputStreamReader(sock.getInputStream())); -// -// while (!sock.isClosed()) { -// String input = in.readLine(); -// if (input != null) { -// for (ClientThread c : clients) { -// c.getWriter().write(input); -// } -// } -// } -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// -// public PrintWriter getWriter() { -// return out; -// } -// -//} From 08ef248205c637e581e4cd132fb2e99d7f381829 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 20:09:03 -0500 Subject: [PATCH 018/145] Remove unused imports --- src/edu/wright/cs/raiderplanner/controller/ChatController.java | 2 -- src/edu/wright/cs/raiderserver/ServerMain.java | 3 --- 2 files changed, 5 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index cd97e477..c45dd731 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -32,10 +32,8 @@ import javafx.scene.layout.HBox; import javafx.scene.paint.Color; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.net.Socket; diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index 1614d814..f130526e 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -21,15 +21,12 @@ package edu.wright.cs.raiderserver; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; -import java.util.ArrayList; import java.util.Scanner; /** From 50337e36f0e1cedd46ce0effed8135b931e59bf8 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 20:10:28 -0500 Subject: [PATCH 019/145] Reactivate chat GUI --- .../controller/ChatController.java | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index c45dd731..39b5ec7e 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -47,62 +47,62 @@ */ public class ChatController { //chat variables -// private static final GridPane userMessagePane = new GridPane(); -// private static final HBox spacingBox = new HBox(); -// private static TextField tfMessageToSend = new TextField(); -// private static TextArea msgArea = new TextArea(); -// private static final Button sendButton = new Button("Send"); -// -// /** -// * Default Constructor. -// */ -// public ChatController() { -// } + private static final GridPane userMessagePane = new GridPane(); + private static final HBox spacingBox = new HBox(); + private static TextField tfMessageToSend = new TextField(); + private static TextArea msgArea = new TextArea(); + private static final Button sendButton = new Button("Send"); + + /** + * Default Constructor. + */ + public ChatController() { + } /** * This will prevent the message area from being edited and set the size for all the buttons * This method will also create padding between the text and message areas and the send button. */ -// public static void createUserMessagePane() { -// msgArea.setEditable(false); -// tfMessageToSend.setPrefWidth(800); -// userMessagePane.setPadding(new Insets(10, 10, 10, 10)); -// sendButton.setBackground(new Background(new BackgroundFill(Color.AQUAMARINE, null, null))); -// spacingBox.setPadding(new Insets(0, 5, 0, 5)); -// userMessagePane.add(tfMessageToSend, 0, 0); -// userMessagePane.add(spacingBox, 1, 0); -// userMessagePane.add(sendButton, 2, 0); -// sendButton.setMinWidth(100); -// sendButton.setDefaultButton(true); -// } -// -// /** -// * This will load the msg_area which is where the user will see messages from other users and -// * him or herself. This will also load the text field where the user will be able to send his or -// * her own message to peers. -// */ -// public static void createMainPane() { -// MenuController.getMainPane().setCenter(msgArea); -// MenuController.getMainPane().setBottom(userMessagePane); -// } -// -// /** -// * This will take in the action of when the send button is pressed. If a user sends a message, -// * the line of text will append to the chat log so the user can see what they sent. It follows -// * the format of USER: sentence time/date. -// * The text box with the user input will be set back to blank after a message is sent. -// */ -// public static void sendButtonAction(String userName) { -// sendButton.setOnAction((ActionEvent exception1) -> { -// DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); -// LocalDateTime time = LocalDateTime.now(); -// if (!(tfMessageToSend.getText().equals(""))) { -// msgArea.appendText(userName + ": " + tfMessageToSend.getText()); -// msgArea.appendText("\t\t\t" + date.format(time) + "\n"); -// tfMessageToSend.setText(""); -// } -// }); -// } + public static void createUserMessagePane() { + msgArea.setEditable(false); + tfMessageToSend.setPrefWidth(800); + userMessagePane.setPadding(new Insets(10, 10, 10, 10)); + sendButton.setBackground(new Background(new BackgroundFill(Color.AQUAMARINE, null, null))); + spacingBox.setPadding(new Insets(0, 5, 0, 5)); + userMessagePane.add(tfMessageToSend, 0, 0); + userMessagePane.add(spacingBox, 1, 0); + userMessagePane.add(sendButton, 2, 0); + sendButton.setMinWidth(100); + sendButton.setDefaultButton(true); + } + + /** + * This will load the msg_area which is where the user will see messages from other users and + * him or herself. This will also load the text field where the user will be able to send his or + * her own message to peers. + */ + public static void createMainPane() { + MenuController.getMainPane().setCenter(msgArea); + MenuController.getMainPane().setBottom(userMessagePane); + } + + /** + * This will take in the action of when the send button is pressed. If a user sends a message, + * the line of text will append to the chat log so the user can see what they sent. It follows + * the format of USER: sentence time/date. + * The text box with the user input will be set back to blank after a message is sent. + */ + public static void sendButtonAction(String userName) { + sendButton.setOnAction((ActionEvent exception1) -> { + DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + LocalDateTime time = LocalDateTime.now(); + if (!(tfMessageToSend.getText().equals(""))) { + msgArea.appendText(userName + ": " + tfMessageToSend.getText()); + msgArea.appendText("\t\t\t" + date.format(time) + "\n"); + tfMessageToSend.setText(""); + } + }); + } /** * This will create the client connection to the socket server to pass messages between users. From b28eeba6f9cd5a037921dc4640469cbb64abb293 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 20:54:36 -0500 Subject: [PATCH 020/145] Send message from GUI to server --- .../controller/ChatController.java | 106 +++++++++++------- 1 file changed, 64 insertions(+), 42 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index 39b5ec7e..aaaca59d 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -52,6 +52,10 @@ public class ChatController { private static TextField tfMessageToSend = new TextField(); private static TextArea msgArea = new TextArea(); private static final Button sendButton = new Button("Send"); + private static Socket sock; + private static int port; + private static OutputStream output; + private static PrintWriter printOutput; /** * Default Constructor. @@ -74,6 +78,22 @@ public static void createUserMessagePane() { userMessagePane.add(sendButton, 2, 0); sendButton.setMinWidth(100); sendButton.setDefaultButton(true); + createServerConnection(); + } + + /** + * This method opens up a connection to the chat server from this client. + */ + private static void createServerConnection() { + port = 8080; + try { + sock = new Socket("localhost", port); + output = sock.getOutputStream(); + printOutput = new PrintWriter(output, true); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } /** @@ -99,6 +119,8 @@ public static void sendButtonAction(String userName) { if (!(tfMessageToSend.getText().equals(""))) { msgArea.appendText(userName + ": " + tfMessageToSend.getText()); msgArea.appendText("\t\t\t" + date.format(time) + "\n"); + printOutput.println(tfMessageToSend.getText()); + printOutput.flush(); tfMessageToSend.setText(""); } }); @@ -107,46 +129,46 @@ public static void sendButtonAction(String userName) { /** * This will create the client connection to the socket server to pass messages between users. */ - public static void createClientSocketConnection() { - int port = 8080; - - try { - // Connect to server - Socket sock = new Socket("localhost", port); - System.out.println("Client ready!"); - - // Handle input - Scanner in = new Scanner(System.in); - OutputStream os = sock.getOutputStream(); - PrintWriter pw = new PrintWriter(os, true); - - // Recieve from server - InputStream is = sock.getInputStream(); - Scanner recieve = new Scanner(is); - - // Handle I/O... - - // Spawn new background thread to handle receipt - // TODO: Hook into GUI - new Thread(() -> { - while (true) { - if (recieve.hasNext()) { - System.out.println(recieve.nextLine()); - } - } - }).start(); - - // Get keyboard input on this thread - while (true) { - pw.println(in.nextLine()); - pw.flush(); - } - } catch (IOException exc) { - System.err.println("Connection error! Aborted."); - } - } - - public static void main(String[] arga) { - createClientSocketConnection(); - } +// public static void createClientSocketConnection() { +// int port = 8080; +// +// try { +// // Connect to server +// Socket sock = new Socket("localhost", port); +// System.out.println("Client ready!"); +// +// // Handle input +// Scanner in = new Scanner(System.in); +// OutputStream os = sock.getOutputStream(); +// PrintWriter pw = new PrintWriter(os, true); +// +// // Recieve from server +// InputStream is = sock.getInputStream(); +// Scanner recieve = new Scanner(is); +// +// // Handle I/O... +// +// // Spawn new background thread to handle receipt +// // TODO: Hook into GUI +// new Thread(() -> { +// while (true) { +// if (recieve.hasNext()) { +// System.out.println(recieve.nextLine()); +// } +// } +// }).start(); +// +// // Get keyboard input on this thread +// while (true) { +// pw.println(in.nextLine()); +// pw.flush(); +// } +// } catch (IOException exc) { +// System.err.println("Connection error! Aborted."); +// } +// } +// +// public static void main(String[] arga) { +// createClientSocketConnection(); +// } } From 494513173b79b2ecda22baa041926eb72f4d602c Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 21:14:08 -0500 Subject: [PATCH 021/145] Echo server message in RaiderPlanner GUI --- .../controller/ChatController.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index aaaca59d..2b7e4d80 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -56,6 +56,8 @@ public class ChatController { private static int port; private static OutputStream output; private static PrintWriter printOutput; + private static InputStream incoming; + private static Scanner incomingMessage; /** * Default Constructor. @@ -78,22 +80,40 @@ public static void createUserMessagePane() { userMessagePane.add(sendButton, 2, 0); sendButton.setMinWidth(100); sendButton.setDefaultButton(true); - createServerConnection(); + setupServerConnection(); } /** * This method opens up a connection to the chat server from this client. */ - private static void createServerConnection() { + private static void setupServerConnection() { + // Establish connection port = 8080; try { + // Handle input sock = new Socket("localhost", port); output = sock.getOutputStream(); printOutput = new PrintWriter(output, true); + + // Handle incoming messages + incoming = sock.getInputStream(); + incomingMessage = new Scanner(incoming); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } + + // Create background thread to grab incoming messages + new Thread(() -> { + while (true) { + if (incomingMessage.hasNext()) { + DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); + LocalDateTime time = LocalDateTime.now(); + msgArea.appendText("response" + ": " + incomingMessage.nextLine()); + msgArea.appendText("\t\t\t" + date.format(time) + "\n"); + } + } + }).start(); } /** From 906f39edad74d2520ef8ad19576d6b002f582e4c Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Sat, 2 Feb 2019 21:14:58 -0500 Subject: [PATCH 022/145] Remove unused server testing code --- .../controller/ChatController.java | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index 2b7e4d80..cdc45664 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -146,49 +146,4 @@ public static void sendButtonAction(String userName) { }); } - /** - * This will create the client connection to the socket server to pass messages between users. - */ -// public static void createClientSocketConnection() { -// int port = 8080; -// -// try { -// // Connect to server -// Socket sock = new Socket("localhost", port); -// System.out.println("Client ready!"); -// -// // Handle input -// Scanner in = new Scanner(System.in); -// OutputStream os = sock.getOutputStream(); -// PrintWriter pw = new PrintWriter(os, true); -// -// // Recieve from server -// InputStream is = sock.getInputStream(); -// Scanner recieve = new Scanner(is); -// -// // Handle I/O... -// -// // Spawn new background thread to handle receipt -// // TODO: Hook into GUI -// new Thread(() -> { -// while (true) { -// if (recieve.hasNext()) { -// System.out.println(recieve.nextLine()); -// } -// } -// }).start(); -// -// // Get keyboard input on this thread -// while (true) { -// pw.println(in.nextLine()); -// pw.flush(); -// } -// } catch (IOException exc) { -// System.err.println("Connection error! Aborted."); -// } -// } -// -// public static void main(String[] arga) { -// createClientSocketConnection(); -// } } From 1ee0e90ac3b4a624bf5f1ac27f1c6cece215e631 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 4 Feb 2019 14:15:21 -0500 Subject: [PATCH 023/145] Added usernames to server communications created basic protocol to pair user names with messages. , --- .../cs/raiderplanner/controller/ChatController.java | 8 ++++++-- src/edu/wright/cs/raiderserver/ServerMain.java | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/edu/wright/cs/raiderplanner/controller/ChatController.java b/src/edu/wright/cs/raiderplanner/controller/ChatController.java index cdc45664..0a16f0e5 100644 --- a/src/edu/wright/cs/raiderplanner/controller/ChatController.java +++ b/src/edu/wright/cs/raiderplanner/controller/ChatController.java @@ -109,7 +109,11 @@ private static void setupServerConnection() { if (incomingMessage.hasNext()) { DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); LocalDateTime time = LocalDateTime.now(); - msgArea.appendText("response" + ": " + incomingMessage.nextLine()); + String line = incomingMessage.nextLine(); + String user = line.substring(0, line.indexOf(',')); + String message = line.substring(line.indexOf(',') + 1); + + msgArea.appendText(user + ": " + message); msgArea.appendText("\t\t\t" + date.format(time) + "\n"); } } @@ -139,7 +143,7 @@ public static void sendButtonAction(String userName) { if (!(tfMessageToSend.getText().equals(""))) { msgArea.appendText(userName + ": " + tfMessageToSend.getText()); msgArea.appendText("\t\t\t" + date.format(time) + "\n"); - printOutput.println(tfMessageToSend.getText()); + printOutput.println(userName + "," + tfMessageToSend.getText()); printOutput.flush(); tfMessageToSend.setText(""); } diff --git a/src/edu/wright/cs/raiderserver/ServerMain.java b/src/edu/wright/cs/raiderserver/ServerMain.java index f130526e..5d513f1d 100644 --- a/src/edu/wright/cs/raiderserver/ServerMain.java +++ b/src/edu/wright/cs/raiderserver/ServerMain.java @@ -34,7 +34,8 @@ * @author lukeg */ public class ServerMain { - + private static final String serverName = "SERVER"; + /** * This starts the socket server listening for connections. */ @@ -71,7 +72,7 @@ public static void main(String[] args) { // Get keyboard input on this thread while (true) { - pw.println(in.nextLine()); + pw.println(serverName + "," + in.nextLine()); pw.flush(); } } catch (IOException exc) { From 693426ffed5695198387e9560a8314f2b3feeb6f Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Wed, 6 Feb 2019 20:22:52 -0500 Subject: [PATCH 024/145] Add adamhs1997 to users.md --- Project1/users.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Project1/users.md diff --git a/Project1/users.md b/Project1/users.md new file mode 100644 index 00000000..848f7e41 --- /dev/null +++ b/Project1/users.md @@ -0,0 +1 @@ +adamhs1997 J. Horvath-Smith From ac0652c500758c37638e7d09f28888f944144ada Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Wed, 6 Feb 2019 21:14:45 -0500 Subject: [PATCH 025/145] Add draft of branching.md --- Project1/branching.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Project1/branching.md diff --git a/Project1/branching.md b/Project1/branching.md new file mode 100644 index 00000000..ba09e1a9 --- /dev/null +++ b/Project1/branching.md @@ -0,0 +1,20 @@ +1. https://www.creativebloq.com/web-design/choose-right-git-branching-strategy-121518344 by "Creative Bloq Staff" +2. https://docs.microsoft.com/en-us/azure/devops/repos/git/git-branching-guidance?view=azure-devops by "Multiple Contributors" +3. https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows by "git-scm.com" + +Links 1 and 2 discuss using what is called "GitHub Flow", a basic branching model where each feature is developed on its own +branch directly from master. Link 3 is similar, but rather than creating new branches from master, you would maintain separate +master and develop branches. Master only would contain "release" code, while develop would contain stable code that has not +yet been pushed into production. In either model, the actual development is done on separate feature branches, so there is always +at least one branch with a stable, working program. + +The model we used was similar to the one described in articles 1 and 2, where each feature was branched directly from master. +The only difference in our model was that we each made personal branches from the feature branch, so each person's individual +work on the feature did not create conflicts. When one person was done with a part of the feature, his changes would be merged +to the main feature branch. When the main feature was complete, this would be merged into master. + +This branching strategy was simple to use and easy to manage. However, it may not necessarily be best for larger projects since, +in theory, any completed feature would be pushed directly into production by committing it to master. In a larger project, it +would probably be best to implement the strategy described in Link 3. This would allow us to have all stable code on develop, +while giving more control over what goes into production by pushing batches of features into master. + From 9133a598bf234da391f1db185aa91373f0e95257 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Wed, 6 Feb 2019 22:05:51 -0500 Subject: [PATCH 026/145] Add adamhs1997.md --- Project1/adamhs1997.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Project1/adamhs1997.md diff --git a/Project1/adamhs1997.md b/Project1/adamhs1997.md new file mode 100644 index 00000000..4410d6eb --- /dev/null +++ b/Project1/adamhs1997.md @@ -0,0 +1,37 @@ +The first issue I chose to work on was https://github.com/gzdwsu/RaiderPlanner/issues/1. This +issue was fairly simple to resolve, and all the problem code was located in +src/edu/wright/cs/raiderplanner/controller/MenuController.java. No new code had to be written, +only existing code had to be rearranged to fit in an existing conditional block. All changes +were made in the `openProfile()` method. The issue was simple: If a user didn't choose a file +to open, certain blocks of the method shouldn't have executed. While the original author of the +method took care of some of this, some of the code that should have been in the `if` block +was not. I simply moved the code into this block. + +Work on this issue was done on the profile-error-adam branch. Three commits were made: +*7190de1 Load file iff is not null +*bc879f8 Change planner file only if chosen file is not null +*f1e72ea Prevent reloading main menu if null file chosen +I believe each of these commits were descriptive and appropriate for each code change. (In all +honesty, this probably could have been one commit, but for the purposes of the project it +seemed best to break up.) As the issue was resolved, the commits were useful to the project. +See pull request at https://github.com/washS118/RaiderPlanner/pull/1. + +--- + +The next issue I worked on was https://github.com/gzdwsu/RaiderPlanner/issues/2. This +issue, being a feature addition, was more complex than the bug above. I worked on this with +L. Gauldin, but kept my commits on a separate feature branch (ServerDev-adam) than his. In +short, the our goal to resolve this issue was to add a simple chat client/server into the +RaiderPlanner application to make the chat feature stub somewhat functional. To start, +L. Gauldin added a stub server application in src/edu/wright/cs/raiderserver/ServerMain.java. +I populated this with functional chat server code. Client code was added to +src/edu/wright/cs/raiderplanner/controller/ChatController.java. + +I made a total of 15 commits to work on this issue. These are too many to list here, but can +be seen in the pull request at https://github.com/washS118/RaiderPlanner/pull/2. Note that +this pull request was to merge my feature development branch (ServerDev-adam) back into the +main feature branch (ServerDev; see branching.md for more on our model). This is not the +complete chat client/server code, and is not all that was eventually merged into master. +I feel that each of these commits was descriptive and appropriate for each code addition. +As we were able to implement a functional chat client in RaiderPlanner by building from +these commits, I feel that this was a positive change for the project. From 6ea9c07973ca612b6284bd09efe30e1632c5cbc8 Mon Sep 17 00:00:00 2001 From: Adam Horvath-Smith Date: Thu, 7 Feb 2019 14:39:41 -0500 Subject: [PATCH 027/145] Add preliminary conclusion --- Project1/conclusion.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Project1/conclusion.md diff --git a/Project1/conclusion.md b/Project1/conclusion.md new file mode 100644 index 00000000..daed91d2 --- /dev/null +++ b/Project1/conclusion.md @@ -0,0 +1,4 @@ +Overall, our work on this project seemed to go fairly smoothly. Both our issues looked to be +resolved, and we had no merge conflicts when pushing up our changes. I believe our branching +strategy was good, and that our code actually helped to improve the functionality of +Raider Planner. From 0528aff3ef3714fe02fb1d1d5095a49b5a9ebd9a Mon Sep 17 00:00:00 2001 From: lilrina Date: Sun, 10 Feb 2019 20:34:48 -0500 Subject: [PATCH 028/145] issue #21 mostly fixed --- docs/about.html | 25 +++++++++++++++++++++++ docs/contribute.html | 25 +++++++++++++++++++++++ docs/download.html | 25 +++++++++++++++++++++++ docs/help.html | 2 +- docs/index.html | 47 ++++++++++++++++++++++---------------------- git | 0 6 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 git diff --git a/docs/about.html b/docs/about.html index e69de29b..a7f1c890 100644 --- a/docs/about.html +++ b/docs/about.html @@ -0,0 +1,25 @@ + + + + + + + RaiderPlanner + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/contribute.html b/docs/contribute.html index e69de29b..a7f1c890 100644 --- a/docs/contribute.html +++ b/docs/contribute.html @@ -0,0 +1,25 @@ + + + + + + + RaiderPlanner + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/download.html b/docs/download.html index e69de29b..a7f1c890 100644 --- a/docs/download.html +++ b/docs/download.html @@ -0,0 +1,25 @@ + + + + + + + RaiderPlanner + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/help.html b/docs/help.html index dbec9d9b..26ff3b47 100644 --- a/docs/help.html +++ b/docs/help.html @@ -42,7 +42,7 @@ Home