public void setGameDetail(final GameDetail detail) { final GameInfo info = detail.info; CShell.frame.setTitle(info.name); // keep our requested game id around _gameId = detail.gameId; VerticalPanel shot = new VerticalPanel(); shot.setHorizontalAlignment(HasAlignment.ALIGN_CENTER); shot.add(new ThumbBox(info.shotMedia, MediaDescSize.GAME_SHOT_SIZE)); shot.add(WidgetUtil.makeShim(5, 5)); Rating rating = new Rating( info.rating, info.ratingCount, detail.memberRating, false, new RateService() { public void handleRate(byte newRating, InfoCallback<RatingResult> callback) { _gamesvc.rateGame(_gameId, newRating, callback); } }, null); shot.add(rating); HorizontalPanel mbits = new HorizontalPanel(); mbits.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); mbits.add( MsoyUI.makeShareButton( Pages.GAMES, Args.compose("d", _gameId), _msgs.gdpGame(), info.name, info.description, info.shotMedia)); shot.add(mbits); setWidget(0, 0, shot); getFlexCellFormatter().setRowSpan(0, 0, 2); getFlexCellFormatter().setVerticalAlignment(0, 0, HasAlignment.ALIGN_TOP); setWidget(0, 1, new GameNamePanel(info.name, info.genre, info.creator, info.description), 2); setWidget(1, 0, new GameBitsPanel(detail)); FlowPanel play = new FlowPanel(); play.setStyleName("playPanel"); play.add(PlayButton.createLarge(_gameId)); if (info.playersOnline > 0) { play.add(MsoyUI.createLabel(_msgs.featuredOnline("" + info.playersOnline), "Online")); } if (!info.integrated) { play.add(MsoyUI.createLabel(_msgs.gdpNoCoins(), null)); } setWidget(1, 1, play, 1, "Play"); getFlexCellFormatter().setHorizontalAlignment(1, 1, HasAlignment.ALIGN_CENTER); // add "Discussions" (if appropriate) and "Shop" button Widget buttons = null; if (info.groupId > 0) { ClickHandler onClick = Link.createHandler(Pages.GROUPS, "f", info.groupId); buttons = MsoyUI.createButton(MsoyUI.LONG_THIN, _msgs.gdpDiscuss(), onClick); } ClickHandler onShop = Link.createHandler(Pages.SHOP, "g", Math.abs(_gameId)); PushButton shop = MsoyUI.createButton(MsoyUI.MEDIUM_THIN, _msgs.gdpShop(), onShop); buttons = (buttons == null) ? shop : MsoyUI.createButtonPair(buttons, shop); setWidget(2, 0, buttons); getFlexCellFormatter().setRowSpan(0, 0, 3); getFlexCellFormatter().setRowSpan(1, 1, 2); setWidget( 3, 0, _tabs = new NaviTabPanel(Pages.GAMES) { protected Args getTabArgs(int tabIdx) { return getTabCode(tabIdx).args(_gameId); } }, 3); // add the about/instructions tab addTab(GameDetails.INSTRUCTIONS, _msgs.tabInstructions(), new InstructionsPanel(detail)); // add comments tab addTab( GameDetails.COMMENTS, _msgs.tabComments(), new LazyPanel() { protected Widget createWidget() { CommentsPanel comments = new CommentsPanel(CommentType.GAME, info.gameId, true); comments.expand(); return comments; } }); // add trophies tab, passing in the potentially negative gameId addTab( GameDetails.TROPHIES, _msgs.tabTrophies(), new LazyPanel() { protected Widget createWidget() { return new GameTrophyPanel(_gameId); } }); // add top rankings tabs if (!CShell.isGuest()) { addTab( GameDetails.MYRANKINGS, _msgs.tabMyRankings(), new LazyPanel() { protected Widget createWidget() { return new TopRankingPanel(info.gameId, true); } }); } addTab( GameDetails.TOPRANKINGS, _msgs.tabTopRankings(), new LazyPanel() { protected Widget createWidget() { return new TopRankingPanel(info.gameId, false); } }); // if we're the creator of the game or support, add the metrics and logs tabs if (info.isCreator(CShell.getMemberId()) || CShell.isSupport()) { // addTab(GameDetails.METRICS, _msgs.tabMetrics(), new LazyPanel() { // protected Widget createWidget () { // return new GameMetricsPanel(detail); // } // }); addTab( GameDetails.LOGS, _msgs.tabLogs(), new LazyPanel() { protected Widget createWidget() { return new GameLogsPanel(info.gameId); } }); addTab( GameDetails.DEV_LOGS, _msgs.tabDevLogs(), new LazyPanel() { protected Widget createWidget() { return new GameLogsPanel(GameInfo.toDevId(info.gameId)); } }); } }
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); }