Skip to content
Browse files

added pretty print and fixed addSubMenu bug that only worked on MenuC…

…omposites (not things that contain menuComposites)
  • Loading branch information...
1 parent efee411 commit e37565618e712266dbb8af3d59c40512c5467b3c @leadVisionary committed Jul 9, 2012
View
5 src/com/visionarysoftwaresolutions/menu/MenuComponentDecorator.java
@@ -35,4 +35,9 @@ public MenuComponent getChild(String text){
public MenuIterator createIterator(){
return component.createIterator();
}
+
+ @Override
+ public String toString(){
+ return component.toString();
+ }
}
View
2 src/com/visionarysoftwaresolutions/menu/MenuFactory.java
@@ -30,7 +30,7 @@ public MenuComponent addSubMenu(MenuComponent menu, MenuComponent newMenu) {
MenuIterator iterator = menu.createIterator();
while(iterator.hasNext()){
MenuComponent contained = iterator.next();
- if(contained instanceof MenuComposite)
+ if(contained instanceof MenuComposite || contained.hasChildren())
{
result.add(contained);
}
View
2 src/com/visionarysoftwaresolutions/menu/composite/MenuComposite.java
@@ -44,7 +44,7 @@ public MenuIterator createIterator() {
@Override
public String toString(){
StringBuilder result = new StringBuilder();
- result.append(super.toString());
+ result.append(getText());
result.append(" children - ");
MenuIterator it = createIterator();
while(it.hasNext()){
View
2 test/com/visionarysoftwaresolutions/menu/MenuFactoryTest.java
@@ -72,7 +72,7 @@ public void testGetSubMenus(){
toTest.addSubMenu(initial, sandwiches);
toTest.addItemToMenu(initial, "Tomato Bisque");
assertTrue(initial.hasChildren());
- Set<MenuComponent> subMenus =toTest.getSubMenus(initial);
+ Set<MenuComponent> subMenus = toTest.getSubMenus(initial);
assertEquals(1, subMenus.size());
}

0 comments on commit e375656

Please sign in to comment.
Something went wrong with that request. Please try again.