diff --git a/.idea/misc.xml b/.idea/misc.xml index fe18ee620100e2d75aa025f3853d282724948ec7..e208459b8afde5f7980720efd6bbb97f7ae24541 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,10 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> -<<<<<<< HEAD <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> -======= - <component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="false" project-jdk-name="12" project-jdk-type="JavaSDK"> ->>>>>>> 319c99e690794f9fba4fc91d12c81e0115df012a <output url="file://$PROJECT_DIR$/out" /> </component> </project> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 801c9401a6a81068ad8089f3ca5e5b72cc408e5d..dee474ec51ceb58e0537eef5f625c4eac72e51aa 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,37 @@ <project version="4"> <component name="ChangeListManager"> <list default="true" id="688d774d-cfc7-4b0d-b00c-5ca931aba600" name="Default Changelist" comment=""> + <change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ApplicationMain$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ApplicationMain$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ApplicationMain.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ApplicationMain.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/PaintGUI$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/PaintGUI$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/PaintGUI.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/PaintGUI.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/StartScreen$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/StartScreen$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/StartScreen.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/StartScreen.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/Client.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/Client.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/ClientUpdate$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/ClientUpdate$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/ClientUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/ClientUpdate.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/DrawingUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/DrawingUpdate.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientUpdate$Action.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientUpdate$Action.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientUpdate.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingController.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingUpdate.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ClientController$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ClientController$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ClientController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ClientController.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/DrawingController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/DrawingController.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/GUI/ApplicationMain.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/ApplicationMain.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/GUI/ChatScreen.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/ChatScreen.form" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/GUI/ChatScreen.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/ChatScreen.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/GUI/StartScreen.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/StartScreen.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/client/Client.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/client/Client.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/client/ClientUpdate.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/client/ClientUpdate.java" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/src/server/ChatController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/server/ChatController.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/remote/IClientUpdate.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/remote/IClientUpdate.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/server/ClientController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/server/ClientController.java" afterDir="false" /> </list> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> @@ -21,19 +45,12 @@ <option name="testRunner" value="GRADLE" /> <option name="delegatedBuild" value="true" /> </component> - <component name="FindInProjectRecents"> - <findStrings> - <find>RMI</find> - <find>Black</find> - <find>colorOptions</find> - <find>Send</find> - <find>message</find> - <find>userSelectComboBox</find> - <find>updateUserList</find> - <find>send</find> - <find>broadcastMessage</find> - <find>sent</find> - </findStrings> + <component name="FileTemplateManagerImpl"> + <option name="RECENT_TEMPLATES"> + <list> + <option value="Class" /> + </list> + </option> </component> <component name="Git.Settings"> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> @@ -53,10 +70,13 @@ <component name="ProjectId" id="1SVgnDiSFxSanFbLYY5D9RJaXPS" /> <component name="PropertiesComponent"> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> - <property name="UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH" value="387" /> + <property name="UI_DESIGNER_EDITOR_MODE.PaletteManager.SHOW" value="true" /> + <property name="UI_DESIGNER_EDITOR_MODE.PaletteManager.STATE" value="right" /> + <property name="UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.STATE" value="left" /> + <property name="UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH" value="280" /> <property name="WebServerToolWindowFactoryState" value="false" /> <property name="aspect.path.notification.shown" value="true" /> - <property name="last_opened_file_path" value="$PROJECT_DIR$/../Git Projects" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$/out/production/comp90015-dsass2-infinitymonkeys-remaster" /> <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" /> <property name="project.structure.last.edited" value="Project" /> @@ -126,7 +146,9 @@ <option name="presentableId" value="Default" /> <updated>1571631720382</updated> <workItem from="1571631723795" duration="17601000" /> - <workItem from="1571654347656" duration="25813000" /> + <workItem from="1571654347656" duration="27259000" /> + <workItem from="1571783604151" duration="19947000" /> + <workItem from="1571812296671" duration="25759000" /> </task> <task id="LOCAL-00001" summary="Changed the join method to send over a reference of the ClientUpdate Interface"> <created>1571646862883</created> @@ -156,7 +178,9 @@ <map> <entry key="MAIN"> <value> - <State /> + <State> + <option name="COLUMN_ORDER" /> + </State> </value> </entry> </map> @@ -166,4 +190,45 @@ <MESSAGE value="Changed the join method to send over a reference of the ClientUpdate Interface" /> <option name="LAST_COMMIT_MESSAGE" value="Changed the join method to send over a reference of the ClientUpdate Interface" /> </component> + <component name="XDebuggerManager"> + <breakpoint-manager> + <breakpoints> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/GUI/StartScreen.java</url> + <line>38</line> + <option name="timeStamp" value="7" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/GUI/StartScreen.java</url> + <line>33</line> + <option name="timeStamp" value="8" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/GUI/StartScreen.java</url> + <line>85</line> + <option name="timeStamp" value="9" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/client/Client.java</url> + <line>47</line> + <option name="timeStamp" value="10" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/client/Client.java</url> + <line>57</line> + <option name="timeStamp" value="11" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/GUI/StartScreen.java</url> + <line>40</line> + <option name="timeStamp" value="12" /> + </line-breakpoint> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/GUI/StartScreen.java</url> + <line>62</line> + <option name="timeStamp" value="13" /> + </line-breakpoint> + </breakpoints> + </breakpoint-manager> + </component> </project> \ No newline at end of file diff --git a/out/production/infinitymonkeys/GUI/ApplicationMain$1.class b/out/production/infinitymonkeys/GUI/ApplicationMain$1.class index 7513f66924483609c50c389a3304af9caca73fe7..7daf4ebca183d7e6b8e4d39d2c016bd7d6e98c54 100644 Binary files a/out/production/infinitymonkeys/GUI/ApplicationMain$1.class and b/out/production/infinitymonkeys/GUI/ApplicationMain$1.class differ diff --git a/out/production/infinitymonkeys/GUI/ApplicationMain.class b/out/production/infinitymonkeys/GUI/ApplicationMain.class index 28c9962ae55431573a7b3eb24d7e89c09d3a496f..f574ba2a0ddbc65b154bb66511c1bda548cbe2d1 100644 Binary files a/out/production/infinitymonkeys/GUI/ApplicationMain.class and b/out/production/infinitymonkeys/GUI/ApplicationMain.class differ diff --git a/out/production/infinitymonkeys/GUI/ChatScreen$1.class b/out/production/infinitymonkeys/GUI/ChatScreen$1.class index 7b2523120100dcd19348a5c91a6127cffe8aa949..0456aba65aada608f38c772da2de7fdc1e55a711 100644 Binary files a/out/production/infinitymonkeys/GUI/ChatScreen$1.class and b/out/production/infinitymonkeys/GUI/ChatScreen$1.class differ diff --git a/out/production/infinitymonkeys/GUI/ChatScreen.class b/out/production/infinitymonkeys/GUI/ChatScreen.class index f115b47e8b3ea64e2f3947947683e46a23c3a491..4f121810b391378cc17c4013d59f1b1157fa63a4 100644 Binary files a/out/production/infinitymonkeys/GUI/ChatScreen.class and b/out/production/infinitymonkeys/GUI/ChatScreen.class differ diff --git a/out/production/infinitymonkeys/GUI/DrawingArea$1.class b/out/production/infinitymonkeys/GUI/DrawingArea$1.class index 153fe6661e260df1c185996c6d8e8f84cc9d88a2..8d0767f47053ee7e77165cda1ad6b206255bccea 100644 Binary files a/out/production/infinitymonkeys/GUI/DrawingArea$1.class and b/out/production/infinitymonkeys/GUI/DrawingArea$1.class differ diff --git a/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class b/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class index 300ae0e92370228635ee2d2eda3cef4cc4aadaae..0dfea6014533d4b2402a663f95c2c029f41e7e9e 100644 Binary files a/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class and b/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class differ diff --git a/out/production/infinitymonkeys/GUI/DrawingArea.class b/out/production/infinitymonkeys/GUI/DrawingArea.class index e8789e03a5bde6470e969558471b15342c72b15e..dea5162edd17755dbf52607a9512faa02522e26a 100644 Binary files a/out/production/infinitymonkeys/GUI/DrawingArea.class and b/out/production/infinitymonkeys/GUI/DrawingArea.class differ diff --git a/out/production/infinitymonkeys/GUI/PaintGUI$1.class b/out/production/infinitymonkeys/GUI/PaintGUI$1.class index 5a07ea2a0857d35e02879ff2acf0c9a200156c0d..96e215a04f61c099d09838995f7e359e972fec38 100644 Binary files a/out/production/infinitymonkeys/GUI/PaintGUI$1.class and b/out/production/infinitymonkeys/GUI/PaintGUI$1.class differ diff --git a/out/production/infinitymonkeys/GUI/PaintGUI$2.class b/out/production/infinitymonkeys/GUI/PaintGUI$2.class new file mode 100644 index 0000000000000000000000000000000000000000..b15be0a1dc4236eed6d5c763ee06e2db4ab89928 Binary files /dev/null and b/out/production/infinitymonkeys/GUI/PaintGUI$2.class differ diff --git a/out/production/infinitymonkeys/GUI/PaintGUI.class b/out/production/infinitymonkeys/GUI/PaintGUI.class index 907fcc25e6b8ebdc3902c860e02dcaef93c12376..88ded32f579c6224edff986c1983774aca5d876f 100644 Binary files a/out/production/infinitymonkeys/GUI/PaintGUI.class and b/out/production/infinitymonkeys/GUI/PaintGUI.class differ diff --git a/out/production/infinitymonkeys/GUI/StartScreen$1.class b/out/production/infinitymonkeys/GUI/StartScreen$1.class index fe73d4e2d50930d8a12d46e1e6e140474f708ea2..f0ec3f4e26dd97aeef8b7b8b07905b0ca5fef5a5 100644 Binary files a/out/production/infinitymonkeys/GUI/StartScreen$1.class and b/out/production/infinitymonkeys/GUI/StartScreen$1.class differ diff --git a/out/production/infinitymonkeys/GUI/StartScreen.class b/out/production/infinitymonkeys/GUI/StartScreen.class index 3081ccaf56b08e087e77adc6eafa834bbd151708..1d786d989283babc6b573dafa0a7e900807ee030 100644 Binary files a/out/production/infinitymonkeys/GUI/StartScreen.class and b/out/production/infinitymonkeys/GUI/StartScreen.class differ diff --git a/out/production/infinitymonkeys/GUI/icon/circle.png b/out/production/infinitymonkeys/GUI/icon/circle.png new file mode 100644 index 0000000000000000000000000000000000000000..0c23e5a725c3b9d87d0765641e401184be837d24 Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/circle.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/eraser.png b/out/production/infinitymonkeys/GUI/icon/eraser.png new file mode 100644 index 0000000000000000000000000000000000000000..d5d98df4ca4a1a677baaf83a00fbc903f814119c Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/eraser.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/freehand.png b/out/production/infinitymonkeys/GUI/icon/freehand.png new file mode 100644 index 0000000000000000000000000000000000000000..5d162ecd975889c2ff84b0b3e456a4d4115eb82f Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/freehand.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/line.png b/out/production/infinitymonkeys/GUI/icon/line.png new file mode 100644 index 0000000000000000000000000000000000000000..31156130a58ec6c455be88f00e470329cba61afd Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/line.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/oval.png b/out/production/infinitymonkeys/GUI/icon/oval.png new file mode 100644 index 0000000000000000000000000000000000000000..665c0a0c7c3b1eaa4ba51e6baa6c150f651f8b5f Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/oval.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/palette.png b/out/production/infinitymonkeys/GUI/icon/palette.png new file mode 100644 index 0000000000000000000000000000000000000000..813d7ffbe98d40089591256979bd1f21514abdc9 Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/palette.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/rectangle.png b/out/production/infinitymonkeys/GUI/icon/rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..94d8278acf49ff157270cc81e0967334936611ec Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/rectangle.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/square.png b/out/production/infinitymonkeys/GUI/icon/square.png new file mode 100644 index 0000000000000000000000000000000000000000..38657f5a2779b68ecab7d083e8c112b879bf77bc Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/square.png differ diff --git a/out/production/infinitymonkeys/GUI/icon/text.png b/out/production/infinitymonkeys/GUI/icon/text.png new file mode 100644 index 0000000000000000000000000000000000000000..33af1a2708cee9b502580ce4b6380c3a1d8740c8 Binary files /dev/null and b/out/production/infinitymonkeys/GUI/icon/text.png differ diff --git a/out/production/infinitymonkeys/META-INF/infinitymonkeys.kotlin_module b/out/production/infinitymonkeys/META-INF/infinitymonkeys.kotlin_module index 8fb60192d378759239a3ecbf60eac8c8de446e9c..2983af70661ad375cc499ebc4da5a68ca46c532e 100644 Binary files a/out/production/infinitymonkeys/META-INF/infinitymonkeys.kotlin_module and b/out/production/infinitymonkeys/META-INF/infinitymonkeys.kotlin_module differ diff --git a/out/production/infinitymonkeys/client/Client.class b/out/production/infinitymonkeys/client/Client.class index f4d0697ec65644133ca160285ecf365130475589..7fea52fe06f8c6079c81f2fc781b3f2678e09aa6 100644 Binary files a/out/production/infinitymonkeys/client/Client.class and b/out/production/infinitymonkeys/client/Client.class differ diff --git a/out/production/infinitymonkeys/client/ClientUpdate$1.class b/out/production/infinitymonkeys/client/ClientUpdate$1.class index a6557db01c39906b9407183cbe45f7985e6f27e8..1b1e4c50ab7b86ddfde6170006a51b4f94794531 100644 Binary files a/out/production/infinitymonkeys/client/ClientUpdate$1.class and b/out/production/infinitymonkeys/client/ClientUpdate$1.class differ diff --git a/out/production/infinitymonkeys/client/ClientUpdate.class b/out/production/infinitymonkeys/client/ClientUpdate.class index 8e2cefd33df97034b4f7915642756b775c22898c..11926f3376c5f6523f889328cbc88369ea2c2a5a 100644 Binary files a/out/production/infinitymonkeys/client/ClientUpdate.class and b/out/production/infinitymonkeys/client/ClientUpdate.class differ diff --git a/out/production/infinitymonkeys/client/DrawingUpdate.class b/out/production/infinitymonkeys/client/DrawingUpdate.class index 9f226e2b4bc72085c560ac2dd87bc6b4b9fd53d7..df881705ca5c05e240dfd409ec2c021575fafe37 100644 Binary files a/out/production/infinitymonkeys/client/DrawingUpdate.class and b/out/production/infinitymonkeys/client/DrawingUpdate.class differ diff --git a/out/production/infinitymonkeys/remote/IClientUpdate$Action.class b/out/production/infinitymonkeys/remote/IClientUpdate$Action.class index e8c67716e8ad38b3061fe7b87f09a74c4e8dc8a5..92cdbe3fe1704265461317700f5d956ea36eb145 100644 Binary files a/out/production/infinitymonkeys/remote/IClientUpdate$Action.class and b/out/production/infinitymonkeys/remote/IClientUpdate$Action.class differ diff --git a/out/production/infinitymonkeys/remote/IClientUpdate.class b/out/production/infinitymonkeys/remote/IClientUpdate.class index 7d8923621a39f42b6628c674a2a110f8b54dd03d..cf1adf4c123b7ac99404efbeece8fb67c6d819de 100644 Binary files a/out/production/infinitymonkeys/remote/IClientUpdate.class and b/out/production/infinitymonkeys/remote/IClientUpdate.class differ diff --git a/out/production/infinitymonkeys/remote/IDrawingController.class b/out/production/infinitymonkeys/remote/IDrawingController.class index 77e8bd2728f2914be430a512c07dfd1396cf82db..4ee26d4196eeb7419ffb011e43e6374bd5eec4c0 100644 Binary files a/out/production/infinitymonkeys/remote/IDrawingController.class and b/out/production/infinitymonkeys/remote/IDrawingController.class differ diff --git a/out/production/infinitymonkeys/remote/IDrawingUpdate.class b/out/production/infinitymonkeys/remote/IDrawingUpdate.class index e988f5b56317e1471a72d9c155b99fb2765377fd..f41f9a05a74d875caa31672fc6b33ccbc09bbf1a 100644 Binary files a/out/production/infinitymonkeys/remote/IDrawingUpdate.class and b/out/production/infinitymonkeys/remote/IDrawingUpdate.class differ diff --git a/out/production/infinitymonkeys/server/ClientController$1.class b/out/production/infinitymonkeys/server/ClientController$1.class index bad43cb0d3d2f3d5df39f5772609ead65f352bde..1d2a2d641a54e21f04f273f959e20c26138470ac 100644 Binary files a/out/production/infinitymonkeys/server/ClientController$1.class and b/out/production/infinitymonkeys/server/ClientController$1.class differ diff --git a/out/production/infinitymonkeys/server/ClientController.class b/out/production/infinitymonkeys/server/ClientController.class index 9b3a65bdc428d61632fca4ce5ff30a4697ff1170..11839990a93f1c085e7afdc6628bb834a5e92355 100644 Binary files a/out/production/infinitymonkeys/server/ClientController.class and b/out/production/infinitymonkeys/server/ClientController.class differ diff --git a/out/production/infinitymonkeys/server/DrawingController.class b/out/production/infinitymonkeys/server/DrawingController.class index 54810ef813fa516a548036a63fa70a7be2a0c5c5..00fe8a78bb29e4f2193e8164d2e79f8e19c0b051 100644 Binary files a/out/production/infinitymonkeys/server/DrawingController.class and b/out/production/infinitymonkeys/server/DrawingController.class differ diff --git a/src/GUI/ApplicationMain.java b/src/GUI/ApplicationMain.java index 32275b92f8dece89d30856904b4cab47a776d11d..02ba6bcc591c84b8f7104c2f274fb9390ae54399 100644 --- a/src/GUI/ApplicationMain.java +++ b/src/GUI/ApplicationMain.java @@ -23,6 +23,26 @@ public class ApplicationMain extends JPanel { return frame; } + public int showManagerQuitMessage() { + int answer = JOptionPane.showConfirmDialog(null, + "Before closing the application for everyone, do you want to give manager permissions to another user?", + "Close the application", JOptionPane.YES_NO_CANCEL_OPTION); + return answer; + } + + public String showAssignManagerMessage() { + int numUsers = client.getChatScreen().getKickUserComboBox().getItemCount(); + String[] userOptions = new String[numUsers]; + for (int i = 0; i < numUsers; i++) { + userOptions[i] = client.getChatScreen().getKickUserComboBox().getItemAt(i).toString(); + } + String input = (String) JOptionPane.showInputDialog(null, "Choose the next manager", + "Assign a new manager before leaving", JOptionPane.QUESTION_MESSAGE, null, + userOptions, // Array of choices + userOptions[0]); // Initial choice + return input; + } + public ApplicationMain(Client client) { this.client = client; this.chatScreen = new ChatScreen(client); @@ -75,24 +95,35 @@ public class ApplicationMain extends JPanel { @Override public void windowClosing(WindowEvent arg0) { - int reply = JOptionPane.showConfirmDialog(null, - "Are you sure you want to quit the session?", - "Shut down session", JOptionPane.YES_NO_OPTION); - - if( reply == JOptionPane.YES_OPTION ) - { - try - { - client.getClientController().quit(client.getUserName()); + + try { + if (client.getUserName().equals(client.getClientController().getAdmin())) { + + int answer = showManagerQuitMessage(); + if (answer == 0) { + String newManager = showAssignManagerMessage(); + client.getClientController().assignAdmin(client.getUserName(), newManager); + client.getClientController().quit(client.getUserName()); + exitApplication(); + } + if (answer == 1) { + exitApplication(); + } } - catch (RemoteException e) - { - StartScreen.showErrorMessage("Error in quitting the server"); - //e.printStackTrace(); + else { + int reply = JOptionPane.showConfirmDialog(null, + "Are you sure you want to quit the session?", + "Shut down session", JOptionPane.YES_NO_OPTION); + if( reply == 0 ) + { + client.getClientController().quit(client.getUserName()); + exitApplication(); + } } - - System.exit(0); + } catch (RemoteException e) { + e.printStackTrace(); } + } }); @@ -103,4 +134,15 @@ public class ApplicationMain extends JPanel { frame.pack(); frame.setVisible(true); } + + public void exitApplication(){ + frame.setVisible(false); + frame.dispose(); + client.setVisibleStartScreen(); + } + + public void setVisible() { + frame.setVisible(true); + chatScreen.setUserName(client.getUserName()); + } } diff --git a/src/GUI/ChatScreen.form b/src/GUI/ChatScreen.form index fc19ecab3953bc99aa5416516e99b31508b22226..93569264919847c10e94e94864226adb23ba7bf6 100644 --- a/src/GUI/ChatScreen.form +++ b/src/GUI/ChatScreen.form @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="GUI.ChatScreen"> - <grid id="27dc6" binding="panel2" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <grid id="27dc6" binding="panel2" layout-manager="GridLayoutManager" row-count="1" column-count="64" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> - <xy x="20" y="20" width="1200" height="1200"/> + <xy x="20" y="20" width="1627" height="1200"/> </constraints> <properties> <maximumSize width="-1" height="-1"/> @@ -12,179 +12,172 @@ </properties> <border type="none"/> <children> - <grid id="b37e3" binding="othersPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <grid id="5d886" binding="chatPanel" layout-manager="GridLayoutManager" row-count="6" column-count="70" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <grid row="0" column="0" row-span="1" col-span="63" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/> </constraints> <properties/> - <border type="none"/> + <border type="none" title="Chat Area"/> <children> - <grid id="bad73" binding="myAreaPanel" layout-manager="GridLayoutManager" row-count="11" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> + <component id="6a928" class="javax.swing.JLabel"> + <constraints> + <grid row="3" column="0" row-span="1" col-span="70" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Your Message"/> + </properties> + </component> + <scrollpane id="ec60d"> <constraints> - <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="7" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <grid row="0" column="1" row-span="1" col-span="68" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/> </constraints> <properties/> - <border type="none" title="My Area"/> + <border type="none"/> <children> - <component id="a35da" class="javax.swing.JLabel" binding="managersNameLabel"> - <constraints> - <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> + <component id="c55f3" class="javax.swing.JTextArea" binding="chatDisplayBox"> + <constraints/> <properties> - <font size="14" style="1"/> - <text value="Manager's Name:"/> - </properties> - </component> - <vspacer id="38e19"> - <constraints> - <grid row="9" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> - </constraints> - </vspacer> - <component id="98bbe" class="javax.swing.JLabel" binding="yourNameLabel"> - <constraints> - <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <font size="14" style="1"/> - <text value="Your Name:"/> - </properties> - </component> - <component id="33d66" class="javax.swing.JLabel" binding="yourNameDisplay"> - <constraints> - <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text value="Here goes User's Name"/> - </properties> - </component> - <grid id="4212" binding="managersPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <border type="none" title="Manager's Tools"/> - <children> - <component id="b7068" class="javax.swing.JComboBox" binding="kickUserComboBox"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <model/> - </properties> - </component> - <vspacer id="aae38"> - <constraints> - <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> - </constraints> - </vspacer> - <component id="be5e9" class="javax.swing.JButton" binding="kickOutButton" default-binding="true"> - <constraints> - <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text value="Kick Out"/> - </properties> - </component> - <component id="1336c" class="javax.swing.JButton" binding="promoteToManagerButton" default-binding="true"> - <constraints> - <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text value="Promote to Manager"/> - </properties> - </component> - </children> - </grid> - <component id="51b56" class="javax.swing.JLabel" binding="managersNameDisplay"> - <constraints> - <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text value="Here goes Admin's Name"/> - </properties> - </component> - <vspacer id="e9e96"> - <constraints> - <grid row="10" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> - </constraints> - </vspacer> - <component id="deaed" class="javax.swing.JButton" binding="exitThisRoomButton" default-binding="true"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text value="Exit This Room"/> + <editable value="false"/> + <lineWrap value="true"/> + <text value=""/> </properties> </component> </children> - </grid> - <grid id="5d886" binding="chatPanel" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> + </scrollpane> + <component id="2b67f" class="javax.swing.JTextField" binding="chatInputBox"> + <constraints> + <grid row="4" column="0" row-span="1" col-span="70" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> + <preferred-size width="150" height="-1"/> + </grid> + </constraints> + <properties/> + </component> + <component id="df8f1" class="javax.swing.JLabel" binding="sendMessageToLabel"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="70" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Send Message To:"/> + </properties> + </component> + <component id="cc35d" class="javax.swing.JComboBox" binding="sendMessageToComboBox"> <constraints> - <grid row="0" column="0" row-span="2" col-span="1" vsize-policy="7" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <grid row="2" column="0" row-span="1" col-span="70" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> </constraints> <properties/> - <border type="none" title="Chat Area"/> + </component> + <component id="9e940" class="javax.swing.JButton" binding="sendButton"> + <constraints> + <grid row="5" column="22" row-span="1" col-span="21" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Send"/> + </properties> + </component> + </children> + </grid> + <grid id="bad73" binding="myAreaPanel" layout-manager="GridLayoutManager" row-count="14" column-count="9" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <grid row="0" column="63" row-span="1" col-span="1" vsize-policy="7" hsize-policy="1" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + </constraints> + <properties/> + <border type="none" title="My Area"/> + <children> + <component id="a35da" class="javax.swing.JLabel" binding="managersNameLabel"> + <constraints> + <grid row="3" column="0" row-span="1" col-span="9" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <font/> + <text value="Manager"/> + </properties> + </component> + <component id="98bbe" class="javax.swing.JLabel" binding="yourNameLabel"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="9" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <font/> + <text value="Username"/> + </properties> + </component> + <component id="33d66" class="javax.swing.JLabel" binding="yourNameDisplay"> + <constraints> + <grid row="2" column="0" row-span="1" col-span="9" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <font style="1"/> + <text value="Here goes User's Name"/> + </properties> + </component> + <component id="51b56" class="javax.swing.JLabel" binding="managersNameDisplay"> + <constraints> + <grid row="4" column="0" row-span="1" col-span="9" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <font style="1"/> + <text value="Here goes Admin's Name"/> + </properties> + </component> + <vspacer id="e9e96"> + <constraints> + <grid row="13" column="0" row-span="1" col-span="9" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + </constraints> + </vspacer> + <grid id="4212" binding="managersPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <grid row="7" column="0" row-span="6" col-span="9" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <enabled value="true"/> + </properties> + <border type="none" title="Manager's Tools"/> <children> - <component id="6a928" class="javax.swing.JLabel"> + <component id="b7068" class="javax.swing.JComboBox" binding="kickUserComboBox"> <constraints> - <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"> + <preferred-size width="152" height="30"/> + </grid> </constraints> <properties> - <text value="Your Message"/> + <enabled value="true"/> + <model/> </properties> </component> - <component id="9e940" class="javax.swing.JButton" binding="sendButton"> + <component id="be5e9" class="javax.swing.JButton" binding="kickOutButton" default-binding="true"> <constraints> - <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"> + <preferred-size width="152" height="30"/> + </grid> </constraints> <properties> - <text value="Send"/> + <enabled value="true"/> + <text value="Kick Out"/> </properties> </component> - <scrollpane id="ec60d"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <border type="none"/> - <children> - <component id="c55f3" class="javax.swing.JTextArea" binding="chatDisplayBox"> - <constraints/> - <properties> - <editable value="false"/> - <lineWrap value="true"/> - </properties> - </component> - </children> - </scrollpane> - <component id="2b67f" class="javax.swing.JTextField" binding="chatInputBox"> + <component id="1336c" class="javax.swing.JButton" binding="promoteToManagerButton" default-binding="true"> <constraints> - <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="150" height="-1"/> + <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"> + <preferred-size width="152" height="30"/> </grid> </constraints> - <properties/> - </component> - <component id="df8f1" class="javax.swing.JLabel" binding="sendMessageToLabel"> - <constraints> - <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> <properties> - <text value="Send Message To:"/> + <text value="Promote to Manager"/> </properties> </component> - <component id="cc35d" class="javax.swing.JComboBox" binding="sendMessageToComboBox"> - <constraints> - <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - </component> </children> </grid> + <component id="deaed" class="javax.swing.JButton" binding="exitThisRoomButton" default-binding="true"> + <constraints> + <grid row="0" column="0" row-span="1" col-span="9" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Exit This Room"/> + </properties> + </component> </children> </grid> </children> diff --git a/src/GUI/ChatScreen.java b/src/GUI/ChatScreen.java index 1c70a5f1b6933fae7b920b0039b8e4af9dc4639a..d0b744beb4aa6943ebe359462f9696306d8a53dc 100644 --- a/src/GUI/ChatScreen.java +++ b/src/GUI/ChatScreen.java @@ -14,7 +14,6 @@ public class ChatScreen { private JButton sendButton; - private JPanel othersPanel; private JComboBox sendMessageToComboBox; private JTextArea chatDisplayBox; private JComboBox kickUserComboBox; @@ -53,6 +52,11 @@ public class ChatScreen { this.yourNameDisplay.setText(userName); } + public void setManagerName(String manager) + { + this.managersNameDisplay.setText(manager); + } + public JButton getSendButton() { return sendButton; } diff --git a/src/GUI/StartScreen.java b/src/GUI/StartScreen.java index 10ae2adbd8c2b4b5a47b8974c2eec8ab072b57be..8d44b481540bb10a147d5212060d78bd2a08a64c 100644 --- a/src/GUI/StartScreen.java +++ b/src/GUI/StartScreen.java @@ -42,9 +42,17 @@ public class StartScreen { { frame.setVisible(false); frame.dispose(); - client.startApplication(); + if (client.getApplicationMain().getFrame() == null) { + client.startApplication(); + } + else { + client.clearChat(); + client.clearDrawingArea(); + client.setVisibleApplication(); + } + } - else if( connectionStatus == 2 ) + else if( connectionStatus == 2 || connectionStatus == 5 ) { showErrorMessage("Duplicate username: Please enter a new username"); } @@ -52,6 +60,12 @@ public class StartScreen { { showErrorMessage("Cannot connect to server: Please check the server address"); } + else if( connectionStatus == 4 ) + { + frame.setVisible(false); + frame.dispose(); + client.setVisibleApplication(); + } else { showErrorMessage("Unknown Connection Status"); @@ -77,4 +91,7 @@ public class StartScreen { frame.setVisible(true); } + public void setVisible(){ + frame.setVisible(true); + } } diff --git a/src/client/Client.java b/src/client/Client.java index 5eed15f56e0382d5755970a297a77061654b344c..1f7b2856a6397c432b08042292ad611db1a8d63b 100644 --- a/src/client/Client.java +++ b/src/client/Client.java @@ -17,6 +17,7 @@ public class Client private final String DEFAULT_USERNAME = "Anonymous"; private final String DEFAULT_SERVER_ADDRESS = "localhost"; + private String defaultUserName; private String userName; private String serverAddress; @@ -38,6 +39,11 @@ public class Client return this.userName; } + public String getDefaultUserName() + { + return this.defaultUserName; + } + public void setUserName(String userName) { this.userName = userName; @@ -80,7 +86,7 @@ public class Client public Client(String username) throws RemoteException { - this.userName = username; + this.defaultUserName = username; this.clientUpdate = new ClientUpdate(this); this.chatUpdate = new ChatUpdate(this); this.drawingUpdate = new DrawingUpdate(this); @@ -107,6 +113,10 @@ public class Client startScreen.go(); } + public void setVisibleStartScreen(){ + startScreen.setVisible(); + } + public void startApplication() { @@ -114,51 +124,71 @@ public class Client applicationMain.getChatScreen().setManagerToolsVisibility(); } + public void setVisibleApplication(){ + applicationMain.setVisible(); + } + // return = 1 -> connected successfully // return = 2 -> duplicate username // return = 3 -> error in locating the server + // return = 4 -> re-connected successfully + // return = 5 -> duplicate username when re-connecting public int connect(String userName, String serverAddress) { - if( !userName.trim().isEmpty() ) - { - setUserName(userName); - } - userName = getUserName(); - - if( serverAddress.trim().isEmpty() ) - { - serverAddress = DEFAULT_SERVER_ADDRESS; - setServerAddress(serverAddress); - } - setServerAddress(serverAddress); - try { - System.out.println("Server address:" + serverAddress); - registryServer = LocateRegistry.getRegistry(serverAddress); - - chatController = (IChatController) registryServer.lookup("ChatController"); - clientController = (IClientController) registryServer.lookup("ClientController"); - drawingController = (IDrawingController) registryServer.lookup("DrawingController"); - - System.out.println("User name:" + userName); - if( clientController.join(userName, this.chatUpdate, this.clientUpdate, this.drawingUpdate) ) - { - System.out.println("Connected to server"); - - return 1; + if (userName.trim().isEmpty()) { + userName = getDefaultUserName(); + } + if (serverAddress.trim().isEmpty()) { + serverAddress = DEFAULT_SERVER_ADDRESS; + } + // If the client wants to reconnect to the same server using the same username + if (registryServer != null && getUserName().equals(userName) + && getServerAddress().equals(serverAddress) + && getApplicationMain().getFrame() != null) { + System.out.println("Server address:" + getServerAddress()); + System.out.println("User name:" + getUserName()); + if (clientController.join(getUserName(), this.chatUpdate, this.clientUpdate, this.drawingUpdate)) { + System.out.println("Connected to server"); + return 4; + } else { + return 5; + } } - else - { - return 2; + // New connection + else { + setUserName(userName); + setServerAddress(serverAddress); + System.out.println("Server address:" + serverAddress); + + registryServer = LocateRegistry.getRegistry(serverAddress); + chatController = (IChatController) registryServer.lookup("ChatController"); + clientController = (IClientController) registryServer.lookup("ClientController"); + drawingController = (IDrawingController) registryServer.lookup("DrawingController"); + + System.out.println("User name:" + getUserName()); + + if (clientController.join(getUserName(), this.chatUpdate, this.clientUpdate, this.drawingUpdate)) { + System.out.println("Connected to server"); + return 1; + } else { + return 2; + } } } catch (Exception e) { - //e.printStackTrace(); - return 3; } } + public void clearChat() { + getApplicationMain().getChatScreen().getChatDisplayBox().setText(""); + } + + public void clearDrawingArea() { + getApplicationMain().getPaintGUI().getDrawingArea().clear(); + } + } \ No newline at end of file diff --git a/src/client/ClientUpdate.java b/src/client/ClientUpdate.java index 9fdef79bf4438c8af406c61911df11a72583d383..32d91daea88adc39a789f14979f989eeb5d62bc8 100644 --- a/src/client/ClientUpdate.java +++ b/src/client/ClientUpdate.java @@ -64,6 +64,9 @@ public class ClientUpdate extends UnicastRemoteObject implements IClientUpdate, { kickUserBox.addItem(s); } + else { + client.getApplicationMain().getChatScreen().setManagerName(s); + } } @@ -81,7 +84,8 @@ public class ClientUpdate extends UnicastRemoteObject implements IClientUpdate, } @Override - public void notifyManagerActions(String toClient, Action action) throws RemoteException { + public int notifyManagerActions(String toClient, Action action) throws RemoteException { + int outcome = 0; switch (action) { case KICKOUT: client.getChatScreen().getChatDisplayBox().append(toClient + " has been kicked out by the manager.\n"); @@ -89,6 +93,9 @@ public class ClientUpdate extends UnicastRemoteObject implements IClientUpdate, case ASSIGNADMIN: client.getChatScreen().getChatDisplayBox().append(toClient + " is the new manager.\n"); break; + case MANAGERQUIT: + outcome = client.getApplicationMain().showManagerQuitMessage(); } + return outcome; } } diff --git a/src/remote/IClientUpdate.java b/src/remote/IClientUpdate.java index 1d4dea6c68a9e1957ee31e94319807e95d08f5cb..853ce0908a0d46bc152d93f548b9458f4d4010b5 100644 --- a/src/remote/IClientUpdate.java +++ b/src/remote/IClientUpdate.java @@ -6,10 +6,10 @@ import java.rmi.RemoteException; public interface IClientUpdate extends Remote, Serializable { - enum Action {KICKOUT, ASSIGNADMIN}; + enum Action {KICKOUT, ASSIGNADMIN, MANAGERQUIT}; boolean updateUserList(String[] users) throws RemoteException; void terminateChat() throws RemoteException; - void notifyManagerActions(String toClient, Action action) throws RemoteException; + int notifyManagerActions(String toClient, Action action) throws RemoteException; void setVisibility() throws RemoteException; } diff --git a/src/server/ClientController.java b/src/server/ClientController.java index dfdb350ab7698554b76cf1eed74f27fc168d0107..3272d27f98d98a2acd950405e25f8fec0751a4f8 100644 --- a/src/server/ClientController.java +++ b/src/server/ClientController.java @@ -22,6 +22,7 @@ public class ClientController extends UnicastRemoteObject implements IClientCont @Override public boolean join(String username, IChatUpdate clientChat, IClientUpdate clientUpdate, IDrawingUpdate clientDrawing) throws RemoteException { + System.out.println("I am in join"); if( getUserIndex(username) < 0 ) { // user with same username is not connected @@ -56,13 +57,12 @@ public class ClientController extends UnicastRemoteObject implements IClientCont if( userIndex >= 0 ) { server.users.remove(userIndex); - - server.chatController.broadcastMessageUserLogout(username); - - broadcastUserList(); + if (!server.users.isEmpty()) { + server.chatController.broadcastMessageUserLogout(username); + broadcastUserList(); + } } - printUserList(); } // for debuggins purposes @@ -109,9 +109,7 @@ public class ClientController extends UnicastRemoteObject implements IClientCont server.users.get(userIndex).getIClientUpdate().terminateChat(); } finally { - System.out.print(server.users); server.users.remove(userIndex); - System.out.print(server.users); broadcastUserList(); broadcastManagerMessage(kickedUser, Action.KICKOUT); }