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:uk.ac.ncl.openlab.intake24.client.survey.prompts.BrandNamePrompt.java

public SurveyStageInterface getInterface(final Callback1<FoodOperation> onComplete,
        final Callback1<Function1<FoodEntry, FoodEntry>> onIntermediateStateChange) {

    final FlowPanel content = new FlowPanel();

    FlowPanel promptPanel = WidgetFactory.createPromptPanel(
            SafeHtmlUtils.fromSafeConstant(
                    messages.brandName_promptText(SafeHtmlUtils.htmlEscape(description.toLowerCase()))),
            ShepherdTour.createTourButton(tour, BrandNamePrompt.class.getSimpleName()));
    ShepherdTour.makeShepherdTarget(promptPanel);

    content.add(promptPanel);//from   ww w.j  av  a  2s  .  c  o m

    final Button contButton = WidgetFactory.createGreenButton(messages.brandName_continueButtonLabel(),
            "brandNameContinueButton", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(FoodOperation.updateEncoded(new Function1<EncodedFood, EncodedFood>() {
                        @Override
                        public EncodedFood apply(EncodedFood argument) {
                            return argument.withBrand(choice);
                        }
                    }));
                }
            });

    contButton.setEnabled(false);
    contButton.getElement().setId("intake24-brand-continue-button");
    ShepherdTour.makeShepherdTarget(contButton);

    VerticalPanel panel = new VerticalPanel();

    for (final String name : brandNames) {
        RadioButton btn = new RadioButton("brand", name);
        btn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
            @Override
            public void onValueChange(ValueChangeEvent<Boolean> event) {
                if (event.getValue())
                    choice = name;
                contButton.setEnabled(true);
            }
        });
        panel.add(btn);
    }

    panel.setSpacing(4);
    panel.addStyleName("scran24-brand-name-choice-panel");
    panel.getElement().setId("intake24-brand-choice-panel");
    ShepherdTour.makeShepherdTarget(panel);

    content.add(panel);
    content.add(WidgetFactory.createButtonsPanel(contButton));

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

From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.BreadLinkedFoodAmountPrompt.java

License:Apache License

@Override
public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete,
        Callback1<Function1<Pair<FoodEntry, Meal>, Pair<FoodEntry, Meal>>> updateIntermediateState) {
    FlowPanel content = new FlowPanel();

    final EncodedFood food = meal.foods.get(foodIndex).asEncoded();
    final EncodedFood mainFood = meal.foods.get(mainFoodIndex).asEncoded();

    final String foodDescription = SafeHtmlUtils.htmlEscape(food.description().toLowerCase());
    final String mainFoodDescription = SafeHtmlUtils.htmlEscape(mainFood.description().toLowerCase());

    final String quantityStr = NumberFormat.getDecimalFormat().format(quantity);

    final FlowPanel quantityPanel = new FlowPanel();

    FlowPanel promptPanel = WidgetFactory.createPromptPanel(
            SafeHtmlUtils.fromSafeConstant(
                    messages.breadLinkedFood_promptText(foodDescription, mainFoodDescription, quantityStr)),
            ShepherdTour.createTourButton(shepherdTour, BreadLinkedFoodAmountPrompt.class.getSimpleName()));

    PromptUtil.addBackLink(content);/*from   w  ww .ja v  a  2s  . co  m*/
    content.add(promptPanel);
    ShepherdTour.makeShepherdTarget(promptPanel);

    Button allButton = WidgetFactory.createButton(messages.breadLinkedFood_allButtonLabel(),
            new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(MealOperation.updateFood(foodIndex, new Function1<FoodEntry, FoodEntry>() {
                        @Override
                        public FoodEntry apply(FoodEntry argument) {
                            EncodedFood f = argument.asEncoded();
                            return f.withPortionSize(
                                    PortionSize.complete(f.completedPortionSize().multiply(quantity))).withFlag(
                                            ShowBreadLinkedFoodAmountPrompt.FLAG_BREAD_LINKED_FOOD_AMOUNT_SHOWN);
                        }
                    }));
                }
            });

    allButton.getElement().setId("intake24-all-button");
    ShepherdTour.makeShepherdTarget(allButton);

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

    final QuantityCounter counter = new QuantityCounter(0.25, quantity, Math.max(1.0, quantity));

    ShepherdTour.makeShepherdTarget(counter.fractionalCounter);
    ShepherdTour.makeShepherdTarget(counter.wholeLabel);
    ShepherdTour.makeShepherdTarget(counter.wholeCounter);

    Button confirmQuantityButton = WidgetFactory.createGreenButton(messages.quantity_continueButtonLabel(),
            "quantityPromptContinueButton", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    onComplete.call(MealOperation.updateFood(foodIndex, new Function1<FoodEntry, FoodEntry>() {
                        @Override
                        public FoodEntry apply(FoodEntry argument) {
                            EncodedFood f = argument.asEncoded();
                            return f.withPortionSize(
                                    PortionSize.complete(f.completedPortionSize().multiply(counter.getValue())))
                                    .withFlag(
                                            ShowBreadLinkedFoodAmountPrompt.FLAG_BREAD_LINKED_FOOD_AMOUNT_SHOWN);
                        }
                    }));
                }
            });

    quantityPanel.add(counter);
    quantityPanel.add(confirmQuantityButton);

    ShepherdTour.makeShepherdTarget(confirmQuantityButton);

    content.add(quantityPanel);

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

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  ww .  ja  v  a 2 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.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 TemplateFoodData.ComponentDef component = food.data.template.get(componentIndex);

    final FlowPanel content = new FlowPanel();

    PromptUtil.addBackLink(content);//from   w w w. j a  v  a2  s  . c  om

    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 Callback2<FoodData, Integer>() {
        @Override
        public void call(final FoodData result, Integer index) {
            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(), Option.none(), Option.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,
            CompoundFoodPrompt.class.getSimpleName());
}

From source file:uk.ac.ncl.openlab.intake24.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(),
            "confirmCompletionButton", new ClickHandler() {
                @Override// w  w w.  j  av  a 2  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,
            ConfirmCompletionPrompt.class.getSimpleName());
}

From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.ConfirmCompletionPromptFlexibleRecall.java

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

    FlowPanel content = new FlowPanel();

    Button confirm = WidgetFactory.createGreenButton(messages.completion_submitButtonLabel(),
            "confirmCompletionButton", new ClickHandler() {
                @Override/* w  w  w  .ja v a 2s  . c om*/
                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.createPromptPanel(promptText));
    if (!timeIsValid) {
        FlowPanel alertPanel = createAlert(
                "Please submit your recall no earlier than " + MIN_SUBMIT_HOUR + ":" + MIN_SUBMIT_MINUTE);
        content.add(alertPanel);
        confirm.getElement().setAttribute("disabled", "disabled");
    }
    content.add(WidgetFactory.createButtonsPanel(confirm));

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

From source file:uk.ac.ncl.openlab.intake24.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//  ww  w  . java  2 s  .c  om
                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,
            ConfirmMealPrompt.class.getSimpleName());
}

From source file:uk.ac.ncl.openlab.intake24.client.survey.prompts.ConfirmMealPromptFlexibleRecall.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();

    TimeQuestionFlexibleRecall timeQuestion = new TimeQuestionFlexibleRecall(promptText, acceptText, skipText,
            initialTime, new TimeQuestionFlexibleRecall.ResultHandler() {
                @Override/*from   w ww . jav a2 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, stateManager);

    Button helpButton = ShepherdTour.createTourButton(tour,
            ConfirmMealPromptFlexibleRecall.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,
            ConfirmMealPromptFlexibleRecall.class.getSimpleName());
}

From source file:uk.ac.ncl.openlab.intake24.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/*from   ww  w . j a  va2s. com*/
        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,
            ConfirmTimeGapPrompt.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//from w  w  w.  j  a  v a 2s  .c  o  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());
}