summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-03-07 02:55:02 (EST)
committerSteffen Kriese2011-03-07 02:55:02 (EST)
commit6c22bf974cec719f3fd8778c9f6dca18625f15a2 (patch)
tree551b3cafe1852748605cc345cc00727088a6d423
parentf6899871f77b75448fc16225eb3328c54d477c7d (diff)
downloadorg.eclipse.riena-6c22bf974cec719f3fd8778c9f6dca18625f15a2.zip
org.eclipse.riena-6c22bf974cec719f3fd8778c9f6dca18625f15a2.tar.gz
org.eclipse.riena-6c22bf974cec719f3fd8778c9f6dca18625f15a2.tar.bz2
FIXED - bug 329033: setBlocked(final boolean blocked) on NavigationNode doesn´t honor current blocked state
https://bugs.eclipse.org/bugs/show_bug.cgi?id=329033
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNode.java6
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/NavigationNodeTest.java48
2 files changed, 53 insertions, 1 deletions
diff --git a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNode.java b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNode.java
index 48b05c8..1a4824e 100644
--- a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNode.java
+++ b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNode.java
@@ -916,8 +916,12 @@ public abstract class NavigationNode<S extends INavigationNode<C>, C extends INa
}
public void setBlocked(final boolean blocked) {
+ final boolean changed = this.blocked != blocked;
this.blocked = blocked;
- notifyBlockedChanged();
+ if (changed) {
+ notifyBlockedChanged();
+ }
+
// taken out because it has caused some problems
// for (final INavigationNode<?> child : getChildren()) {
// child.setBlocked(blocked);
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/NavigationNodeTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/NavigationNodeTest.java
index fef5323..30adfce 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/NavigationNodeTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/navigation/model/NavigationNodeTest.java
@@ -37,6 +37,54 @@ import org.eclipse.riena.ui.filter.impl.UIFilter;
@NonUITestCase
public class NavigationNodeTest extends RienaTestCase {
+ public void testSetBlockedCalledOnce() {
+ final NavigationNodeId id = new NavigationNodeId("4711");
+ final NaviNode node = new NaviNode(id);
+ node.setNavigationProcessor(new NavigationProcessor());
+
+ final SetBlockCalledDetector setBlockedCalledDetector = new SetBlockCalledDetector();
+ node.addSimpleListener(setBlockedCalledDetector);
+
+ assertFalse(node.isBlocked());
+ node.setBlocked(true);
+
+ assertTrue(setBlockedCalledDetector.blockedCalled);
+ }
+
+ public void testSetBlockedCalledTwice() {
+ final NavigationNodeId id = new NavigationNodeId("4711");
+ final NaviNode node = new NaviNode(id);
+ node.setNavigationProcessor(new NavigationProcessor());
+
+ assertFalse(node.isBlocked());
+ node.setBlocked(true);
+
+ final SetBlockCalledDetector setBlockedCalledDetector = new SetBlockCalledDetector();
+ node.addSimpleListener(setBlockedCalledDetector);
+
+ assertTrue(node.isBlocked());
+
+ // call setBlocked again. this time no event should have been fired
+ node.setBlocked(true);
+
+ assertFalse(setBlockedCalledDetector.blockedCalled);
+
+ }
+
+ /**
+ * Checks of the setBlocked() fires a event.
+ */
+ private class SetBlockCalledDetector extends SimpleNavigationNodeAdapter {
+ private boolean blockedCalled;
+
+ @Override
+ public void block(final INavigationNode<?> source, final boolean block) {
+ super.block(source, block);
+ blockedCalled = true;
+ System.out.println("NavigationNodeTest.SetBlockCalledDetector.block()");
+ }
+ }
+
/**
* Tests the constructor of the
*/