From 274565fa24b7b04e99b7dec621005d93801f7fbb Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 26 Oct 2012 10:36:28 +0300 Subject: Fixed missing stylenames on menu item #10077 Change-Id: Iadbfee6d86efef06d549d587e2ac6e2e6b519fb1 --- .../src/com/vaadin/client/ui/menubar/VMenuBar.java | 11 ++++++-- .../menubar/MenuBarPrimaryStylenames.html | 31 +++++++++++++++++++++- .../menubar/MenuBarPrimaryStylenames.java | 2 ++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/client/src/com/vaadin/client/ui/menubar/VMenuBar.java b/client/src/com/vaadin/client/ui/menubar/VMenuBar.java index 38d6d513bf..83b1c58d0a 100644 --- a/client/src/com/vaadin/client/ui/menubar/VMenuBar.java +++ b/client/src/com/vaadin/client/ui/menubar/VMenuBar.java @@ -783,6 +783,8 @@ public class VMenuBar extends SimpleFocusablePanel implements protected boolean selected = false; protected String description = null; + private String styleName; + /** * Default menu item {@link Widget} constructor for GWT.create(). * @@ -889,6 +891,10 @@ public class VMenuBar extends SimpleFocusablePanel implements super.setStyleName(primaryStyleName + "-menuitem"); } + if (styleName != null) { + addStyleDependentName(styleName); + } + if (enabled) { removeStyleDependentName("disabled"); } else { @@ -1003,15 +1009,16 @@ public class VMenuBar extends SimpleFocusablePanel implements } if (uidl.hasAttribute(MenuBarConstants.ATTRIBUTE_ITEM_STYLE)) { - String itemStyle = uidl + styleName = uidl .getStringAttribute(MenuBarConstants.ATTRIBUTE_ITEM_STYLE); - addStyleDependentName(itemStyle); } if (uidl.hasAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION)) { description = uidl .getStringAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION); } + + updateStyleNames(); } public TooltipInfo getTooltip() { diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.html b/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.html index 1232418978..3a8e8d81af 100644 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.html +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.html @@ -26,6 +26,21 @@ vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] my-menu-bar-menuitem + + assertCSSClass + vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] + my-menu-bar-menuitem-normal + + + assertCSSClass + vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] + icon-white + + + assertCSSClass + vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] + icon-headphones + assertCSSClass vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[1] @@ -126,6 +141,21 @@ vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] my-other-menu-menuitem + + assertCSSClass + vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] + my-other-menu-menuitem-normal + + + assertCSSClass + vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] + icon-white + + + assertCSSClass + vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[0] + icon-headphones + assertCSSClass vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]/domChild[1] @@ -211,7 +241,6 @@ vaadin=runcomvaadintestscomponentsmenubarMenuBarPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VMenuBar[0]#item0 [tab] - diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java index 79bec2e65e..ad8e2b05ed 100644 --- a/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java +++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarPrimaryStylenames.java @@ -14,6 +14,8 @@ public class MenuBarPrimaryStylenames extends TestBase { mainMenu.setPrimaryStyleName("my-menu-bar"); MenuItem submenu1 = mainMenu.addItem("Submenu1", null); + submenu1.setStyleName("normal icon-white icon-headphones"); + MenuItem item1 = submenu1.addItem("Item1", null); item1.setCheckable(true); item1.setStyleName("my-menu-item"); -- cgit v1.2.3