summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-04-12 09:53:23 (EDT)
committerSteffen Kriese2011-04-12 09:53:23 (EDT)
commit6f1172321bcb9cc8ab9eadced4681beb1c934034 (patch)
tree14ab8ca851cf9ca895389339fc278bbab64d0216
parent7e1778966a284a1fff8f5c8fa1d06c7d1168027e (diff)
downloadorg.eclipse.riena-6f1172321bcb9cc8ab9eadced4681beb1c934034.zip
org.eclipse.riena-6f1172321bcb9cc8ab9eadced4681beb1c934034.tar.gz
org.eclipse.riena-6f1172321bcb9cc8ab9eadced4681beb1c934034.tar.bz2
RESOLVED - bug 342446: Navigationtree is empty if one child in the navigationtree is set to visible(false)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=342446
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/ModuleNode.java26
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/ModuleNodeTest.java95
2 files changed, 95 insertions, 26 deletions
diff --git a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/ModuleNode.java b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/ModuleNode.java
index f859cf5..f0f50f1 100644
--- a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/ModuleNode.java
+++ b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/ModuleNode.java
@@ -113,9 +113,29 @@ public class ModuleNode extends NavigationNode<IModuleNode, ISubModuleNode, IMod
}
public boolean isPresentSubModules() {
- // consider number of visible children only
- return isPresentSingleSubModule()
- || !(getVisibleChildCount(this) == 1 && getVisibleChildCount(getChild(0)) == 0);
+ // 1. check if flag is set
+ // 2. check if module has more than one child
+ // 3. check if module has only one child with subChilds
+ return isPresentSingleSubModule() || getVisibleChildCount(this) > 1 || hasSingleChildWithChildren();
+ }
+
+ /**
+ * Checks if this node has a single child with children as well.
+ *
+ * @return
+ */
+ private boolean hasSingleChildWithChildren() {
+ if (getVisibleChildCount(this) == 1) {
+ final Iterator<ISubModuleNode> childIter = getChildren().iterator();
+ while (childIter.hasNext()) {
+ final INavigationNode<?> child = childIter.next();
+ if (child.isVisible() && !child.getChildren().isEmpty()) {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
/*
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/ModuleNodeTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/ModuleNodeTest.java
index 4369da7..38f6847 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/ModuleNodeTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/ModuleNodeTest.java
@@ -21,41 +21,90 @@ import org.eclipse.riena.navigation.NavigationNodeId;
@NonUITestCase
public class ModuleNodeTest extends TestCase {
- /**
- * Tests the method {@code calcDepth()}
- */
- public void testCalcDepth() {
-
- final ModuleNode m = new ModuleNode();
- assertEquals(0, m.calcDepth());
+ public void testCalcDepthNoChild() {
+ final ModuleNode module = new ModuleNode();
+ assertEquals(0, module.calcDepth());
+ }
+ public void testCalcDepthOneChild() {
+ final ModuleNode module = new ModuleNode();
final SubModuleNode sm = new SubModuleNode(new NavigationNodeId("module1"));
- m.addChild(sm);
- assertEquals(0, m.calcDepth());
+ module.addChild(sm);
+ assertEquals(0, module.calcDepth());
+ }
+
+ public void testCalcDepthTwoChilds() {
+ final ModuleNode module = new ModuleNode();
+ final SubModuleNode sm = new SubModuleNode(new NavigationNodeId("subModule1"));
+ final SubModuleNode sm2 = new SubModuleNode(new NavigationNodeId("subModule2"));
+ module.addChild(sm);
+ module.addChild(sm2);
+ assertEquals(2, module.calcDepth());
+ }
- final SubModuleNode sm2 = new SubModuleNode(new NavigationNodeId("module2"));
- m.addChild(sm2);
- assertEquals(2, m.calcDepth());
+ public void testCalcDepthTwoChildsAndExpanded() {
+ final ModuleNode module = new ModuleNode();
+ final SubModuleNode sm = new SubModuleNode(new NavigationNodeId("subModule1"));
+ final SubModuleNode sm2 = new SubModuleNode(new NavigationNodeId("subModule2"));
+ module.addChild(sm);
+ module.addChild(sm2);
+ assertEquals(2, module.calcDepth());
final SubModuleNode sm21 = new SubModuleNode(new NavigationNodeId("module21"));
sm21.setNavigationProcessor(new NavigationProcessor());
sm2.addChild(sm21);
- assertEquals(2, m.calcDepth());
+ assertEquals(2, module.calcDepth());
sm2.setExpanded(true);
- assertEquals(3, m.calcDepth());
+ assertEquals(3, module.calcDepth());
+ }
- sm21.setEnabled(false);
- assertEquals(3, m.calcDepth());
- sm21.setVisible(false);
- assertEquals(2, m.calcDepth());
+ public void testCalcDepthTwoChildsAndSetVisible() {
+ final ModuleNode module = new ModuleNode();
+ final NavigationProcessor navigationProcessor = new NavigationProcessor();
+ final SubModuleNode sm = new SubModuleNode(new NavigationNodeId("subModule1"));
+ sm.setNavigationProcessor(navigationProcessor);
+ final SubModuleNode sm2 = new SubModuleNode(new NavigationNodeId("subModule2"));
+ sm2.setNavigationProcessor(navigationProcessor);
+ final SubModuleNode sm3 = new SubModuleNode(new NavigationNodeId("subModule3"));
+ sm3.setNavigationProcessor(navigationProcessor);
+ module.addChild(sm);
+ module.addChild(sm2);
+ module.addChild(sm3);
+ assertEquals(3, module.calcDepth());
+
+ sm3.setVisible(false);
+ assertEquals(2, module.calcDepth());
+ }
- /*
- * If there are 2 children of Module and Child 1 is not visible then the
- * tree shell not be rendered
- */
+ public void testCalcDepthTwoChildsAndInvisibleWithSubChilds() {
+ final ModuleNode module = new ModuleNode();
+ final NavigationProcessor navigationProcessor = new NavigationProcessor();
+ final SubModuleNode sm = new SubModuleNode(new NavigationNodeId("subModule1"));
+ sm.setNavigationProcessor(navigationProcessor);
sm.setVisible(false);
- assertEquals(0, m.calcDepth());
+ final SubModuleNode sm2 = new SubModuleNode(new NavigationNodeId("subModule2"));
+ sm2.setNavigationProcessor(navigationProcessor);
+ sm2.setExpanded(true);
+
+ final SubModuleNode sm21 = new SubModuleNode(new NavigationNodeId("subModule2.1"));
+ sm21.setNavigationProcessor(navigationProcessor);
+ module.addChild(sm);
+ module.addChild(sm2);
+ sm2.addChild(sm21);
+
+ assertEquals(2, module.calcDepth());
+ }
+
+ public void testIsPresentSubModules() throws Exception {
+ final SubModuleNode childOne = new SubModuleNode(new NavigationNodeId("nodeOne"));
+ childOne.setVisible(false);
+ final SubModuleNode childTwo = new SubModuleNode(new NavigationNodeId("nodeTwo"));
+
+ final ModuleNode module = new ModuleNode();
+ module.addChild(childOne);
+ module.addChild(childTwo);
+ assertFalse(module.isPresentSubModules());
}
}