]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #3785, implemented style names for MenuBar.MenuItem
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 1 Dec 2009 07:14:38 +0000 (07:14 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Tue, 1 Dec 2009 07:14:38 +0000 (07:14 +0000)
svn changeset:10110/svn branch:6.2

src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
src/com/vaadin/ui/MenuBar.java

index 1a3d37283865cf7579db75f65dddb2dfd8625e89..1424d5844241ef1b3a4a084a57e459d40adf20a0 100644 (file)
@@ -205,6 +205,10 @@ public class VMenuBar extends Widget implements Paintable,
             currentItem = currentMenu.addItem(itemHTML.toString(), cmd);
             currentItem.setSeparator(item.hasAttribute("separator"));
             currentItem.setEnabled(!item.hasAttribute("disabled"));
+            if (item.hasAttribute("style")) {
+                String itemStyle = item.getStringAttribute("style");
+                currentItem.addStyleName(itemStyle);
+            }
 
             if (item.getChildCount() > 0) {
                 menuStack.push(currentMenu);
index 5715e230c4d13c128154b7350933048b18de4dbf..528b6eec0a7de8d2be070246a4e12b05e8cb4932 100644 (file)
@@ -86,6 +86,10 @@ public class MenuBar extends AbstractComponent {
             target.startTag("item");
             target.addAttribute("id", item.getId());
 
+            if (item.getStyleName() != null) {
+                target.addAttribute("style", item.getStyleName());
+            }
+
             if (item.isSeparator()) {
                 target.addAttribute("separator", true);
                 target.endTag("item");
@@ -130,7 +134,7 @@ public class MenuBar extends AbstractComponent {
 
     /** Deserialize changes received from client. */
     @Override
-    public void changeVariables(Object source, Map variables) {
+    public void changeVariables(Object source, Map<String, Object> variables) {
         Stack<MenuItem> items = new Stack<MenuItem>();
         boolean found = false;
 
@@ -391,6 +395,7 @@ public class MenuBar extends AbstractComponent {
         private boolean enabled = true;
         private boolean visible = true;
         private boolean isSeparator = false;
+        private String styleName;
 
         /**
          * Constructs a new menu item that can optionally have an icon and a
@@ -691,6 +696,15 @@ public class MenuBar extends AbstractComponent {
             return isSeparator;
         }
 
+        public void setStyleName(String styleName) {
+            this.styleName = styleName;
+            requestRepaint();
+        }
+
+        public String getStyleName() {
+            return styleName;
+        }
+
     }// class MenuItem
 
 }// class MenuBar