List of usage examples for com.google.gwt.user.client.ui HTMLPanel HTMLPanel
@SuppressIsSafeHtmlCastCheck
public HTMLPanel(String tag, @IsSafeHtml String html)
From source file:org.gwtbootstrap3.client.ui.base.button.CustomIconTextMixin.java
License:Apache License
public void setShortcut(final String shortcutHtml) { shortcut = new HTMLPanel("span", shortcutHtml); }
From source file:org.spiffyui.client.MainHeader.java
License:Apache License
/** * Creates a new MainHeader panel//from w w w .j a v a2 s. co m */ public MainHeader() { String html = "<div id=\"headerleft\">" + "<div id=\"headerlogo\"> </div>" + "<span class=\"headertitle\" id=\"" + HEADER_TITLE + "\"></span>" + "</div>" + "<div id=\"headerright\">" + "<div id=\"" + HEADER_ACTIONS_BLOCK + "\">" + "<span id=\"" + HEADER_STRING + "\"></span> " + "</div>" + "</div>"; m_panel = new HTMLPanel("div", html); m_panel.getElement().setId("mainHeaderContainer"); add(m_panel); if (RootPanel.get("mainHeader") != null) { RootPanel.get("mainHeader").add(this); } else { throw new IllegalStateException( "Unable to locate the mainHeader element. You must import spiffyui.min.js before using the Main Header."); } }
From source file:org.spiffyui.spsample.client.WidgetsPanel.java
License:Apache License
/** * A helper method that adds a widget and some HTML description to the sliding * grid panel/*from w ww.j a v a 2s . c o m*/ * * @param widget the widget to add * @param id the ID of the new cell * @param title the title of the new cell * @param htmlText the HTML description of the widget * @param type the type of cell to add: TALL, BIG, or WIDE * * @return the HTMLPanel used to add the contents to the new cell */ private HTMLPanel addToSlidingGrid(Widget widget, String id, String title, String htmlText, int type) { HTMLPanel p = new HTMLPanel("div", "<h3 id=\"WID_" + id + "\">" + title + "</h3>" + htmlText + "<span id=\"" + id + "\"></span>"); if (widget != null) { p.add(widget, id); } switch (type) { case WIDE: m_slideGridPanel.addWide(p); break; case TALL: m_slideGridPanel.addTall(p); break; case BIG: m_slideGridPanel.addBig(p); break; default: m_slideGridPanel.add(p); break; } return p; }
From source file:org.zanata.webtrans.client.ui.ValidationMessagePanelView.java
License:Apache License
@Override public void updateValidationMessages(Map<ValidationAction, List<String>> messages) { if (messages == null || messages.isEmpty()) { clear();//from w w w . j a va 2 s. co m return; } this.displayMessages = messages; contents.clear(); int warningCount = 0; int errorCount = 0; for (Entry<ValidationAction, List<String>> entry : messages.entrySet()) { for (String message : entry.getValue()) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendEscaped(message); HTMLPanel liElement = new HTMLPanel("li", builder.toSafeHtml().asString()); liElement.setTitle(entry.getKey().getId().getDisplayName()); if (isErrorLocked(entry.getKey().getRules())) { liElement.addStyleName("txt--danger"); errorCount++; } else { liElement.addStyleName("txt--warning"); warningCount++; } contents.add(liElement); } } headerLabel.setText(this.messages.validationNotificationHeading(warningCount, errorCount)); removeStyleName("is-hidden"); }
From source file:org.zanata.webtrans.client.ui.ValidationWarningPanel.java
License:Open Source License
private void refreshView(Map<ValidationAction, List<String>> errorMessages) { translations.clear();/*from www. j a va 2 s . com*/ errorList.clear(); saveAsFuzzyOpt = false; for (String target : targets) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(TextContentsDisplay.asSyntaxHighlight(Lists.newArrayList(target)).toSafeHtml()); translations.add(new HTMLPanel("li", builder.toSafeHtml().asString())); } for (List<String> messages : errorMessages.values()) { for (String message : messages) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendEscaped(message); errorList.add(new HTMLPanel("li", builder.toSafeHtml().asString())); } } }
From source file:org.zanata.webtrans.client.view.SourceContentsView.java
License:Open Source License
private DisclosurePanel getUrlWidget() { DisclosurePanel widget = new DisclosurePanel(); widget.setAnimationEnabled(true);//from www .j ava 2s . co m HTMLPanel header = new HTMLPanel("div", ""); header.setStyleName("button button--small"); header.add(new InlineHTML("<i class='i i--star l--push-right-quarter'/>")); header.add(new InlineLabel("Link")); widget.setHeader(header); urlTextField = new TextBox(); urlTextField.setReadOnly(true); HTMLPanel content = new HTMLPanel("div", ""); content.setStyleName("bg--pop-highest txt--meta"); content.add(urlTextField); widget.setContent(content); widget.getHeader().getParent().setStyleName(""); return widget; }
From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.ChoosePortionSizeMethodPrompt.java
License:Apache License
@Override public SurveyStageInterface getInterface(final Callback1<FoodOperation> onComplete, Callback1<Function1<FoodEntry, FoodEntry>> updateIntermediateState) { final FlowPanel content = new FlowPanel(); content.addStyleName("intake24-choose-portion-method-prompt"); PromptUtil.addBackLink(content);//from w w w.j a v a2 s.c o m final HTMLPanel header = new HTMLPanel("h2", food.description()); content.add(header); FlowPanel promptPanel = WidgetFactory.createPromptPanel( SafeHtmlUtils.fromSafeConstant(messages.choosePortionMethod_promptText(food.description())), ShepherdTour.createTourButton(tour, ChoosePortionSizeMethodPrompt.class.getSimpleName())); content.add(promptPanel); ShepherdTour.makeShepherdTarget(promptPanel); final FlowPanel methodPanel = new FlowPanel(); methodPanel.getElement().setId("intake24-choose-portion-panel"); ShepherdTour.makeShepherdTarget(methodPanel); int index = 0; for (final PortionSizeMethod m : food.data.portionSizeMethods) { Image img = new Image(m.imageUrl); final int indexClosure = index; index++; ClickHandler clickHandler = new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(FoodOperation.updateEncoded(new Function1<EncodedFood, EncodedFood>() { @Override public EncodedFood apply(EncodedFood argument) { return argument.withSelectedPortionSizeMethod(indexClosure); } })); } }; img.addClickHandler(clickHandler); img.addStyleName("intake24-choose-portion-image"); FlowPanel container = new FlowPanel(); container.addStyleName("intake24-choose-portion-container"); container.add(img); Label label = new Label(SafeHtmlUtils.htmlEscape(descriptions.getString(m.description))); label.addStyleName("intake24-choose-portion-label"); label.addClickHandler(clickHandler); container.add(label); methodPanel.add(container); } content.add(methodPanel); return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS, ChoosePortionSizeMethodPrompt.class.getSimpleName()); }
From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.DeleteMealPrompt.java
License:Apache License
@Override public SurveyStageInterface getInterface(final Callback1<SurveyOperation> onComplete, final Callback1<Function1<Survey, Survey>> onIntermediateStateChange) { SafeHtml promptText = SafeHtmlUtils.fromSafeConstant( messages.deleteMeal_promptText(SafeHtmlUtils.htmlEscape(meal.name.toLowerCase()))); Button deleteButton = WidgetFactory.createRedButton(messages.deleteMeal_deleteButtonLabel(), "deleteMealButton", new ClickHandler() { @Override/* w w w . ja v a 2s . co m*/ public void onClick(ClickEvent event) { onComplete.call(SurveyOperation.update(new Function1<Survey, Survey>() { @Override public Survey apply(Survey argument) { return argument.minusMeal(mealIndex) .withSelection(new Selection.EmptySelection(SelectionMode.AUTO_SELECTION)); } })); } }); Button cancelButton = WidgetFactory.createButton(messages.deleteMeal_keepButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(SurveyOperation.noChange); } }); FlowPanel contents = new FlowPanel(); contents.add(new HTMLPanel("h1", meal.safeNameWithTimeCapitalised())); contents.add(WidgetFactory.createPromptPanel(promptText)); contents.add(WidgetFactory.createButtonsPanel(deleteButton, cancelButton)); return new SurveyStageInterface.Aligned(contents, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS, DeleteMealPrompt.class.getSimpleName()); }
From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.DrinkReminderPrompt.java
License:Apache License
@Override public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete, final Callback1<Function1<Meal, Meal>> onIntermediateStateChange) { final SafeHtml promptText = SafeHtmlUtils.fromSafeConstant( messages.drinkReminder_promptText((SafeHtmlUtils.htmlEscape(meal.name.toLowerCase())))); final String addDrinkText = SafeHtmlUtils.htmlEscape(messages.drinkReminder_addDrinkButtonLabel()); final String noDrinkText = SafeHtmlUtils.htmlEscape(messages.drinkReminder_noDrinkButtonLabel()); FlowPanel content = new FlowPanel(); final HTMLPanel header = new HTMLPanel("h1", meal.name + " (" + meal.time.map(argument -> argument.toString()).getOrElse("Time unknown") + ")"); content.add(header);/*from w w w . j a va 2s .c o m*/ content.add(new YesNoQuestion(promptText, addDrinkText, noDrinkText, new YesNoQuestion.ResultHandler() { @Override public void handleYes() { onComplete.call(MealOperation.editFoodsRequest(true)); } @Override public void handleNo() { onComplete.call(MealOperation.update(argument -> argument.markConfirmedNoDrinks())); } })); return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS, DrinkReminderPrompt.class.getSimpleName()); }
From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.EditMealPrompt.java
License:Apache License
@Override public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete, final Callback1<Function1<Meal, Meal>> onIntermediateStateChange) { final SafeHtml promptText = SafeHtmlUtils .fromSafeConstant(messages.editMeal_promptText(SafeHtmlUtils.htmlEscape(meal.name.toLowerCase()))); final Function1<FoodEntry, Boolean> foodFilter = new Function1<FoodEntry, Boolean>() { @Override/*from w w w . ja v a 2s . c o m*/ public Boolean apply(FoodEntry argument) { return !argument.isDrink(); } }; final Function1<FoodEntry, Boolean> drinkFilter = new Function1<FoodEntry, Boolean>() { @Override public Boolean apply(FoodEntry argument) { return argument.isDrink(); } }; final Button done = WidgetFactory.createGreenButton(messages.editMeal_finishButtonLabel(), "editMealFinishButton", new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(new MealOperation() { @Override public <R> R accept(Visitor<R> visitor) { return visitor.visitUpdate(new Function1<Meal, Meal>() { @Override public Meal apply(Meal argument) { return argument .withFoods(TreePVector.<FoodEntry>empty() .plusAll(foodList.getEnteredItems()) .plusAll(drinkList.getEnteredItems())) .markFreeEntryComplete().clearAssociatedFoodsComplete(); } }); } }); } }); done.getElement().setId("intake24-done-button"); final Callback1<List<FoodEntry>> onChange = new Callback1<List<FoodEntry>>() { @Override public void call(List<FoodEntry> arg1) { TreePVector<FoodEntry> newItems = TreePVector.<FoodEntry>empty().plusAll(foodList.getEnteredItems()) .plusAll(drinkList.getEnteredItems()); onIntermediateStateChange.call(Meal.updateFoodsFunc(newItems)); } }; // Food list foodList = new EditableFoodList(meal.foods, foodFilter, messages.editMeal_addFoodButtonLabel(), false, onChange); final HTMLPanel foodHeader = new HTMLPanel("h2", SafeHtmlUtils.htmlEscape(messages.editMeal_foodHeader())); final FlowPanel foodListContainer = new FlowPanel(); foodListContainer.getElement().setId("intake24-food-list"); foodListContainer.add(foodHeader); foodListContainer.add(foodList); ShepherdTour.makeShepherdTarget(foodListContainer); // Drinks list drinkList = new EditableFoodList(meal.foods, drinkFilter, messages.editMeal_addDrinkButtonLabel(), true, onChange); final HTMLPanel drinksHeader = new HTMLPanel("h2", SafeHtmlUtils.htmlEscape(messages.editMeal_drinksHeader())); drinkList.getElement().setId("intake24-drink-list"); final FlowPanel drinkListContainer = new FlowPanel(); drinkListContainer.getElement().setId("intake24-drink-list"); drinkListContainer.add(drinksHeader); drinkListContainer.add(drinkList); ShepherdTour.makeShepherdTarget(drinkListContainer); Button changeTime = WidgetFactory.createButton(messages.editMeal_changeTimeButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(MealOperation.editTimeRequest); } }); changeTime.getElement().setId("intake24-change-time-button"); Button delete = WidgetFactory.createButton(messages.editMeal_deleteMealButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(MealOperation.deleteRequest(true)); } }); delete.getElement().setId("intake24-delete-button"); final HTMLPanel header = new HTMLPanel("h1", LocaleUtil.capitaliseFirstCharacter(meal.safeNameWithTime())); header.getElement().setId("intake24-meal-name"); ShepherdTour.makeShepherdTarget(header); FlowPanel contents = new FlowPanel(); contents.addStyleName("intake24-edit-meal-prompt"); contents.add(header); Panel promptPanel = WidgetFactory.createPromptPanel(promptText, ShepherdTour.createTourButton(tour, EditMealPrompt.class.getSimpleName())); contents.add(promptPanel); ShepherdTour.makeShepherdTarget(promptPanel); contents.add(foodListContainer); contents.add(drinkListContainer); contents.add(WidgetFactory.createButtonsPanel(changeTime, delete, done)); ShepherdTour.makeShepherdTarget(changeTime, delete, done); return new SurveyStageInterface.Aligned(contents, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS, EditMealPrompt.class.getSimpleName(), Option.<Callback>some(new Callback() { @Override public void call() { if (addDrink) drinkList.focusNew(); } })); }