Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COMP90015-DSAss2-InfinityMonkeys-remaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ho Dac Hai
COMP90015-DSAss2-InfinityMonkeys-remaster
Commits
2969ca84
Commit
2969ca84
authored
Oct 24, 2019
by
Pedroza Aguirre Isaac
Browse files
Options
Downloads
Patches
Plain Diff
Admin functions changes
parent
32dc06cd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.idea/workspace.xml
+1
-29
1 addition, 29 deletions
.idea/workspace.xml
src/GUI/ApplicationMain.java
+32
-9
32 additions, 9 deletions
src/GUI/ApplicationMain.java
src/server/ClientController.java
+21
-0
21 additions, 0 deletions
src/server/ClientController.java
with
54 additions
and
38 deletions
.idea/workspace.xml
+
1
−
29
View file @
2969ca84
...
...
@@ -2,37 +2,8 @@
<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/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"
/>
...
...
@@ -149,6 +120,7 @@
<workItem
from=
"1571654347656"
duration=
"27259000"
/>
<workItem
from=
"1571783604151"
duration=
"19947000"
/>
<workItem
from=
"1571812296671"
duration=
"25759000"
/>
<workItem
from=
"1571879738075"
duration=
"3774000"
/>
</task>
<task
id=
"LOCAL-00001"
summary=
"Changed the join method to send over a reference of the ClientUpdate Interface"
>
<created>
1571646862883
</created>
...
...
This diff is collapsed.
Click to expand it.
src/GUI/ApplicationMain.java
+
32
−
9
View file @
2969ca84
...
...
@@ -8,6 +8,7 @@ import java.awt.event.WindowAdapter;
import
java.awt.event.WindowEvent
;
import
java.rmi.RemoteException
;
import
java.util.ArrayList
;
import
java.util.Random
;
public
class
ApplicationMain
extends
JPanel
{
private
Client
client
;
...
...
@@ -25,7 +26,14 @@ public class ApplicationMain extends JPanel {
public
int
showManagerQuitMessage
()
{
int
answer
=
JOptionPane
.
showConfirmDialog
(
null
,
"Before closing the application for everyone, do you want to give manager permissions to another user?"
,
"Do you want to terminate the application for all the users?"
,
"Close the application"
,
JOptionPane
.
YES_NO_CANCEL_OPTION
);
return
answer
;
}
public
int
showNextManagerMessage
()
{
int
answer
=
JOptionPane
.
showConfirmDialog
(
null
,
"Before leaving, do you want to choose the next manager manually?"
,
"Close the application"
,
JOptionPane
.
YES_NO_CANCEL_OPTION
);
return
answer
;
}
...
...
@@ -99,17 +107,32 @@ public class ApplicationMain extends JPanel {
try
{
if
(
client
.
getUserName
().
equals
(
client
.
getClientController
().
getAdmin
()))
{
int
answer
=
showManagerQuitMessage
();
int
terminateAppAnswer
=
showManagerQuitMessage
();
if
(
terminateAppAnswer
==
0
)
{
}
else
if
(
terminateAppAnswer
==
1
)
{
int
answer
=
showNextManagerMessage
();
// If the manager wants to assign the next manager manually
if
(
answer
==
0
)
{
String
newManager
=
showAssignManagerMessage
();
client
.
getClientController
().
assignAdmin
(
client
.
getUserName
(),
newManager
);
client
.
getClientController
().
quit
(
client
.
getUserName
());
exitApplication
();
}
// If the manager wants to assign the next manager by random choice
if
(
answer
==
1
)
{
int
numUsers
=
client
.
getChatScreen
().
getKickUserComboBox
().
getItemCount
();
Random
random
=
new
Random
();
int
randomUserIndex
=
random
.
nextInt
(
numUsers
);
String
newManager
=
client
.
getChatScreen
().
getKickUserComboBox
().
getItemAt
(
randomUserIndex
).
toString
();
client
.
getClientController
().
assignAdmin
(
client
.
getUserName
(),
newManager
);
client
.
getClientController
().
quit
(
client
.
getUserName
());
exitApplication
();
}
}
}
else
{
int
reply
=
JOptionPane
.
showConfirmDialog
(
null
,
"Are you sure you want to quit the session?"
,
...
...
This diff is collapsed.
Click to expand it.
src/server/ClientController.java
+
21
−
0
View file @
2969ca84
...
...
@@ -200,4 +200,25 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
return
true
;
}
public
void
kickAllUsers
(
String
manager
)
{
int
adminIndex
=
getUserIndex
(
manager
);
IClientUpdate
client
;
if
(
server
.
users
.
get
(
adminIndex
).
isAdmin
()
)
{
for
(
User
u
:
server
.
users
)
{
client
=
u
.
getIClientUpdate
();
client
.
notifyManagerActions
(
toClient
,
remote
.
IClientUpdate
.
Action
.
ASSIGNADMIN
);
client
.
setVisibility
();
}
}
else
{
System
.
out
.
println
(
"You are not the manager"
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment