1 package org
.argeo
.slc
.client
.ui
.services
;
3 import org
.argeo
.slc
.SlcException
;
4 import org
.argeo
.slc
.client
.ui
.ClientUiPlugin
;
5 import org
.argeo
.slc
.core
.attachment
.Attachment
;
6 import org
.argeo
.slc
.core
.attachment
.SimpleAttachment
;
7 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
8 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResultListener
;
9 import org
.argeo
.slc
.msg
.test
.tree
.AddTreeTestResultAttachmentRequest
;
10 import org
.argeo
.slc
.msg
.test
.tree
.CloseTreeTestResultRequest
;
11 import org
.argeo
.slc
.msg
.test
.tree
.CreateTreeTestResultRequest
;
12 import org
.argeo
.slc
.msg
.test
.tree
.ResultPartRequest
;
13 import org
.argeo
.slc
.services
.TestManagerService
;
14 import org
.argeo
.slc
.test
.TestResultPart
;
15 import org
.eclipse
.ui
.handlers
.IHandlerService
;
17 /** In memory access to a test manager service */
18 public class TestManagerServiceAdapter
implements TreeTestResultListener
{
19 // private static final Log log = LogFactory
20 // .getLog(TestManagerServiceAdapter.class);
22 private Boolean onlyOnClose
= false;
24 private TestManagerService testManagerService
;
26 public void resultPartAdded(TreeTestResult testResult
,
27 TestResultPart testResultPart
) {
31 if (testResult
.getResultParts().size() == 1
32 && testResult
.getResultParts().values().iterator().next()
33 .getParts().size() == 1) {
34 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
36 testManagerService
.createTreeTestResult(req
);
38 ResultPartRequest req
= new ResultPartRequest(testResult
);
39 testManagerService
.addResultPart(req
);
43 public void close(TreeTestResult testResult
) {
46 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
48 testManagerService
.createTreeTestResult(req
);
50 CloseTreeTestResultRequest req
= new CloseTreeTestResultRequest(
52 testManagerService
.closeTreeTestResult(req
);
55 // TODO : clean this -> pb of thread && commandID hardCoded.
56 // We force the refresh of the list view.
57 ClientUiPlugin
.getDefault().getWorkbench().getDisplay().syncExec(
60 IHandlerService handlerService
= (IHandlerService
) ClientUiPlugin
61 .getDefault().getWorkbench().getService(
62 IHandlerService
.class);
66 "org.argeo.slc.client.ui.RefreshResultList",
68 } catch (Exception e
) {
70 throw new SlcException(
71 "Problem while rendering result. "
81 public void addAttachment(TreeTestResult testResult
, Attachment attachment
) {
84 AddTreeTestResultAttachmentRequest req
= new AddTreeTestResultAttachmentRequest();
85 req
.setResultUuid(testResult
.getUuid());
86 req
.setAttachment((SimpleAttachment
) attachment
);
87 testManagerService
.addAttachment(req
);
91 /** Publishes the test result only when it gets closed. */
92 public void setOnlyOnClose(Boolean onlyOnClose
) {
93 this.onlyOnClose
= onlyOnClose
;
96 public void setTestManagerService(TestManagerService testManagerService
) {
97 this.testManagerService
= testManagerService
;