From 3a711eb9f0dbf0385627521a622c4c5d024173b3 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Fri, 1 Oct 2010 10:50:31 +0000 Subject: [PATCH] First draft of TestResult Detail Implementation git-svn-id: https://svn.argeo.org/slc/trunk@3814 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../META-INF/MANIFEST.MF | 3 + .../client/aspects/ContentProviderAspect.java | 3 +- .../ProcessDetailContentProvider.java | 6 +- .../ResultDetailContentProvider.java | 265 ++++++++++++++++++ .../ResultDetailLabelProvider.java | 37 +++ .../META-INF/MANIFEST.MF | 5 +- .../META-INF/spring/core.xml | 6 + .../META-INF/spring/osgi.xml | 2 + .../org/argeo/slc/client/rcp/Perspective.java | 5 +- .../META-INF/MANIFEST.MF | 1 + .../META-INF/spring/commands.xml | 4 + .../META-INF/spring/osgi.xml | 12 +- .../META-INF/spring/views.xml | 8 + .../org.argeo.slc.client.ui/plugin.xml | 16 ++ .../ProcessDetailsDisplayHandler.java | 15 +- .../commands/ResultDetailsDisplayHandler.java | 48 ++++ .../client/ui/views/ProcessDetailView.java | 12 +- .../slc/client/ui/views/ProcessListView.java | 13 +- .../slc/client/ui/views/ResultDetailView.java | 79 ++++++ .../slc/client/ui/views/ResultListView.java | 83 +++++- 20 files changed, 574 insertions(+), 49 deletions(-) create mode 100644 eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailContentProvider.java create mode 100644 eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailLabelProvider.java create mode 100644 eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ResultDetailsDisplayHandler.java create mode 100644 eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultDetailView.java diff --git a/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF b/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF index ba13ce9c7..a20690305 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF +++ b/eclipse/plugins/org.argeo.slc.client.core/META-INF/MANIFEST.MF @@ -12,7 +12,10 @@ Import-Package: org.apache.commons.io;version="1.4.0", org.apache.commons.logging;version="1.1.1", org.argeo.eclipse.spring, org.argeo.eclipse.ui, + org.argeo.slc.core.structure.tree, + org.argeo.slc.core.test.tree, org.argeo.slc.dao.process, + org.argeo.slc.dao.test.tree, org.argeo.slc.process, org.aspectj.lang, org.aspectj.lang.annotation, diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java index f92d9d571..9a104b0b4 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java @@ -29,7 +29,8 @@ public class ContentProviderAspect { // PointCuts @Pointcut("(execution (* org.argeo.slc.client.contentprovider.ProcessListTableLabelProvider.get*(..)) && args(o,..))" - + " || (execution (* org.argeo.slc.client.contentprovider.ProcessDetailContentProvider.get*(..)) && args(o,..))") + + " || (execution (* org.argeo.slc.client.contentprovider.ProcessDetailContentProvider.get*(..)) && args(o,..))" + + " || (execution (* org.argeo.slc.client.contentprovider.ResultDetailContentProvider.get*(..)) && args(o,..))") void contentProviderGetterWrapper(Object o) { } diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java index da2a793ee..a89c90752 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java @@ -108,6 +108,9 @@ public class ProcessDetailContentProvider implements ITreeContentProvider { } public Object[] getElements(Object parent) { + // return getChildren(parent); + // Here we must dupplicate the code otherwise the inner call to method + // getChildren(parent); is not intercepted by AspectJ if (parent instanceof SlcExecution) { slcExecution = (SlcExecution) parent; @@ -125,7 +128,6 @@ public class ProcessDetailContentProvider implements ITreeContentProvider { log.debug(" Realized flows : "); return steps.toArray(); } - // return getChildren(parent); return null; } @@ -162,7 +164,7 @@ public class ProcessDetailContentProvider implements ITreeContentProvider { // public ExecutionModuleDescriptor getDescriptor() { // return descriptor; // } - // Object o = thisJoinPoint.getArgs()[0]; + // Object o = thisJoinPoint.getArgs()[0]; // public void cacheDescriptor(ExecutionModuleDescriptor descriptor) { // this.descriptor = descriptor; diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailContentProvider.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailContentProvider.java new file mode 100644 index 000000000..c9f1818be --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailContentProvider.java @@ -0,0 +1,265 @@ +package org.argeo.slc.client.contentprovider; + +import java.util.SortedMap; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.slc.core.structure.tree.TreeSPath; +import org.argeo.slc.core.test.tree.PartSubList; +import org.argeo.slc.core.test.tree.TreeTestResult; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * Basic tree view of the chosen process details + */ +public class ResultDetailContentProvider implements ITreeContentProvider { + private final static Log log = LogFactory + .getLog(ResultDetailContentProvider.class); + + private TreeTestResult treeTestResult; + + public Object[] getChildren(Object parent) { + if (parent instanceof TreeTestResult) { + treeTestResult = (TreeTestResult) parent; + + SortedMap parts = treeTestResult + .getResultParts(); + + for (TreeSPath key : parts.keySet()) { + log.debug("Test[" + key.toString() + "] isPassed = " + + parts.get(key).getIsPassed()); + } + + return parts.keySet().toArray(); + } + // if (parent instanceof ExecutionModuleNode) { + // ExecutionModuleNode executionModuleNode = (ExecutionModuleNode) + // parent; + // ExecutionModuleDescriptor emd = + // executionModuleNode.getDescriptor(); + // emd = executionModuleNode.getAgentNode().getAgent() + // .getExecutionModuleDescriptor(emd.getName(), + // emd.getVersion()); + // executionModuleNode.cacheDescriptor(emd); + // // for (String flowName : + // executionModuleNode.getFlowDescriptors() + // // .keySet()) { + // // executionModuleNode.addChild(new FlowNode(flowName, + // // executionModuleNode)); + // // } + // return executionModuleNode.getChildren(); + // } else if (parent instanceof AgentNode) { + // AgentNode agentNode = (AgentNode) parent; + // + // if (log.isTraceEnabled()) + // log.trace("Scan agent " + agentNode); + // + // agentNode.clearChildren(); + // for (ExecutionModuleDescriptor desc : agentNode.getAgent() + // .listExecutionModuleDescriptors()) { + // agentNode.addChild(new ExecutionModuleNode(agentNode, desc)); + // } + // + // return agentNode.getChildren(); + // } else if (parent instanceof TreeParent) { + // return ((TreeParent) parent).getChildren(); + // } else if (parent instanceof FlowNode) { + // return new Object[0]; + // } else { + // List agentNodes = new ArrayList(); + // for (SlcAgent slcAgent : slcAgents) { + // agentNodes.add(new AgentNode(slcAgent)); + // } + // return agentNodes.toArray(); + // } + return null; + } + + public Object getParent(Object node) { + // if (node instanceof TreeObject) { + // return ((TreeObject) node).getParent(); + // } + return null; + } + + public boolean hasChildren(Object parent) { + // if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded()) + // { + // return ((TreeParent) parent).hasChildren(); + // } else if (parent instanceof AgentNode) { + // return true; + // } else if (parent instanceof ExecutionModuleNode) { + // return true; + // } + return false; + } + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + if (parent instanceof TreeTestResult) { + treeTestResult = (TreeTestResult) parent; + + SortedMap parts = treeTestResult + .getResultParts(); + + for (TreeSPath key : parts.keySet()) { + log.debug("Test[" + key.toString() + "] isPassed = " + + parts.get(key).getIsPassed()); + } + + return parts.keySet().toArray(); + } + // return getChildren(parent); + return null; + } + + // public class AgentNode extends TreeParent { + // private final SlcAgent agent; + // + // public AgentNode(SlcAgent agent) { + // super(agent.toString()); + // this.agent = agent; + // } + + // public SlcAgent getAgent() { + // return agent; + // } + // } + + // public class ExecutionModuleNode extends TreeParent { + // private final AgentNode agentNode; + // private ExecutionModuleDescriptor descriptor; + // private Map flowDescriptors; + // + // public ExecutionModuleNode(AgentNode agentNode, + // ExecutionModuleDescriptor descriptor) { + // super(descriptor.toString()); + // this.agentNode = agentNode; + // this.descriptor = descriptor; + // + // } + // + // public AgentNode getAgentNode() { + // return agentNode; + // } + // + // public ExecutionModuleDescriptor getDescriptor() { + // return descriptor; + // } + // Object o = thisJoinPoint.getArgs()[0]; + + // public void cacheDescriptor(ExecutionModuleDescriptor descriptor) { + // this.descriptor = descriptor; + // + // SortedMap folderNodes = new TreeMap(); + // + // flowDescriptors = new HashMap(); + // for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) { + // // if (log.isTraceEnabled()) + // // log.trace("fd.path=" + fd.getPath() + ", fd.name=" + // // + fd.getName()); + // + // // find path and label + // String path; + // String label; + // int lastSlash = fd.getName().lastIndexOf('/'); + // if ((fd.getPath() == null || fd.getPath().trim().equals("")) + // && lastSlash >= 0) { + // path = fd.getName().substring(0, lastSlash); + // label = fd.getName().substring(lastSlash + 1); + // } else { + // path = fd.getPath(); + // label = fd.getName(); + // } + // // if (log.isTraceEnabled()) + // // log.trace("path=" + path + ", label=" + label); + // + // if (path == null || path.trim().equals("") + // || path.trim().equals("/")) { + // // directChildren.put(name, new FlowNode(name, this)); + // addChild(new FlowNode(label, fd.getName(), this)); + // } else { + // FolderNode folderNode = mkdirs(this, path, folderNodes); + // folderNode + // .addChild(new FlowNode(label, fd.getName(), this)); + // } + // + // flowDescriptors.put(fd.getName(), fd); + // } + // // TODO: make it readonly + // } + // + // protected FolderNode mkdirs(TreeParent root, String path, + // SortedMap folderNodes) { + // // Normalize + // if (path.charAt(0) != '/') + // path = '/' + path; + // if (path.charAt(path.length() - 1) == '/') + // path = path.substring(0, path.length() - 1); + // + // if (folderNodes.containsKey(path)) + // return folderNodes.get(path); + // + // int lastIndx = path.lastIndexOf('/'); + // String folderName; + // String parentPath; + // if (lastIndx >= 0) { + // folderName = path.substring(lastIndx + 1); + // parentPath = path.substring(0, lastIndx); + // } else { + // folderName = path; + // parentPath = ""; + // } + // + // TreeParent parent; + // if (parentPath.equals("")) + // parent = root; + // else + // parent = mkdirs(root, parentPath, folderNodes); + // FolderNode newFolder = new FolderNode(folderName); + // parent.addChild(newFolder); + // folderNodes.put(path, newFolder); + // return newFolder; + // } + // + // public Map getFlowDescriptors() { + // return flowDescriptors; + // } + // + // } + // + // public class FlowNode extends TreeObject { + // private final String flowName; + // private final ExecutionModuleNode executionModuleNode; + // + // public FlowNode(String label, String flowName, + // ExecutionModuleNode executionModuleNode) { + // super(label); + // this.flowName = flowName; + // this.executionModuleNode = executionModuleNode; + // } + // + // public String getFlowName() { + // return flowName; + // } + // + // public ExecutionModuleNode getExecutionModuleNode() { + // return executionModuleNode; + // } + // + // } + // + // public class FolderNode extends TreeParent { + // public FolderNode(String name) { + // super(name); + // } + // + // } +} diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailLabelProvider.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailLabelProvider.java new file mode 100644 index 000000000..e32e49347 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ResultDetailLabelProvider.java @@ -0,0 +1,37 @@ +package org.argeo.slc.client.contentprovider; + +import org.argeo.slc.process.SlcExecution; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** + * @author bsinou + * + * Fill ResultDetail view. Deported in an external bundle so that main + * slc ui bundle does not depend on DB implementation. + */ +public class ResultDetailLabelProvider extends LabelProvider implements + ITableLabelProvider { + public String getColumnText(Object obj, int index) { + + SlcExecution se = (SlcExecution) obj; + switch (index) { + + case 0: + return getText(se.getStartDate()); + case 1: + return se.getHost(); + case 2: + return se.getUuid(); + case 3: + return se.currentStep().getType(); + } + return getText(obj); + } + + public Image getColumnImage(Object obj, int index) { + return null; + } + +} diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF index 9102d24b3..3326e7470 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/MANIFEST.MF @@ -7,7 +7,10 @@ Require-Bundle: org.eclipse.ui;resolution:=optional Import-Package: org.aopalliance.aop;version="1.0.0", org.argeo.slc.client.aspects, org.argeo.slc.client.contentprovider, - org.argeo.slc.dao.process;version="0.13.0.SNAPSHOT-r3777", + org.argeo.slc.core.structure.tree, + org.argeo.slc.core.test.tree, + org.argeo.slc.dao.process, + org.argeo.slc.dao.test.tree, org.hibernate, org.hibernate.classic, org.springframework.aop;version="2.5.6.SEC01", diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml index 62f8cbbd4..027c50d41 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml @@ -14,6 +14,12 @@ + + diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml index 97e6e5474..51602be3b 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml @@ -21,6 +21,8 @@ + + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml index 89fb801c1..8f5dcaba6 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/osgi.xml @@ -16,7 +16,6 @@ interface="org.argeo.slc.core.test.tree.TreeTestResultListener" /> - @@ -25,6 +24,12 @@ + + + + @@ -38,7 +43,10 @@ bean-name="processListStructuredContentProvider" /> - + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml index 5ad45642a..0d2b0a3ac 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml @@ -15,6 +15,14 @@ + + + + + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml b/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml index 4c822efc5..743dc915f 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml @@ -17,6 +17,13 @@ name="Results" restorable="true"> + + + + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ProcessDetailsDisplayHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ProcessDetailsDisplayHandler.java index a538ca029..cdc28812b 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ProcessDetailsDisplayHandler.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ProcessDetailsDisplayHandler.java @@ -1,7 +1,5 @@ package org.argeo.slc.client.ui.commands; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.argeo.slc.client.ui.views.ProcessDetailView; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -17,8 +15,8 @@ import org.eclipse.ui.handlers.HandlerUtil; */ public class ProcessDetailsDisplayHandler extends AbstractHandler { - private static final Log log = LogFactory - .getLog(ProcessDetailsDisplayHandler.class); + // private static final Log log = LogFactory + // .getLog(ProcessDetailsDisplayHandler.class); public Object execute(ExecutionEvent event) throws ExecutionException { @@ -27,15 +25,14 @@ public class ProcessDetailsDisplayHandler extends AbstractHandler { String uuid = event .getParameter("org.argeo.slc.client.commands.processUuid"); - // mode = 2 : VIEW_VISIBLE, Show view mode that indicates the view - // should be created or made visible if already created . + // mode = 1 : VIEW_ACTIVATE, Show view mode that indicates the view + // should be made visible and activated. Use of this mode has the same + // effect as calling showView. try { ProcessDetailView pView = (ProcessDetailView) HandlerUtil .getActiveWorkbenchWindow(event).getActivePage() - .showView(ProcessDetailView.ID, "UUID-" + uuid, 2); - log.debug("Newly created pView : " + pView); + .showView(ProcessDetailView.ID, "UUID-" + uuid, 1); pView.setUuid(uuid); - log.debug("uuid set"); pView.retrieveResults(); } catch (Exception e) { e.printStackTrace(); diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ResultDetailsDisplayHandler.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ResultDetailsDisplayHandler.java new file mode 100644 index 000000000..894733550 --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/commands/ResultDetailsDisplayHandler.java @@ -0,0 +1,48 @@ +package org.argeo.slc.client.ui.commands; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.slc.client.ui.views.ResultDetailView; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.ui.handlers.HandlerUtil; + +/** + * Command handler to set visible or create a ResultDetailView. UUID of the + * testResult is passed via command parameters. + * + * @author bsinou + * + */ + +public class ResultDetailsDisplayHandler extends AbstractHandler { + private static final Log log = LogFactory + .getLog(ResultDetailsDisplayHandler.class); + + public Object execute(ExecutionEvent event) throws ExecutionException { + + // We pass the UUID of the test result we want to display via command + // parameters. + String uuid = event + .getParameter("org.argeo.slc.client.commands.resultUuid"); + + // mode = 2 : VIEW_VISIBLE, Show view mode that indicates the view + // should be created or made visible if already created . + // mode = 1 : VIEW_ACTIVATE, Show view mode that indicates the view + // should be made visible and activated. Use of this mode has the same + // effect as calling + try { + ResultDetailView rView = (ResultDetailView) HandlerUtil + .getActiveWorkbenchWindow(event).getActivePage() + .showView(ResultDetailView.ID, "UUID-" + uuid, 1); + if (log.isTraceEnabled()) + log.trace("Newly created rView : " + rView); + rView.setUuid(uuid); + rView.retrieveResults(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessDetailView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessDetailView.java index 51b8f2605..d08a45407 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessDetailView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessDetailView.java @@ -1,7 +1,5 @@ package org.argeo.slc.client.ui.views; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.argeo.slc.dao.process.SlcExecutionDao; import org.argeo.slc.process.SlcExecution; import org.eclipse.jface.viewers.IContentProvider; @@ -13,14 +11,15 @@ import org.eclipse.ui.part.ViewPart; /** * Multi-instance view that enables to browse the details of a given - * TreeTestResult + * SlcExecution * * @author bsinou * */ public class ProcessDetailView extends ViewPart { - private final static Log log = LogFactory.getLog(ProcessDetailView.class); + // private final static Log log = + // LogFactory.getLog(ProcessDetailView.class); public static final String ID = "org.argeo.slc.client.ui.processDetailView"; private TreeViewer viewer; @@ -34,12 +33,10 @@ public class ProcessDetailView extends ViewPart { private SlcExecutionDao slcExecutionDao; public void createPartControl(Composite parent) { - // log.debug("In create part Control &&& uuid = " + uuid); viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(contentProvider); viewer.setLabelProvider(labelProvider); // viewer.setInput(getViewSite()); - log.debug("PartControl CREATED."); } public void setFocus() { @@ -52,9 +49,7 @@ public class ProcessDetailView extends ViewPart { public void retrieveResults() { se = slcExecutionDao.getSlcExecution(uuid); - log.debug("========= Se : " + se); viewer.setInput(se); - log.debug("Input SET"); } public void setUuid(String uuid) { @@ -73,5 +68,4 @@ public class ProcessDetailView extends ViewPart { public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao) { this.slcExecutionDao = slcExecutionDao; } - } \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java index 63d017b79..83194d603 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ProcessListView.java @@ -2,8 +2,6 @@ package org.argeo.slc.client.ui.views; import java.util.ArrayList; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.argeo.slc.SlcException; import org.argeo.slc.client.ui.ClientUiPlugin; import org.argeo.slc.dao.process.SlcExecutionDao; @@ -37,7 +35,7 @@ import org.eclipse.ui.part.ViewPart; * */ public class ProcessListView extends ViewPart { - private final static Log log = LogFactory.getLog(ProcessListView.class); + // private final static Log log = LogFactory.getLog(ProcessListView.class); public static final String ID = "org.argeo.slc.client.ui.processListView"; @@ -108,11 +106,7 @@ public class ProcessListView extends ViewPart { if (obj instanceof SlcExecution) { SlcExecution se = (SlcExecution) obj; - log.debug("DOUBLE CLICK ON process d'UUID" + se.getUuid()); - // ClientUiPlugin.getDefault().getWorkbench().getDisplay() - // .syncExec(new Runnable() { - // public void run() { IWorkbench iw = ClientUiPlugin.getDefault().getWorkbench(); IHandlerService handlerService = (IHandlerService) iw .getService(IHandlerService.class); @@ -124,14 +118,13 @@ public class ProcessListView extends ViewPart { Command cmd = cmdService .getCommand("org.argeo.slc.client.ui.displayProcessDetails"); - // log.debug("cmd : " + cmd); ArrayList parameters = new ArrayList(); // get the parameter IParameter iparam = cmd .getParameter("org.argeo.slc.client.commands.processUuid"); - Parameterization params = new Parameterization(iparam, - se.getUuid()); // "testUUID");// + Parameterization params = new Parameterization(iparam, se + .getUuid()); // "testUUID");// parameters.add(params); // build the parameterized command diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultDetailView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultDetailView.java new file mode 100644 index 000000000..755e4d9cb --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultDetailView.java @@ -0,0 +1,79 @@ +package org.argeo.slc.client.ui.views; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.slc.core.test.tree.TreeTestResult; +import org.argeo.slc.dao.test.tree.TreeTestResultDao; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.part.ViewPart; + +/** + * Multi-instance view that enables to browse the details of a given + * TreeTestResult + * + * @author bsinou + * + */ + +public class ResultDetailView extends ViewPart { + private final static Log log = LogFactory.getLog(ResultDetailView.class); + public static final String ID = "org.argeo.slc.client.ui.resultDetailView"; + + private TreeViewer viewer; + + private String uuid; + private TreeTestResult ttr; + + // IoC + private IContentProvider contentProvider; + private ITableLabelProvider labelProvider; + private TreeTestResultDao treeTestResultDao; + + public void createPartControl(Composite parent) { + // log.debug("In create part Control &&& uuid = " + uuid); + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(contentProvider); + viewer.setLabelProvider(labelProvider); + // viewer.setInput(getViewSite()); + if (log.isDebugEnabled()) + log.debug("PartControl CREATED."); + } + + public void setFocus() { + viewer.getControl().setFocus(); + } + + public TreeViewer getViewer() { + return viewer; + } + + public void retrieveResults() { + ttr = treeTestResultDao.getTestResult(uuid); + log.debug("========= ttr: " + ttr); + viewer.setInput(ttr); + log.debug("Input SET"); + setFocus(); + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + // IoC + public void setContentProvider(IContentProvider contentProvider) { + this.contentProvider = contentProvider; + } + + public void setLabelProvider(ITableLabelProvider labelProvider) { + this.labelProvider = labelProvider; + } + + public void setTreeTestResultDao(TreeTestResultDao treeTestResultDao) { + this.treeTestResultDao = treeTestResultDao; + } + +} \ No newline at end of file diff --git a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultListView.java b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultListView.java index 1ca5909a5..c61f8de34 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultListView.java +++ b/eclipse/plugins/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/ResultListView.java @@ -1,12 +1,22 @@ package org.argeo.slc.client.ui.views; +import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.slc.SlcException; +import org.argeo.slc.client.ui.ClientUiPlugin; import org.argeo.slc.core.test.tree.ResultAttributes; import org.argeo.slc.dao.test.tree.TreeTestResultCollectionDao; +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.IParameter; +import org.eclipse.core.commands.Parameterization; +import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; @@ -17,6 +27,10 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.part.ViewPart; public class ResultListView extends ViewPart { @@ -33,8 +47,8 @@ public class ResultListView extends ViewPart { viewer = new TableViewer(table); viewer.setLabelProvider(new ViewLabelProvider()); viewer.setContentProvider(new ViewContentProvider()); - viewer.setInput(getViewSite()); + viewer.addDoubleClickListener(new ViewDoubleClickListener()); } protected Table createTable(Composite parent) { @@ -63,15 +77,11 @@ public class ResultListView extends ViewPart { return table; } + // View Specific inner class protected static class ViewContentProvider implements IStructuredContentProvider { - // private List lst; public void inputChanged(Viewer arg0, Object arg1, Object arg2) { - // if (arg2 instanceof List) { - // lst = (List) arg2; - // log.trace("result count: " + lst.size()); - // } } public void dispose() { @@ -79,17 +89,11 @@ public class ResultListView extends ViewPart { @SuppressWarnings("unchecked") public Object[] getElements(Object obj) { - // if (lst == null) - // return new Object[0]; - // else - // return lst.toArray(); if (obj instanceof List) { return ((List) obj).toArray(); } else { return new Object[0]; } - // return - // testResultCollectionDao.listResultAttributes(null).toArray(); } } @@ -130,6 +134,61 @@ public class ResultListView extends ViewPart { } } + // Handle Events + /** + * The ResultAttributes expose a part of the information contained in the + * TreeTestResult, It has the same UUID as the corresponding treeTestResult. + */ + class ViewDoubleClickListener implements IDoubleClickListener { + public void doubleClick(DoubleClickEvent evt) { + Object obj = ((IStructuredSelection) evt.getSelection()) + .getFirstElement(); + + if (obj instanceof ResultAttributes) { + ResultAttributes ra = (ResultAttributes) obj; + log.debug("Double-clic on result with UUID" + ra.getUuid()); + + IWorkbench iw = ClientUiPlugin.getDefault().getWorkbench(); + IHandlerService handlerService = (IHandlerService) iw + .getService(IHandlerService.class); + try { + // get the command from plugin.xml + IWorkbenchWindow window = iw.getActiveWorkbenchWindow(); + ICommandService cmdService = (ICommandService) window + .getService(ICommandService.class); + Command cmd = cmdService + .getCommand("org.argeo.slc.client.ui.displayResultDetails"); + + // log.debug("cmd : " + cmd); + ArrayList parameters = new ArrayList(); + + // get the parameter + IParameter iparam = cmd + .getParameter("org.argeo.slc.client.commands.resultUuid"); + + Parameterization params = new Parameterization(iparam, + ra.getUuid()); + parameters.add(params); + + // build the parameterized command + ParameterizedCommand pc = new ParameterizedCommand(cmd, + parameters.toArray(new Parameterization[parameters + .size()])); + + // execute the command + handlerService = (IHandlerService) window + .getService(IHandlerService.class); + handlerService.executeCommand(pc, null); + + } catch (Exception e) { + e.printStackTrace(); + throw new SlcException("Problem while rendering result. " + + e.getMessage()); + } + } + } + } + // Ioc public void setTestResultCollectionDao( TreeTestResultCollectionDao testResultCollectionDao) { -- 2.39.2