List of usage examples for com.google.gwt.event.dom.client FocusHandler FocusHandler
FocusHandler
From source file:stroom.widget.dropdowntree.client.view.QuickFilter.java
License:Apache License
public QuickFilter() { RESOURCES.style().ensureInjected();/* www . j ava 2s .c om*/ setStyleName(RESOURCES.style().quickFilter() + " stroom-border stroom-content"); textBox.setStyleName(RESOURCES.style().textBox()); label.setStyleName(RESOURCES.style().label()); clearButton = GlyphButton.create(GlyphIcons.CLEAR); clearButton.addStyleName(RESOURCES.style().clear()); add(textBox); add(label); add(clearButton); label.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { label.setVisible(false); textBox.setFocus(true); } }); textBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(final FocusEvent event) { label.setVisible(false); } }); textBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(final BlurEvent event) { reset(); } }); textBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(final KeyUpEvent event) { onChange(); } }); clearButton.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { clear(); } }); onChange(); }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.widget.RichTextAreaExtended.java
License:Apache License
@Override public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) { if (!hasHandlers) { addFocusHandler(new FocusHandler() { @Override/* w w w . j ava 2s . co m*/ public void onFocus(FocusEvent event) { fireValueChangeEvent(); } }); addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { fireValueChangeEvent(); } }); addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { fireValueChangeEvent(); } }); hasHandlers = true; } return addHandler(handler, ValueChangeEvent.getType()); }
From source file:uk.ac.ncl.openlab.intake24.client.survey.scheme.MultipleChoiceCheckboxQuestion.java
@Override public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete, Callback2<Survey, Boolean> onIntermediateStateChange) { final FlowPanel content = new FlowPanel(); content.addStyleName("intake24-multiple-choice-question"); content.addStyleName("intake24-survey-content-container"); content.add(WidgetFactory.createPromptPanel(questionText)); FlowPanel checkboxesDiv = new FlowPanel(); checkboxesDiv.addStyleName("scran24-ready-meals-checkboxes-block"); final ArrayList<CheckBox> checkBoxes = new ArrayList<CheckBox>(); for (String option : options) { FlowPanel rowDiv = new FlowPanel(); CheckBox checkBox = new CheckBox(SafeHtmlUtils.htmlEscape(option)); checkBox.setFormValue(option);/* w w w .j a v a 2 s . c o m*/ checkBox.addStyleName("scran24-ready-meals-checkbox"); checkBoxes.add(checkBox); rowDiv.add(checkBox); checkboxesDiv.add(rowDiv); } if (!otherOptionName.isEmpty()) { FlowPanel otherPanel = new FlowPanel(); otherOption = new CheckBox(otherOptionName.getOrDie() + ": "); otherPanel.add(otherOption); otherBox = new TextBox(); otherPanel.add(otherBox); checkboxesDiv.add(otherPanel); otherBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { otherOption.setValue(true); } }); } content.add(checkboxesDiv); Button accept = WidgetFactory.createGreenButton(acceptText, "multipleChoiceCheckboxContinueButton", new ClickHandler() { @Override public void onClick(ClickEvent event) { StringBuilder value = new StringBuilder(); boolean first = true; for (CheckBox checkBox : checkBoxes) if (checkBox.getValue()) { if (first) first = false; else value.append(", "); value.append(checkBox.getFormValue()); } if (!otherOptionName.isEmpty()) { if (otherOption.getValue()) { if (!first) value.append(", "); value.append(otherBox.getText()); } } onComplete.call(state.withData(dataField, value.toString())); } }); content.add(checkboxesDiv); content.add(accept); return new SimpleSurveyStageInterface(content, MultipleChoiceCheckboxQuestion.class.getSimpleName()); }