protected boolean shouldDisplayUpload(MsoyItemType type) { // for now, if you're in a theme, there is no uploading of stuff if (CShell.frame.getThemeId() != 0 && !type.isUsableAnywhere()) { // TODO: we should have Buy but not Upload, punt! return false; } return type.isUploadableType(); }
public StuffPanel(InventoryModels models, int memberId, MsoyItemType type) { setStyleName("itemPanel"); _models = models; _memberId = memberId; _type = type; boolean displayUpload = shouldDisplayUpload(type); // prepare the search box _search = new HorizontalPanel(); _search.setStyleName("Search"); _search.setSpacing(5); _search.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE); _search.add(MsoyUI.createLabel(_msgs.stuffSearch(), "SearchTitle")); final ListBox searchTypes = new ListBox(); MsoyItemType[] items = CShell.getClientMode().isMinimal() ? MsoyItemType.DJ_ITEMS : MsoyItemType.STUFF_ITEMS; for (MsoyItemType searchType : items) { searchTypes.addItem(_dmsgs.xlateItemsType(searchType), searchType.toByte() + ""); if (searchType == type) { searchTypes.setSelectedIndex(searchTypes.getItemCount() - 1); } } _search.add(searchTypes); _searchBox = new SearchBox( new SearchBox.Listener() { public void search(String query) { String type = searchTypes.getValue(searchTypes.getSelectedIndex()); Link.go(Pages.STUFF, type, _memberId, 0, query); } public void clearSearch() { Link.go(Pages.STUFF, _type, _memberId, 0); } }); _search.add(_searchBox); _search.add(MsoyUI.createImageButton("GoButton", _searchBox.makeSearchListener())); // a drop down for setting filters _filters = new ListBox(); for (String element2 : FLABELS) { _filters.addItem(element2); } _filters.addChangeHandler( new ChangeHandler() { public void onChange(ChangeEvent event) { showInventory(_mostRecentPage, null); } }); // compute the number of rows of items we can fit on the page int used = displayUpload ? NAVIGATION_HEIGHT + GET_STUFF_HEIGHT : NAVIGATION_HEIGHT; int rows = MsoyUI.computeRows(used, ITEM_BOX_HEIGHT, 2); // now create our grid of items _contents = new PagedGrid<Item>(rows, COLUMNS) { @Override protected void displayPageFromClick(int page) { // route our page navigation through the URL Link.go(Pages.STUFF, ((InventoryModels.Stuff) _model).makeArgs(_memberId, page)); } @Override protected Widget createWidget(Item item) { return new ItemEntry(item, !(item instanceof IdentGameItem)); } @Override protected String getEmptyMessage() { if (_model instanceof InventoryModels.Stuff) { String query = ((InventoryModels.Stuff) _model).query; if (query != null) { return _msgs.panelNoMatches(query); } } return _msgs.panelNoItems(_dmsgs.xlateItemType(_type)); } @Override protected boolean displayNavi(int items) { return true; } @Override protected void addCustomControls(FlexTable controls) { controls.setText(0, 0, _msgs.ipfTitle()); controls.getFlexCellFormatter().setStyleName(0, 0, "Show"); controls.setWidget(0, 1, _filters); } }; _contents.addStyleName("Contents"); // finally optionally add the "create your own" sales blurb if (displayUpload) { createUploadInterface(); } }