Package com.google.gwt.user.client.ui.SuggestBox

Examples of com.google.gwt.user.client.ui.SuggestBox.SuggestionDisplay


    }
  }

  public void testMoveSelectionUpAndDown() {
    SuggestBox box = new SuggestBox();
    SuggestionDisplay display = box.getSuggestionDisplay();
    SuggestOracle oracle = box.getSuggestOracle();

    // Show some suggestions.
    List<Suggestion> suggestions = createSuggestions("test0", "test1", "test2",
        "test3");
    display.showSuggestions(box, suggestions, false, false, NULL_CALLBACK);
    assertNull(display.getCurrentSelection());

    display.moveSelectionDown();
    assertEquals(suggestions.get(0), display.getCurrentSelection());
    display.moveSelectionDown();
    assertEquals(suggestions.get(1), display.getCurrentSelection());
    display.moveSelectionDown();
    assertEquals(suggestions.get(2), display.getCurrentSelection());
    display.moveSelectionUp();
    assertEquals(suggestions.get(1), display.getCurrentSelection());
    display.moveSelectionUp();
    assertEquals(suggestions.get(0), display.getCurrentSelection());
  }
View Full Code Here


    assertEquals(suggestions.get(0), display.getCurrentSelection());
  }

  public void testShowSuggestionsAutoSelectDisabled() {
    SuggestBox box = new SuggestBox();
    SuggestionDisplay display = box.getSuggestionDisplay();
    SuggestOracle oracle = box.getSuggestOracle();

    // Show some suggestions with auto select disabled.
    List<Suggestion> suggestions = createSuggestions("test0", "test1", "test2");
    display.showSuggestions(box, suggestions, false, false, NULL_CALLBACK);

    // Nothing should be selected.
    assertNull(display.getCurrentSelection());
  }
View Full Code Here

    assertNull(display.getCurrentSelection());
  }

  public void testShowSuggestionsAutoSelectEnabled() {
    SuggestBox box = new SuggestBox();
    SuggestionDisplay display = box.getSuggestionDisplay();
    SuggestOracle oracle = box.getSuggestOracle();

    // Show some suggestions with auto select enabled.
    List<Suggestion> suggestions = createSuggestions("test0", "test1", "test2");
    display.showSuggestions(box, suggestions, false, true, NULL_CALLBACK);

    // First item should be selected.
    assertEquals(suggestions.get(0), display.getCurrentSelection());
  }
View Full Code Here

  }

  @UiHandler("searchBox")
  void searchBoxEnter(KeyDownEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
      SuggestionDisplay suggestionDisplay = searchBox.getSuggestionDisplay();

      // This should always be true unless GWT changes the type of the suggestion generated by the
      // SuggestBox. It is too complicated and nasty to switch out the SuggestBox suggestion display
      // factory, so we're left with this type safety check and broken functionality if GWT changes.
      Preconditions.checkState(suggestionDisplay instanceof DefaultSuggestionDisplay);
View Full Code Here

   public static List<MenuItem> getMenuItems(MenuBar menuBar) {
      return GwtReflectionUtils.getPrivateFieldValue(menuBar, "items");
   }

   public static List<MenuItem> getMenuItems(SuggestBox suggestBox) {
      SuggestionDisplay display = GwtReflectionUtils.getPrivateFieldValue(suggestBox, "display");
      MenuBar suggestionMenu = GwtReflectionUtils.getPrivateFieldValue(display, "suggestionMenu");
      return getMenuItems(suggestionMenu);
   }
View Full Code Here

   @Test
   public void suggestBoxItems() {
      // Arrange
      SuggestBox box = new SuggestBox();
      SuggestionDisplay display = GwtReflectionUtils.getPrivateFieldValue(box, "display");
      MenuBar bar = GwtReflectionUtils.getPrivateFieldValue(display, "suggestionMenu");

      Command cmd = new Command() {
         public void execute() {
         }
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.SuggestBox.SuggestionDisplay

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.