Example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromSafeConstant.

Prototype

public static SafeHtml fromSafeConstant(String s) 

Source Link

Document

Returns a SafeHtml constructed from a safe string, i.e., without escaping the string.

Usage

From source file:net.scran24.user.client.survey.prompts.CompoundFoodPrompt.java

License:Apache License

@Override
public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete,
        Callback1<Function1<Pair<FoodEntry, Meal>, Pair<FoodEntry, Meal>>> updateIntermediateState) {
    final TemplateFood food = (TemplateFood) meal.foods.get(foodIndex);
    final ComponentDef component = food.data.template.get(componentIndex);

    final FlowPanel content = new FlowPanel();

    PromptUtil.addBackLink(content);/*from w w  w .  j  ava 2s.com*/

    component.headerConstructor.accept(new Option.SideEffectVisitor<Function0<Widget>>() {
        @Override
        public void visitSome(Function0<Widget> item) {
            Widget header = item.apply();
            ShepherdTour.makeShepherdTarget(header);
            content.add(header);
        }

        @Override
        public void visitNone() {
        }
    });

    SafeHtml promptText;

    if (isFirst)
        promptText = SafeHtmlUtils.fromSafeConstant(component.primaryInstancePrompt);
    else
        promptText = SafeHtmlUtils.fromSafeConstant(component.secondaryInstancePrompt);

    final Panel promptPanel = WidgetFactory.createPromptPanel(promptText,
            WidgetFactory.createHelpButton(new ClickHandler() {
                @Override
                public void onClick(ClickEvent arg0) {
                    String promptType = CompoundFoodPrompt.class.getSimpleName() + "." + food.data.template_id;
                    GoogleAnalytics.trackHelpButtonClicked(promptType);
                    ShepherdTour.startTour(tour.plusAll(foodBrowser.getShepherdTourSteps()), promptType);
                }
            }));

    content.add(promptPanel);
    ShepherdTour.makeShepherdTarget(promptPanel);
    promptPanel.getElement().setId("intake24-compound-food-prompt");

    String skipLabel;

    if (isFirst)
        skipLabel = component.primarySkipButtonLabel;
    else
        skipLabel = component.secondarySkipButtonLabel;

    Option<SkipFoodHandler> skipHandler = allowSkip
            ? Option.some(new SkipFoodHandler(skipLabel, new Callback() {
                @Override
                public void call() {
                    onComplete.call(MealOperation.updateTemplateFood(foodIndex,
                            new Function1<TemplateFood, TemplateFood>() {
                                @Override
                                public TemplateFood apply(TemplateFood argument) {
                                    return argument.markComponentComplete(componentIndex);
                                }
                            }));
                }
            }))
            : Option.<SkipFoodHandler>none();

    foodBrowser = new FoodBrowser(locale, new Callback1<FoodData>() {
        @Override
        public void call(final FoodData result) {
            onComplete.call(MealOperation.update(new Function1<Meal, Meal>() {
                @Override
                public Meal apply(Meal argument) {
                    EncodedFood componentFood = new EncodedFood(result, FoodLink.newLinked(food.link.id),
                            "compound food template");
                    return argument.plusFood(componentFood).updateFood(foodIndex,
                            food.addComponent(componentIndex, componentFood.link.id));
                }
            }));
        }
    }, new Callback1<String>() {
        @Override
        public void call(String code) {
            throw new RuntimeException("Special foods are not allowed as compound food ingredients");
        }
    }, new Callback() {
        @Override
        public void call() {
            onComplete.call(MealOperation.update(new Function1<Meal, Meal>() {
                @Override
                public Meal apply(Meal argument) {
                    MissingFood missingFood = new MissingFood(FoodLink.newLinked(food.link.id), component.name,
                            false).withFlag(MissingFood.NOT_HOME_RECIPE_FLAG);

                    return argument.plusFood(missingFood).updateFood(foodIndex,
                            food.addComponent(componentIndex, missingFood.link.id));
                }
            }));
        }
    }, skipHandler, false, Option.<Pair<String, String>>none());

    foodBrowser.browse(component.categoryCode, component.dataSetLabel, component.foodsLabel,
            component.categoriesLabel);

    content.add(foodBrowser);

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.client.survey.prompts.ConfirmCompletionPrompt.java

@Override
public SurveyStageInterface getInterface(final Callback1<SurveyOperation> onComplete,
        final Callback1<Function1<Survey, Survey>> onIntermediateStateChange) {
    final SafeHtml promptText = SafeHtmlUtils.fromSafeConstant(messages.completion_promptText());

    FlowPanel content = new FlowPanel();

    content.add(WidgetFactory.createPromptPanel(promptText));

    Button confirm = WidgetFactory.createGreenButton(messages.completion_submitButtonLabel(),
            new ClickHandler() {
                @Override//from w w  w.  ja  v  a2  s .c  o m
                public void onClick(ClickEvent event) {
                    onComplete.call(SurveyOperation.update(new Function1<Survey, Survey>() {
                        @Override
                        public Survey apply(Survey argument) {
                            return argument.markCompletionConfirmed();
                        }
                    }));
                }
            });

    content.add(WidgetFactory.createButtonsPanel(confirm));

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.client.survey.prompts.ConfirmMealPrompt.java

License:Apache License

@Override
public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete,
        final Callback1<Function1<Meal, Meal>> onIntermediateStateChange) {
    final SafeHtml promptText = SafeHtmlUtils.fromSafeConstant(selectPromptMessage(meal.name));
    final String skipText = SafeHtmlUtils.htmlEscape(selectDeleteButtonMessage(meal.name));
    final String acceptText = SafeHtmlUtils.htmlEscape(messages.confirmMeal_confirmButtonLabel());
    final Time initialTime = meal.guessTime();

    FlowPanel content = new FlowPanel();

    TimeQuestion timeQuestion = new TimeQuestion(promptText, acceptText, skipText, initialTime,
            new TimeQuestion.ResultHandler() {
                @Override//  w  ww.  j  ava2 s. c  o  m
                public void handleSkip() {
                    onComplete.call(MealOperation.deleteRequest(false));
                }

                @Override
                public void handleAccept(Time time) {
                    onComplete.call(MealOperation.update(Meal.updateTimeFunc(time)));
                }
            }, false);

    Button helpButton = ShepherdTour.createTourButton(tour, ConfirmMealPrompt.class.getSimpleName());
    helpButton.getElement().addClassName("intake24-prompt-float-widget");
    timeQuestion.promptPanel.insert(helpButton, 0);

    content.add(timeQuestion);

    ShepherdTour.makeShepherdTarget(timeQuestion.promptPanel, timeQuestion.timePicker.hourCounter,
            timeQuestion.timePicker.minuteCounter, timeQuestion.skipButton, timeQuestion.confirmButton);

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.client.survey.prompts.ConfirmTimeGapPrompt.java

@Override
public SurveyStageInterface getInterface(final Callback1<SurveyOperation> onComplete,
        final Callback1<Function1<Survey, Survey>> onIntermediateStateChange) {

    FlowPanel content = new FlowPanel();

    final SafeHtml promptText = gap.accept(new TimeGap.Visitor<SafeHtml>() {
        @Override//w w w.  j  a v a2 s  .co m
        public SafeHtml visitBeforeMeal(int mealIndex) {
            Meal meal = survey.meals.get(mealIndex);
            return SafeHtmlUtils.fromSafeConstant(messages
                    .timeGap_promptText_beforeMeal(meal.name.toLowerCase(), meal.time.getOrDie().toString()));
        }

        @Override
        public SafeHtml visitAfterMeal(int mealIndex) {
            Meal meal = survey.meals.get(mealIndex);
            return SafeHtmlUtils.fromSafeConstant(messages.timeGap_promptText_afterMeal(meal.name.toLowerCase(),
                    meal.time.getOrDie().toString()));
        }

        @Override
        public SafeHtml visitBetweenMeals(int mealIndex1, int mealIndex2) {
            Meal meal1 = survey.meals.get(mealIndex1);
            Meal meal2 = survey.meals.get(mealIndex2);
            return SafeHtmlUtils.fromSafeConstant(messages.timeGap_promptText_betweenMeals(
                    meal1.name.toLowerCase(), meal1.time.getOrDie().toString(), meal2.name.toLowerCase(),
                    meal2.time.getOrDie().toString()));
        }
    });

    content.add(new YesNoQuestion(promptText, messages.timeGap_addMealButtonLabel(),
            messages.timeGap_confirmTimeGapButtonLabel(), new YesNoQuestion.ResultHandler() {
                @Override
                public void handleYes() {
                    onComplete.call(SurveyOperation.addMealRequest(0));
                }

                @Override
                public void handleNo() {
                    onComplete.call(SurveyOperation.update(new Function1<Survey, Survey>() {
                        @Override
                        public Survey apply(final Survey argument) {
                            return gap.accept(new TimeGap.Visitor<Survey>() {
                                @Override
                                public Survey visitBeforeMeal(int mealIndex) {
                                    return argument.updateMeal(mealIndex,
                                            argument.meals.get(mealIndex).markNoMealsBefore());
                                }

                                @Override
                                public Survey visitAfterMeal(int mealIndex) {
                                    return argument.updateMeal(mealIndex,
                                            argument.meals.get(mealIndex).markNoMealsAfter());
                                }

                                @Override
                                public Survey visitBetweenMeals(int mealIndex1, int mealIndex2) {
                                    return argument
                                            .updateMeal(mealIndex1,
                                                    argument.meals.get(mealIndex1).markNoMealsAfter())
                                            .updateMeal(mealIndex2,
                                                    argument.meals.get(mealIndex2).markNoMealsBefore());
                                }
                            });
                        }
                    }, true));
                }
            }));

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.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(),
            new ClickHandler() {
                @Override/*from  w  w  w  . j av  a 2  s . c  om*/
                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);
}

From source file:net.scran24.user.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(new Function1<Time, String>() {
                @Override//w w  w  .  java 2  s . co m
                public String apply(Time argument) {
                    return argument.toString();
                }
            }).getOrElse("Time unknown") + ")");

    content.add(header);

    content.add(new YesNoQuestion(promptText, addDrinkText, noDrinkText, new ResultHandler() {
        @Override
        public void handleYes() {
            onComplete.call(MealOperation.editFoodsRequest(true));
        }

        @Override
        public void handleNo() {
            onComplete.call(MealOperation.update(new Function1<Meal, Meal>() {
                @Override
                public Meal apply(Meal argument) {
                    return argument.markConfirmedNoDrinks();
                }
            }));
        }
    }));

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.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/* ww  w  .j a  v a  2s. c om*/
        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(),
            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();

                                }
                            });
                        }
                    });
                }
            });

    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,
            Option.<Callback>some(new Callback() {
                @Override
                public void call() {
                    if (addDrink)
                        drinkList.focusNew();
                }
            }));
}

From source file:net.scran24.user.client.survey.prompts.EditRecipeIngredientsPrompt.java

@Override
public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete,
        final Callback1<Function1<Pair<FoodEntry, Meal>, Pair<FoodEntry, Meal>>> onIntermediateStateChange) {
    final SafeHtml promptText = SafeHtmlUtils.fromSafeConstant(messages.editRecipeIngredientsPrompt_promptText(
            SafeHtmlUtils.htmlEscape(meal.foods.get(foodIndex).description())));
    final UUID compoundFoodId = meal.foods.get(foodIndex).link.id;

    final Function1<FoodEntry, Boolean> noLinkedFoodsFilter = new Function1<FoodEntry, Boolean>() {
        @Override//from w  ww  .  ja  v a 2  s  .  c  o m
        public Boolean apply(FoodEntry argument) {
            return argument.link.linkedTo.accept(new Option.Visitor<UUID, Boolean>() {
                @Override
                public Boolean visitSome(UUID item) {
                    return !item.equals(compoundFoodId);
                }

                @Override
                public Boolean visitNone() {
                    return true;
                }
            });
        }
    };

    final Button done = WidgetFactory
            .createGreenButton(messages.editRecipeIngredientsPrompt_continueButtonLabel(), new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(MealOperation.update(new Function1<Meal, Meal>() {
                        @Override
                        public Meal apply(Meal argument) {
                            ArrayList<FoodEntry> linkedFoods = new ArrayList<FoodEntry>();
                            for (FoodEntry e : ingredientList.getEnteredItems())
                                linkedFoods.add(e.relink(FoodLink.newLinked(compoundFoodId))
                                        .withCustomDataField(RawFood.KEY_LIMIT_LOOKUP_TO_CATEGORY,
                                                SpecialData.CATEGORY_CODE_RECIPE_INGREDIENTS));

                            return argument.withFoods(filter(argument.foods, noLinkedFoodsFilter))
                                    .plusAllFoods(linkedFoods).updateFood(foodIndex, argument.foods
                                            .get(foodIndex).withFlag(CompoundFood.FLAG_INGREDIENTS_COMPLETE));
                        }
                    }));
                }
            });

    done.getElement().setId("intake24-done-button");

    ingredientList = new EditableFoodList(messages.editMeal_addFoodButtonLabel(), false,
            new Callback1<List<FoodEntry>>() {
                @Override
                public void call(List<FoodEntry> arg1) {
                    onIntermediateStateChange
                            .call(new Function1<Pair<FoodEntry, Meal>, Pair<FoodEntry, Meal>>() {
                                @Override
                                public Pair<FoodEntry, Meal> apply(Pair<FoodEntry, Meal> argument) {

                                    ArrayList<FoodEntry> linkedFoods = new ArrayList<FoodEntry>();
                                    for (FoodEntry e : ingredientList.getEnteredItems())
                                        linkedFoods.add(e.relink(FoodLink.newLinked(compoundFoodId))
                                                .withCustomDataField(RawFood.KEY_LIMIT_LOOKUP_TO_CATEGORY,
                                                        SpecialData.CATEGORY_CODE_RECIPE_INGREDIENTS));

                                    return Pair.create(null,
                                            argument.right
                                                    .withFoods(
                                                            filter(argument.right.foods, noLinkedFoodsFilter))
                                                    .plusAllFoods(linkedFoods));
                                }
                            });
                }
            });

    ingredientList.disableLinkedFoodsIndentation();

    for (FoodEntry f : Meal.linkedFoods(meal.foods, meal.foods.get(foodIndex)))
        ingredientList.addItem(Option.some(f));

    final HTMLPanel foodHeader = new HTMLPanel("h2",
            SafeHtmlUtils.htmlEscape(messages.editRecipeIngredientsPrompt_ingredientsHeader()));
    final FlowPanel foodListContainer = new FlowPanel();
    foodListContainer.getElement().setId("intake24-ingredient-list");
    foodListContainer.add(foodHeader);
    foodListContainer.add(ingredientList);
    ShepherdTour.makeShepherdTarget(foodListContainer);

    FlowPanel contents = new FlowPanel();
    contents.addStyleName("intake24-edit-meal-prompt");

    Panel promptPanel = WidgetFactory.createPromptPanel(promptText,
            ShepherdTour.createTourButton(tour, EditRecipeIngredientsPrompt.class.getSimpleName()));
    contents.add(promptPanel);
    ShepherdTour.makeShepherdTarget(promptPanel);

    contents.add(foodListContainer);
    contents.add(WidgetFactory.createButtonsPanel(done));

    ShepherdTour.makeShepherdTarget(done);

    return new SurveyStageInterface.Aligned(contents, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.client.survey.prompts.EditTimePrompt.java

License:Apache License

@Override
public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete,
        final Callback1<Function1<Meal, Meal>> onIntermediateStateChange) {
    final SafeHtml question = SafeHtmlUtils.fromSafeConstant(ConfirmMealPrompt.selectPromptMessage(mealName));
    final String skipText = messages.editTime_cancelButtonLabel();
    final String acceptText = messages.editTime_confirmButtonLabel();

    FlowPanel content = new FlowPanel();

    TimeQuestion timeQuestion = new TimeQuestion(question, acceptText, skipText, currentTime,
            new TimeQuestion.ResultHandler() {
                @Override//from w  w w  . j  a v a 2s.  c om
                public void handleSkip() {
                    onComplete.call(MealOperation.noChange);
                }

                @Override
                public void handleAccept(Time time) {
                    onComplete.call(MealOperation.update(Meal.updateTimeFunc(time)));
                }
            }, false);

    Button helpButton = ShepherdTour.createTourButton(tour, EditTimePrompt.class.getSimpleName());
    helpButton.getElement().getStyle().setFloat(com.google.gwt.dom.client.Style.Float.RIGHT);
    timeQuestion.promptPanel.insert(helpButton, 0);

    content.add(timeQuestion);

    ShepherdTour.makeShepherdTarget(timeQuestion.promptPanel, timeQuestion.timePicker.hourCounter,
            timeQuestion.timePicker.minuteCounter, timeQuestion.skipButton, timeQuestion.confirmButton);

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}

From source file:net.scran24.user.client.survey.prompts.EmptySurveyPrompt.java

@Override
public SurveyStageInterface getInterface(final Callback1<SurveyOperation> onComplete,
        final Callback1<Function1<Survey, Survey>> onIntermediateStateChange) {

    FlowPanel content = new FlowPanel();

    content.add(/*from  w ww .j a va 2  s  .c o  m*/
            WidgetFactory.createPromptPanel(SafeHtmlUtils.fromSafeConstant(messages.emptySurvey_promptText())));

    Button addMeal = WidgetFactory.createButton(messages.energyValidation_addMealButtonLabel(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(SurveyOperation.addMealRequest(0));
                }
            });

    content.add(WidgetFactory.createButtonsPanel(addMeal));

    return new SurveyStageInterface.Aligned(content, HasHorizontalAlignment.ALIGN_LEFT,
            HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS);
}