List of usage examples for com.google.gwt.event.dom.client HasFocusHandlers addFocusHandler
HandlerRegistration addFocusHandler(FocusHandler handler);
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void processEvents(ComponentGVO vo, UIObject ui, EventListenerGVO event, List<com.qualogy.qafe.gwt.client.vo.ui.event.InputVariableGVO> inputVariables, String appId) { if (ui != null) { String nonHandledEventName = null; String nonHandledEventMessage = null; if (event instanceof OnEnterEventListenerGVO) { if (ui instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui; hasAllKeyHandlers.addKeyDownHandler(EventFactory.createOnEnterListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONENTER; }/*ww w . ja va 2s. c o m*/ } if (event instanceof OnFocusEventListenerGVO) { if (ui instanceof HasFocusHandlers) { HasFocusHandlers hasFocusHandlers = (HasFocusHandlers) ui; hasFocusHandlers.addFocusHandler(EventFactory.createFocusListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONFOCUS; } } if (event instanceof OnExitEventListenerGVO) { if (ui instanceof HasBlurHandlers) { HasBlurHandlers hasBlurHandlers = (HasBlurHandlers) ui; hasBlurHandlers.addBlurHandler(EventFactory.createOnExitListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONEXIT; } } if (event instanceof ClickEventListenerGVO) { if (ui instanceof HasClickHandlers) { ui.addStyleName("qafe_hand"); HasClickHandlers hasClickHandlers = (HasClickHandlers) ui; hasClickHandlers.addClickHandler(EventFactory.createClickListener(event, inputVariables)); } else if (ui instanceof MenuItem) { MenuItem menuItem = (MenuItem) ui; menuItem.setCommand(EventFactory.createCommandListener(menuItem, event, inputVariables)); ui.addStyleName("qafe_hand"); } else if (ui instanceof AreaWidget) { AreaWidget area = (AreaWidget) ui; area.setCommand(EventFactory.createCommandListener(area, event, inputVariables)); ui.addStyleName("qafe_hand"); } else if (ui instanceof TabPanel) { TabPanel tabPanel = (TabPanel) ui; String eventComponentId = event.getEventComponentId(); String[] components = eventComponentId.split("\\."); if (components.length == 1) { tabPanel.addSelectionHandler( EventFactory.createTabPanelListener(tabPanel, event, inputVariables)); ui.addStyleName("qafe_hand"); } } else { nonHandledEventName = QAMLConstants.EVENT_ONCLICK; } } if (event instanceof DoubleClickEventListenerGVO) { if (ui instanceof HasDoubleClickHandlers) { //ui.addStyleName("qafe_hand"); HasDoubleClickHandlers hasDoubleClickHandlers = (HasDoubleClickHandlers) ui; hasDoubleClickHandlers .addDoubleClickHandler(EventFactory.createDoubleClickListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONDBLCLICK; } } if (event instanceof OnChangeEventListenerGVO) { if (ui instanceof QSuggestBox) { QSuggestBox suggestionBox = (QSuggestBox) ui; suggestionBox.addKeyUpHandler( EventFactory.createSuggestionOnKeyUpHandler(suggestionBox, event, inputVariables)); } else if (ui instanceof QDatePicker && ui instanceof HasValueChangeHandlers) { HasValueChangeHandlers hasValueChangeHandlers = (HasValueChangeHandlers) ui; hasValueChangeHandlers.addValueChangeHandler( (EventFactory.createOnValueChangeHandler(event, inputVariables))); } else if (ui instanceof HasDataChangeHandlers) { HasDataChangeHandlers hasDataChangeHandlers = (HasDataChangeHandlers) ui; hasDataChangeHandlers .addDataChangeHandler((EventFactory.createOnDataChangeHandler(event, inputVariables))); } else if (ui instanceof HasChangeHandlers) { HasChangeHandlers hasChangeHandlers = (HasChangeHandlers) ui; hasChangeHandlers .addChangeHandler((EventFactory.createOnChangeListener(event, inputVariables))); } else if (ui instanceof SourcesChangeEvents) { SourcesChangeEvents sourcesChangeEvents = (SourcesChangeEvents) ui; sourcesChangeEvents .addChangeListener(EventFactory.createLegacyOnChangeListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONCHANGE; } } if (event instanceof OnMouseEnterEventListenerGVO) { if (ui instanceof HasAllMouseHandlers) { HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui; hasAllMouseHandlers .addMouseOverHandler(EventFactory.createOnMouseEnterListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_ENTER; } } if (event instanceof OnMouseExitEventListenerGVO) { if (ui instanceof HasAllMouseHandlers) { HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui; hasAllMouseHandlers .addMouseOutHandler(EventFactory.createOnMouseExitListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_EXIT; } } if (event instanceof OnMouseMoveEventListenerGVO) { if (ui instanceof HasAllMouseHandlers) { HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui; hasAllMouseHandlers .addMouseMoveHandler(EventFactory.createOnMouseMoveListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_MOVE; } } if (event instanceof OnMouseUpEventListenerGVO) { if (ui instanceof HasAllMouseHandlers) { HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui; hasAllMouseHandlers .addMouseUpHandler(EventFactory.createOnMouseUpListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_UP; } } if (event instanceof OnMouseDownEventListenerGVO) { if (ui instanceof HasAllMouseHandlers) { HasAllMouseHandlers hasAllMouseHandlers = (HasAllMouseHandlers) ui; hasAllMouseHandlers .addMouseDownHandler(EventFactory.createOnMouseDownListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONMOUSE_DOWN; } } if (event instanceof OnKeyPressEventListenerGVO) { if (ui instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui; hasAllKeyHandlers .addKeyPressHandler(EventFactory.createOnKeyPressListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONKEYPRESS; } } if (event instanceof OnKeyDownEventListenerGVO) { if (ui instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui; hasAllKeyHandlers .addKeyDownHandler(EventFactory.createOnKeyDownListener(event, inputVariables)); } else if (ui instanceof HasNativeKeyHandlers) { HasNativeKeyHandlers hasNativeKeyHandlers = (HasNativeKeyHandlers) ui; hasNativeKeyHandlers.addNativeKeyDownHandler( EventFactory.createOnNativeKeyDownListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONKEYDOWN; } } if (event instanceof OnKeyUpEventListenerGVO) { if (ui instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) ui; hasAllKeyHandlers.addKeyUpHandler(EventFactory.createOnKeyUpListener(event, inputVariables)); } else if (ui instanceof HasNativeKeyHandlers) { HasNativeKeyHandlers hasNativeKeyHandlers = (HasNativeKeyHandlers) ui; hasNativeKeyHandlers .addNativeKeyUpHandler(EventFactory.createOnNativeKeyUpListener(event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONKEYUP; } } if (event instanceof OnLoadEventListenerGVO) { if (!(vo instanceof WindowGVO)) { nonHandledEventName = QAMLConstants.EVENT_ONLOAD; nonHandledEventMessage = "Support on Window only."; } } if (event instanceof OnUnLoadEventListenerGVO) { if (!(vo instanceof WindowGVO)) { nonHandledEventName = QAMLConstants.EVENT_ONUNLOAD; nonHandledEventMessage = "Support on Window only."; } } if (event instanceof OnFinishEventListenerGVO) { if (ui instanceof FormPanel) { FormPanel formPanel = (FormPanel) ui; formPanel.addSubmitCompleteHandler( EventFactory.createSubmitCompleteHandler(ui, event, inputVariables)); } else { nonHandledEventName = QAMLConstants.EVENT_ONFINISH; } } if (event instanceof OnTimerEventListenerGVO) { //check a timer is already scheduled for this event- this happens when there are multiple component reference mentioned in that event if (!ClientApplicationContext.getInstance().isTimerScheduledForEvent(appId, vo.getWindow(), event.getEventId())) { OnTimerHandler timerHandler = new OnTimerHandler(); timerHandler.processOnTimer(ui, vo, appId, event, inputVariables); } else { nonHandledEventName = QAMLConstants.EVENT_ONTIMER; nonHandledEventMessage = "Timer is already scheduled."; } } if (nonHandledEventName != null) { if (nonHandledEventMessage == null) { nonHandledEventMessage = ""; } ClientApplicationContext.getInstance() .log("The component [" + DOM.getElementAttribute(ui.getElement(), "id") + "] for event [" + event.getEventId() + "] does not support " + nonHandledEventName + " listener. " + nonHandledEventMessage, null); } } }
From source file:com.qualogy.qafe.mgwt.client.activities.ActivityHelper.java
License:Apache License
public static void registerEvents(ComponentGVO component, UIObject widget, NotifyHandler notifyHandler, String windowId, String context, AbstractActivity activity) { if (widget == null) { return;/*from w w w . j a va 2 s .c o m*/ } if (component == null) { return; } if (activity == null) { return; } EventListenerGVO[] events = component.getEvents(); if (events == null) { return; } for (int i = 0; i < events.length; i++) { HandlerRegistration handlerRegistration = null; EventListenerGVO eventGVO = events[i]; if (eventGVO instanceof ClickEventListenerGVO) { if (isCellItemSelectEvent(component, eventGVO)) { if (widget instanceof HasCellItemSelectHandlers) { String cellItem = getCellItem(component, eventGVO); HasCellItemSelectHandlers hasCellItemSelectHandlers = (HasCellItemSelectHandlers) widget; CellItemSelectHandler cellItemSelectHandler = createCellItemSelectHandler(component, eventGVO, notifyHandler, windowId, context, activity); hasCellItemSelectHandlers.addCellItemSelectHandler(cellItem, cellItemSelectHandler); } } else if (widget instanceof HasSuggestionHandlers) { HasSuggestionHandlers hasSuggestionHandlers = (HasSuggestionHandlers) widget; SuggestionSelectHandler suggestionSelectHandler = createSuggestionSelectHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasSuggestionHandlers.addSuggestionSelectHandler(suggestionSelectHandler); } else { if (widget instanceof HasClickHandlers) { // TODO System.out.println("HasClickHandlers" + widget); } if (widget instanceof HasTapHandlers) { HasTapHandlers hasTapHandlers = (HasTapHandlers) widget; TapHandler tapHandler = createTapHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasTapHandlers.addTapHandler(tapHandler); } } } else if (eventGVO instanceof DoubleClickEventListenerGVO) { if (widget instanceof HasLongTapHandlers) { HasLongTapHandlers hasLongTapHandlers = (HasLongTapHandlers) widget; LongTapHandler longTapHandler = createLongTapHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasLongTapHandlers.addLongTapHandler(longTapHandler); } } else if (eventGVO instanceof OnChangeEventListenerGVO) { if (widget instanceof HasSuggestionHandlers) { HasSuggestionHandlers hasSuggestionHandlers = (HasSuggestionHandlers) widget; SuggestionHandler suggestionHandler = createSuggestionHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasSuggestionHandlers.addSuggestionHandler(suggestionHandler); } else if (widget instanceof HasDataChangeHandlers) { HasDataChangeHandlers hasDataChangeHandlers = (HasDataChangeHandlers) widget; DataChangeHandler dataChangeHandler = createDataChangeHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasDataChangeHandlers.addDataChangeHandler(dataChangeHandler); } } else if (eventGVO instanceof OnExitEventListenerGVO) { if (widget instanceof HasBlurHandlers) { HasBlurHandlers hasBlurHandlers = (HasBlurHandlers) widget; BlurHandler blurHandler = createBlurHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasBlurHandlers.addBlurHandler(blurHandler); } } else if (eventGVO instanceof OnFocusEventListenerGVO) { if (widget instanceof HasFocusHandlers) { HasFocusHandlers hasFocusHandlers = (HasFocusHandlers) widget; FocusHandler focusHandler = createFocusHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasFocusHandlers.addFocusHandler(focusHandler); } } else if (eventGVO instanceof OnEnterEventListenerGVO) { if (widget instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) widget; KeyDownHandler keyDownHandler = createKeyEnterHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasAllKeyHandlers.addKeyDownHandler(keyDownHandler); } } else if (eventGVO instanceof OnKeyPressEventListenerGVO) { if (widget instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) widget; KeyPressHandler keyPressHandler = createKeyPressHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasAllKeyHandlers.addKeyPressHandler(keyPressHandler); } } else if (eventGVO instanceof OnKeyDownEventListenerGVO) { if (widget instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) widget; KeyDownHandler keyDownHandler = createKeyDownHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasAllKeyHandlers.addKeyDownHandler(keyDownHandler); } } else if (eventGVO instanceof OnKeyUpEventListenerGVO) { if (widget instanceof HasAllKeyHandlers) { HasAllKeyHandlers hasAllKeyHandlers = (HasAllKeyHandlers) widget; KeyUpHandler keyUpHandler = createKeyUpHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasAllKeyHandlers.addKeyUpHandler(keyUpHandler); } } else if (eventGVO instanceof OnMouseDownEventListenerGVO) { if (widget instanceof HasTouchHandlers) { HasTouchHandlers hasTouchHandlers = (HasTouchHandlers) widget; TouchStartHandler touchStartHandler = createTouchStartHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasTouchHandlers.addTouchStartHandler(touchStartHandler); } } else if (eventGVO instanceof OnMouseMoveEventListenerGVO) { if (widget instanceof HasTouchHandlers) { HasTouchHandlers hasTouchHandlers = (HasTouchHandlers) widget; TouchMoveHandler touchMoveHandler = createTouchMoveHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasTouchHandlers.addTouchMoveHandler(touchMoveHandler); } } else if (eventGVO instanceof OnMouseUpEventListenerGVO) { if (widget instanceof HasTouchHandlers) { HasTouchHandlers hasTouchHandlers = (HasTouchHandlers) widget; TouchEndHandler touchEndHandler = createTouchEndHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasTouchHandlers.addTouchEndHandler(touchEndHandler); } } else if (eventGVO instanceof OnLoadEventListenerGVO) { if (widget instanceof HasLoadHandlers) { HasLoadHandlers hasLoadHandlers = (HasLoadHandlers) widget; LoadHandler loadHandler = createLoadHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasLoadHandlers.addLoadHandler(loadHandler); } } else if (eventGVO instanceof OnUnLoadEventListenerGVO) { if (widget instanceof HasUnloadHandlers) { HasUnloadHandlers hasUnloadHandlers = (HasUnloadHandlers) widget; UnloadHandler unloadHandler = createUnloadHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasUnloadHandlers.addUnloadHandler(unloadHandler); } } else if (eventGVO instanceof OnTimerEventListenerGVO) { // The timer event is attached to a view only, // and a view can contain only one timer for each event AbstractView view = activity.getView(); if (view instanceof HasTimerHandlers) { HasTimerHandlers hasTimerHandlers = (HasTimerHandlers) view; TimerHandler timerHandler = createTimerHandler(component, widget, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasTimerHandlers.addTimerHandler(timerHandler); } } else if (eventGVO instanceof OnScrollEventListenerGVO) { String listenerType = eventGVO.getEventListenerType(); if (QAMLConstants.EVENT_ONSCROLL_BOTTOM.equals(listenerType)) { if (widget instanceof HasScrollBottomHandlers) { HasScrollBottomHandlers hasScrollBottomHandlers = (HasScrollBottomHandlers) widget; ScrollBottomHandler scrollBottomHandler = createScrollBottomHandler(component, eventGVO, notifyHandler, windowId, context, activity); handlerRegistration = hasScrollBottomHandlers.addScrollBottomHandler(scrollBottomHandler); } } } if (handlerRegistration != null) { activity.addHandlerRegistration(handlerRegistration); } } }
From source file:fr.putnami.pwt.core.widget.client.helper.CompositeFocusHelper.java
License:Open Source License
public void addHasFocusContent(HasFocusHandlers hasFocusContent) { if (this.hasFocusContents.add(hasFocusContent)) { hasFocusContent.addFocusHandler(this.focusHandler); }//ww w. ja va2s . com }
From source file:net.sf.mmm.client.ui.impl.gwt.widget.adapter.UiWidgetAdapterGwtWidgetActive.java
License:Apache License
/** * {@inheritDoc}/*from w ww . ja v a 2 s. co m*/ */ @Override protected void applyEventAdapterForFocus(EventAdapterGwt adapter) { HasFocusHandlers focusHandlers = getWidgetAsHasFocusHandlers(); if (focusHandlers != null) { HandlerRegistration registration = focusHandlers.addFocusHandler(adapter); addHandlerRegistration(registration); } HasBlurHandlers blurHandlers = getWidgetAsHasBlurHandlers(); if (blurHandlers != null) { HandlerRegistration registration = blurHandlers.addBlurHandler(adapter); addHandlerRegistration(registration); } }