List of usage examples for com.google.gwt.user.client.ui FlowPanel clear
@Override
public void clear()
From source file:ch.takoyaki.email.html.client.ui.generic.ClosableTabLayoutPanel.java
License:Open Source License
private void renameAction(final IsWidget content, final FlowPanel hpanel, final InlineHTML titlew, final Widget closeButton) { hpanel.clear(); final TextBox tb = new TextBox(); tb.addStyleName("tabrename"); final String originalText = titlew.getText(); tb.setText(originalText);/*from w w w. j av a 2 s .com*/ tb.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { boolean enterPressed = KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode(); boolean escapePressed = KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode(); if (enterPressed) { if (renameTabEventHandler != null) { if (renameTabEventHandler.onRename(ClosableTabLayoutPanel.this, getTab().getWidgetIndex(content), originalText, tb.getText())) { titlew.setText(tb.getText()); } else { titlew.setHTML(originalText); } } else { titlew.setText(tb.getText()); } } if (escapePressed) { titlew.setHTML(originalText); } if (enterPressed || escapePressed) { hpanel.clear(); hpanel.add(titlew); hpanel.add(closeButton); } } }); hpanel.add(tb); tb.selectAll(); titlew.setHTML(""); }
From source file:cl.uai.client.rubric.PreviousCommentsInterface.java
License:Open Source License
private void updateAllCommentsInInterfaces() { removeAllCommentsFromInterfaces();/*w ww. ja v a2 s . c om*/ previousCommentsAll.clear(); previousCommentsMine.clear(); previousCommentsRecent.clear(); previousCommentsMostUsed.clear(); previousCommentsFavorites.clear(); for (FlowPanel f : previousCommentsCriteria.values()) { f.clear(); } Collections.sort(previousComments, Comment.CommentTextComparator); for (Comment c : previousComments) { if (c.isOwnComment()) { addCommentLabelToInterface(c, previousCommentsMine); } if (c.isFavorite()) { addCommentLabelToInterface(c, previousCommentsFavorites); } addCommentLabelToInterface(c, previousCommentsAll); for (int cid : c.getCriteriaIds()) { if (previousCommentsCriteria.get(cid) != null) { FlowPanel f = previousCommentsCriteria.get(cid); addCommentLabelToInterface(c, f); } } if (EMarkingConfiguration.getMarkingType() == EMarkingConfiguration.EMARKING_TYPE_MARKER_TRAINING) { for (int did : c.getDrafts()) { FlowPanel f = previousCommentsDrafts.get(did); if (f != null) { addCommentLabelToInterface(c, f); } } } } Collections.sort(previousComments, Comment.CommentTimesUsedComparator); for (Comment c : previousComments) { addCommentLabelToInterface(c, previousCommentsMostUsed); } Collections.sort(previousComments, Comment.CommentLastUsedComparator); for (Comment c : previousComments) { addCommentLabelToInterface(c, previousCommentsRecent); } }
From source file:com.github.gwtcannonjs.demo.client.DemoLauncher.java
License:Open Source License
public void setup(Panel container) { final FlowPanel demoContainer = new FlowPanel(); demoContainer.addStyleName("demo-container"); Label selectDemoLabel = new Label("? Select a demo"); selectDemoLabel.addStyleName("select-demo"); demoContainer.add(selectDemoLabel);/*from w w w . j a v a2s .c om*/ FlowPanel menu = new FlowPanel(); menu.addStyleName("menu"); Label title = new Label("GWT CannonJS"); title.addStyleName("page-title"); for (final DemoInstance instance : DemoInstanceFactory.get().getAllInstances()) { Label item = new Label(instance.getName()); item.addStyleName("menu-item"); item.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { demoContainer.clear(); final Frame demoFrame = new Frame( "index.html?demo=" + URL.encodeQueryString(instance.getName())); HTMLPanel sourceCodeWidget = new HTMLPanel(highlightJava(instance.getSourceCode())); sourceCodeWidget.addStyleName("source-code"); TabPanel tabPanel = new TabPanel(); tabPanel.add(demoFrame, "Demo"); tabPanel.add(sourceCodeWidget, "Source code"); demoContainer.add(tabPanel); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { focus(demoFrame.getElement()); } private native void focus(Element iframeElement) /*-{ iframeElement.contentWindow.focus(); }-*/; }); } }); menu.add(item); } container.add(title); container.add(menu); container.add(demoContainer); }
From source file:com.google.appinventor.client.GalleryGuiFactory.java
License:Open Source License
/** * Loads the proper tab GUI with gallery's app data. * @param apps: list of returned gallery apps from callback. * @param container: the GUI panel where apps will reside. * @param refreshable: if true then the GUI can be reloaded later. *//*from w w w . ja va 2 s.co m*/ public void generateHorizontalAppList(List<GalleryApp> apps, FlowPanel container, Boolean refreshable) { if (refreshable) { // Flush the panel's content if we knew new stuff is coming in! container.clear(); } for (final GalleryApp app : apps) { // Create the associated GUI object for app GalleryAppWidget gaw = new GalleryAppWidget(app); // Create necessary GUI wrappers and components FlowPanel appCard = new FlowPanel(); FlowPanel appCardContent = new FlowPanel(); FlowPanel appCardMeta = new FlowPanel(); // Special processing for the app title, mainly for fade-out effect HTML appTitle = new HTML("" + "<div class='gallery-title'>" + gaw.nameLabel.getText() + "<span class='paragraph-end-block'></span></div>"); // Special processing for the app author, mainly for fade-out effect HTML appAuthor = new HTML("" + "<div class='gallery-subtitle'>" + gaw.authorLabel.getText() + "<span class='paragraph-end-block'></span></div>"); gaw.image.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } }); appTitle.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } }); // Add everything to the top-level stuff appCard.add(gaw.image); appCard.add(appCardContent); appCardContent.add(appTitle); appCardContent.add(appAuthor); appCardContent.add(appCardMeta); // Set helper icons Image numViews = new Image(); numViews.setUrl("/images/numView.png"); Image numDownloads = new Image(); numDownloads.setUrl("/images/numDownload.png"); Image numLikes = new Image(); numLikes.setUrl("/images/numLikeHollow.png"); // For generic cards, do not show comment // Image numComments = new Image(); // numComments.setUrl("/image/numComment.png"); // appCardMeta.add(numViews); // appCardMeta.add(gaw.numViewsLabel); appCardMeta.add(numDownloads); appCardMeta.add(gaw.numDownloadsLabel); appCardMeta.add(numLikes); appCardMeta.add(gaw.numLikesLabel); // For generic cards, do not show comment // appCardMeta.add(numComments); // appCardMeta.add(gaw.numCommentsLabel); // Add associated styling appCard.addStyleName("gallery-card"); gaw.image.addStyleName("gallery-card-cover"); // gaw.nameLabel.addStyleName("gallery-title"); // gaw.authorLabel.addStyleName("gallery-subtitle"); appCardContent.addStyleName("gallery-card-content"); gaw.numViewsLabel.addStyleName("gallery-meta"); gaw.numDownloadsLabel.addStyleName("gallery-meta"); gaw.numLikesLabel.addStyleName("gallery-meta"); // gaw.numCommentsLabel.addStyleName("gallery-meta"); container.add(appCard); } container.addStyleName("gallery-app-collection"); container.addStyleName("clearfix"); /* For redesigned navigation buttons */ }
From source file:com.google.appinventor.client.GalleryGuiFactory.java
License:Open Source License
/** * Creates list of comments in the app page. * @param comments: list of returned gallery comments from callback. * @param container: the GUI panel where comments will reside. *//*from w w w .ja v a2s . c o m*/ public void generateAppPageComments(List<GalleryComment> comments, FlowPanel container) { container.clear(); // so don't show previous listing if (comments == null) { Label noComments = new Label("This app does not have any comments yet."); noComments.addStyleName("comment-nope"); container.add(noComments); } for (GalleryComment c : comments) { FlowPanel commentItem = new FlowPanel(); FlowPanel commentPerson = new FlowPanel(); FlowPanel commentMeta = new FlowPanel(); FlowPanel commentContent = new FlowPanel(); // Add commentPerson, default avatar for now Image cPerson = new Image(); cPerson.setUrl(PERSON_URL); commentPerson.add(cPerson); commentPerson.addStyleName("comment-person"); commentItem.add(commentPerson); // Add commentContent Label cAuthor = new Label(c.getUserName()); cAuthor.addStyleName("comment-author"); commentMeta.add(cAuthor); Date commentDate = new Date(c.getTimeStamp()); DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy/MM/dd hh:mm:ss a"); Label cDate = new Label(" on " + dateFormat.format(commentDate)); cDate.addStyleName("comment-date"); commentMeta.add(cDate); commentMeta.addStyleName("comment-meta"); commentContent.add(commentMeta); Label cText = new Label(c.getComment()); cText.addStyleName("comment-text"); commentContent.add(cText); commentContent.addStyleName("comment-content"); commentItem.add(commentContent); commentItem.addStyleName("comment-item"); commentItem.addStyleName("clearfix"); container.add(commentItem); } }
From source file:com.google.appinventor.client.GalleryGuiFactory.java
License:Open Source License
/** * Creates a sidebar showcasing apps; the CSS name will be the same as the * passed-in container's name. This sidebar shows up as a tab under parent. * * @param apps: list of returned gallery apps from callback. * * @param parent: the parent TabPanel that this panel will reside in. * * @param container: the panel containing this particular sidebar. * * @param name: the name or title of this particular sidebar. * * @param desc: the short description of this particular sidebar. * * @param refreshable: if true then this sidebar can be reloaded later. * * @param isDefault: if true then this sidebar is the default tab showing. *//*w w w . j a va2s.c o m*/ public void generateSidebar(List<GalleryApp> apps, TabPanel parent, FlowPanel container, String name, String desc, Boolean refreshable, Boolean isDefault) { if (refreshable) { // Flush the panel's content if we knew new stuff is coming in! container.clear(); } parent.add(container, name); if (isDefault) { parent.selectTab(0); //TODO: fix order } Label descLabel = new Label(desc); descLabel.addStyleName("gallery-showcase-desc"); container.add(descLabel); for (final GalleryApp app : apps) { // Create the associated GUI object for app GalleryAppWidget gaw = new GalleryAppWidget(app); // Create necessary GUI wrappers and components FlowPanel appCard = new FlowPanel(); FlowPanel appCardContent = new FlowPanel(); FlowPanel appCardMeta = new FlowPanel(); // Special processing for the app title, mainly for fade-out effect HTML appTitle = new HTML("" + "<div class='gallery-title'>" + gaw.nameLabel.getText() + "<span class='paragraph-end-block'></span></div>"); // Special processing for the app author, mainly for fade-out effect HTML appAuthor = new HTML("" + "<div class='gallery-subtitle'>" + gaw.authorLabel.getText() + "<span class='paragraph-end-block'></span></div>"); gaw.image.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } }); appTitle.addClickHandler(new ClickHandler() { // @Override public void onClick(ClickEvent event) { Ode.getInstance().switchToGalleryAppView(app, GalleryPage.VIEWAPP); } }); // Add everything to the top-level stuff appCard.add(gaw.image); appCard.add(appCardContent); appCardContent.add(appTitle); appCardContent.add(appAuthor); appCardContent.add(appCardMeta); // Set helper icons // Image numViews = new Image(); // numViews.setUrl(NUM_VIEW_ICON_URL); Image numDownloads = new Image(); numDownloads.setUrl(DOWNLOAD_ICON_URL); Image numLikes = new Image(); numLikes.setUrl(HOLLOW_HEART_ICON_URL); // For generic cards, do not show comment // Image numComments = new Image(); // numComments.setUrl(NUM_COMMENT_ICON_URL); // appCardMeta.add(numViews); // appCardMeta.add(gaw.numViewsLabel); appCardMeta.add(numDownloads); appCardMeta.add(gaw.numDownloadsLabel); appCardMeta.add(numLikes); appCardMeta.add(gaw.numLikesLabel); // For generic cards, do not show comment // appCardMeta.add(numComments); // appCardMeta.add(gaw.numCommentsLabel); // Add associated styling appCard.addStyleName("gallery-card"); appCard.addStyleName("clearfix"); gaw.image.addStyleName("gallery-card-cover"); // gaw.nameLabel.addStyleName("gallery-title"); // gaw.authorLabel.addStyleName("gallery-subtitle"); appCardContent.addStyleName("gallery-card-content"); gaw.numViewsLabel.addStyleName("gallery-meta"); gaw.numDownloadsLabel.addStyleName("gallery-meta"); gaw.numLikesLabel.addStyleName("gallery-meta"); // gaw.numCommentsLabel.addStyleName("gallery-meta"); container.add(appCard); } }
From source file:com.gwtmobile.ui.client.widgets.HeaderPanel.java
License:Apache License
@Override public void add(Widget w) { FlowPanel contents = (FlowPanel) getWidget(1); if (Beans.isDesignTime() && contents.getWidgetCount() > 0) { Widget widget = contents.getWidget(0); if (widget instanceof Label && ((Label) widget).getText().contains(getDesignTimeMessage())) { contents.clear(); }//www . j a v a 2 s . c om } contents.add(w); }
From source file:com.gwtmobile.ui.client.widgets.HeaderPanel.java
License:Apache License
public void setCaption(String caption) { if (!caption.isEmpty()) { FlowPanel contents = (FlowPanel) getWidget(1); contents.clear(); contents.add(new HTML(caption)); }//from w w w . j a v a 2 s . c o m }
From source file:com.xpn.xwiki.watch.client.ui.articles.ArticleListWidget.java
License:Open Source License
protected void updateLeftActionsPanel(final FlowPanel actionsPanel, final FeedArticle article) { // TODO: uncomment this when we'll implement checkboxes usage // CheckBox selectArticle = new CheckBox(); // //TODO: replace article.getFlagStatus with article.getSelectStatus // selectArticle.setTitle(watch.getTranslation((article.getFlagStatus()==-1) ? "article.select.remove.caption" : "article.select.add.caption")); // selectArticle.addClickListener(new ClickListener() { // public void onClick(Widget widget) { // //TODO: implement me // } // }); // actionsPanel.add(selectArticle); Image flagImage = new Image(watch .getSkinFile((article.getFlagStatus() == 1) ? Constants.IMAGE_FLAG_ON : Constants.IMAGE_FLAG_OFF)); // put the flag action only if the user has the right to edit if (watch.getConfig().getHasEditRight()) { Image loadingFlagImage = new Image(watch.getSkinFile(Constants.IMAGE_LOADING_SPINNER)); flagImage.setTitle(watch.getTranslation( (article.getFlagStatus() == 1) ? "article.flag.remove.caption" : "article.flag.add.caption")); //create a loading widget with the flag image as main widget and loadingFlagImage as loading widget final LoadingWidget flagLoadingWidget = new DefaultLoadingWidget(watch, flagImage, loadingFlagImage); flagLoadingWidget.addStyleName(watch.getStyleName("article-flag")); flagImage.addStyleName("clickable"); flagImage.addClickListener(new ClickListener() { public void onClick(Widget widget) { int flagstatus = article.getFlagStatus(); final int newflagstatus = (flagstatus == 1) ? 0 : 1; watch.getDataManager().updateArticleFlagStatus(article, newflagstatus, new LoadingAsyncCallback(flagLoadingWidget) { public void onFailure(Throwable caught) { super.onFailure(caught); }/*from www.j a v a 2s . com*/ public void onSuccess(Object result) { super.onSuccess(result); article.setFlagStatus(newflagstatus); actionsPanel.clear(); updateLeftActionsPanel(actionsPanel, article); } }); } }); actionsPanel.add(flagLoadingWidget); } else { // otherwise, add only the image actionsPanel.add(flagImage); } }
From source file:com.xpn.xwiki.watch.client.ui.articles.ArticleListWidget.java
License:Open Source License
protected void updateRightActionsPanel(final FlowPanel actionsPanel, final FeedArticle article) { Image extLinkImage = new Image(watch.getSkinFile(Constants.IMAGE_EXT_LINK)); extLinkImage.setTitle(watch.getTranslation("articlelist.open")); extLinkImage.addStyleName("clickable"); extLinkImage.addClickListener(new ClickListener() { public void onClick(Widget widget) { Window.open(article.getUrl(), "_blank", ""); }/*ww w .j a v a 2 s . c o m*/ }); actionsPanel.add(extLinkImage); Image trashImage = new Image(watch.getSkinFile( (article.getFlagStatus() == -1) ? Constants.IMAGE_TRASH_ON : Constants.IMAGE_TRASH_OFF)); // add the trash button only if the user has the right to edit if (watch.getConfig().getHasEditRight()) { Image trashLoadingImage = new Image(watch.getSkinFile(Constants.IMAGE_LOADING_SPINNER)); trashImage .setTitle(watch.getTranslation((article.getFlagStatus() == -1) ? "article.trash.remove.caption" : "article.trash.add.caption")); final LoadingWidget trashLoadingWidget = new DefaultLoadingWidget(watch, trashImage, trashLoadingImage); trashLoadingWidget.addStyleName(watch.getStyleName("article-trash")); trashImage.addStyleName("clickable"); trashImage.addClickListener(new ClickListener() { public void onClick(Widget widget) { // trash/untrash article int flagstatus = article.getFlagStatus(); final int newflagstatus; if (flagstatus == -1) { // the article is trashed, untrash it newflagstatus = 0; } else { //the article isn't trashed, it can be trashed newflagstatus = -1; } watch.getDataManager().updateArticleFlagStatus(article, newflagstatus, new LoadingAsyncCallback(trashLoadingWidget) { public void onFailure(Throwable caught) { super.onFailure(caught); } public void onSuccess(Object result) { super.onSuccess(result); article.setFlagStatus(newflagstatus); actionsPanel.clear(); updateRightActionsPanel(actionsPanel, article); } }); } }); actionsPanel.add(trashLoadingWidget); } else { //otherwise add just the image actionsPanel.add(trashImage); } }