@Override
 public String serialize(IVkWidget widget) {
   StringBuffer buffer = new StringBuffer("{");
   buffer.append("widgetName:'").append(widget.getWidgetName()).append("'");
   buffer.append(",style:'").append(VkDesignerUtil.getCssText((Widget) widget)).append("'");
   serializeAttributes(buffer, (Widget) widget);
   VkMenuBarHorizontal menuBar = (VkMenuBarHorizontal) widget;
   buffer.append(",items:[");
   for (int i = 0, allItems = 0, k = 0; i < menuBar.getItemCount(); i++, allItems++) {
     buffer.append("{html:'").append(menuBar.getItems().get(i).getHTML()).append("'");
     if (menuBar.getItems().get(i).getSubMenu() == null) {
       if (menuBar.getCommandJs().containsKey(i))
         buffer
             .append(",js:'")
             .append(menuBar.getCommandJs().get(i).replace('\'', '"'))
             .append("'");
       else
         buffer
             .append(",child:")
             .append(
                 VkStateHelper.getInstance()
                     .getWidgetEngineMapping()
                     .getEngineMap()
                     .get(((IVkWidget) menuBar.getWidgets().get(i)).getWidgetName())
                     .serialize((IVkWidget) menuBar.getWidgets().get(i)));
     } else
       buffer
           .append(",menu:")
           .append(serialize((IVkWidget) menuBar.getItems().get(i).getSubMenu()));
     buffer.append("},");
     if (k < menuBar.getSeperatorIndices().size()
         && menuBar.getSeperatorIndices().get(k) == allItems + 1) {
       buffer.append("{separator:''},");
       allItems++;
       k++;
     }
   }
   if (buffer.charAt(buffer.length() - 1) == ',') buffer.deleteCharAt(buffer.length() - 1);
   buffer.append("]}");
   return buffer.toString();
 }
  @Override
  public void applyAttribute(String attributeName, Widget invokingWidget) {
    final VkMenuBarHorizontal menuBar = (VkMenuBarHorizontal) invokingWidget;
    if (attributeName.equals(ADD_SEPERATOR)) addSeparator(menuBar);
    else if (attributeName.equals(ADD_ITEM)) showAddItemAttributeDialog(menuBar);
    else if (attributeName.equals(REMOVE_ITEM)) {
      final ListBox listBox = new ListBox();
      listBox.setWidth("200px");
      int itemCount = menuBar.getItemCount();
      if (itemCount == 0) {
        Window.alert("No Items found to remove");
        return;
      }
      for (int i = 0; i < itemCount; i++)
        listBox.addItem(menuBar.getMenuItem(i).getText(), Integer.toString(i));
      VkDesignerUtil.showAddListDialog(
          "Choose the item to edit",
          listBox,
          new IDialogCallback() {
            @Override
            public void save(String number) {
              menuBar.removeItem(menuBar.getMenuItem(listBox.getSelectedIndex()));
            }
          });
    } else if (attributeName.equals(EDIT_ITEM)) {
      final ListBox listBox = new ListBox();
      listBox.setWidth("200px");
      int itemCount = menuBar.getItemCount();
      if (itemCount == 0) {
        Window.alert("No Items found to edit");
        return;
      }
      for (int i = 0; i < itemCount; i++)
        listBox.addItem(menuBar.getMenuItem(i).getText(), Integer.toString(i));
      VkDesignerUtil.showAddListDialog(
          "Choose the item to edit",
          listBox,
          new IDialogCallback() {
            @Override
            public void save(String number) {
              int index = listBox.getSelectedIndex();
              showEditItemAttributeDialog(menuBar, index);
            }
          });
    } else if (attributeName.equals(ADD_MENU)) {
      final TextBox nameTb = new TextBox();
      nameTb.setWidth("300px");
      VkDesignerUtil.showAddTextAttributeDialog(
          "Please provide name of sub-menu",
          nameTb,
          new IDialogCallback() {

            @Override
            public void save(String js) {
              final VkMenuBarVertical widget =
                  (VkMenuBarVertical)
                      VkStateHelper.getInstance().getEngine().getWidget(VkMenuBarVertical.NAME);
              menuBar.add(widget);
              menuBar.getMenuItem(menuBar.getItemCount() - 1).setText(nameTb.getText());
            }
          });
    } else VkStateHelper.getInstance().getEngine().applyAttribute(attributeName, invokingWidget);
  }