Exemplo n.º 1
0
  @Inject
  public TestNGTestAction(
      ActionManager actionManager,
      RunClassTestAction runClassTestAction,
      RunAllTestAction runAllTestAction,
      RunClassContextTestAction runClassContextTestAction,
      RunTestXMLAction runTestXMLAction,
      KeyBindingAgent keyBinding) {

    actionManager.registerAction("TestNGActionRunClass", runClassTestAction);
    actionManager.registerAction("TestNGActionRunAll", runAllTestAction);
    actionManager.registerAction("TestNGActionRunXML", runTestXMLAction);
    actionManager.registerAction("TestNGActionRunClassContext", runClassContextTestAction);

    keyBinding
        .getGlobal()
        .addKey(new KeyBuilder().action().alt().charCode('n').build(), "TestNGActionRunAll");

    keyBinding
        .getGlobal()
        .addKey(new KeyBuilder().action().shift().charCode('n').build(), "TestNGActionRunClass");

    this.runAllTestAction = runAllTestAction;
    this.runClassContextTestAction = runClassContextTestAction;
    this.runClassTestAction = runClassTestAction;
    this.runTestXMLAction = runTestXMLAction;
  }
Exemplo n.º 2
0
  /** Render Popup Menu component. */
  private void redraw() {
    String idPrefix = itemIdPrefix;
    if (idPrefix == null) {
      idPrefix = "";
    } else {
      idPrefix += "/";
    }

    table = new PopupMenuTable();
    table.setStyleName(POPUP_RESOURCES.popup().popupMenuTable());
    table.setCellPadding(0);
    table.setCellSpacing(0);

    for (int i = 0; i < list.size(); i++) {
      Action menuItem = list.get(i);

      if (menuItem instanceof Separator) {
        final String separatorText = ((Separator) menuItem).getText();
        if (separatorText == null) {
          table.getCellFormatter().setStyleName(i, 0, POPUP_RESOURCES.popup().popupMenuDelimiter());
        } else {
          table.setWidget(i, 0, new Label(separatorText));
          table
              .getCellFormatter()
              .setStyleName(i, 0, POPUP_RESOURCES.popup().popupMenuTextDelimiter());
        }
        table.getFlexCellFormatter().setColSpan(i, 0, hasCheckedItems ? 5 : 4);
      } else {
        Presentation presentation = presentationFactory.getPresentation(menuItem);

        if (presentation.getImageResource() != null) {
          Image image = new Image(presentation.getImageResource());
          table.setWidget(i, 0, image);

        } else if (presentation.getSVGResource() != null) {
          SVGImage image = new SVGImage(presentation.getSVGResource());
          table.setWidget(i, 0, image);
        } else if (presentation.getHTMLResource() != null) {
          table.setHTML(i, 0, presentation.getHTMLResource());
        }
        table
            .getCellFormatter()
            .setStyleName(
                i,
                0,
                presentation.isEnabled()
                    ? POPUP_RESOURCES.popup().popupMenuIconField()
                    : POPUP_RESOURCES.popup().popupMenuIconFieldDisabled());

        int work = 1;
        if (hasCheckedItems && menuItem instanceof ToggleAction) {
          ToggleAction toggleAction = (ToggleAction) menuItem;
          ActionEvent e =
              new ActionEvent(
                  presentationFactory.getPresentation(toggleAction),
                  actionManager,
                  managerProvider.get());

          if (toggleAction.isSelected(e)) {
            // Temporary solution
            table.setHTML(i, work, "<i class=\"fa fa-check\"></i>");
          }

          table
              .getCellFormatter()
              .setStyleName(
                  i,
                  work,
                  presentation.isEnabled()
                      ? POPUP_RESOURCES.popup().popupMenuCheckField()
                      : POPUP_RESOURCES.popup().popupMenuCheckFieldDisabled());
          work++;
        }

        table.setHTML(
            i,
            work,
            "<nobr id=\""
                + idPrefix
                + presentation.getText()
                + "\">"
                + presentation.getText()
                + "</nobr>");
        table
            .getCellFormatter()
            .setStyleName(
                i,
                work,
                presentation.isEnabled()
                    ? POPUP_RESOURCES.popup().popupMenuTitleField()
                    : POPUP_RESOURCES.popup().popupMenuTitleFieldDisabled());
        if (showTooltips) {
          Tooltip.create(
              (elemental.dom.Element) table.getCellFormatter().getElement(i, work),
              BOTTOM,
              MIDDLE,
              presentation.getText());
        }

        work++;
        String hotKey =
            KeyMapUtil.getShortcutText(
                keyBindingAgent.getKeyBinding(actionManager.getId(menuItem)));
        if (hotKey == null) {
          hotKey = "&nbsp;";
        } else {
          hotKey = "<nobr>&nbsp;" + hotKey + "&nbsp;</nobr>";
        }

        table.setHTML(i, work, hotKey);
        table
            .getCellFormatter()
            .setStyleName(
                i,
                work,
                presentation.isEnabled()
                    ? POPUP_RESOURCES.popup().popupMenuHotKeyField()
                    : POPUP_RESOURCES.popup().popupMenuHotKeyFieldDisabled());

        work++;

        if (menuItem instanceof ActionGroup
            && !(((ActionGroup) menuItem).canBePerformed()
                && !Utils.hasVisibleChildren(
                    (ActionGroup) menuItem,
                    presentationFactory,
                    actionManager,
                    managerProvider.get()))) {
          table.setWidget(i, work, new SVGImage(POPUP_RESOURCES.subMenu()));
          table
              .getCellFormatter()
              .setStyleName(
                  i,
                  work,
                  presentation.isEnabled()
                      ? POPUP_RESOURCES.popup().popupMenuSubMenuField()
                      : POPUP_RESOURCES.popup().popupMenuSubMenuFieldDisabled());
        } else {
          table
              .getCellFormatter()
              .setStyleName(
                  i,
                  work,
                  presentation.isEnabled()
                      ? POPUP_RESOURCES.popup().popupMenuSubMenuField()
                      : POPUP_RESOURCES.popup().popupMenuSubMenuFieldDisabled());
        }

        work++;

        table.getRowFormatter().getElement(i).setAttribute("item-index", Integer.toString(i));
        table
            .getRowFormatter()
            .getElement(i)
            .setAttribute("item-enabled", Boolean.toString(presentation.isEnabled()));

        String actionId = actionManager.getId(menuItem);
        String debugId;
        if (actionId == null) {
          debugId = idPrefix + menuItem.getTemplatePresentation().getText();
        } else {
          debugId = idPrefix + actionId;
        }
        UIObject.ensureDebugId(table.getRowFormatter().getElement(i), debugId);
      }
    }

    popupMenuPanel.add(table);
  }