List of usage examples for com.google.gwt.user.client.ui Label addClickHandler
public HandlerRegistration addClickHandler(ClickHandler handler)
From source file:net.cbtltd.client.panel.ReservationPopup.java
private VerticalPanel createContent() { VerticalPanel form = new VerticalPanel(); final Label title = new Label(CONSTANTS.titleLabel()); title.addStyleName(AbstractField.CSS.cbtAbstractPopupLabel()); form.add(title);//from w ww . j av a 2 s .c o m final Label closeButton = new Label(); closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ReservationPopup.this.hide(); } }); closeButton.addStyleName(AbstractField.CSS.cbtAbstractPopupClose()); form.add(closeButton); //----------------------------------------------- // Reservation number //----------------------------------------------- reservationField = new SuggestField(this, null, new NameIdAction(Service.RESERVATION), CONSTANTS.reservationnameLabel(), 20, tab++); reservationField.setFieldHalf(); reservationField.setEnabled(false); reservationField.setHelpText(CONSTANTS.reservationHelp()); form.add(reservationField); //----------------------------------------------- // Supplier field //----------------------------------------------- // supplierField = new SuggestField(this, null, // new NameIdAction(Service.PARTY), // CONSTANTS.supplierLabel(), // 20, // tab++); // supplierField.setType(Party.Type.Organization.name()); // supplierField.setEnabled(false); // supplierField.setHelpText(CONSTANTS.supplierHelp()); // form.add(supplierField); //----------------------------------------------- // Product field //----------------------------------------------- productField = new SuggestField(this, null, new NameIdAction(Service.PRODUCT), CONSTANTS.productLabel(), 20, tab++); productField.setType(Product.Type.Accommodation.name()); productField.setAllOrganizations(true); productField.setEnabled(false); productField.setHelpText(CONSTANTS.productHelp()); form.add(productField); //----------------------------------------------- // Agent field //----------------------------------------------- // agentField = new SuggestField(this, null, // new NameIdAction(Service.PARTY), // CONSTANTS.agentLabel(), // 20, // tab++); // agentField.setEnabled(false); // agentField.setHelpText(CONSTANTS.agentHelp()); // form.add(agentField); // //----------------------------------------------- // Customer (Guest) field //----------------------------------------------- customerField = new SuggestField(this, null, new NameIdAction(Service.PARTY), CONSTANTS.customerLabel(), 20, tab++); customerField.setType(Party.Type.Customer.name()); customerField.setHelpText(CONSTANTS.customerHelp()); Image customerButton = new Image(AbstractField.BUNDLE.plus()); customerButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { PartyPopup.getInstance().show(Party.Type.Customer, customerField, null); } }); customerField.addButton(customerButton); customerField.setFieldStyle(AbstractField.CSS.cbtSuggestFieldSecure()); form.add(customerField); //----------------------------------------------- // Guest Email Address field //----------------------------------------------- emailaddressField = new TextField(this, null, CONSTANTS.emailaddressLabel(), tab++); emailaddressField.setMaxLength(100); emailaddressField.setHelpText(CONSTANTS.emailaddressHelp()); form.add(emailaddressField); //----------------------------------------------- // Guest First Name field //----------------------------------------------- firstnameField = new TextField(this, null, CONSTANTS.firstnameLabel(), tab++); firstnameField.setMaxLength(100); firstnameField.setHelpText(CONSTANTS.firstnameHelp()); form.add(firstnameField); //----------------------------------------------- // Guest Family Name field //----------------------------------------------- familynameField = new TextField(this, null, CONSTANTS.familynameLabel(), tab++); familynameField.setMaxLength(100); familynameField.setHelpText(CONSTANTS.familynameHelp()); form.add(familynameField); //----------------------------------------------- // Arrival and Departure Dates //----------------------------------------------- fromtodateField = new DatespanField(this, null, CONSTANTS.fromtodateLabel(), tab++); // fromtodateField.setDefaultDuration(1.0); fromtodateField.setHelpText(CONSTANTS.fromtodateHelp()); form.add(fromtodateField); //----------------------------------------------- // Quoted Price field //----------------------------------------------- quoteField = new MoneyField(this, null, CONSTANTS.quoteLabel(), tab++); quoteField.setEnabled(AbstractRoot.writeable(AccessControl.QUOTE_PERMISSION)); quoteField.setUnitenabled(false); quoteField.setHelpText(CONSTANTS.quoteHelp()); form.add(quoteField); //----------------------------------------------- // Rack Rate field //----------------------------------------------- priceField = new MoneyField(this, null, CONSTANTS.priceLabel(), tab++); priceField.setEnabled(false); priceField.setUnitenabled(false); priceField.setHelpText(CONSTANTS.priceHelp()); form.add(priceField); //----------------------------------------------- // STO field //----------------------------------------------- costField = new MoneyField(this, null, CONSTANTS.discountLabel(), tab++); costField.setEnabled(false); costField.setUnitenabled(false); costField.setHelpText(CONSTANTS.discountHelp()); //form.add(costField); //----------------------------------------------- // Notes field //----------------------------------------------- notesField = new TextAreaField(this, null, CONSTANTS.notesLabel(), tab++); notesField.setMaxLength(3000); notesField.setHelpText(CONSTANTS.notesHelp()); form.add(notesField); //----------------------------------------------- // Logo field //----------------------------------------------- final Image paygate = new Image(AbstractField.BUNDLE.paygate()); // final Image godaddy= new Image(AbstractField.BUNDLE.godaddy()); final Image thawte = new Image(AbstractField.BUNDLE.thawte()); final Image mastercard = new Image(AbstractField.BUNDLE.mastercard()); final Image visa = new Image(AbstractField.BUNDLE.visa()); logoImages = new HorizontalPanel(); logoImages.setTitle(CONSTANTS.logoLabel()); logoImages.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); logoImages.addStyleName(AbstractField.CSS.cbtAbstractPopupLabel()); logoImages.add(paygate); // images.add(godaddy); logoImages.add(thawte); logoImages.add(mastercard); logoImages.add(visa); form.add(logoImages); //----------------------------------------------- // Card Holder Name field //----------------------------------------------- cardholderField = new TextField(this, null, CONSTANTS.cardholderLabel(), tab++); cardholderField.setMaxLength(50); cardholderField.setHelpText(CONSTANTS.cardholderHelp()); form.add(cardholderField); //----------------------------------------------- // Card Number field //----------------------------------------------- cardnumberField = new TextField(this, null, CONSTANTS.cardnumberLabel(), tab++); cardnumberField.setHelpText(CONSTANTS.cardnumberHelp()); form.add(cardnumberField); //----------------------------------------------- // Card Expiry Month field //----------------------------------------------- cardmonthField = new ListField(this, null, Finance.getMonths(), null, false, tab++); carddetailLabel = new HelpLabel(CONSTANTS.carddetailLabel(), CONSTANTS.carddetailHelp(), cardmonthField); form.add(carddetailLabel); cardmonthField.setFieldStyle(AbstractField.CSS.cbtListFieldCCmonth()); //----------------------------------------------- // Card Expiry Year field //----------------------------------------------- cardyearField = new ListField(this, null, Finance.getYears(), null, false, tab++); cardyearField.setFieldStyle(AbstractField.CSS.cbtListFieldCCyear()); //----------------------------------------------- // Card Security Code field //----------------------------------------------- cardcodeField = new TextField(this, null, null, tab++); cardcodeField.setFieldStyle(AbstractField.CSS.cbtTextFieldCCcode()); HorizontalPanel ccc = new HorizontalPanel(); ccc.add(cardmonthField); ccc.add(cardyearField); ccc.add(cardcodeField); form.add(ccc); //----------------------------------------------- // Deposit Amount field //----------------------------------------------- amountField = new DoubleunitField(this, null, // NameId.getList(Currency.EXCHANGE_CURRENCY_NAMES, Currency.EXCHANGE_CURRENCIES), new CurrencyrateNameId(), CONSTANTS.amountLabel(), AbstractField.AF, tab++); amountField.setHelpText(CONSTANTS.amountHelp()); amountField.setEnabled(false); amountField.setUnitenabled(false); form.add(amountField); //----------------------------------------------- // Message field //----------------------------------------------- messageField = new TextAreaField(this, null, CONSTANTS.messageLabel(), tab++); messageField.setHelpText(CONSTANTS.messageHelp()); form.add(messageField); form.add(createCommands()); onRefresh(); onReset(Reservation.State.Provisional.name()); return form; }
From source file:net.cbtltd.client.panel.RulePopup.java
private VerticalPanel createContent() { final VerticalPanel form = new VerticalPanel(); final Label title = new Label(CONSTANTS.ruleLabel()); title.addStyleName(AbstractField.CSS.cbtAbstractPopupLabel()); form.add(title);/* w w w .ja v a 2 s.com*/ final Label closeButton = new Label(); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { RulePopup.this.hide(); } }); closeButton.addStyleName(AbstractField.CSS.cbtAbstractPopupClose()); form.add(closeButton); //----------------------------------------------- // Name field //----------------------------------------------- nameField = new SuggestField(this, null, new NameIdAction(Service.ATTRIBUTE), CONSTANTS.nameLabel(), 20, tab++); nameField.setType(Value.Type.LeaseRule.name()); nameField.setHelpText(CONSTANTS.nameHelp()); Image nameButton = new Image(AbstractField.BUNDLE.plus()); nameButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ValuePopup.getInstance().show(Value.Type.LeaseRule, CONSTANTS.nameLabel(), NameId.Type.Rule.name() + modelid, nameField); } }); nameButton.setTitle(CONSTANTS.namebuttonHelp()); nameField.addButton(nameButton); form.add(nameField); // ----------------------------------------------- // Date Range field // ----------------------------------------------- fromtodateField = new DatespanField(this, null, CONSTANTS.fromtodateLabel(), tab++); fromtodateField.setHelpText(CONSTANTS.fromtodateError()); fromtodateField.setHelpText(CONSTANTS.fromtodateHelp()); form.add(fromtodateField); // ----------------------------------------------- // Quantity field // ----------------------------------------------- quantityField = new DoubleunitField(this, null, NameId.getList(CONSTANTS.units(), UNITS), CONSTANTS.quantityLabel(), AbstractField.QF, tab++); quantityField.setRange(0.0, 1000000.0); quantityField.setHelpText(CONSTANTS.quantityHelp()); form.add(quantityField); // ----------------------------------------------- // Unit Rule field // ----------------------------------------------- valueField = new DoubleunitField(this, null, new CurrencyNameId(), CONSTANTS.valueLabel(), AbstractField.AF, tab++); valueField.setRange(0.01, 1000000.0); valueField.setHelpText(CONSTANTS.valueHelp()); form.add(valueField); form.add(createCommands()); onRefresh(); onReset(Rule.CREATED); return form; }
From source file:net.cbtltd.client.panel.SessionPopup.java
private VerticalPanel createContent() { VerticalPanel form = new VerticalPanel(); form.addStyleName(CSS.magnify()); final Label closeButton = new Label(); closeButton.addClickHandler(new ClickHandler() { @Override//from w w w. j av a2s.c o m public void onClick(ClickEvent event) { SessionPopup.this.hide(); } }); closeButton.addStyleName(AbstractField.CSS.cbtAbstractPopupClose()); form.add(closeButton); final HTML helpLabel = new HTML(CONSTANTS.helpLabel()); helpLabel.addStyleName(AbstractField.CSS.cbtAbstractField()); helpLabel.addStyleName(CSS.helpLabel()); form.add(helpLabel); //----------------------------------------------- // Email address to identify user //----------------------------------------------- emailaddressField = new TextField(this, null, CONSTANTS.emailaddressLabel(), tab++); emailaddressField.setDefaultValue(Cookies.getCookie("emailaddress")); emailaddressField.setFocus(true); emailaddressField.setHelpText(CONSTANTS.emailaddressHelp()); form.add(emailaddressField); //----------------------------------------------- // Password field //----------------------------------------------- passwordField = new PasswordField(this, null, CONSTANTS.passwordLabel(), tab++); passwordField.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { sessionLogin.execute(); } }); passwordField.setSecure(true); passwordField.addStyleName(CSS.passwordField()); passwordField.setHelpText(CONSTANTS.passwordHelp()); form.add(passwordField); //----------------------------------------------- // Request New Password button //----------------------------------------------- passwordcreateButton = new Label(CONSTANTS.passwordcreateLabel()); passwordcreateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { passwordCreate.execute(); } }); passwordcreateButton.addStyleName(CSS.passwordcreateStyle()); form.add(passwordcreateButton); //----------------------------------------------- // Auto Login field //----------------------------------------------- autologinField = new CheckField(this, null, CONSTANTS.autologinLabel(), tab++); autologinField.setReadOption(Session.LOGGED_OUT, true); autologinField.setDefaultValue(false); //form.add(autologinField); final HorizontalPanel bar = new HorizontalPanel(); bar.addStyleName(AbstractField.CSS.cbtAbstractCommand()); //----------------------------------------------- // Login button //----------------------------------------------- final CommandButton loginButton = new CommandButton(this, CONSTANTS.loginLabel(), sessionLogin, tab++); loginButton.addStyleName(AbstractField.CSS.cbtGradientGreen()); bar.add(loginButton); bar.add(autologinField); form.add(bar); //----------------------------------------------- // Transition array to define the finite state machine //----------------------------------------------- fsm = new ArrayList<Transition>(); fsm.add(new Transition(Session.LOGGED_OUT, loginButton, Session.LOGGED_IN)); onReset(Session.LOGGED_OUT); return form; }
From source file:net.scran24.user.client.survey.flat.MealPanel.java
License:Apache License
private void addFoodRow(UnorderedList<FlowPanel> list, final WithIndex<FoodEntry> f) { String desc = f.value.description(); FlowPanel foodRow = new FlowPanel(); foodRow.addStyleName("intake24-food"); Label foodLabel = new Label(desc); foodLabel.addStyleName("intake24-food-name"); if (!f.value.link.linkedTo.isEmpty()) foodLabel.addStyleName("intake24-linked-food-name"); foodLabel.addClickHandler(new ClickHandler() { @Override/* ww w .java 2s . c o m*/ public void onClick(ClickEvent event) { requestSelectionChange .call(new Selection.SelectedFood(mealIndex, f.index, SelectionMode.MANUAL_SELECTION)); } }); FlowPanel encodingComplete = new FlowPanel(); FlowPanel portionSizeComplete = new FlowPanel(); if (!f.value.isTemplate()) { foodRow.add(portionSizeComplete); foodRow.add(encodingComplete); } foodRow.add(foodLabel); if (!f.value.isRaw()) { encodingComplete.addStyleName("intake24-checkbox-checked-icon"); encodingComplete.setTitle(messages.navPanelMatchedTooltip()); } else { encodingComplete.addStyleName("intake24-checkbox-unchecked-icon"); encodingComplete.setTitle(messages.navPanelNotMatchedTooltip()); } if (f.value.isPortionSizeComplete()) { portionSizeComplete.addStyleName("intake24-checkbox-checked-icon"); portionSizeComplete.setTitle(messages.navPanelPortionSizeComplete()); } else { portionSizeComplete.addStyleName("intake24-checkbox-unchecked-icon"); portionSizeComplete.setTitle(messages.navPanelPortionSizeIncomplete()); } boolean thisFoodSelected = selection.accept(new Visitor<Boolean>() { @Override public Boolean visitMeal(SelectedMeal meal) { return false; } @Override public Boolean visitFood(SelectedFood food) { return (food.mealIndex == mealIndex) && (food.foodIndex == f.index); } @Override public Boolean visitNothing(EmptySelection selection) { return false; } }); if (thisFoodSelected) foodRow.addStyleName("intake24-selected-food"); list.addItem(foodRow); }
From source file:net.scran24.user.client.survey.flat.MealPanel.java
License:Apache License
public MealPanel(final Meal meal, final int mealIndex, final Selection selection, final Callback1<Selection> requestSelectionChange) { this.mealIndex = mealIndex; this.selection = selection; this.requestSelectionChange = requestSelectionChange; FlowPanel contents = new FlowPanel(); initWidget(contents);//from w ww . ja v a2 s .co m boolean thisMealSelected = selection.accept(new Visitor<Boolean>() { @Override public Boolean visitMeal(SelectedMeal meal) { return meal.mealIndex == mealIndex; } @Override public Boolean visitFood(SelectedFood food) { return false; } @Override public Boolean visitNothing(EmptySelection selection) { return false; } }); final FlowPanel mealRow = new FlowPanel(); mealRow.addStyleName("intake24-meal"); if (thisMealSelected) mealRow.addStyleName("intake24-selected-meal"); final Label label = new Label(meal.name); label.addStyleName("intake24-meal-name"); label.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { requestSelectionChange.call(new Selection.SelectedMeal(mealIndex, SelectionMode.MANUAL_SELECTION)); } }); meal.time.accept(new SideEffectVisitor<Time>() { @Override public void visitSome(Time item) { Label timeLabel = new Label(meal.time.getOrDie().toString()); timeLabel.addStyleName("intake24-meal-time"); mealRow.add(timeLabel); } @Override public void visitNone() { final FlowPanel questionIcon = new FlowPanel(); questionIcon.addStyleName("intake24-meal-question-icon"); questionIcon.setTitle(messages.navPanelSuggestedTooltip()); mealRow.add(questionIcon); } }); mealRow.add(label); contents.add(mealRow); if (!meal.foods.isEmpty()) { UnorderedList<FlowPanel> foodList = new UnorderedList<FlowPanel>(); foodList.addStyleName("intake24-food-list"); PVector<WithIndex<FoodEntry>> withIndex = zipWithIndex(meal.foods); PVector<WithIndex<FoodEntry>> topLevel = filter(withIndex, new Function1<WithIndex<FoodEntry>, Boolean>() { @Override public Boolean apply(WithIndex<FoodEntry> argument) { return argument.value.link.linkedTo.isEmpty(); } }); for (final WithIndex<FoodEntry> f : topLevel) { addFoodRow(foodList, f); PVector<WithIndex<FoodEntry>> linkedToThis = filter(withIndex, new Function1<WithIndex<FoodEntry>, Boolean>() { @Override public Boolean apply(WithIndex<FoodEntry> argument) { return argument.value.link.linkedTo.accept(new Option.Visitor<UUID, Boolean>() { @Override public Boolean visitSome(UUID item) { return item.equals(f.value.link.id); } @Override public Boolean visitNone() { return false; } }); } }); for (final WithIndex<FoodEntry> linked : linkedToThis) { addFoodRow(foodList, linked); } } contents.add(foodList); } }
From source file:net.scran24.user.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);/* w ww. ja va2 s. c om*/ 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); }
From source file:net.scran24.user.client.survey.prompts.FoodBrowser.java
License:Apache License
private Widget createFoodButton(final FoodHeader foodHeader) { String description;/*from w w w. j av a 2 s .co m*/ if (foodHeader.code.equals(SpecialData.FOOD_CODE_SANDWICH)) description = messages.foodBrowser_homemadeSandwich(); else if (foodHeader.code.equals(SpecialData.FOOD_CODE_SALAD)) description = messages.foodBrowser_homemadeSalad(); else description = foodHeader.description(); Label item = new Label(description); item.addStyleName("intake24-food-browser-food"); if (foodHeader.code.equals(SpecialData.FOOD_CODE_SANDWICH)) item.addStyleName("intake24-food-browser-sandwich-wizard"); else if (foodHeader.code.equals(SpecialData.FOOD_CODE_SALAD)) item.addStyleName("intake24-food-browser-salad-wizard"); item.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { if (foodHeader.code.equals(SpecialData.FOOD_CODE_SANDWICH) || foodHeader.code.equals(SpecialData.FOOD_CODE_SALAD)) { onSpecialFoodChosen.call(foodHeader.code); } else lookupService.getFoodData(foodHeader.code, locale, new AsyncCallback<FoodData>() { @Override public void onFailure(Throwable caught) { contents.clear(); contents.add(WidgetFactory.createDefaultErrorMessage()); } @Override public void onSuccess(final FoodData result) { onFoodChosen.call(result); } }); } }); return item; }
From source file:net.scran24.user.client.survey.prompts.FoodBrowser.java
License:Apache License
private void show(final LookupResult result, final String resultName, final String foodHeader, final String categoryHeader) { final FlowPanel ui = new FlowPanel(); ui.addStyleName("intake24-food-browser-ui"); ui.add(historyBackLink());//from www. j av a 2s .c om if (!result.foods.isEmpty()) { foodsContainer = new FlowPanel(); foodsContainer.addStyleName("intake24-food-browser-foods-container"); foodsContainer.getElement().setId("intake24-food-browser-foods-container"); for (final FoodHeader food : result.foods) if (food.code.equals(SpecialData.FOOD_CODE_SANDWICH) || food.code.equals(SpecialData.FOOD_CODE_SALAD)) foodsContainer.add(createFoodButton(food)); HTMLPanel header = new HTMLPanel("h2", foodHeader); foodsContainer.add(header); for (final FoodHeader food : result.foods) if (!(food.code.equals(SpecialData.FOOD_CODE_SANDWICH) || food.code.equals(SpecialData.FOOD_CODE_SALAD))) foodsContainer.add(createFoodButton(food)); ui.add(foodsContainer); } else { foodsContainer = null; } if (!result.categories.isEmpty()) { categoriesContainer = new FlowPanel(); categoriesContainer.addStyleName("intake24-food-browser-categories-container"); categoriesContainer.getElement().setId("intake24-food-browser-categories-container"); HTMLPanel header = new HTMLPanel("h2", categoryHeader); categoriesContainer.add(header); for (final CategoryHeader categoryData : result.categories) { Label item = new Label(categoryData.description()); item.addStyleName("intake24-food-browser-category"); item.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { pushHistory(result, resultName, foodHeader, categoryHeader); browse(categoryData.code, categoryData.description()); } }); categoriesContainer.add(item); } ui.add(categoriesContainer); } else { categoriesContainer = null; } if (result.categories.isEmpty() && result.foods.isEmpty()) { FlowPanel div = new FlowPanel(); div.addStyleName("intake24-food-lookup-no-results"); div.add(new HTMLPanel(messages.foodBrowser_searchResultsEmpty())); ui.add(div); } FlowPanel div = new FlowPanel(); div.addStyleName("intake24-food-browser-browse-all-container"); final Panel buttonsPanel = WidgetFactory.createButtonsPanel(); div.add(buttonsPanel); if (allowBrowsingAllFoods) { browseAllFoodsButton = WidgetFactory.createButton(messages.foodBrowser_browseAllFoodsLabel()); browseAllFoodsButton.addStyleName("intake24-food-browser-browse-all-button"); browseAllFoodsButton.getElement().setId("intake24-food-browser-browse-all-button"); browseAllFoodsButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { pushHistory(result, resultName, foodHeader, categoryHeader); limitBrowseAllCategory.accept(new Option.SideEffectVisitor<Pair<String, String>>() { @Override public void visitSome(Pair<String, String> item) { browse(item.left, item.right); } @Override public void visitNone() { browseAll(); } }); } }); buttonsPanel.add(browseAllFoodsButton); } else { browseAllFoodsButton = null; } cantFindButton = WidgetFactory.createButton(messages.foodBrowser_cantFindButtonLabel()); cantFindButton.getElement().setId("intake24-food-browser-cant-find-button"); tryAgainButton = null; missingFoodButton = null; cantFindPopupPrompt = null; cantFindButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent arg0) { cantFindButton.setEnabled(false); final FlowPanel fadeDiv = new FlowPanel(); fadeDiv.addStyleName("intake24-food-browser-overlay"); final FlowPanel popupDiv = new FlowPanel(); popupDiv.addStyleName("intake24-food-browser-popup"); popupDiv.getElement().setId("cant-find-food-popup"); cantFindPopupPrompt = new HTMLPanel(allowBrowsingAllFoods ? SafeHtmlUtils.fromSafeConstant(messages.foodBrowser_cantFindFullPopupContents()) : SafeHtmlUtils.fromSafeConstant(messages.foodBrowser_cantFindBrowseOnlyPopupContents())); tryAgainButton = WidgetFactory.createButton(messages.foodBrowser_cantFindTryAgainButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { cantFindButton.setEnabled(true); popupDiv.removeFromParent(); PromptInterfaceManager.scrollPromptIntoView(); tryAgainButton = null; missingFoodButton = null; cantFindPopupPrompt = null; // fadeDiv.removeFromParent(); } }); tryAgainButton.getElement().setId("intake24-food-browser-try-again-button"); missingFoodButton = WidgetFactory.createButton(messages.foodBrowser_reportMissingFoodButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { GoogleAnalytics.trackMissingFoodReported(); onMissingFoodReported.call(); } }); missingFoodButton.getElement().setId("intake24-food-browser-missing-food-button"); popupDiv.add(cantFindPopupPrompt); popupDiv.add(WidgetFactory.createButtonsPanel(tryAgainButton, missingFoodButton)); // ui.add(fadeDiv); ui.add(popupDiv); Scheduler.get().scheduleDeferred(new ScheduledCommand() { public native void scrollIntoView() /*-{ $wnd.$('html, body').animate({ scrollTop : $wnd.$("#cant-find-food-popup").offset().top }, 500); }-*/; @Override public void execute() { scrollIntoView(); } }); } }); skipFoodHandler.accept(new Option.SideEffectVisitor<SkipFoodHandler>() { @Override public void visitSome(final SkipFoodHandler handler) { skipFoodButton = WidgetFactory.createButton(handler.skipButtonLabel, new ClickHandler() { @Override public void onClick(ClickEvent event) { handler.onFoodSkipped.call(); } }); skipFoodButton.getElement().setId("intake24-food-browser-skip-food-button"); buttonsPanel.add(skipFoodButton); } @Override public void visitNone() { skipFoodButton = null; } }); buttonsPanel.add(cantFindButton); ui.add(div); contents.clear(); contents.add(ui); IEHack.forceReflowDeferred(); }
From source file:nl.mpi.tg.eg.experiment.client.view.AnnotationTimelinePanel.java
License:Open Source License
private void insertTierAnnotation(final AnnotationData annotationData, final VideoPanel videoPanel, final AnnotationTimelineView annotationTimelineView) { final Label label1 = new Label(annotationData.getAnnotationHtml()); label1.setStylePrimaryName("annotationTimelineTierSegment"); final SingleShotEventListner tierSegmentListner = new SingleShotEventListner() { @Override/*from w w w .ja v a2 s .c o m*/ protected void singleShotFired() { // if (addAnnotationButton != null) { // // todo: this would be better if the button was not added when a tier is clicked // absolutePanel.remove(addAnnotationButton); // } clearHighlights(); videoPanel.playSegment(annotationData); annotationTimelineView.setEditingAnnotation(annotationData); label1.setStyleDependentName("Highlight", true); resetSingleShot(); } }; label1.addClickHandler(tierSegmentListner); label1.addTouchStartHandler(tierSegmentListner); label1.addTouchMoveHandler(tierSegmentListner); label1.addTouchEndHandler(tierSegmentListner); label1.setWidth(getWidth(annotationData, videoPanel.getDurationTime()) + "px"); final int topPosition = getTierTopPosition(annotationData.getStimulus()); absolutePanel.add(label1, getLeftPosition(annotationData, videoPanel.getDurationTime()), topPosition); annotationLebels.put(annotationData, label1); }
From source file:nl.mpi.tg.eg.experiment.client.view.MenuButton.java
License:Open Source License
public MenuButton(final PresenterEventListner presenterListerner) { final Label headerIcon = new Label(); headerIcon.addStyleName("headerIcon"); if (presenterListerner != null) { final Label headerArrow = new Label(); headerArrow.addStyleName("headerArrow"); this.add(headerArrow); final Label headerButton = new Label(presenterListerner.getLabel()); headerButton.addStyleName("headerButton"); this.add(headerButton); SingleShotEventListner singleShotEventListner = new SingleShotEventListner() { @Override/* w w w .j a v a2 s .c o m*/ protected void singleShotFired() { presenterListerner.eventFired(null, this); } }; headerArrow.addClickHandler(singleShotEventListner); headerButton.addClickHandler(singleShotEventListner); headerIcon.addClickHandler(singleShotEventListner); headerArrow.addTouchStartHandler(singleShotEventListner); headerButton.addTouchStartHandler(singleShotEventListner); headerIcon.addTouchStartHandler(singleShotEventListner); headerArrow.addTouchMoveHandler(singleShotEventListner); headerButton.addTouchMoveHandler(singleShotEventListner); headerIcon.addTouchMoveHandler(singleShotEventListner); headerArrow.addTouchEndHandler(singleShotEventListner); headerButton.addTouchEndHandler(singleShotEventListner); headerIcon.addTouchEndHandler(singleShotEventListner); } this.add(headerIcon); }