diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-04-22 11:13:05 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-04-22 11:13:05 +0000 |
commit | 4b5a536ea653e78f7aeae86162e8c67fc4a93fcc (patch) | |
tree | f0135a801a0382bd53fbf66e923487769dd5b013 /src/com/vaadin | |
parent | 3ea13cd6c790c406b62612f52f2889c78e9c6e19 (diff) | |
parent | d8d4cbafb4d33994e9baedebceb8cbb7bebab791 (diff) | |
download | vaadin-framework-4b5a536ea653e78f7aeae86162e8c67fc4a93fcc.tar.gz vaadin-framework-4b5a536ea653e78f7aeae86162e8c67fc4a93fcc.zip |
Merged fix for #4528 - PaintException if last menuItem of a sub menu is invisible
svn changeset:12766/svn branch:6.4
Diffstat (limited to 'src/com/vaadin')
-rw-r--r-- | src/com/vaadin/ui/MenuBar.java | 77 |
1 files changed, 35 insertions, 42 deletions
diff --git a/src/com/vaadin/ui/MenuBar.java b/src/com/vaadin/ui/MenuBar.java index 03057c6207..036aa1b718 100644 --- a/src/com/vaadin/ui/MenuBar.java +++ b/src/com/vaadin/ui/MenuBar.java @@ -76,63 +76,56 @@ public class MenuBar extends AbstractComponent { target.endTag("options"); target.startTag("items"); - Iterator<MenuItem> itr = menuItems.iterator(); - // This generates the tree from the contents of the menu - while (itr.hasNext()) { - - MenuItem item = itr.next(); - if (!item.isVisible()) { - continue; - } + for (MenuItem item : menuItems) { + paintItem(target, item); + } - target.startTag("item"); - target.addAttribute("id", item.getId()); + target.endTag("items"); + } - if (item.getStyleName() != null) { - target.addAttribute("style", item.getStyleName()); - } + private void paintItem(PaintTarget target, MenuItem item) + throws PaintException { + if (!item.isVisible()) { + return; + } - if (item.isSeparator()) { - target.addAttribute("separator", true); - target.endTag("item"); - } else { - target.addAttribute("text", item.getText()); + target.startTag("item"); - Command command = item.getCommand(); - if (command != null) { - target.addAttribute("command", true); - } + target.addAttribute("id", item.getId()); - Resource icon = item.getIcon(); - if (icon != null) { - target.addAttribute("icon", icon); - } + if (item.getStyleName() != null) { + target.addAttribute("style", item.getStyleName()); + } - if (!item.isEnabled()) { - target.addAttribute("disabled", true); - } + if (item.isSeparator()) { + target.addAttribute("separator", true); + } else { + target.addAttribute("text", item.getText()); - if (item.hasChildren()) { - iteratorStack.push(itr); // For later use + Command command = item.getCommand(); + if (command != null) { + target.addAttribute("command", true); + } - // Go through the children - itr = item.getChildren().iterator(); - } else { - target.endTag("item"); // Item had no children, end - // description - } + Resource icon = item.getIcon(); + if (icon != null) { + target.addAttribute("icon", icon); + } + if (!item.isEnabled()) { + target.addAttribute("disabled", true); } - // The end submenu. More than one submenu may end at once. - while (!itr.hasNext() && !iteratorStack.empty()) { - itr = iteratorStack.pop(); - target.endTag("item"); + if (item.hasChildren()) { + for (MenuItem child : item.getChildren()) { + paintItem(target, child); + } } + } - target.endTag("items"); + target.endTag("item"); } /** Deserialize changes received from client. */ |