Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…omposites (not things that contain menuComposites)
  • Loading branch information...
commit e37565618e712266dbb8af3d59c40512c5467b3c 1 parent efee411
@leadVisionary authored
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());
}
Please sign in to comment.
Something went wrong with that request. Please try again.