Beispiel #1
0
  @Override
  public void setEnabled(boolean enabled1) {
    super.setEnabled(enabled1);

    if (!isEnabled()) {
      getElement().addClassName(appearance.css().menuItemDisabledClass());
      getElement().setAttribute("aria-disabled", "true");
    } else {
      getElement().removeClassName(appearance.css().menuItemDisabledClass());
      getElement().removeAttribute("aria-disabled");
    }
  }
Beispiel #2
0
  @Override
  public void onBrowserEvent(Event event) {

    int eventType = event.getTypeInt();
    switch (eventType) {
      case Event.ONMOUSEDOWN:
        {
          event.preventDefault();
          event.stopPropagation();
        }
        break;
      case Event.ONMOUSEOVER:
        {
          if (isEnabled()) {
            if (menu != null) {
              menu.setActiveMenuItem(this);
            }
          }
        }
        break;
      case Event.ONMOUSEOUT:
        {
          if (menu != null) {
            if (subMenu != null) {
              if (!subMenuVisible) {
                menu.setActiveMenuItem(null);
              }
            } else {
              menu.setActiveMenuItem(null);
            }
          }
        }
        break;
      case Event.ONCLICK:
        {
          handleClick();
        }
        break;
      case Event.ONTOUCHSTART:
        {
          event.stopPropagation();

          if (isEnabled()) {
            if (menu != null) {
              menu.setActiveMenuItem(this);
            }
          }
        }
        break;
      case Event.ONTOUCHEND:
        {
          if (menu != null) {
            if (subMenu != null) {
              if (!subMenuVisible) {
                menu.setActiveMenuItem(null);
              }
            } else {
              menu.setActiveMenuItem(null);
            }
          }
        }
        break;
      default:
        {
          super.onBrowserEvent(event);
        }
    }
  }