1
- // Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
1
+ // Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
2
2
package edu .csus .ecs .pc2 .ui ;
3
3
4
+ import java .awt .Dimension ;
4
5
import java .io .File ;
5
6
6
7
import javax .swing .JFrame ;
11
12
import edu .csus .ecs .pc2 .core .Utilities ;
12
13
import edu .csus .ecs .pc2 .core .execute .Executable ;
13
14
import edu .csus .ecs .pc2 .core .log .Log ;
15
+ import edu .csus .ecs .pc2 .core .model .ClientId ;
16
+ import edu .csus .ecs .pc2 .core .model .ClientType ;
14
17
import edu .csus .ecs .pc2 .core .model .IInternalContest ;
15
18
import edu .csus .ecs .pc2 .core .model .IRunListener ;
16
19
import edu .csus .ecs .pc2 .core .model .Run ;
17
20
import edu .csus .ecs .pc2 .core .model .RunEvent ;
18
21
import edu .csus .ecs .pc2 .core .model .RunEvent .Action ;
19
22
import edu .csus .ecs .pc2 .core .security .Permission ;
20
23
import edu .csus .ecs .pc2 .ui .judge .JudgeView ;
21
- import java .awt .Dimension ;
22
24
23
25
/**
24
26
* Judge can chose judgement and execute run.
25
- *
27
+ *
26
28
27
29
* @version $Id$
28
30
*/
31
33
public class SelectJudgementFrame extends JFrame implements UIPlugin {
32
34
33
35
/**
34
- *
36
+ *
35
37
*/
36
38
private static final long serialVersionUID = 6532349396307812235L ;
37
39
@@ -45,10 +47,10 @@ public class SelectJudgementFrame extends JFrame implements UIPlugin {
45
47
46
48
private Log log = null ;
47
49
48
-
50
+
49
51
/**
50
52
* This method initializes
51
- *
53
+ *
52
54
*/
53
55
public SelectJudgementFrame () {
54
56
super ();
@@ -57,7 +59,7 @@ public SelectJudgementFrame() {
57
59
58
60
/**
59
61
* This method initializes this
60
- *
62
+ *
61
63
*/
62
64
private void initialize () {
63
65
this .setContentPane (getSelectJudgementPane ());
@@ -67,6 +69,7 @@ private void initialize() {
67
69
this .setTitle ("Select Run Judgement" );
68
70
69
71
this .addWindowListener (new java .awt .event .WindowAdapter () {
72
+ @ Override
70
73
public void windowClosing (java .awt .event .WindowEvent e ) {
71
74
getSelectJudgementPane ().handleCancelButton ();
72
75
}
@@ -75,33 +78,39 @@ public void windowClosing(java.awt.event.WindowEvent e) {
75
78
76
79
}
77
80
81
+ @ Override
78
82
public void setContestAndController (IInternalContest inContest , IInternalController inController ) {
79
83
this .contest = inContest ;
80
84
this .controller = inController ;
81
85
82
- if (!inContest .getAccount (inContest .getClientId ()).getPermissionList ().isAllowed (Permission .Type .JUDGE_RUN )) {
86
+ ClientId clientId = inContest .getClientId ();
87
+
88
+ // SERVER client can do anything, but we have to check it explicitly since there is no server in the account list
89
+ if (clientId == null ||
90
+ (!clientId .getClientType ().equals (ClientType .Type .SERVER ) &&
91
+ !inContest .getAccount (clientId ).getPermissionList ().isAllowed (Permission .Type .JUDGE_RUN ))) {
83
92
throw new SecurityException ("SelectJudgementFame requires JUDGE_RUN permission" );
84
93
}
85
94
getSelectJudgementPane ().setContestAndController (contest , controller );
86
95
getSelectJudgementPane ().setParentFrame (this );
87
96
88
97
contest .addRunListener (new RunListenerImplementation ());
89
-
98
+
90
99
log = controller .getLog ();
91
100
}
92
-
101
+
93
102
public void setRun (Run theRun , boolean rejudgeRun ) {
94
103
Executable tempEexecutable = new Executable (contest , controller , theRun , null , null );
95
104
// clear as soon as we start this run, so View Outputs does not show old info
96
-
105
+
97
106
String temporaryExecuteableDirectory = tempEexecutable .getExecuteDirectoryName ();
98
-
107
+
99
108
if (! new File (temporaryExecuteableDirectory ).isDirectory ()){
100
109
// create directory if not present, needed for cleardirectory
101
110
log .info ("Creating directory " +temporaryExecuteableDirectory );
102
111
Utilities .insureDir (temporaryExecuteableDirectory );
103
112
}
104
-
113
+
105
114
tempEexecutable .clearDirectory (temporaryExecuteableDirectory );
106
115
107
116
getSelectJudgementPane ().setRun (theRun );
@@ -119,33 +128,37 @@ public void setRun(Run theRun, boolean rejudgeRun) {
119
128
}
120
129
}
121
130
131
+ @ Override
122
132
public String getPluginTitle () {
123
133
return "Edit Run Frame" ;
124
134
}
125
135
126
136
/**
127
137
* Run Listener for SelectJudgementFrame.
128
- *
138
+ *
129
139
130
140
* @version $Id$
131
141
*/
132
142
133
143
// $HeadURL$
134
144
public class RunListenerImplementation implements IRunListener {
135
145
146
+ @ Override
136
147
public void runAdded (RunEvent event ) {
137
148
// System.out.println("sjf: : "+event.getAction()+" "+event.getSentToClientId()+" "+event.getRun());
138
149
// ignore
139
150
}
140
-
151
+
152
+ @ Override
141
153
public void refreshRuns (RunEvent event ) {
142
154
// ignore
143
155
}
144
156
157
+ @ Override
145
158
public void runChanged (RunEvent event ) {
146
-
159
+
147
160
// System.out.println("sjf: : "+event.getAction()+" "+event.getSentToClientId()+" "+event.getWhoModifiedRun()+" "+event.getRun());
148
-
161
+
149
162
if (run != null ) {
150
163
if (event .getRun ().getElementId ().equals (run .getElementId ())) {
151
164
// RUN_NOT_AVAILABLE is undirected (sentToClient is null)
@@ -155,6 +168,7 @@ public void runChanged(RunEvent event) {
155
168
JOptionPane .showMessageDialog (null , "Run " + run .getNumber () + " (Site " + run .getSiteNumber () + ") is not available." );
156
169
157
170
SwingUtilities .invokeLater (new Runnable () {
171
+ @ Override
158
172
public void run () {
159
173
getSelectJudgementPane ().enableUpdateButtons (false );
160
174
}
@@ -163,9 +177,9 @@ public void run() {
163
177
setVisible (false );
164
178
} else {
165
179
if (event .getSentToClientId () != null && event .getSentToClientId ().equals (contest .getClientId ())) {
166
-
180
+
167
181
getSelectJudgementPane ().setRunAndFiles (event .getRun (), event .getRunFiles (), event .getRunResultFiles ());
168
- // stop processing once we get it
182
+ // stop processing once we get it
169
183
// stops both the duplicate checkedout_run and the run_not_available going to other judges
170
184
run = null ;
171
185
}
@@ -174,14 +188,15 @@ public void run() {
174
188
}
175
189
}
176
190
191
+ @ Override
177
192
public void runRemoved (RunEvent event ) {
178
193
// TODO Auto-generated method stub
179
194
}
180
195
}
181
196
182
197
/**
183
198
* This method initializes selectJudgementPane
184
- *
199
+ *
185
200
* @return edu.csus.ecs.pc2.ui.SelectJudgementPane
186
201
*/
187
202
private SelectJudgementPaneNew getSelectJudgementPane () {
0 commit comments