1 package org
.argeo
.slc
.client
.ui
.services
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.argeo
.slc
.SlcException
;
6 import org
.argeo
.slc
.client
.ui
.ClientUiPlugin
;
7 import org
.argeo
.slc
.core
.attachment
.Attachment
;
8 import org
.argeo
.slc
.core
.attachment
.SimpleAttachment
;
9 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
10 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultListener
;
11 import org
.argeo
.slc
.msg
.test
.tree
.AddTreeTestResultAttachmentRequest
;
12 import org
.argeo
.slc
.msg
.test
.tree
.CloseTreeTestResultRequest
;
13 import org
.argeo
.slc
.msg
.test
.tree
.CreateTreeTestResultRequest
;
14 import org
.argeo
.slc
.msg
.test
.tree
.ResultPartRequest
;
15 import org
.argeo
.slc
.services
.TestManagerService
;
16 import org
.argeo
.slc
.test
.TestResultPart
;
17 import org
.eclipse
.ui
.handlers
.IHandlerService
;
19 /** In memory access to a test manager service */
20 public class TestManagerServiceAdapter
implements TreeTestResultListener
{
21 private static final Log log
= LogFactory
22 .getLog(TestManagerServiceAdapter
.class);
24 private Boolean onlyOnClose
= false;
26 private TestManagerService testManagerService
;
28 public void resultPartAdded(TreeTestResult testResult
,
29 TestResultPart testResultPart
) {
33 if (testResult
.getResultParts().size() == 1
34 && testResult
.getResultParts().values().iterator().next()
35 .getParts().size() == 1) {
36 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
38 testManagerService
.createTreeTestResult(req
);
40 ResultPartRequest req
= new ResultPartRequest(testResult
);
41 testManagerService
.addResultPart(req
);
45 public void close(TreeTestResult testResult
) {
48 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
50 testManagerService
.createTreeTestResult(req
);
52 CloseTreeTestResultRequest req
= new CloseTreeTestResultRequest(
54 testManagerService
.closeTreeTestResult(req
);
57 // TODO : clean this -> pb of thread && commandID hardCoded.
58 // We force the refresh of the list view.
59 ClientUiPlugin
.getDefault().getWorkbench().getDisplay().syncExec(
62 IHandlerService handlerService
= (IHandlerService
) ClientUiPlugin
63 .getDefault().getWorkbench().getService(
64 IHandlerService
.class);
68 "org.argeo.slc.client.ui.RefreshResultList",
70 } catch (Exception e
) {
72 throw new SlcException(
73 "Problem while rendering result. "
83 public void addAttachment(TreeTestResult testResult
, Attachment attachment
) {
86 AddTreeTestResultAttachmentRequest req
= new AddTreeTestResultAttachmentRequest();
87 req
.setResultUuid(testResult
.getUuid());
88 req
.setAttachment((SimpleAttachment
) attachment
);
89 testManagerService
.addAttachment(req
);
93 /** Publishes the test result only when it gets closed. */
94 public void setOnlyOnClose(Boolean onlyOnClose
) {
95 this.onlyOnClose
= onlyOnClose
;
98 public void setTestManagerService(TestManagerService testManagerService
) {
99 this.testManagerService
= testManagerService
;