Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java76
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/TestSuiteBrowserLabelProvider.java23
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestDataDecorator.java33
3 files changed, 103 insertions, 29 deletions
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java
index 539e7ca4a..3efed86a5 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java
@@ -32,6 +32,9 @@ import org.eclipse.jubula.client.core.persistence.PMException;
import org.eclipse.jubula.client.core.persistence.PMObjectDeletedException;
import org.eclipse.jubula.client.core.persistence.PersistenceManager;
import org.eclipse.jubula.client.core.persistence.locking.LockManager;
+import org.eclipse.jubula.client.core.utils.ITreeNodeOperation;
+import org.eclipse.jubula.client.core.utils.ITreeTraverserContext;
+import org.eclipse.jubula.client.core.utils.TreeTraverser;
import org.eclipse.jubula.tools.constants.StringConstants;
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
@@ -45,6 +48,62 @@ public class NodeBP {
private static final Log LOG = LogFactory.getLog(NodeBP.class);
/**
+ *
+ * Checks whether a given node is a descendant of the root traversal node.
+ */
+ private static final class IsSubNodeOperation
+ implements ITreeNodeOperation<INodePO> {
+
+ /** whether the given node is a descendant of the root traversal node */
+ private boolean m_isSubNode;
+
+ /** the node to check */
+ private INodePO m_node;
+
+ /**
+ * Constructor
+ *
+ * @param node The node to check.
+ */
+ public IsSubNodeOperation(INodePO node) {
+ m_node = node;
+ m_isSubNode = false;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public boolean operate(ITreeTraverserContext<INodePO> ctx,
+ INodePO parent, INodePO node, boolean alreadyVisited) {
+
+ if (node == m_node) {
+ m_isSubNode = true;
+ }
+
+ return !m_isSubNode;
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public void postOperate(ITreeTraverserContext<INodePO> ctx,
+ INodePO parent, INodePO node, boolean alreadyVisited) {
+ // no-op
+ }
+
+ /**
+ *
+ * @return <code>true</code> if the given node is a descendant of the
+ * root traversal node. Otherwise <code>false</code>.
+ */
+ public boolean isSubNode() {
+ return m_isSubNode;
+ }
+ }
+
+ /**
* Utility class
*/
protected NodeBP() {
@@ -128,10 +187,19 @@ public class NodeBP {
* Test Suite.
*/
public static ITestSuitePO getOwningTestSuite(INodePO node) {
- INodePO tmpNode = node;
- while (tmpNode != null && !(tmpNode instanceof ITestSuitePO)) {
- tmpNode = tmpNode.getParentNode();
+ IProjectPO activeProject = GeneralStorage.getInstance().getProject();
+ if (activeProject != null) {
+ IsSubNodeOperation op = new IsSubNodeOperation(node);
+ for (ITestSuitePO testSuite
+ : activeProject.getTestSuiteCont().getTestSuiteList()) {
+ TreeTraverser traverser = new TreeTraverser(testSuite, op);
+ traverser.traverse(true);
+ if (op.isSubNode()) {
+ return testSuite;
+ }
+ }
}
- return (ITestSuitePO)tmpNode;
+
+ return null;
}
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/TestSuiteBrowserLabelProvider.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/TestSuiteBrowserLabelProvider.java
index 037f67d34..a68e72df2 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/TestSuiteBrowserLabelProvider.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/TestSuiteBrowserLabelProvider.java
@@ -101,17 +101,20 @@ public class TestSuiteBrowserLabelProvider extends GeneralLabelProvider {
checkNode((IExecTestCasePO)node, aut, locale, toolTip);
} else if (node instanceof ICapPO) {
ICapPO cap = (ICapPO)node;
- IExecTestCasePO execTC =
- (IExecTestCasePO)node.getParentNode()
- .getParentNode();
+ INodePO grandParent = node.getParentNode().getParentNode();
boolean overWrittenName = false;
- for (ICompNamesPairPO pair : execTC.getCompNamesPairs()) {
- if (pair.getFirstName().equals(cap.getComponentName())
- && pair.getSecondName() != null
- && !pair.getSecondName().equals(
- cap.getComponentName())) {
- overWrittenName = true;
- break;
+ if (grandParent instanceof IExecTestCasePO) {
+ IExecTestCasePO execTC = (IExecTestCasePO)grandParent;
+ for (ICompNamesPairPO pair
+ : execTC.getCompNamesPairs()) {
+ if (pair.getFirstName().equals(
+ cap.getComponentName())
+ && pair.getSecondName() != null
+ && !pair.getSecondName().equals(
+ cap.getComponentName())) {
+ overWrittenName = true;
+ break;
+ }
}
}
checkNode(aut, locale, cap, toolTip, overWrittenName);
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestDataDecorator.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestDataDecorator.java
index 976285d63..73c0b85e9 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestDataDecorator.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestDataDecorator.java
@@ -48,7 +48,6 @@ public class TestDataDecorator extends AbstractLightweightLabelDecorator {
*/
public void decorate(Object element, IDecoration decoration) {
decoration.setForegroundColor(Layout.DEFAULT_OS_COLOR);
-
final INodePO node = (INodePO)element;
if (shouldNotDecorate(node, decoration)) {
return;
@@ -84,22 +83,26 @@ public class TestDataDecorator extends AbstractLightweightLabelDecorator {
&& node.getSumSpecTcFlag();
} else if (node instanceof ICapPO) {
ICapPO cap = (ICapPO)node;
- IExecTestCasePO execTC =
- (IExecTestCasePO)node.getParentNode().getParentNode();
+ INodePO grandParent = node.getParentNode().getParentNode();
boolean overWrittenName = false;
- for (ICompNamesPairPO pair : execTC.getCompNamesPairs()) {
- if (pair.getFirstName().equals(cap.getComponentName())
- && pair.getSecondName() != null
- && !pair.getSecondName().equals(
- cap.getComponentName())) {
-
- overWrittenName = true;
- break;
+ if (grandParent instanceof IExecTestCasePO) {
+ IExecTestCasePO execTC = (IExecTestCasePO)grandParent;
+ for (ICompNamesPairPO pair
+ : execTC.getCompNamesPairs()) {
+ if (pair.getFirstName().equals(
+ cap.getComponentName())
+ && pair.getSecondName() != null
+ && !pair.getSecondName().equals(
+ cap.getComponentName())) {
+
+ overWrittenName = true;
+ break;
+ }
+ }
+ flag = cap.getCompleteTdFlag(locale);
+ if (!overWrittenName) {
+ flag = flag && cap.getCompleteOMFlag(aut);
}
- }
- flag = cap.getCompleteTdFlag(locale);
- if (!overWrittenName) {
- flag = flag && cap.getCompleteOMFlag(aut);
}
}
} else {

Back to the top