Esempio n. 1
0
  protected void init() {
    ClickHandler onClick =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            search();
          }
        };

    HorizontalPanel searchBox = new HorizontalPanel();
    searchBox.setSpacing(10);
    searchBox.setStyleName("SearchBox");
    searchBox.add(new Label(_msgs.awardMedalsMemberSearch()));
    searchBox.add(_search = new TextBox());
    EnterClickAdapter.bind(_search, onClick);
    searchBox.add(new Button(_msgs.awardMedalsFind(), onClick));
    add(searchBox);
  }
Esempio n. 2
0
  public CatalogPanel(CatalogModels models) {
    super("catalogPanel", 0, 0);
    _models = models;

    // create our listings interface
    _listings = new SmartTable("Listings", 0, 0);
    // the blurb and type will be set into (0, 0) and (0, 1) later
    _listings.getFlexCellFormatter().setRowSpan(0, 0, 2);

    getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP);
    setWidget(0, 2, _listings);
    getFlexCellFormatter().setVerticalAlignment(0, 2, HasAlignment.ALIGN_TOP);

    _searchBox = new TextBox();
    _searchBox.setVisibleLength(20);
    _searchBox.addStyleName("itemSearchBox");
    ClickHandler clickListener =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String query = _searchBox.getText().trim();
            if (query.split("\\W+").length > 1) {
              _query.sortBy = CatalogQuery.SORT_BY_RELEVANCE;
            }
            Link.go(Pages.SHOP, ShopUtil.composeArgs(_query, null, query, 0));
          }
        };
    EnterClickAdapter.bind(_searchBox, clickListener);

    Button searchGo = new Button(_msgs.catalogSearch());
    searchGo.addClickHandler(clickListener);

    HorizontalPanel search = new HorizontalPanel();
    search.add(_searchBox);
    search.add(WidgetUtil.makeShim(5, 5));
    search.add(searchGo);
    _listings.setWidget(1, 0, search);

    _sortBox = new ListBox();
    for (String label : SORT_LABELS) {
      _sortBox.addItem(label);
    }
    _sortBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            _query.sortBy = SORT_VALUES[((ListBox) event.getSource()).getSelectedIndex()];
            Link.go(Pages.SHOP, ShopUtil.composeArgs(_query, 0));
          }
        });

    _items =
        new ListingGrid(HEADER_HEIGHT) {
          @Override
          protected void displayPageFromClick(int page) {
            Link.go(Pages.SHOP, ShopUtil.composeArgs(_query, page));
          }

          @Override
          protected String getEmptyMessage() {
            String name = _dmsgs.xlateItemType(_query.itemType);
            if (_model instanceof Listings) {
              GroupName theme = ((Listings) _model).theme;
              if (theme != null) {
                name = theme.toString() + " " + name;
              }
            }
            if (_query.tag != null) {
              return _msgs.catalogNoTag(name, _query.tag);
            } else if (_query.search != null) {
              return _msgs.catalogNoMatch(name, _query.search);
            } else if (_query.creatorId != 0) {
              return _msgs.catalogNoCreator(name);
            } else {
              return _msgs.catalogNoList(name);
            }
          }

          @Override
          protected void configureNavi(
              FlexTable controls, int row, int col, int start, int limit, int total) {
            super.configureNavi(controls, row, col, start, limit, total);
            controls
                .getFlexCellFormatter()
                .setHorizontalAlignment(row, col, HasAlignment.ALIGN_RIGHT);
          }

          @Override
          protected void addCustomControls(FlexTable controls) {
            controls.setWidget(0, 0, new InlineLabel(_msgs.catalogSortBy(), false, false, false));
            controls.getFlexCellFormatter().setStyleName(0, 0, "SortBy");
            controls.setWidget(0, 1, _sortBox);
          }
        };
    _listings.setWidget(2, 0, _items, 2);
    _listings.getFlexCellFormatter().setHeight(2, 0, "100%");
    _listings.getFlexCellFormatter().setVerticalAlignment(2, 0, HasAlignment.ALIGN_TOP);
  }