1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import jalview.jbgui.GWebserviceInfo; |
24 |
|
import jalview.util.MessageManager; |
25 |
|
import jalview.ws.WSClientI; |
26 |
|
|
27 |
|
import java.awt.BorderLayout; |
28 |
|
import java.awt.Color; |
29 |
|
import java.awt.Font; |
30 |
|
import java.awt.Graphics; |
31 |
|
import java.awt.Graphics2D; |
32 |
|
import java.awt.GridLayout; |
33 |
|
import java.awt.Image; |
34 |
|
import java.awt.MediaTracker; |
35 |
|
import java.awt.event.ActionEvent; |
36 |
|
import java.awt.image.BufferedImage; |
37 |
|
import java.util.Vector; |
38 |
|
|
39 |
|
import javax.swing.JComponent; |
40 |
|
import javax.swing.JEditorPane; |
41 |
|
import javax.swing.JInternalFrame; |
42 |
|
import javax.swing.JOptionPane; |
43 |
|
import javax.swing.JPanel; |
44 |
|
import javax.swing.JScrollPane; |
45 |
|
import javax.swing.JTabbedPane; |
46 |
|
import javax.swing.JTextArea; |
47 |
|
import javax.swing.event.HyperlinkEvent; |
48 |
|
import javax.swing.event.HyperlinkListener; |
49 |
|
import javax.swing.text.html.HTMLEditorKit; |
50 |
|
import javax.swing.text.html.StyleSheet; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@author |
57 |
|
@version |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 290 (290) |
Complexity: 82 |
Complexity Density: 0.43 |
|
59 |
|
public class WebserviceInfo extends GWebserviceInfo |
60 |
|
implements HyperlinkListener, IProgressIndicator |
61 |
|
{ |
62 |
|
|
63 |
|
|
64 |
|
public static final int STATE_QUEUING = 0; |
65 |
|
|
66 |
|
|
67 |
|
public static final int STATE_RUNNING = 1; |
68 |
|
|
69 |
|
|
70 |
|
public static final int STATE_STOPPED_OK = 2; |
71 |
|
|
72 |
|
|
73 |
|
public static final int STATE_CANCELLED_OK = 3; |
74 |
|
|
75 |
|
|
76 |
|
public static final int STATE_STOPPED_ERROR = 4; |
77 |
|
|
78 |
|
|
79 |
|
public static final int STATE_STOPPED_SERVERERROR = 5; |
80 |
|
|
81 |
|
int currentStatus = STATE_QUEUING; |
82 |
|
|
83 |
|
Image image; |
84 |
|
|
85 |
|
int angle = 0; |
86 |
|
|
87 |
|
String title = ""; |
88 |
|
|
89 |
|
jalview.ws.WSClientI thisService; |
90 |
|
|
91 |
|
boolean serviceIsCancellable; |
92 |
|
|
93 |
|
JInternalFrame frame; |
94 |
|
|
95 |
|
private IProgressIndicator progressBar; |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
97 |
0 |
@Override... |
98 |
|
public void setVisible(boolean aFlag) |
99 |
|
{ |
100 |
0 |
super.setVisible(aFlag); |
101 |
0 |
frame.setVisible(aFlag); |
102 |
|
}; |
103 |
|
|
104 |
|
JTabbedPane subjobs = null; |
105 |
|
|
106 |
|
java.util.Vector jobPanes = null; |
107 |
|
|
108 |
|
private boolean serviceCanMergeResults = false; |
109 |
|
|
110 |
|
private boolean viewResultsImmediatly = true; |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
@param |
116 |
|
|
117 |
|
|
118 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
0 |
public boolean isViewResultsImmediatly()... |
120 |
|
{ |
121 |
0 |
return viewResultsImmediatly; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
@param |
128 |
|
|
129 |
|
|
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0 |
public void setViewResultsImmediatly(boolean viewResultsImmediatly)... |
132 |
|
{ |
133 |
0 |
this.viewResultsImmediatly = viewResultsImmediatly; |
134 |
|
} |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
136 |
0 |
private StyleSheet getStyleSheet(HTMLEditorKit editorKit)... |
137 |
|
{ |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
0 |
StyleSheet myStyleSheet = new StyleSheet(); |
142 |
|
|
143 |
0 |
myStyleSheet.addStyleSheet(editorKit.getStyleSheet()); |
144 |
|
|
145 |
0 |
editorKit.setStyleSheet(myStyleSheet); |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
0 |
return myStyleSheet; |
159 |
|
|
160 |
|
} |
161 |
|
|
162 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 5 |
Complexity Density: 0.15 |
|
163 |
0 |
public synchronized int addJobPane()... |
164 |
|
{ |
165 |
0 |
JScrollPane jobpane = new JScrollPane(); |
166 |
0 |
JComponent _progressText; |
167 |
0 |
if (renderAsHtml) |
168 |
|
{ |
169 |
0 |
JEditorPane progressText = new JEditorPane("text/html", ""); |
170 |
0 |
progressText.addHyperlinkListener(this); |
171 |
0 |
_progressText = progressText; |
172 |
|
|
173 |
|
|
174 |
0 |
progressText.setEditable(false); |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
0 |
progressText.setText("<html><h1>WS Job</h1></html>"); |
185 |
|
} |
186 |
|
else |
187 |
|
{ |
188 |
0 |
JTextArea progressText = new JTextArea(); |
189 |
0 |
_progressText = progressText; |
190 |
|
|
191 |
0 |
progressText.setFont(new java.awt.Font("Verdana", 0, 10)); |
192 |
0 |
progressText.setBorder(null); |
193 |
0 |
progressText.setEditable(false); |
194 |
0 |
progressText.setText("WS Job"); |
195 |
0 |
progressText.setLineWrap(true); |
196 |
0 |
progressText.setWrapStyleWord(true); |
197 |
|
} |
198 |
0 |
jobpane.setName("JobPane"); |
199 |
0 |
jobpane.getViewport().add(_progressText, null); |
200 |
0 |
jobpane.setBorder(null); |
201 |
0 |
if (jobPanes == null) |
202 |
|
{ |
203 |
0 |
jobPanes = new Vector(); |
204 |
|
} |
205 |
0 |
int newpane = jobPanes.size(); |
206 |
0 |
jobPanes.add(jobpane); |
207 |
|
|
208 |
0 |
if (newpane == 0) |
209 |
|
{ |
210 |
0 |
this.add(jobpane, BorderLayout.CENTER); |
211 |
|
} |
212 |
|
else |
213 |
|
{ |
214 |
0 |
if (newpane == 1) |
215 |
|
{ |
216 |
|
|
217 |
0 |
JScrollPane firstpane; |
218 |
0 |
this.remove(firstpane = (JScrollPane) jobPanes.get(0)); |
219 |
0 |
subjobs = jalview.jbgui.GDesktop.createTabbedPane(); |
220 |
0 |
this.add(subjobs, BorderLayout.CENTER); |
221 |
0 |
subjobs.add(firstpane); |
222 |
0 |
subjobs.setTitleAt(0, firstpane.getName()); |
223 |
|
} |
224 |
0 |
subjobs.add(jobpane); |
225 |
|
} |
226 |
0 |
return newpane; |
227 |
|
} |
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
@param |
233 |
|
|
234 |
|
@param |
235 |
|
|
236 |
|
@param |
237 |
|
|
238 |
|
|
239 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
240 |
0 |
public WebserviceInfo(String title, String info, boolean makeVisible)... |
241 |
|
{ |
242 |
0 |
init(title, info, 520, 500, makeVisible); |
243 |
|
} |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
@param |
249 |
|
|
250 |
|
@param |
251 |
|
|
252 |
|
@param |
253 |
|
|
254 |
|
@param |
255 |
|
|
256 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
257 |
0 |
public WebserviceInfo(String title, String info, int width, int height,... |
258 |
|
boolean makeVisible) |
259 |
|
{ |
260 |
0 |
init(title, info, width, height, makeVisible); |
261 |
|
} |
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
@return |
267 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
268 |
0 |
public jalview.ws.WSClientI getthisService()... |
269 |
|
{ |
270 |
0 |
return thisService; |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
@param |
278 |
|
|
279 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
280 |
0 |
public void setthisService(jalview.ws.WSClientI newservice)... |
281 |
|
{ |
282 |
0 |
thisService = newservice; |
283 |
0 |
serviceIsCancellable = newservice.isCancellable(); |
284 |
0 |
frame.setClosable(!serviceIsCancellable); |
285 |
0 |
serviceCanMergeResults = newservice.canMergeResults(); |
286 |
0 |
rebuildButtonPanel(); |
287 |
|
} |
288 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
289 |
0 |
private void rebuildButtonPanel()... |
290 |
|
{ |
291 |
0 |
if (buttonPanel != null) |
292 |
|
{ |
293 |
0 |
buttonPanel.removeAll(); |
294 |
0 |
if (serviceIsCancellable) |
295 |
|
{ |
296 |
0 |
buttonPanel.add(cancel); |
297 |
0 |
frame.setClosable(false); |
298 |
|
} |
299 |
|
else |
300 |
|
{ |
301 |
0 |
frame.setClosable(true); |
302 |
|
} |
303 |
|
} |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
@param |
310 |
|
|
311 |
|
@param |
312 |
|
|
313 |
|
@param |
314 |
|
|
315 |
|
@param |
316 |
|
|
317 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 2 |
Complexity Density: 0.1 |
|
318 |
0 |
void init(String title, String info, int width, int height,... |
319 |
|
boolean makeVisible) |
320 |
|
{ |
321 |
0 |
frame = new JInternalFrame(); |
322 |
0 |
frame.setContentPane(this); |
323 |
0 |
Desktop.addInternalFrame(frame, title, makeVisible, width, height); |
324 |
0 |
frame.setClosable(false); |
325 |
|
|
326 |
0 |
progressBar = new ProgressBar(statusPanel, statusBar); |
327 |
|
|
328 |
0 |
this.title = title; |
329 |
0 |
setInfoText(info); |
330 |
|
|
331 |
0 |
java.net.URL url = getClass() |
332 |
|
.getResource("/images/Jalview_Logo_small.png"); |
333 |
0 |
image = java.awt.Toolkit.getDefaultToolkit().createImage(url); |
334 |
|
|
335 |
0 |
MediaTracker mt = new MediaTracker(this); |
336 |
0 |
mt.addImage(image, 0); |
337 |
|
|
338 |
0 |
try |
339 |
|
{ |
340 |
0 |
mt.waitForID(0); |
341 |
|
} catch (Exception ex) |
342 |
|
{ |
343 |
|
} |
344 |
|
|
345 |
0 |
AnimatedPanel ap = new AnimatedPanel(); |
346 |
0 |
titlePanel.add(ap, BorderLayout.CENTER); |
347 |
|
|
348 |
0 |
Thread thread = new Thread(ap); |
349 |
0 |
thread.start(); |
350 |
0 |
final WebserviceInfo thisinfo = this; |
351 |
0 |
frame.addInternalFrameListener( |
352 |
|
new javax.swing.event.InternalFrameAdapter() |
353 |
|
{ |
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
354 |
0 |
public void internalFrameClosed(... |
355 |
|
javax.swing.event.InternalFrameEvent evt) |
356 |
|
{ |
357 |
|
|
358 |
0 |
WSClientI service = thisinfo.getthisService(); |
359 |
0 |
if (service != null && service.isCancellable()) |
360 |
|
{ |
361 |
0 |
service.cancelJob(); |
362 |
|
} |
363 |
|
}; |
364 |
|
}); |
365 |
0 |
frame.validate(); |
366 |
|
|
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
@param |
373 |
|
|
374 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
375 |
0 |
public void setStatus(int status)... |
376 |
|
{ |
377 |
0 |
currentStatus = status; |
378 |
|
} |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
|
@param |
384 |
|
@param |
385 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 9 |
Complexity Density: 0.39 |
|
386 |
0 |
public void setStatus(int jobpane, int status)... |
387 |
|
{ |
388 |
0 |
if (jobpane < 0 || jobpane >= jobPanes.size()) |
389 |
|
{ |
390 |
0 |
throw new Error(MessageManager.formatMessage( |
391 |
|
"error.setstatus_called_non_existent_job_pane", new String[] |
392 |
|
{ Integer.valueOf(jobpane).toString() })); |
393 |
|
} |
394 |
0 |
switch (status) |
395 |
|
{ |
396 |
0 |
case STATE_QUEUING: |
397 |
0 |
setProgressName(jobpane + " - QUEUED", jobpane); |
398 |
0 |
break; |
399 |
0 |
case STATE_RUNNING: |
400 |
0 |
setProgressName(jobpane + " - RUNNING", jobpane); |
401 |
0 |
break; |
402 |
0 |
case STATE_STOPPED_OK: |
403 |
0 |
setProgressName(jobpane + " - FINISHED", jobpane); |
404 |
0 |
break; |
405 |
0 |
case STATE_CANCELLED_OK: |
406 |
0 |
setProgressName(jobpane + " - CANCELLED", jobpane); |
407 |
0 |
break; |
408 |
0 |
case STATE_STOPPED_ERROR: |
409 |
0 |
setProgressName(jobpane + " - BROKEN", jobpane); |
410 |
0 |
break; |
411 |
0 |
case STATE_STOPPED_SERVERERROR: |
412 |
0 |
setProgressName(jobpane + " - ALERT", jobpane); |
413 |
0 |
break; |
414 |
0 |
default: |
415 |
0 |
setProgressName(jobpane + " - UNKNOWN STATE", jobpane); |
416 |
|
} |
417 |
|
} |
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
@return |
423 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
424 |
0 |
public String getInfoText()... |
425 |
|
{ |
426 |
0 |
return infoText.getText(); |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
@param |
433 |
|
|
434 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
435 |
0 |
public void setInfoText(String text)... |
436 |
|
{ |
437 |
0 |
infoText.setText(text); |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
@param |
444 |
|
|
445 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
446 |
0 |
public void appendInfoText(String text)... |
447 |
|
{ |
448 |
0 |
infoText.append(text); |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
@return |
455 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
456 |
0 |
public String getProgressText(int which)... |
457 |
|
{ |
458 |
0 |
if (jobPanes == null) |
459 |
|
{ |
460 |
0 |
addJobPane(); |
461 |
|
} |
462 |
0 |
if (renderAsHtml) |
463 |
|
{ |
464 |
0 |
return ((JEditorPane) ((JScrollPane) jobPanes.get(which)) |
465 |
|
.getViewport().getComponent(0)).getText(); |
466 |
|
} |
467 |
|
else |
468 |
|
{ |
469 |
0 |
return ((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport() |
470 |
|
.getComponent(0)).getText(); |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
@param |
478 |
|
|
479 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
480 |
0 |
public void setProgressText(int which, String text)... |
481 |
|
{ |
482 |
0 |
if (jobPanes == null) |
483 |
|
{ |
484 |
0 |
addJobPane(); |
485 |
|
} |
486 |
0 |
if (renderAsHtml) |
487 |
|
{ |
488 |
0 |
((JEditorPane) ((JScrollPane) jobPanes.get(which)).getViewport() |
489 |
|
.getComponent(0)).setText(ensureHtmlTagged(text)); |
490 |
|
} |
491 |
|
else |
492 |
|
{ |
493 |
0 |
((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport() |
494 |
|
.getComponent(0)).setText(text); |
495 |
|
} |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
@param |
502 |
|
@param |
503 |
|
|
504 |
|
@param |
505 |
|
|
506 |
|
@return |
507 |
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 9 |
Complexity Density: 0.82 |
|
508 |
0 |
private String getHtmlFragment(String text, boolean leaveFirst,... |
509 |
|
boolean leaveLast) |
510 |
|
{ |
511 |
0 |
if (text == null) |
512 |
|
{ |
513 |
0 |
return null; |
514 |
|
} |
515 |
0 |
String lowertxt = text.toLowerCase(); |
516 |
0 |
int htmlpos = leaveFirst ? -1 : lowertxt.indexOf("<body"); |
517 |
|
|
518 |
0 |
int htmlend = leaveLast ? -1 : lowertxt.indexOf("</body"); |
519 |
0 |
int htmlpose = lowertxt.indexOf(">", htmlpos), |
520 |
|
htmlende = lowertxt.indexOf(">", htmlend); |
521 |
0 |
if (htmlend == -1 && htmlpos == -1) |
522 |
|
{ |
523 |
0 |
return text; |
524 |
|
} |
525 |
0 |
if (htmlend > -1) |
526 |
|
{ |
527 |
0 |
return text.substring((htmlpos == -1 ? 0 : htmlpose + 1), htmlend); |
528 |
|
} |
529 |
0 |
return text.substring(htmlpos == -1 ? 0 : htmlpose + 1); |
530 |
|
} |
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
@param |
536 |
|
@return |
537 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 9 |
Complexity Density: 0.56 |
|
538 |
0 |
private String ensureHtmlTagged(String text)... |
539 |
|
{ |
540 |
0 |
if (text == null) |
541 |
|
{ |
542 |
0 |
return ""; |
543 |
|
} |
544 |
0 |
String lowertxt = text.toLowerCase(); |
545 |
0 |
int htmlpos = lowertxt.indexOf("<body"); |
546 |
0 |
int htmlend = lowertxt.indexOf("</body"); |
547 |
0 |
int doctype = lowertxt.indexOf("<!doctype"); |
548 |
0 |
int xmltype = lowertxt.indexOf("<?xml"); |
549 |
0 |
if (htmlend == -1) |
550 |
|
{ |
551 |
0 |
text = text + "</body></html>"; |
552 |
|
} |
553 |
0 |
if (htmlpos > -1) |
554 |
|
{ |
555 |
0 |
if ((doctype > -1 && htmlpos > doctype) |
556 |
|
|| (xmltype > -1 && htmlpos > xmltype)) |
557 |
|
{ |
558 |
0 |
text = "<html><head></head><body>\n" + text.substring(htmlpos - 1); |
559 |
|
} |
560 |
|
} |
561 |
|
else |
562 |
|
{ |
563 |
0 |
text = "<html><head></head><body>\n" + text; |
564 |
|
} |
565 |
0 |
if (text.indexOf("<meta") > -1) |
566 |
|
{ |
567 |
0 |
System.err |
568 |
|
.println("HTML COntent: \n" + text + "<< END HTML CONTENT\n"); |
569 |
|
|
570 |
|
} |
571 |
0 |
return text; |
572 |
|
} |
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
@param |
578 |
|
|
579 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
580 |
0 |
public void appendProgressText(int which, String text)... |
581 |
|
{ |
582 |
0 |
if (jobPanes == null) |
583 |
|
{ |
584 |
0 |
addJobPane(); |
585 |
|
} |
586 |
0 |
if (renderAsHtml) |
587 |
|
{ |
588 |
0 |
String txt = getHtmlFragment( |
589 |
|
((JEditorPane) ((JScrollPane) jobPanes.get(which)) |
590 |
|
.getViewport().getComponent(0)).getText(), |
591 |
|
true, false); |
592 |
0 |
((JEditorPane) ((JScrollPane) jobPanes.get(which)).getViewport() |
593 |
|
.getComponent(0)) |
594 |
|
.setText(ensureHtmlTagged( |
595 |
|
txt + getHtmlFragment(text, false, true))); |
596 |
|
} |
597 |
|
else |
598 |
|
{ |
599 |
0 |
((JTextArea) ((JScrollPane) jobPanes.get(which)).getViewport() |
600 |
|
.getComponent(0)).append(text); |
601 |
|
} |
602 |
|
} |
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
607 |
0 |
public void setProgressText(String text)... |
608 |
|
{ |
609 |
0 |
setProgressText(0, text); |
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
615 |
0 |
public void appendProgressText(String text)... |
616 |
|
{ |
617 |
0 |
appendProgressText(0, text); |
618 |
|
} |
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
623 |
0 |
public String getProgressText()... |
624 |
|
{ |
625 |
0 |
return getProgressText(0); |
626 |
|
} |
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
@param |
632 |
|
|
633 |
|
@return |
634 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
635 |
0 |
public String getProgressName(int which)... |
636 |
|
{ |
637 |
0 |
if (jobPanes == null) |
638 |
|
{ |
639 |
0 |
addJobPane(); |
640 |
|
} |
641 |
0 |
if (subjobs != null) |
642 |
|
{ |
643 |
0 |
return subjobs.getTitleAt(which); |
644 |
|
} |
645 |
|
else |
646 |
|
{ |
647 |
0 |
return ((JScrollPane) jobPanes.get(which)).getViewport() |
648 |
|
.getComponent(0).getName(); |
649 |
|
} |
650 |
|
} |
651 |
|
|
652 |
|
|
653 |
|
|
654 |
|
|
655 |
|
@param |
656 |
|
|
657 |
|
@param |
658 |
|
|
659 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
660 |
0 |
public void setProgressName(String name, int which)... |
661 |
|
{ |
662 |
0 |
if (subjobs != null) |
663 |
|
{ |
664 |
0 |
subjobs.setTitleAt(which, name); |
665 |
0 |
subjobs.revalidate(); |
666 |
0 |
subjobs.repaint(); |
667 |
|
} |
668 |
0 |
JScrollPane c = (JScrollPane) jobPanes.get(which); |
669 |
0 |
c.getViewport().getComponent(0).setName(name); |
670 |
0 |
c.repaint(); |
671 |
|
} |
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
676 |
|
@param |
677 |
|
|
678 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
679 |
0 |
protected void cancel_actionPerformed(ActionEvent e)... |
680 |
|
{ |
681 |
0 |
if (!serviceIsCancellable) |
682 |
|
{ |
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
|
687 |
0 |
warnUser( |
688 |
|
MessageManager.getString( |
689 |
|
"warn.job_cannot_be_cancelled_close_window"), |
690 |
|
MessageManager.getString("action.cancel_job")); |
691 |
|
} |
692 |
|
else |
693 |
|
{ |
694 |
0 |
thisService.cancelJob(); |
695 |
|
} |
696 |
0 |
frame.setClosable(true); |
697 |
|
} |
698 |
|
|
699 |
|
|
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
@param |
704 |
|
@param |
705 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
706 |
0 |
public void warnUser(final String message, final String title)... |
707 |
|
{ |
708 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
709 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
710 |
0 |
public void run()... |
711 |
|
{ |
712 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, message, |
713 |
|
title, JvOptionPane.WARNING_MESSAGE); |
714 |
|
|
715 |
|
} |
716 |
|
}); |
717 |
|
} |
718 |
|
|
719 |
|
|
720 |
|
|
721 |
|
|
722 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
723 |
0 |
public void setResultsReady()... |
724 |
|
{ |
725 |
0 |
frame.setClosable(true); |
726 |
0 |
buttonPanel.remove(cancel); |
727 |
0 |
buttonPanel.add(showResultsNewFrame); |
728 |
0 |
if (serviceCanMergeResults) |
729 |
|
{ |
730 |
0 |
buttonPanel.add(mergeResults); |
731 |
0 |
buttonPanel.setLayout(new GridLayout(2, 1, 5, 5)); |
732 |
|
} |
733 |
0 |
buttonPanel.validate(); |
734 |
0 |
validate(); |
735 |
0 |
if (viewResultsImmediatly) |
736 |
|
{ |
737 |
0 |
showResultsNewFrame.doClick(); |
738 |
|
} |
739 |
|
} |
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
|
744 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
745 |
0 |
public void setFinishedNoResults()... |
746 |
|
{ |
747 |
0 |
frame.setClosable(true); |
748 |
0 |
buttonPanel.remove(cancel); |
749 |
0 |
buttonPanel.validate(); |
750 |
0 |
validate(); |
751 |
|
} |
752 |
|
|
|
|
| 0% |
Uncovered Elements: 56 (56) |
Complexity: 16 |
Complexity Density: 0.36 |
|
753 |
|
class AnimatedPanel extends JPanel implements Runnable |
754 |
|
{ |
755 |
|
long startTime = 0; |
756 |
|
|
757 |
|
BufferedImage offscreen; |
758 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
759 |
0 |
public void run()... |
760 |
|
{ |
761 |
0 |
startTime = System.currentTimeMillis(); |
762 |
|
|
763 |
0 |
while (currentStatus < STATE_STOPPED_OK) |
764 |
|
{ |
765 |
0 |
try |
766 |
|
{ |
767 |
0 |
Thread.sleep(50); |
768 |
|
|
769 |
0 |
int units = (int) ((System.currentTimeMillis() - startTime) |
770 |
|
/ 10f); |
771 |
0 |
angle += units; |
772 |
0 |
angle %= 360; |
773 |
0 |
startTime = System.currentTimeMillis(); |
774 |
|
|
775 |
0 |
if (currentStatus >= STATE_STOPPED_OK) |
776 |
|
{ |
777 |
0 |
angle = 0; |
778 |
|
} |
779 |
|
|
780 |
0 |
repaint(); |
781 |
|
} catch (Exception ex) |
782 |
|
{ |
783 |
|
} |
784 |
|
} |
785 |
|
|
786 |
0 |
cancel.setEnabled(false); |
787 |
|
} |
788 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 11 |
Complexity Density: 0.35 |
|
789 |
0 |
void drawPanel()... |
790 |
|
{ |
791 |
0 |
if (offscreen == null || offscreen.getWidth(this) != getWidth() |
792 |
|
|| offscreen.getHeight(this) != getHeight()) |
793 |
|
{ |
794 |
0 |
offscreen = new BufferedImage(getWidth(), getHeight(), |
795 |
|
BufferedImage.TYPE_INT_ARGB); |
796 |
|
} |
797 |
|
|
798 |
0 |
Graphics2D g = (Graphics2D) offscreen.getGraphics(); |
799 |
|
|
800 |
0 |
g.setColor(Color.white); |
801 |
0 |
g.fillRect(0, 0, getWidth(), getHeight()); |
802 |
|
|
803 |
0 |
g.setFont(new Font("Arial", Font.BOLD, 12)); |
804 |
0 |
g.setColor(Color.black); |
805 |
|
|
806 |
0 |
switch (currentStatus) |
807 |
|
{ |
808 |
0 |
case STATE_QUEUING: |
809 |
0 |
g.drawString( |
810 |
|
title.concat(" - ").concat( |
811 |
|
MessageManager.getString("label.state_queueing")), |
812 |
|
60, 30); |
813 |
|
|
814 |
0 |
break; |
815 |
|
|
816 |
0 |
case STATE_RUNNING: |
817 |
0 |
g.drawString( |
818 |
|
title.concat(" - ").concat( |
819 |
|
MessageManager.getString("label.state_running")), |
820 |
|
60, 30); |
821 |
|
|
822 |
0 |
break; |
823 |
|
|
824 |
0 |
case STATE_STOPPED_OK: |
825 |
0 |
g.drawString( |
826 |
|
title.concat(" - ").concat( |
827 |
|
MessageManager.getString("label.state_completed")), |
828 |
|
60, 30); |
829 |
|
|
830 |
0 |
break; |
831 |
|
|
832 |
0 |
case STATE_CANCELLED_OK: |
833 |
0 |
g.drawString( |
834 |
|
title.concat(" - ") |
835 |
|
.concat(MessageManager |
836 |
|
.getString("label.state_job_cancelled")), |
837 |
|
60, 30); |
838 |
|
|
839 |
0 |
break; |
840 |
|
|
841 |
0 |
case STATE_STOPPED_ERROR: |
842 |
0 |
g.drawString( |
843 |
|
title.concat(" - ").concat( |
844 |
|
MessageManager.getString("label.state_job_error")), |
845 |
|
60, 30); |
846 |
|
|
847 |
0 |
break; |
848 |
|
|
849 |
0 |
case STATE_STOPPED_SERVERERROR: |
850 |
0 |
g.drawString( |
851 |
|
title.concat(" - ") |
852 |
|
.concat(MessageManager |
853 |
|
.getString("label.server_error_try_later")), |
854 |
|
60, 30); |
855 |
|
|
856 |
0 |
break; |
857 |
|
} |
858 |
|
|
859 |
0 |
if (image != null) |
860 |
|
{ |
861 |
0 |
int x = image.getWidth(this) / 2, y = image.getHeight(this) / 2; |
862 |
0 |
g.rotate(Math.toRadians(angle), 10 + x, 10 + y); |
863 |
0 |
g.drawImage(image, 10, 10, this); |
864 |
0 |
g.rotate(-Math.toRadians(angle), 10 + x, 10 + y); |
865 |
|
} |
866 |
|
} |
867 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
868 |
0 |
public void paintComponent(Graphics g1)... |
869 |
|
{ |
870 |
0 |
drawPanel(); |
871 |
|
|
872 |
0 |
g1.drawImage(offscreen, 0, 0, this); |
873 |
|
} |
874 |
|
} |
875 |
|
|
876 |
|
boolean renderAsHtml = false; |
877 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
878 |
0 |
public void setRenderAsHtml(boolean b)... |
879 |
|
{ |
880 |
0 |
renderAsHtml = b; |
881 |
|
} |
882 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
883 |
0 |
public void hyperlinkUpdate(HyperlinkEvent e)... |
884 |
|
{ |
885 |
0 |
Desktop.hyperlinkUpdate(e); |
886 |
|
} |
887 |
|
|
888 |
|
|
889 |
|
|
890 |
|
|
891 |
|
@see |
892 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
893 |
0 |
@Override... |
894 |
|
public void setProgressBar(String message, long id) |
895 |
|
{ |
896 |
0 |
progressBar.setProgressBar(message, id); |
897 |
|
} |
898 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
899 |
0 |
@Override... |
900 |
|
public void registerHandler(final long id, |
901 |
|
final IProgressIndicatorHandler handler) |
902 |
|
{ |
903 |
0 |
progressBar.registerHandler(id, handler); |
904 |
|
} |
905 |
|
|
906 |
|
|
907 |
|
|
908 |
|
@return |
909 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
910 |
0 |
@Override... |
911 |
|
public boolean operationInProgress() |
912 |
|
{ |
913 |
0 |
return progressBar.operationInProgress(); |
914 |
|
} |
915 |
|
} |