Community
Participate
Working Groups
see fixed method below /** * Fires a INavigationHistoryEvent when the forward history changes. */ private void fireForewardHistoryChangedEvent() { if (navigationListener.size() == 0) { return; } INavigationHistoryEvent event = new NavigationHistoryEvent(histForward.subList(0, histForward.size())); for (INavigationHistoryListener listener : navigationListener) { listener.forwardHistoryChanged(event); } }
fixed method above.....however not clear why historyForward and historyBackward throw multiple events....need to investigate
applied patch for riena 1.1.0m6 * fired foreward history changed event content * fixed, history changed events are fired when a new listener is registered exclusivly for this new listener. so the listener can initialize corresponding widgets prior to the first navigation applied patch below Index: src/org/eclipse/riena/navigation/model/NavigationProcessor.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.riena/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationProcessor.java,v retrieving revision 1.27 diff -u -r1.27 NavigationProcessor.java --- src/org/eclipse/riena/navigation/model/NavigationProcessor.java 9 Mar 2009 10:14:50 -0000 1.27 +++ src/org/eclipse/riena/navigation/model/NavigationProcessor.java 24 Mar 2009 15:03:18 -0000 @@ -20,6 +20,8 @@ import java.util.Stack; import java.util.Vector; +import org.eclipse.equinox.log.Logger; + import org.eclipse.riena.core.Log4r; import org.eclipse.riena.core.marker.IMarker; import org.eclipse.riena.internal.navigation.Activator; @@ -37,15 +39,13 @@ import org.eclipse.riena.ui.core.marker.DisabledMarker; import org.eclipse.riena.ui.core.marker.HiddenMarker; -import org.eclipse.equinox.log.Logger; - /** * Default implementation for the navigation processor */ public class NavigationProcessor implements INavigationProcessor, INavigationHistory { private static final Logger LOGGER = Log4r.getLogger(Activator.getDefault(), NavigationProcessor.class); - private static int maxStacksize = 20; + private static int maxStacksize = 40; private Stack<INavigationNode<?>> histBack = new Stack<INavigationNode<?>>(); private Stack<INavigationNode<?>> histForward = new Stack<INavigationNode<?>>(); private Map<INavigationNode<?>, INavigationNode<?>> navigationMap = new HashMap<INavigationNode<?>, INavigationNode<?>>(); @@ -917,7 +917,7 @@ if (navigationListener.size() == 0) { return; } - INavigationHistoryEvent event = new NavigationHistoryEvent(histBack.subList(0, histForward.size())); + INavigationHistoryEvent event = new NavigationHistoryEvent(histForward.subList(0, histForward.size())); for (INavigationHistoryListener listener : navigationListener) { listener.forwardHistoryChanged(event); } @@ -977,6 +977,11 @@ public synchronized void addNavigationHistoryListener(INavigationHistoryListener listener) { if (!navigationListener.contains(listener)) { navigationListener.add(listener); + INavigationHistoryEvent event = new NavigationHistoryEvent(histBack.subList(0, + (histBack.size() > 0 ? histBack.size() - 1 : 0))); + listener.backHistoryChanged(event); + event = new NavigationHistoryEvent(histForward.subList(0, histForward.size())); + listener.forwardHistoryChanged(event); } } Index: .project =================================================================== RCS file: /cvsroot/rt/org.eclipse.riena/org.eclipse.riena.navigation/.project,v retrieving revision 1.2 diff -u -r1.2 .project --- .project 10 Dec 2008 12:51:06 -0000 1.2 +++ .project 24 Mar 2009 15:03:17 -0000 @@ -20,15 +20,9 @@ <arguments> </arguments> </buildCommand> - <buildCommand> - <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> - <arguments> - </arguments> - </buildCommand> </buildSpec> <natures> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> - <nature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</nature> </natures> </projectDescription>
modifications for .project file in the patch was a mistake. please ignore.
firing of history navigation changed events are occurs at the wrong place. that causes the problems. here is the fix that will build a correct history and fires the correct events. Index: src/org/eclipse/riena/navigation/model/NavigationProcessor.java =================================================================== RCS file: /cvsroot/rt/org.eclipse.riena/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationProcessor.java,v retrieving revision 1.27 diff -u -r1.27 NavigationProcessor.java --- src/org/eclipse/riena/navigation/model/NavigationProcessor.java 9 Mar 2009 10:14:50 -0000 1.27 +++ src/org/eclipse/riena/navigation/model/NavigationProcessor.java 25 Mar 2009 09:57:49 -0000 @@ -20,6 +20,8 @@ import java.util.Stack; import java.util.Vector; +import org.eclipse.equinox.log.Logger; + import org.eclipse.riena.core.Log4r; import org.eclipse.riena.core.marker.IMarker; import org.eclipse.riena.internal.navigation.Activator; @@ -37,15 +39,13 @@ import org.eclipse.riena.ui.core.marker.DisabledMarker; import org.eclipse.riena.ui.core.marker.HiddenMarker; -import org.eclipse.equinox.log.Logger; - /** * Default implementation for the navigation processor */ public class NavigationProcessor implements INavigationProcessor, INavigationHistory { private static final Logger LOGGER = Log4r.getLogger(Activator.getDefault(), NavigationProcessor.class); - private static int maxStacksize = 20; + private static int maxStacksize = 40; private Stack<INavigationNode<?>> histBack = new Stack<INavigationNode<?>>(); private Stack<INavigationNode<?>> histForward = new Stack<INavigationNode<?>>(); private Map<INavigationNode<?>, INavigationNode<?>> navigationMap = new HashMap<INavigationNode<?>, INavigationNode<?>>(); @@ -61,7 +61,6 @@ // if toActivate is module, module group or sub application // the same sub module will be activated on activation of // the toActivate, in any case there is nothing to do - buildHistory(toActivate); } else { if (!toActivate.isVisible() || !toActivate.isEnabled()) { return; @@ -79,7 +78,6 @@ if (allowsDeactivate(navigationContext)) { if (allowsActivate(navigationContext)) { deactivate(navigationContext); - buildHistory(toActivate); activate(navigationContext); } } @@ -815,6 +813,8 @@ for (INavigationNode<?> next : parent.getChildren()) { if (next.equals(child)) { next.setSelected(true); + //We have a new selected child. Remember in history. + buildHistory(next); } else { next.setSelected(false); } @@ -917,7 +917,7 @@ if (navigationListener.size() == 0) { return; } - INavigationHistoryEvent event = new NavigationHistoryEvent(histBack.subList(0, histForward.size())); + INavigationHistoryEvent event = new NavigationHistoryEvent(histForward.subList(0, histForward.size())); for (INavigationHistoryListener listener : navigationListener) { listener.forwardHistoryChanged(event); } @@ -934,6 +934,17 @@ } /** + * Answers the currently selected SubModuleNode in the NavigationTree + * + * @return the currently selected SubModuleNode in the NavigationTree or + * null + */ + public INavigationNode<?> getSelectedChild() { + //always the top most histback item is the currently selected + return histBack.peek(); + } + + /** * Answer the current size of the previous navigation history * * @see org.eclipse.riena.navigation.INavigationNode#getHistorySize() @@ -977,6 +988,11 @@ public synchronized void addNavigationHistoryListener(INavigationHistoryListener listener) { if (!navigationListener.contains(listener)) { navigationListener.add(listener); + INavigationHistoryEvent event = new NavigationHistoryEvent(histBack.subList(0, + (histBack.size() > 0 ? histBack.size() - 1 : 0))); + listener.backHistoryChanged(event); + event = new NavigationHistoryEvent(histForward.subList(0, histForward.size())); + listener.forwardHistoryChanged(event); } }
Please provide a patch as an attachment.
Created attachment 129837 [details] patch ased on riena 1.1.0m6 changed sources
Created attachment 129838 [details] patch in eclipse format
Created attachment 130214 [details] latest cumulated changes ther was another bug for building the history. we have to change the history only for the active and selected node. see NavigationProcesseor#setSelectedchild() line 817ff. setSelectedChild is called for every node in the chain, but if we have nested subModules, only the active subModule node must be added to the history
Accepted last patch: - renamed getSelectedChild() to getSelectedNode() - also added this method to the INavigationProcessor interface Thanks!