[Exmmt-commit] SF.net SVN: exmmt: [63] net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/n
Status: Inactive
Brought to you by:
lgrammel
From: <lgr...@us...> - 2006-06-05 23:51:58
|
Revision: 63 Author: lgrammel Date: 2006-06-05 02:55:47 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=63&view=rev Log Message: ----------- #1500774 scenario "shopping list" Modified Paths: -------------- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java Modified: net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java =================================================================== --- net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:53:13 UTC (rev 62) +++ net.sourceforge.exmmt/trunk/src/java/net/sourceforge/exmmt/navigation/Focus.java 2006-06-05 09:55:47 UTC (rev 63) @@ -17,12 +17,12 @@ import net.sourceforge.exmmt.builder.Composite; public class Focus { - + private Composite focusedElement; public Focus(Composite root) { assert root != null; - + this.focusedElement = root; } @@ -46,16 +46,16 @@ if (focusedElement.isRoot()) { return; } - + List<Composite> siblings = focusedElement.getParent().getChildren(); - + int currentIndex = siblings.indexOf(focusedElement); - + assert currentIndex >= 0; assert currentIndex <= siblings.size() - 1; - + int newIndex = currentIndex + 1; - + assert newIndex >= 1; assert newIndex <= siblings.size(); @@ -65,8 +65,35 @@ assert newIndex >= 0; assert newIndex <= siblings.size() - 1; - + focusedElement = siblings.get(newIndex); } + public void moveToPreviousSibling() { + if (focusedElement.isRoot()) { + return; + } + + List<Composite> siblings = focusedElement.getParent().getChildren(); + + int currentIndex = siblings.indexOf(focusedElement); + + assert currentIndex >= 0; + assert currentIndex <= siblings.size() - 1; + + int newIndex = currentIndex - 1; + + assert newIndex >= -1; + assert newIndex <= siblings.size() - 2; + + if (newIndex == -1) { + newIndex = siblings.size() - 1; + } + + assert newIndex >= 0; + assert newIndex <= siblings.size() - 1; + + focusedElement = siblings.get(newIndex); + } + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |