private void showMessagePopup() {
   Label validationMessageLabel = new Label();
   validationMessageLabel.setStyleName("validation-textbox-message-label"); // $NON-NLS-1$
   validationMessageLabel.setText(getValidationMessage());
   VerticalPanel messagePanel = new VerticalPanel();
   messagePanel.add(validationMessageLabel);
   HorizontalPanel bottomPanel = new HorizontalPanel();
   SimplePanel hSpacer = new SimplePanel();
   hSpacer.setStylePrimaryName("validation-textbox-left-image-buffer"); // $NON-NLS-1$
   bottomPanel.add(hSpacer);
   SimplePanel tailImagePanel = new SimplePanel();
   image = new Image(GWT.getModuleBaseURL() + "images/spacer.gif"); // $NON-NLS-1$
   image.setStylePrimaryName("validation-textbox-tail-image"); // $NON-NLS-1$
   tailImagePanel.add(image);
   bottomPanel.add(tailImagePanel);
   messagePanel.add(bottomPanel);
   popupPanel = new PopupPanel(true, false);
   popupPanel.setWidget(messagePanel);
   popupPanel.setPopupPositionAndShow(
       new PositionCallback() {
         public void setPosition(int offsetWidth, int offsetHeight) {
           int absLeft = -1;
           int absTop = -1;
           absLeft = textBox.getAbsoluteLeft();
           absTop = textBox.getAbsoluteTop();
           Rectangle popupSize = ElementUtils.getSize(popupPanel.getElement());
           popupPanel.setPopupPosition(
               absLeft, absTop - popupSize.height >= 0 ? absTop - popupSize.height : absTop);
         }
       });
   popupPanel.show();
 }
Exemple #2
0
 public Tipsy() {
   initWidget(panel);
   panel.setStylePrimaryName(STYLE);
   panel.add(innerLabel);
   innerLabel.setStylePrimaryName(STYLE_INNER);
   //        RootPanel.get().add(this);
   //        this.setVisible(false);
 }
  public ValidationTextBox() {
    textBox = new TextBox();
    textBox.addKeyUpHandler(
        new KeyUpHandler() {

          @Override
          public void onKeyUp(KeyUpEvent event) {
            performValidation(true);
            fireOnKeyUp(event);
          }
        });

    imagePanel =
        new SimplePanel() {

          @Override
          public void onBrowserEvent(Event event) {
            super.onBrowserEvent(event);
            switch (DOM.eventGetType(event)) {
              case Event.ONMOUSEOVER:
                {
                  if (!validate()) {
                    showMessagePopup();
                  }
                  break;
                }

              case Event.ONMOUSEOUT:
                {
                  hideMessagePopup();
                  break;
                }
            }
          }
        };
    imagePanel.setStylePrimaryName("validation-textbox-image-panel"); // $NON-NLS-1$
    imagePanel.sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT);
    this.add(textBox);
    textBox.setWidth("100%");
    this.setCellWidth(textBox, "100%");
    this.setStylePrimaryName("custom-text-box"); // $NON-NLS-1$
    SimplePanel hSpacer = new SimplePanel();
    hSpacer.setWidth("10px");
    this.add(hSpacer);
    image = new Image(GWT.getModuleBaseURL() + "images/spacer.gif"); // $NON-NLS-1$
    image.setStylePrimaryName("validation-textbox-image");
    imagePanel.add(image);
    imagePanel.addStyleDependentName("invalid");
    this.add(imagePanel);
  }
Exemple #4
0
  /**
   * This constructor uses the SearchHandler of the new SearchPageUnified. This will be the default
   * constructor after development of the new feature is finished.
   *
   * @param isUnified
   */
  public ResultsView(boolean isUnified) {
    super();
    this.setStylePrimaryName(STYLE.resultsView());
    contentPanel = getContentPanel();
    bookViewMap = new HashMap<Book, ResultsBookView>();
    unPickables = new HashSet<Book>();

    com.bookspicker.client.view.SearchPageUnified.SearchHandler searchHandler =
        new com.bookspicker.client.view.SearchPageUnified.SearchHandler();

    searchTextBox = new SuggestionTextBox(classSuggestionString);
    searchTextBox.setVisibleLength(40);

    autoCompleteBox = new BpSuggestBox(BpOracle.getInstance(), searchTextBox);
    autoCompleteBox.addSelectionHandler(
        new SelectionHandler<Suggestion>() {

          @Override
          public void onSelection(SelectionEvent<Suggestion> event) {
            if (event.getSelectedItem() instanceof BpOracleSuggestion) {
              BpOracleSuggestion bpSuggestion = (BpOracleSuggestion) event.getSelectedItem();
              autoCompleteBox.setSavedQuery(bpSuggestion.getQueryString());
            }
          }
        });

    autoCompleteBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {

          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            autoCompleteBox.cleanSavedQuery();
          }
        });

    searchTextBox.reset();
    autoCompleteBox.setLimit(8);
    autoCompleteBox.setWidth("25em");
    autoCompleteBox.setAutoSelectEnabled(true);

    if (SearchPage.AUTO_COMPLETE) {
      searchTextBox.addKeyPressHandler(searchHandler);
      searchTextBox.addKeyDownHandler(searchHandler);
      autoCompleteBox.addSelectionHandler(searchHandler);
      searchBox.setWidget(0, 0, autoCompleteBox);
    } else {
      searchTextBox.addKeyPressHandler(searchHandler);
      searchBox.setWidget(0, 0, searchTextBox);
    }
    searchBox.setStylePrimaryName(STYLE.searchBox());

    InlineLabel searchButton = new InlineLabel("Search");
    searchButton.setStylePrimaryName(STYLE.bpYellowButton());
    searchButton.addStyleName(STYLE.searchButton());
    searchButton.addStyleDependentName(STYLE.bpYellowButton());
    searchButton.addClickHandler(searchHandler);
    searchBox.setWidget(0, 1, searchButton);

    loadingIcon = new Image(Resources.INSTANCE.loadingIconSmall());
    loadingIcon.setStylePrimaryName(STYLE.loadingIcon());
    loadingIcon.addStyleName(STYLE.loadingIconHidden());
    searchBox.setWidget(0, 2, loadingIcon);

    SimplePanel searchWrapper = new SimplePanel();
    searchWrapper.setStylePrimaryName(STYLE.searchBoxWrapper());
    searchWrapper.setWidget(searchBox);
    contentPanel.add(searchWrapper);

    results.setStylePrimaryName(STYLE.resultsList());

    contentPanel.add(results);
  }