/**
   * Adds a mouse click handler to the icon panel.
   *
   * <p>
   *
   * @param handler the click handler
   * @return the handler registration
   */
  public HandlerRegistration addIconClickHandler(final ClickHandler handler) {

    final HandlerRegistration internalHandlerRegistration =
        m_iconPanel.addDomHandler(handler, ClickEvent.getType());
    m_iconClickHandlers.add(handler);
    HandlerRegistration result =
        new HandlerRegistration() {

          public void removeHandler() {

            internalHandlerRegistration.removeHandler();
            m_iconClickHandlers.remove(handler);
          }
        };
    return result;
  }
Esempio n. 2
0
  /**
   * Initialize popup menu.
   *
   * @param actionGroup action group
   * @param presentationFactory presentation factory
   * @param lockLayer lock layer, uses as root for attaching this popup menu
   * @param actionSelectedHandler handler for action selected event
   * @param keyBindingAgent agent for key binding
   * @param itemIdPrefix id prefix of the item
   */
  private void initPopupMenu(
      ActionGroup actionGroup,
      PresentationFactory presentationFactory,
      MenuLockLayer lockLayer,
      ActionSelectedHandler actionSelectedHandler,
      KeyBindingAgent keyBindingAgent,
      String itemIdPrefix) {
    this.presentationFactory = presentationFactory;
    this.keyBindingAgent = keyBindingAgent;
    this.itemIdPrefix = itemIdPrefix;
    this.lockLayer = lockLayer;
    this.actionSelectedHandler = actionSelectedHandler;

    List<Utils.VisibleActionGroup> visibleActionGroupList =
        Utils.renderActionGroup(
            actionGroup, presentationFactory, actionManager, managerProvider.get());

    list = new ArrayList<>();
    for (Utils.VisibleActionGroup groupActions : visibleActionGroupList) {
      list.addAll(groupActions.getActionList());
    }

    popupMenuPanel = new SimplePanel();
    disableTextSelection(popupMenuPanel.getElement(), true);
    initWidget(popupMenuPanel);

    popupMenuPanel.addDomHandler(
        new MouseOutHandler() {
          @Override
          public void onMouseOut(MouseOutEvent event) {
            closeSubPopupTimer.cancel();

            PopupMenu.this.setStyleNormal(hoveredTR);
            hoveredTR = null;

            if (subPopupAnchor != null) {
              setStyleHovered(subPopupAnchor);
            }
          }
        },
        MouseOutEvent.getType());

    popupMenuPanel.setStyleName(POPUP_RESOURCES.popup().popupMenuMain());

    hasCheckedItems = hasCheckedItems();
  }
Esempio n. 3
0
  @Override
  protected void start() {
    root.add(loginBar);

    goTop.addStyleName(style.gotop());
    goTop.addDomHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            root.getElement().setScrollTop(0);
          }
        },
        ClickEvent.getType());

    gotoTask =
        new DelayedTask() {
          @Override
          public void onExecute() {
            if (!gotoShowing && scrollTop >= 800) {
              goTop.addStyleName(style.gotopshow());
              gotoShowing = true;
            } else if (scrollTop < 800 && gotoShowing) {
              goTop.removeStyleName(style.gotopshow());
              gotoShowing = false;
            }
          }
        };

    navTask =
        new DelayedTask() {
          @Override
          public void onExecute() {
            if (scrollTop >= navMix && scrollTop <= navMax) {
              return;
            }
            currentli.removeClassName(style.active());
            int i = 0;
            while (i < pns.size()) {
              PositionNav nav = pns.get(i);
              navMix = nav.getScrollTop() - OFFSET;
              navMax =
                  ((i == (pns.size() - 1))
                          ? root.getElement().getScrollHeight()
                          : pns.get(i + 1).getScrollTop())
                      - OFFSET;
              if (scrollTop >= navMix && scrollTop <= navMax) {
                currentli = nav.getElm();
                break;
              }
              i++;
            }
            currentli.addClassName(style.active());
          }
        };

    initPostion();

    root.addDomHandler(
        new ScrollHandler() {
          @Override
          public void onScroll(ScrollEvent event) {
            scrollTop = event.getRelativeElement().getScrollTop();
            gotoTask.delay(100);
            navTask.delay(30);
          }
        },
        ScrollEvent.getType());
  }