Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2015-08-13 13:39:38 +0000
committerMarvin Mueller2015-08-13 13:41:01 +0000
commit3d516b25c1b4aa45e059fd7cc8d9d9769836de71 (patch)
treecacd182c852c9ac6c81f18e07ab44c4b3c69d79c /org.eclipse.jubula.client.ui.rcp
parent13a13ad318949121ed8f91ede0f586e8826c711c (diff)
downloadorg.eclipse.jubula.core-3d516b25c1b4aa45e059fd7cc8d9d9769836de71.tar.gz
org.eclipse.jubula.core-3d516b25c1b4aa45e059fd7cc8d9d9769836de71.tar.xz
org.eclipse.jubula.core-3d516b25c1b4aa45e059fd7cc8d9d9769836de71.zip
Sprint task - Allow Show specification also for reused projects
http://eclip.se/472028
Diffstat (limited to 'org.eclipse.jubula.client.ui.rcp')
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java46
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java11
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java26
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java8
4 files changed, 81 insertions, 10 deletions
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java
index 082e8e24b..1a9b1a631 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java
@@ -23,6 +23,7 @@ import org.eclipse.jubula.client.core.model.IExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.model.ITestCasePO;
+import org.eclipse.jubula.client.core.model.ITestSuitePO;
import org.eclipse.jubula.client.core.model.NodeMaker;
import org.eclipse.jubula.client.core.model.TestResultNode;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
@@ -73,18 +74,17 @@ public class UINodeBP {
execTc = (IExecTestCasePO)firstElement;
} else if (firstElement instanceof TestResultNode) {
TestResultNode trNode = (TestResultNode)firstElement;
- INodePO nodePO = trNode.getNode();
+ INodePO nodePO = getExecFromTestResultNode(trNode);
if (nodePO instanceof ITestCasePO
&& !(nodePO instanceof IExecTestCasePO)) {
- nodePO = NodePM.getNode(GeneralStorage.getInstance()
- .getProject().getId(), nodePO.getGuid());
+ nodePO = NodePM.getNode(nodePO.getGuid());
}
while (!(nodePO instanceof IExecTestCasePO)) {
trNode = trNode.getParent();
if (trNode == null) {
return null;
}
- nodePO = trNode.getNode();
+ nodePO = getExecFromTestResultNode(trNode);
}
execTc = (IExecTestCasePO)nodePO;
}
@@ -93,6 +93,28 @@ public class UINodeBP {
}
return null;
}
+
+ /**
+ *
+ * @param structuredSel find the referenced {@link ITestSuitePO}
+ * @return a valid {@link ITestSuitePO} <code>null</code> if no reference
+ * could be found
+ */
+ public static ITestSuitePO getSpecTS(IStructuredSelection structuredSel) {
+ Object firstElement = structuredSel.getFirstElement();
+ if (firstElement instanceof TestResultNode) {
+ TestResultNode trNode = (TestResultNode)firstElement;
+ INodePO nodePO = trNode.getNode();
+ if (nodePO instanceof ITestSuitePO) {
+ return (ITestSuitePO) NodePM.getNode(
+ GeneralStorage.getInstance()
+ .getProject().getId(), nodePO.getGuid());
+ }
+ } else if (firstElement instanceof ITestSuitePO) {
+ return (ITestSuitePO) firstElement;
+ }
+ return null;
+ }
/**
* Tries to select a node with the given ID in the given TreeViewer.
@@ -154,4 +176,20 @@ public class UINodeBP {
tv.setSelection(oldSelection);
return null;
}
+
+ /**
+ * This method is getting the Node from {@link TestResultNode}.
+ * If this is a generated {@link ITestCasePO} than it is searched in the
+ * database for the correct node.
+ * @param trNode the testResult node
+ * @return an {@link INodePO} which can be of any kind and from any project
+ */
+ private static INodePO getExecFromTestResultNode(TestResultNode trNode) {
+ INodePO nodePO = trNode.getNode();
+ if (nodePO instanceof ITestCasePO
+ && nodePO.isGenerated()) {
+ nodePO = NodePM.getNode(nodePO.getGuid());
+ }
+ return nodePO;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java
index fe9aa56ef..698a6d665 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java
@@ -12,8 +12,12 @@ package org.eclipse.jubula.client.ui.rcp.handlers;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
+import org.eclipse.jubula.client.core.model.ITestSuitePO;
+import org.eclipse.jubula.client.ui.constants.Constants;
+import org.eclipse.jubula.client.ui.rcp.Plugin;
import org.eclipse.jubula.client.ui.rcp.businessprocess.UINodeBP;
import org.eclipse.jubula.client.ui.rcp.controllers.MultipleTCBTracker;
+import org.eclipse.ui.IViewPart;
/**
@@ -28,6 +32,13 @@ public class ShowSpecificationHandler extends AbstractShowSpecificationHandler {
if (specTc != null) {
showSpecUINode(specTc, MultipleTCBTracker.getInstance()
.getMainTCB());
+ return null;
+ }
+ ITestSuitePO testSuite = UINodeBP.getSpecTS(getSelection());
+ if (testSuite != null) {
+ IViewPart view = Plugin.showView(Constants.TS_BROWSER_ID);
+ showSpecUINode(testSuite, view);
+
}
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java
index 64c24a41b..35288e8a5 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java
@@ -13,7 +13,7 @@ package org.eclipse.jubula.client.ui.rcp.handlers.open;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jubula.client.core.businessprocess.db.TestCaseBP;
+import org.eclipse.jubula.client.core.businessprocess.db.NodeBP;
import org.eclipse.jubula.client.core.model.IAUTMainPO;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.IPersistentObject;
@@ -71,20 +71,36 @@ public abstract class AbstractOpenHandler extends AbstractHandler {
protected boolean isEditableImpl(INodePO selected) {
return true;
}
-
+
+ /**
+ *
+ * @param testSuite the testsuite to open the editor for
+ */
+ protected void openEditorForSpecTS(ITestSuitePO testSuite) {
+ openEditorForSpec(testSuite);
+ }
/**
* @param specTc the spec to open the editor for
*/
protected void openEditorForSpecTC(ISpecTestCasePO specTc) {
- boolean isNodeEditable = TestCaseBP.belongsToCurrentProject(specTc);
+ openEditorForSpec(specTc);
+ }
+
+ /**
+ * This method is checking if the node belongs to the current project
+ * and if not is opening a dialog to show that this node is from a other project
+ * @param node the node to open.
+ */
+ private void openEditorForSpec(INodePO node) {
+ boolean isNodeEditable = NodeBP.belongsToCurrentProject(node);
if (isNodeEditable) {
- IEditorPart editor = openEditor(specTc);
+ IEditorPart editor = openEditor(node);
editor.getSite().getPage().activate(editor);
if (editor instanceof AbstractJBEditor) {
AbstractJBEditor jbEditor =
(AbstractJBEditor) editor;
jbEditor.setSelection(
- new StructuredSelection(specTc));
+ new StructuredSelection(node));
}
} else {
ErrorHandlingUtil.createMessageDialog(
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java
index f235670d7..e1db23826 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java
@@ -14,6 +14,7 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
+import org.eclipse.jubula.client.core.model.ITestSuitePO;
import org.eclipse.jubula.client.ui.rcp.businessprocess.UINodeBP;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -42,6 +43,11 @@ public class OpenSpecificationHandler extends AbstractOpenHandler {
*/
private void openSpecNode(IStructuredSelection structuredSel) {
ISpecTestCasePO specTc = UINodeBP.getSpecTC(structuredSel);
- openEditorForSpecTC(specTc);
+ if (specTc != null) {
+ openEditorForSpecTC(specTc);
+ } else {
+ ITestSuitePO testSuite = UINodeBP.getSpecTS(structuredSel);
+ openEditorForSpecTS(testSuite);
+ }
}
} \ No newline at end of file

Back to the top