List of usage examples for com.google.gwt.user.client.ui UIObject addStyleName
public void addStyleName(String style)
From source file:com.pietschy.gwt.pectin.client.style.StyleBinding.java
License:Apache License
protected void updateTarget(Boolean value) { for (UIObject widget : widgets) { if (Boolean.TRUE.equals(value)) { widget.addStyleName(styleName); } else {/*from ww w . j a v a 2s . com*/ widget.removeStyleName(styleName); } } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void addStyle(ComponentGVO vo, UIObject ui) { if (vo != null) { String styles = vo.getStyleClass(); if (styles != null && !ui.getStyleName().contains(styles)) { ui.addStyleName(styles); }//w w w .j a v a 2 s. c o m if (ui != null) { setStyleForElement(ui.getElement(), vo.getStyleProperties()); } } }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.RendererHelper.java
License:Apache License
public static void handleRequiredClassStyle(UIObject ui, String invalidClassName, Boolean applyRequiredStyle) { if (applyRequiredStyle) { ui.removeStyleName(DEFAULT_VALID_STYLE); ui.addStyleName(invalidClassName); } else {//from w ww . j av a 2 s . co m ui.removeStyleName(invalidClassName); ui.addStyleName(DEFAULT_VALID_STYLE); } }
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; }/*from www .ja va2s . 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.gwt.client.ui.renderer.TextAreaRenderer.java
License:Apache License
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { Widget uiObject = null;//from www . ja va 2 s.co m if (component != null) { if (component instanceof TextAreaGVO) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; final String finalParent = parent; TextAreaGVO gvo = (TextAreaGVO) component; if (gvo.getDisplayname() != null && gvo.getDisplayname().length() > 0) { if (gvo.getMenu() != null) { uiObject = new LabeledTextAreaFieldWidget(gvo.getDisplayname(), gvo.getOrientation(), gvo, uuid, parent) { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new LabeledTextAreaFieldWidget(gvo.getDisplayname(), gvo.getOrientation(), gvo, uuid, parent); } } else { if (gvo.getRich() != null) { if (gvo.getRich().booleanValue()) { // This sample is taken from the KitchenSick demo RichTextArea area = new RichTextArea(); RichTextToolbar tb = new RichTextToolbar(area); VerticalPanel p = null; if (gvo.getMenu() != null) { p = new VerticalPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { p = new VerticalPanel(); } p.add(tb); p.add(area); area.setHeight("14em"); area.setWidth("100%"); tb.setWidth("100%"); p.setWidth("100%"); //p.setStyleName("qafe_rich_textarea"); DOM.setStyleAttribute(p.getElement(), "marginRight", "4px"); RendererHelper.fillIn(component, area, uuid, parent, context); RendererHelper.fillIn(component, p, uuid, parent, context); area.setText(gvo.getValue()); area.setEnabled(gvo.getEditable().booleanValue()); uiObject = p; if (gvo.getRequired() != null && gvo.getRequired().booleanValue()) { DOM.setElementProperty(uiObject.getElement(), "required", "true"); RendererHelper.setStyleForElement(uiObject.getElement(), "background", "red"); } } else { if (gvo.getMenu() != null) { uiObject = new QTextArea() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new QTextArea(); } QTextArea ta = (QTextArea) uiObject; RendererHelper.fillIn(component, uiObject, uuid, parent, context); if (gvo.getCols() > 0) { ta.setCharacterWidth(gvo.getCols()); } else { ta.setCharacterWidth(80); } if (gvo.getMaxLength() != null) { if (gvo.getMaxLength().intValue() > 0) { DOM.setElementAttribute(uiObject.getElement(), "maxlength", gvo.getMaxLength().toString()); } } ta.setVisibleLines(gvo.getRows()); ta.setText(gvo.getValue()); ta.setEditable(gvo.getEditable().booleanValue()); if (gvo.getRequired() != null && gvo.getRequired().booleanValue()) { DOM.setElementProperty(uiObject.getElement(), "required", "true"); RendererHelper.setStyleForElement(uiObject.getElement(), "background", "red"); ((QTextArea) uiObject).addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { if (event.getSource() instanceof QTextArea) { UIObject ui = (UIObject) event.getSource(); String value = ((QTextArea) ui).getText(); if (value != null && value.length() > 0) { ui.removeStyleName("qafe_invalid_field"); } else { ui.addStyleName("qafe_invalid_field"); } } } }); } } } } //uiObject.setStylePrimaryName(gvo.getStyleClassName()); handleMaxLengthAttribute(gvo, uiObject); handleMinLengthAttribute(gvo, uiObject); } } return uiObject; }
From source file:com.qualogy.qafe.gwt.client.vo.functions.execute.SetMaskHelper.java
License:Apache License
public static void setMask(final String componentId, final String className, final boolean mask) { List<UIObject> uiObjects = ComponentRepository.getInstance().getComponent(componentId); if (uiObjects == null) { setMaskNative(componentId, className, mask); return;// w w w .j a v a 2s . c om } for (UIObject uiObject : uiObjects) { uiObject.removeStyleName(RendererHelper.QAFE_GLASS_PANEL_STYLE); if (mask) { uiObject.addStyleName(RendererHelper.QAFE_GLASS_PANEL_STYLE); } } }
From source file:com.qualogy.qafe.gwt.client.vo.handlers.ChangeStyleHandler.java
License:Apache License
private void handleChangeStyle(UIObject object, Element element, List<ChangeStyleActionGVO> actions) { for (ChangeStyleActionGVO changeStyleAction : actions) { String action = changeStyleAction.getAction().toLowerCase(); String key = changeStyleAction.getKey(); String style = changeStyleAction.getStyle(); if (ACTION_REMOVE.equals(action)) { if (key != null && key.trim().length() > 0) { RendererHelper.setStyleForElement(element, key, null); }/*from w w w . j ava 2s .c om*/ if (style != null && style.trim().length() > 0) { object.removeStyleName(style); } } else if (ACTION_SET.equals(action)) { if (key != null && key.trim().length() > 0) { RendererHelper.setStyleForElement(element, key, changeStyleAction.getValue()); } if (style != null && style.trim().length() > 0) { object.addStyleName(style); } } } }
From source file:com.wfairclough.foundation4gwt.client.ui.base.StyleHelper.java
License:Apache License
/** * Helper method to add a style name.//from ww w . j a va2s.c om * * @param widget the widget to add the style frome * @param style the style to add to the widget */ public static void addStyle(UIObject widget, String style) { widget.addStyleName(style); }
From source file:gwt.material.design.addins.client.swipeable.MaterialSwipeablePanel.java
License:Apache License
/** * Ignore any elements to be swipeable//from ww w . j a v a2s . c om */ public void ignore(UIObject object, UIObject... objects) { object.addStyleName(AddinsCssName.IGNORED); if (objects != null) { for (UIObject obj : objects) { obj.addStyleName(AddinsCssName.IGNORED); } } }
From source file:gwt.material.design.client.base.mixin.EnabledMixin.java
License:Apache License
private void setEnabled(UIObject obj, boolean enabled) { if (enabled) { obj.removeStyleName("disabled"); obj.removeStyleName("grey lighten-2"); obj.getElement().removeAttribute(DISABLED); if (uiObject instanceof HasWaves) { if (((HasWaves) uiObject).getWaves() == null) { uiObject.addStyleName(Waves.WAVES_STYLE); Waves.detectAndApply();//from w ww. j a va 2 s . c om } } } else { obj.addStyleName("disabled"); obj.addStyleName("grey lighten-2"); obj.getElement().setAttribute(DISABLED, ""); if (uiObject instanceof HasWaves) { uiObject.removeStyleName(Waves.WAVES_STYLE); } } if (obj instanceof HasWidgets) { for (Widget widget : (HasWidgets) obj) { if (widget instanceof HasEnabled) { setEnabled(widget, enabled); } } } }