コード例 #1
0
  /**
   * Is the undo menu option disabled?
   *
   * @return
   */
  public static boolean isUndoDisabled(SWTBot bot) {
    Matcher<MenuItem> undoMatcher =
        new BaseMatcher<MenuItem>() {

          @Override
          public boolean matches(Object item) {
            if (!(item instanceof MenuItem)) {
              return false;
            }
            return ((MenuItem) item).getText().startsWith("&Undo");
          }

          @Override
          public void describeTo(Description description) {
            description.appendText("disabled, and no text for an non-undoable item");
          }
        };
    try {
      SWTBotMenu undoMenu = bot.menu().menu("Edit").menu(undoMatcher, false, 0);
      boolean isEnabled = undoMenu.isEnabled();
      undoMenu.hide();
      return isEnabled;
    } catch (WidgetNotFoundException ex) {
      return false;
    }
  }