List of usage examples for com.google.gwt.event.dom.client FocusHandler FocusHandler
FocusHandler
From source file:org.bonitasoft.forms.client.view.widget.ElementAttributeSupport.java
License:Open Source License
protected void addHtmlAttribute(Widget fieldWidget, final String htmlAttributeName, final String htmlAttributeValue) { //Working for bug 4991: the "Html Attributes" of date widget if (fieldWidget instanceof DateBox) { fieldWidget = ((DateBox) fieldWidget).getTextBox(); }/* w ww .j a v a 2 s . c o m*/ try { final SUPPORTED_EVENT event = SUPPORTED_EVENT.valueOf(htmlAttributeName.toLowerCase()); switch (event) { case onclick: ((HasClickHandlers) fieldWidget).addClickHandler(new ClickHandler() { public void onClick(final ClickEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case ondbclick: ((HasDoubleClickHandlers) fieldWidget).addDoubleClickHandler(new DoubleClickHandler() { public void onDoubleClick(final DoubleClickEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onblur: ((HasBlurHandlers) fieldWidget).addBlurHandler(new BlurHandler() { public void onBlur(final BlurEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onchange: if (fieldWidget instanceof HasChangeHandlers) { ((HasChangeHandlers) fieldWidget).addChangeHandler(new ChangeHandler() { public void onChange(final ChangeEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); } else if (fieldWidget instanceof HasValueChangeHandlers<?>) { final HasValueChangeHandlers<Serializable> widget = (HasValueChangeHandlers<Serializable>) fieldWidget; widget.addValueChangeHandler(new ValueChangeHandler<Serializable>() { public void onValueChange(final ValueChangeEvent<Serializable> event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); } break; case onfocus: ((HasFocusHandlers) fieldWidget).addFocusHandler(new FocusHandler() { public void onFocus(final FocusEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onkeydown: ((HasKeyDownHandlers) fieldWidget).addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(final KeyDownEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onkeyup: ((HasKeyUpHandlers) fieldWidget).addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(final KeyUpEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onkeypress: ((HasKeyUpHandlers) fieldWidget).addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(final KeyUpEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onmousedown: ((HasMouseDownHandlers) fieldWidget).addMouseDownHandler(new MouseDownHandler() { public void onMouseDown(final MouseDownEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onmouseup: ((HasMouseUpHandlers) fieldWidget).addMouseUpHandler(new MouseUpHandler() { public void onMouseUp(final MouseUpEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onmouseover: ((HasMouseOverHandlers) fieldWidget).addMouseOverHandler(new MouseOverHandler() { public void onMouseOver(final MouseOverEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onmouseout: ((HasMouseOutHandlers) fieldWidget).addMouseOutHandler(new MouseOutHandler() { public void onMouseOut(final MouseOutEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; case onmousemove: ((HasMouseMoveHandlers) fieldWidget).addMouseMoveHandler(new MouseMoveHandler() { public void onMouseMove(final MouseMoveEvent event) { DOMUtils.getInstance().javascriptEval(htmlAttributeValue); } }); break; default: break; } } catch (final Exception e) { if (fieldWidget instanceof CheckBox || fieldWidget instanceof CheckboxGroupWidget || fieldWidget instanceof RadioButtonGroupWidget || fieldWidget instanceof FileUploadWidget || fieldWidget instanceof SuggestBox || fieldWidget instanceof AsyncSuggestBoxWidget || fieldWidget instanceof DateBox) { final NodeList<Element> inputs = fieldWidget.getElement().getElementsByTagName("input"); if (inputs != null) { for (int i = 0; i < inputs.getLength(); i++) { inputs.getItem(i).setAttribute(htmlAttributeName, htmlAttributeValue); } } } else if (fieldWidget instanceof DurationWidget) { final NodeList<Element> selects = fieldWidget.getElement().getElementsByTagName("select"); if (selects != null) { for (int i = 0; i < selects.getLength(); i++) { selects.getItem(i).setAttribute(htmlAttributeName, htmlAttributeValue); } } } else if (fieldWidget instanceof ImageWidget) { final NodeList<Element> images = fieldWidget.getElement().getElementsByTagName("img"); if (images != null) { for (int i = 0; i < images.getLength(); i++) { images.getItem(i).setAttribute(htmlAttributeName, htmlAttributeValue); } } } else if (fieldWidget instanceof FileDownloadWidget) { final NodeList<Element> links = fieldWidget.getElement().getElementsByTagName("a"); if (links != null) { for (int i = 0; i < links.getLength(); i++) { links.getItem(i).setAttribute(htmlAttributeName, htmlAttributeValue); } } } else if (fieldWidget instanceof TableWidget || fieldWidget instanceof EditableGridWidget) { final NodeList<Element> tables = fieldWidget.getElement().getElementsByTagName("table"); if (tables != null) { for (int i = 0; i < tables.getLength(); i++) { tables.getItem(i).setAttribute(htmlAttributeName, htmlAttributeValue); } } } else if (fieldWidget instanceof RichTextWidget) { final NodeList<Element> iframes = fieldWidget.getElement().getElementsByTagName("iframe"); if (iframes != null) { for (int i = 0; i < iframes.getLength(); i++) { iframes.getItem(i).setAttribute(htmlAttributeName, htmlAttributeValue); } } } else { fieldWidget.getElement().setAttribute(htmlAttributeName, htmlAttributeValue); } } }
From source file:org.cleanlogic.cesiumjs4gwt.showcase.components.ShowcaseSearchPanel.java
License:Apache License
private void setTxtSearchProperties() { txtSearch.setText(I18N.filterByKeywords()); txtSearch.setStyleName("emptytextbox"); txtSearch.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { if (event.getSource() == txtSearch) { if (txtSearch.getText().equals(I18N.filterByKeywords())) { txtSearch.setText(""); txtSearch.removeStyleName("emptytextbox"); }/* ww w . ja va 2s . c o m*/ } } }); txtSearch.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { if (event.getSource() == txtSearch) { if (txtSearch.getText().trim().equals("")) { txtSearch.setText(I18N.filterByKeywords()); txtSearch.addStyleName("emptytextbox"); } } } }); txtSearch.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { if (event.getSource() == txtSearch) { buildEvent.setFilter(txtSearch.getText()); bus.fireEvent(buildEvent); } } }); }
From source file:org.cruxframework.crux.widgets.client.filter.Filter.java
License:Apache License
/** * @return/* ww w . jav a2s. com*/ */ private FocusHandler createFocusHandler() { return new FocusHandler() { public void onFocus(FocusEvent event) { if (initialText != null && initialText.equals(getText())) { getValueBox().setText(""); removeStyleDependentName("focused"); addStyleDependentName("focused"); } } }; }
From source file:org.cruxframework.crux.widgets.client.grid.Grid.java
License:Apache License
private Widget setEditorEventHandlers(final Widget widget, final DataRow row) { widget.addDomHandler(new FocusHandler() { @Override/*from w w w . j ava 2 s .c om*/ public void onFocus(FocusEvent event) { ensureEditorFocused(); } }, FocusEvent.getType()); widget.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ensureEditorFocused(); } }, ClickEvent.getType()); if (!showEditorButtons) { if (widget instanceof HasAllKeyHandlers) { widget.addDomHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { int keycode = event.getNativeEvent().getKeyCode(); switch (keycode) { case KeyCodes.KEY_ENTER: confirmLastEditedRowValues(row); break; case KeyCodes.KEY_ESCAPE: rollbackRowEdition(row); break; default: return; } } }, KeyPressEvent.getType()); } widget.addDomHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { final Timer timer = new Timer() { @Override public void run() { if (!editorFocused) { confirmLastEditedRowValues(row); this.cancel(); } } }; timer.schedule(100); } }, BlurEvent.getType()); } return widget; }
From source file:org.datacleaner.monitor.scheduling.widgets.CustomizeSchedulePanel.java
License:Open Source License
public CustomizeSchedulePanel(SchedulingServiceAsync service, TenantIdentifier tenant, ScheduleDefinition schedule) {/* w ww . j a v a 2 s . com*/ super(); _service = service; _tenant = tenant; _schedule = schedule; _service.getServerDate(new DCAsyncCallback<String>() { @Override public void onSuccess(String result) { serverDateAsString = result; serverDate = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").parse(serverDateAsString); } }); MultiWordSuggestOracle suggestions = new MultiWordSuggestOracle(); suggestions.add("@yearly"); suggestions.add("@monthly"); suggestions.add("@weekly"); suggestions.add("@daily"); suggestions.add("@hourly"); suggestions.add("@minutely"); periodicTriggerExpressionTextBox = new SuggestBox(suggestions); periodicTriggerExpressionTextBox.getValueBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { periodicTriggerRadio.setValue(true); Element elementById = DOM.getElementById("periodicErrorMessage"); if (periodicTriggerExpressionTextBox.getText().equals("")) { elementById.setInnerHTML("Specify cron expression for periodic scheduling"); } else { elementById.setInnerHTML(""); } } }); initWidget(uiBinder.createAndBindUi(this)); dateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss"))); dateBox.getDatePicker().setWidth("200px"); dateBox.getTextBox().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { oneTimeTriggerRadio.setValue(true); Element elementByIdForDate = DOM.getElementById("serverDate"); elementByIdForDate.setInnerHTML("Server Time : " + serverDateAsString); } }); dateBox.getTextBox().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { Element elementById = DOM.getElementById("errorMessage"); if (dateBox.getValue() == null) { elementById.setInnerHTML("Select date for one time schedule"); } else { Date scheduleDate = dateBox.getValue(); elementById.setInnerHTML(""); if (scheduleDate.before(serverDate)) { elementById.setInnerHTML("Past date can not be selected for one time schedule"); } else { elementById.setInnerHTML(""); } } } }); oneTimeTriggerRadio.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Element elementById = DOM.getElementById("errorMessage"); Element elementByIdForDate = DOM.getElementById("serverDate"); elementByIdForDate.setInnerHTML("Server Time : " + serverDateAsString); if (dateBox.getValue() == null) { elementById.setInnerHTML("Select date for one time schedule"); } } }); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { Date scheduleDate = dateBox.getValue(); Element elementById = DOM.getElementById("errorMessage"); elementById.setInnerHTML(""); if (scheduleDate.before(serverDate)) { elementById.setInnerHTML("Past date can not be selected for one time schedule"); } else { elementById.setInnerHTML(""); } } }); final String expression = _schedule.getCronExpression(); final JobIdentifier scheduleAfterJob = _schedule.getDependentJob(); final String expressionForOneTime = _schedule.getDateForOneTimeSchedule(); final String hotFolder = _schedule.getHotFolder(); if (expression != null) { periodicTriggerRadio.setValue(true); periodicTriggerExpressionTextBox.setText(expression); } else if (expressionForOneTime != null) { oneTimeTriggerRadio.setValue(true); dateBox.getTextBox().setValue(expressionForOneTime); } else if (scheduleAfterJob != null) { dependentTriggerRadio.setValue(true); dependentTriggerJobListBox.addItem(scheduleAfterJob.getName()); dependentTriggerJobListBox.setSelectedIndex(0); } else if (hotFolder != null) { hotFolderTriggerRadio.setValue(true); hotFolderTriggerLocation.setValue(hotFolder); } else { manualTriggerRadio.setValue(true); } final Boolean runOnHadoopSetting = _schedule.isRunOnHadoop(); if (runOnHadoopSetting != null) { runOnHadoop.setValue(runOnHadoopSetting.booleanValue()); } else { runOnHadoop.setValue(false); } dependentTriggerJobListBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { dependentTriggerRadio.setValue(true); } }); _service.getDependentJobCandidates(_tenant, _schedule, new DCAsyncCallback<List<JobIdentifier>>() { @Override public void onSuccess(List<JobIdentifier> result) { for (JobIdentifier jobIdentifier : result) { final String jobName = jobIdentifier.getName(); if (scheduleAfterJob != null && jobName.equals(scheduleAfterJob.getName())) { // already added } else { dependentTriggerJobListBox.addItem(jobName); } } } }); hotFolderTriggerLocation.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent arg0) { hotFolderTriggerRadio.setValue(true); } }); }
From source file:org.datacleaner.monitor.shared.widgets.ColorBox.java
License:Open Source License
public ColorBox(String colorString) { this.panel = new FlowPanel(); this.textbox = new TextBox(); this.blotch = new Anchor(); this.popup = new ColorPopup(); textbox.setText(colorString);//from ww w. jav a 2 s . c om popup.addAutoHidePartner(blotch.getElement()); textbox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { enterEditMode(); } }); textbox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { keyPressed = true; popup.setHex(getValue()); setStyleAttribute(blotch.getElement(), "backgroundColor", getValue()); } }); blotch.addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent event) { if (!popup.isShowing()) { enterEditMode(); } else { popup.hide(); } } }); popup.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (!keyPressed) { setValue(popup.getHex()); setStyleAttribute(blotch.getElement(), "backgroundColor", popup.getHex()); } else { popup.setHex(getValue()); setStyleAttribute(blotch.getElement(), "backgroundColor", getValue()); keyPressed = false; } popup.clicked = false; } }); panel.add(textbox); panel.add(blotch); initWidget(panel); blotch.addStyleName("blotch"); addStyleName("gwt-ColorBox"); }
From source file:org.datacleaner.monitor.shared.widgets.StringParameterizedMetricTextBox.java
License:Open Source License
public StringParameterizedMetricTextBox(String text, final CheckBox checkBoxToActivate, SuggestOracle suggestOracle) {/* ww w .ja va 2s. c o m*/ super(suggestOracle); setStyleName("form-control"); addStyleName("StringParameterizedMetricTextBox"); setText(text); getValueBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { showSuggestionList(); } }); if (checkBoxToActivate != null) { getValueBox().addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { final String text = getText(); if (text != null && !"".equals(text)) { // activate checkbox whenever something is written. checkBoxToActivate.setValue(true); } } }); } }
From source file:org.drools.guvnor.client.asseteditor.drools.ChoiceList.java
License:Apache License
/** * Pass in a list of suggestions for the popup lists. * Set a click listener to get notified when the OK button is clicked. *//*ww w . ja v a 2 s . co m*/ public ChoiceList(final DSLSentence[] sen, final DSLRuleEditor self) { super(true); setGlassEnabled(true); this.sentences = sen; filter = new TextBox(); filter.setWidth("100%"); final String defaultMessage = Constants.INSTANCE.enterTextToFilterList(); filter.setText(defaultMessage); filter.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { filter.setText(""); } }); filter.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { filter.setText(defaultMessage); } }); filter.addKeyUpHandler(new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { applyChoice(self); } else { populateList(ListUtil.filter(sentences, filter.getText())); } } }); filter.setFocus(true); VerticalPanel panel = new VerticalPanel(); panel.add(filter); list = new ListBox(); list.setVisibleItemCount(5); populateList(ListUtil.filter(this.sentences, "")); panel.add(list); Button ok = new Button(Constants.INSTANCE.OK()); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { applyChoice(self); } }); Button cancel = new Button(Constants.INSTANCE.Cancel()); cancel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { hide(); } }); HorizontalPanel buttons = new HorizontalPanel(); buttons.add(ok); buttons.add(cancel); panel.add(buttons); add(panel); setStyleName("ks-popups-Popup"); //NON-NLS }
From source file:org.drools.guvnor.client.asseteditor.ruleflow.HumanTaskNode.java
License:Apache License
/** * Show parameters when clicked./*from w w w . j a va 2 s. c o m*/ */ public void onClick(Widget arg0) { if (parametersForm != null) { parametersForm.clear(); for (final String key : attributes.keySet()) { final String value = attributes.get(key); final TextBox tb = new TextBox(); tb.setWidth("300px"); tb.setText(value); tb.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { tb.selectAll(); } }); tb.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { attributes.put(key, tb.getText()); } }); parametersForm.addAttribute(key, tb); } } }
From source file:org.drools.guvnor.client.asseteditor.ruleflow.SplitNode.java
License:Apache License
/** * Show parameters when clicked.// w w w .j a v a 2 s . c o m */ public void onClick(Widget arg0) { if (parametersForm != null) { parametersForm.clear(); // Add Type: parametersForm.addAttribute(constants.Type2(), new Label(type.toString())); for (final ConnectionRef connectionRef : constraints.keySet()) { final Constraint constraint = constraints.get(connectionRef); final TextBox priorityTextBox = new TextBox(); priorityTextBox.setWidth("30px"); priorityTextBox.setText(constraint.getPriority() + ""); priorityTextBox.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { priorityTextBox.selectAll(); } }); priorityTextBox.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { final Constraint constraint = constraints.get(connectionRef); constraint.setPriority(Integer.parseInt(priorityTextBox.getText())); constraints.put(connectionRef, constraint); } }); final TextBox constraintTextBox = new TextBox(); constraintTextBox.setWidth("300px"); constraintTextBox.setText(constraint.getConstraint()); constraintTextBox.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { constraintTextBox.selectAll(); } }); constraintTextBox.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { final Constraint constraint = constraints.get(connectionRef); constraint.setConstraint(constraintTextBox.getText()); constraints.put(connectionRef, constraint); } }); Panel panel = new HorizontalPanel(); panel.add(new Label(constants.Priority())); panel.add(priorityTextBox); panel.add(new Label(constants.ValueRuleFlow())); panel.add(constraintTextBox); parametersForm.addAttribute(constraint.getName(), panel); } } }