List of usage examples for com.google.gwt.user.client.ui Panel clear
public void clear()
From source file:com.chinarewards.gwt.license.client.core.ui.impl.ButtonMenuProcessor.java
@Override public void initrender(Panel container, String name) { // organize tree // sort according to menuID string length Collections.sort(items, new Comparator<MenuItem>() { public int compare(MenuItem paramT1, MenuItem paramT2) { return paramT1.getMenuId().length() - paramT2.getMenuId().length(); }//from www . ja v a 2 s. c o m }); // pack into the MenuNode structure // for (MenuItem m : items) { // // append children recursively // root.appendChild(new MenuNode(m)); // } ScrollPanel menuWrapper = new ScrollPanel(createButtonMenuWidget(name)); container.clear(); container.add(menuWrapper); }
From source file:com.chinarewards.gwt.license.client.core.ui.impl.SimpleMenuProcessor.java
public void initrender(Panel container, String name) { Collections.sort(items, new Comparator<MenuItem>() { public int compare(MenuItem paramT1, MenuItem paramT2) { return paramT1.getMenuId().length() - paramT2.getMenuId().length(); }/*from w w w . ja va2 s .co m*/ }); // // pack into the MenuNode structure // for (MenuItem m : items) { // // append children recursively // root.appendChild(new MenuNode(m)); // } Tree tree = new Tree(); tree.addStyleName("hihi"); TreeItem rootItem = new TreeItem(""); for (MenuNode n : root.getChildren()) { System.out.println(n.getValue().getTitle()); addSubTreeNode(rootItem, n); } // re-root child elements to the root of tree while (rootItem.getChildCount() > 0) { //for (int i = 0; i < rootItem.getChildCount(); i++) { TreeItem item = rootItem.getChild(0); tree.addItem(item); item.setState(true); } ScrollPanel menuWrapper = new ScrollPanel(tree); container.clear(); container.add(menuWrapper); }
From source file:com.google.api.explorer.client.FullView.java
License:Apache License
/** * Generate breadcrumbs into the specified container using the format link > link > text where the * last breadcrumb is always plain text. *//*from w ww .j av a 2 s. c o m*/ private void generateBreadcrumbs(Panel container, List<Title> titles) { container.clear(); // For all of the titles previous to the last, add a link and a separator. for (Title notLast : titles.subList(0, titles.size() - 1)) { container.add(new InlineHyperlink(notLast.getTitle(), notLast.getFragment())); container.add(new InlineLabel(" > ")); } // Append only the text for the last title. Title lastTitle = Iterables.getLast(titles); container.add(new InlineLabel(lastTitle.getTitle())); if (lastTitle.getSubtitle() != null) { Label subtitle = new InlineLabel(" - " + lastTitle.getSubtitle()); subtitle.addStyleName(style.methodSubtitle()); container.add(subtitle); } }
From source file:com.xpn.xwiki.watch.client.ui.filterbar.TagCloudWidget.java
License:Open Source License
public void updateTagsList(List list) { Panel tagsPanel = (Panel) ((LoadingWidget) panel).getMainWidget(); tagsPanel.clear(); tagsPanel.add(getTitlePanel());//from w w w .j ava2 s.c om tagsLink.clear(); if (list != null) { for (int i = 0; i < list.size(); i++) { List result = (List) list.get(i); final String name = (String) result.get(0); int count = ((Number) result.get(1)).intValue(); Label label = new Label(name); int pixels = 9 + count; if (pixels > 15) pixels = 15; label.addStyleName(watch.getStyleName("tagscloud", "link")); label.addStyleName(watch.getStyleName("tagscloud", "" + pixels)); tagsLink.put(name, label); label.addClickListener(new ClickListener() { public void onClick(Widget widget) { watch.refreshOnTagActivated(name); } }); tagsPanel.add(label); } } }
From source file:de.schott.gae.football.client.AbstractAsyncCallback.java
License:Apache License
@Override public void onFailure(Throwable caught) { Panel error = RootPanel.get("error"); error.clear(); error.add(new Label(caught.getLocalizedMessage())); }
From source file:de.schott.gae.football.client.DatabasePage.java
License:Apache License
/** * Create page with possible solutions. async. * // w ww . j a v a 2s. c om * @param implementations */ private void createPage(List<TransferObject> implementations) { Panel root = RootPanel.get(FootballEntry.CONTENT_ID); root.clear(); VerticalPanel panel = new VerticalPanel(); Label lblHeader = new Label("Choose Database implementation"); lblHeader.setStyleName("h1"); // Make some radio buttons, all in one group. VerticalPanel radioPanel = new VerticalPanel(); final List<RadioButton> radioButtons = new ArrayList<RadioButton>(); for (TransferObject to : implementations) { RadioButton radio = new RadioButton("radiogroup", (String) to.get("name")); radio.setValue((Boolean) to.get("selected")); Integer id = (Integer) to.get("id"); radio.setFormValue(id.toString()); radioButtons.add(radio); radioPanel.add(radio); } Button btnOk = new Button("Save"); btnOk.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { TransferObject to = new TransferObject(); for (RadioButton radio : radioButtons) { if (radio.getValue()) { Integer id = Integer.parseInt(radio.getFormValue()); to.put("id", id); mDatabaseService.setDatastoreImplementation(to, new AbstractAsyncCallback<Void>() { @Override public void onSuccess(Void result) { Window.alert("New Implementation saved."); createView(); } }); break; } } } }); panel.add(lblHeader); panel.add(radioPanel); panel.add(btnOk); root.add(panel); }
From source file:de.schott.gae.football.client.GamePage.java
License:Apache License
/** * Show game.//from w w w. j av a2 s .c om * * @param gameId */ public void showGame(final String gameId) { // Ask for user AsyncCallback<String> callback = new AbstractAsyncCallback<String>() { @Override public void onSuccess(String result) { if (result == null) { Panel root = RootPanel.get(FootballEntry.CONTENT_ID); root.clear(); root.add(new Label("You are not logged in. Please log in first.")); } else { // Logged in showGameInternal(gameId); } } }; mUserService.getRegisteredUser(callback); }
From source file:de.schott.gae.football.client.GamePage.java
License:Apache License
private void showGameInternal(final String gameId) { final VerticalPanel panel = new VerticalPanel(); final HorizontalPanel panelComment = new HorizontalPanel(); Panel root = RootPanel.get(FootballEntry.CONTENT_ID); // Set up callbacks. AsyncCallback<TransferObject> gameCallback = new AbstractAsyncCallback<TransferObject>() { public void onSuccess(TransferObject to) { mLblHeader.setText(DF.format((Date) to.get("date")) + " - " + to.get("team1_name") + " vs. " + to.get("team2_name") + " (" + to.get("goal1") + ":" + to.get("goal2") + ")"); }//w ww. j a v a2s . co m }; mGameService.getGame(gameId, gameCallback); // Load comments reloadComments(gameId); // Setup timer to refresh list automatically. Timer refreshTimer = new Timer() { @Override public void run() { reloadComments(gameId); } }; refreshTimer.scheduleRepeating(REFRESH_INTERVALL); final AsyncCallback<Void> saveCallback = new AbstractAsyncCallback<Void>() { @Override public void onSuccess(Void result) { reloadComments(gameId); } }; mBtnSave.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { try { int minute = Integer.parseInt(mTxtMinute.getText()); String message = mTxtComment.getText(); if (minute <= 0) { Window.alert("Please enter a correct minute."); } else if (message == null || message.isEmpty()) { Window.alert("Please enter a correct message."); } else { mGameService.saveComment(gameId, minute, message, saveCallback); mTxtComment.setText(""); mTxtMinute.setText(""); } } catch (NumberFormatException e) { Window.alert("Please enter a correct minute."); } } }); panel.add(mLblHeader); panel.add(mTableComments); panelComment.add(mTxtMinute); panelComment.add(mTxtComment); panelComment.add(mBtnSave); panel.add(panelComment); root.clear(); root.add(panel); }
From source file:de.schott.gae.football.client.LeaguePage.java
License:Apache License
public LeaguePage() { // Initialize the service proxy. if (mUserService == null) { mUserService = GWT.create(UserService.class); }/* w ww . j av a 2s . c om*/ if (mLeagueService == null) { mLeagueService = GWT.create(LeagueService.class); } // Callback for checking user. mUserCallback = new AbstractAsyncCallback<String>() { @Override public void onSuccess(String result) { if (result == null) { Panel root = RootPanel.get(FootballEntry.CONTENT_ID); root.clear(); root.add(new Label("You are not logged in. Please log in first.")); } else { // Logged in createOverview(); } } }; }
From source file:de.schott.gae.football.client.LeaguePage.java
License:Apache License
private void createOverview() { final FlexTable tableLeague = new FlexTable(); VerticalPanel panel = new VerticalPanel(); Label lblHeader = new Label("League Overview"); lblHeader.setStyleName("h1"); Panel root = RootPanel.get(FootballEntry.CONTENT_ID); // Set up callbacks. AsyncCallback<List<TransferObject>> leagueCallback = new AbstractAsyncCallback<List<TransferObject>>() { public void onSuccess(List<TransferObject> result) { // Create table with game information. tableLeague.clear();//ww w.j a v a2 s. c o m int row = 0; for (TransferObject l : result) { Label lblHeader = new Label((String) l.get("name")); lblHeader.setStyleName("h2"); tableLeague.setWidget(row++, 0, lblHeader); tableLeague.setStyleName("league_table"); @SuppressWarnings("unchecked") List<TransferObject> games = (List<TransferObject>) l.get("games"); for (TransferObject game : games) { final String id = (String) game.get("id"); Button btnShowGame = new Button("Show Game"); btnShowGame.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { new GamePage().showGame(id); } }); tableLeague.setWidget(row, 0, btnShowGame); tableLeague.setText(row, 1, DF.format((Date) game.get("date"))); tableLeague.setText(row, 2, (String) game.get("team1_name")); tableLeague.setText(row, 3, "-"); tableLeague.setText(row, 4, (String) game.get("team2_name")); tableLeague.setText(row, 5, game.get("goal1") + " : " + game.get("goal2")); row++; } } } }; mLeagueService.getLeagues(leagueCallback); panel.add(lblHeader); panel.add(tableLeague); root.clear(); root.add(panel); }