Example usage for com.google.gwt.user.client.ui UIObject setStyleName

List of usage examples for com.google.gwt.user.client.ui UIObject setStyleName

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui UIObject setStyleName.

Prototype

public void setStyleName(String style) 

Source Link

Document

Clears all of the object's style names and sets it to the given style.

Usage

From source file:com.qualogy.qafe.gwt.client.vo.functions.execute.ChangeStyleExecute.java

License:Apache License

public void execute(BuiltInFunctionGVO builtInFunction) {
    if (builtInFunction instanceof ChangeStyleGVO) {

        if (builtInFunction.getComponents() != null) {
            for (BuiltInComponentGVO builtInComponentGVO : builtInFunction.getComponents()) {

                String component = builtInComponentGVO.getComponentIdUUID();
                List<UIObject> uiObjects = null;
                if (component != null) {
                    uiObjects = RendererHelper.getComponent(component);
                } else {
                    uiObjects = RendererHelper.getNamedComponent(builtInComponentGVO.getComponentName());
                }//  w w  w .j a  v  a2  s  . co  m

                if (uiObjects == null) { // Components within a window are not found. Check for SDI.
                    if (!(ClientApplicationContext.getInstance().isMDI())) {
                        UIObject mainPanel = ClientApplicationContext.getInstance().getMainPanel().getWidget();
                        uiObjects = new ArrayList<UIObject>();
                        if (mainPanel != null) {
                            uiObjects.add(mainPanel);
                        }
                    }
                }
                if (uiObjects != null) {
                    for (UIObject object : uiObjects) {

                        if (object != null) {
                            if (object instanceof QWindowPanel) {
                                object = ((QWindowPanel) object).getQRootPanel();
                            }
                            Element element = object.getElement();
                            if (element != null) {
                                ChangeStyleGVO changeStyle = (ChangeStyleGVO) builtInFunction;
                                if (changeStyle.getActions() != null) {
                                    for (ChangeStyleActionGVO changeStyleAction : changeStyle.getActions()) {

                                        if ("remove".equalsIgnoreCase(changeStyleAction.getAction())) {
                                            if (changeStyleAction.getKey() != null) {
                                                if (changeStyleAction.getKey().trim().length() > 0) {
                                                    RendererHelper.setStyleForElement(element,
                                                            changeStyleAction.getKey(), null);
                                                }
                                            }
                                            if (changeStyleAction.getStyle() != null) {
                                                if (changeStyleAction.getStyle().trim().length() > 0) {
                                                    // UIObject uiObject =
                                                    // RendererHelper.getComponent(component);
                                                    object.removeStyleName(changeStyleAction.getStyle());
                                                }
                                            }

                                        } else if ("set".equalsIgnoreCase(changeStyleAction.getAction())) {

                                            if (changeStyleAction.getKey() != null) {
                                                if (changeStyleAction.getKey().trim().length() > 0) {

                                                    RendererHelper.setStyleForElement(element,
                                                            changeStyleAction.getKey(),
                                                            changeStyleAction.getValue());
                                                }
                                            }
                                            if (changeStyleAction.getStyle() != null) {
                                                if (changeStyleAction.getStyle().trim().length() > 0) {
                                                    // UIObject uiObject =
                                                    // RendererHelper.getComponent(component);
                                                    //object.addStyleName(changeStyleAction.getStyle());
                                                    object.setStyleName(changeStyleAction.getStyle());
                                                }
                                            }

                                        }

                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }
    FunctionsExecutor.setProcessedBuiltIn(true);

}

From source file:com.qualogy.qafe.gwt.client.vo.functions.execute.SetValueExecute.java

License:Apache License

public static void processValue(UIObject uiObject, Object valueToSet, SetValueGVO setValue,
        DataContainerGVO valueDTC) {/*from  ww  w. jav a 2s  . c  o  m*/
    if (uiObject != null) {
        if (uiObject instanceof HasText) {
            if (uiObject instanceof QRadioButton) {
                QRadioButton qRadioButton = (QRadioButton) uiObject;
                qRadioButton.reset();
                if (valueToSet != null) {
                    qRadioButton.setValue(valueToSet.toString());
                }

            } else if (uiObject instanceof CheckBox) {
                CheckBox checkBox = (CheckBox) uiObject;
                String checkedValue = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.CHECKED_VALUE_ATTRIBUTE_TAG);
                String unCheckedValue = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.UNCHECKED_VALUE_ATTRIBUTE_TAG);
                String checkedValueDomain = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.CHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG);
                String unCheckedValueDomain = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.UNCHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG);

                if (valueToSet != null) {
                    if (checkedValue != null && checkedValue.equals(valueToSet)) {
                        checkBox.setChecked(true);
                    } else if (unCheckedValue != null && unCheckedValue.equals(valueToSet)) {
                        checkBox.setChecked(false);
                    } else if (isInDomain(valueToSet.toString(), checkedValueDomain)) {
                        checkBox.setChecked(true);
                    } else if (isInDomain(valueToSet.toString(), unCheckedValueDomain)) {
                        checkBox.setChecked(false);
                    }
                } else {
                    checkBox.setChecked(false);
                }
            } else if (uiObject instanceof HTML) {
                HTML html = (HTML) uiObject;
                if (valueToSet != null) {
                    html.setHTML(valueToSet.toString());
                } else {
                    html.setHTML("");
                }
            } else if (uiObject instanceof PushButton) {
                ((PushButton) uiObject).getUpFace().setText(valueToSet.toString());
                ((PushButton) uiObject).getDownFace().setText(valueToSet.toString());
            } else if (uiObject instanceof RichTextArea) {
                RichTextArea richTextArea = (RichTextArea) uiObject;
                richTextArea.setHTML(valueToSet.toString());
            } else {
                HasText hasText = (HasText) uiObject;
                if (valueDTC != null) {
                    if (valueDTC.getKind() == DataContainerGVO.KIND_STRING) {
                        if (valueDTC.getStringDataType() == DataContainerGVO.TYPE_DATE) {
                            if (uiObject instanceof QDatePicker) {
                                ((QDatePicker) uiObject).setValue(valueDTC.getDateData());
                            }
                        } else {
                            hasText.setText(valueToSet.toString());
                            uiObject.setStyleName(uiObject.getStyleName().replaceAll("qafe_invalid_field",
                                    "qafe_valid_field"));
                        }
                    } else {
                        hasText.setText(valueToSet.toString());
                    }
                } else if (valueToSet != null) {
                    hasText.setText(valueToSet.toString());
                } else {
                    hasText.setText("");
                }
            }
        } else if (uiObject instanceof Frame) {
            Frame frame = (Frame) uiObject;
            if (valueToSet != null) {
                frame.setUrl(valueToSet.toString());
            } else {
                frame.setUrl("");
            }
        }

        if (uiObject instanceof ListBox) {
            ListBox listBox = (ListBox) uiObject;
            // If it is needed to populate data and select a data from dropdown it should be seperate calls.
            if (valueDTC != null && valueDTC.getListofDC() != null) {
                processListBox(setValue, uiObject, valueDTC);
            } else {
                processValue4ListBox(listBox, valueToSet, setValue.getAction());
            }

        }

        if (uiObject instanceof Image) {
            Image image = (Image) uiObject;
            if (valueToSet != null) {
                image.setUrl(valueToSet.toString());
            }

        }

        if (uiObject instanceof QDatePicker) {
            QDatePicker qDatePicker = (QDatePicker) uiObject;
            if (valueDTC != null) {
                qDatePicker.setValue(valueDTC.getDateData(), true);
            }
        }

        if (uiObject instanceof QSliderBar) {
            QSliderBar slider = (QSliderBar) uiObject;
            slider.setValue(valueToSet);
        }

        if (uiObject instanceof HasDataGridMethods) {
            HasDataGridMethods dataGrid = (HasDataGridMethods) uiObject;
            List<DataContainerGVO> listOfDataMap = new ArrayList<DataContainerGVO>();
            if (valueDTC.getKind() == DataContainerGVO.KIND_MAP) {
                listOfDataMap.add(new DataContainerGVO(valueDTC.getDataMap()));
                dataGrid.insertData(listOfDataMap, false, setValue.getSenderId(), setValue.getListenerType());
            } else if (valueDTC.getKind() == DataContainerGVO.KIND_COLLECTION) {
                listOfDataMap = valueDTC.getListofDC();
                dataGrid.insertData(listOfDataMap, false, setValue.getSenderId(), setValue.getListenerType());
            } else if (valueDTC.getKind() == DataContainerGVO.KIND_STRING) {
                String cellOnRowToSet = setValue.getComponentId();
                listOfDataMap.add(new DataContainerGVO(valueDTC.getDataString()));
                dataGrid.setDataToCell(new DataContainerGVO(valueDTC.getDataString()), false,
                        setValue.getSenderId(), cellOnRowToSet);
            }
            dataGrid.redraw();
        }
    }
}

From source file:com.qualogy.qafe.gwt.client.vo.handlers.SetValueHandler.java

License:Apache License

private void processValue(UIObject uiObject, Object value, SetValueGVO setValueGVO,
        DataContainerGVO dataContainerGVO) {
    if (uiObject != null) {
        if (uiObject instanceof HasText) {
            if (uiObject instanceof QRadioButton) {
                QRadioButton qRadioButton = (QRadioButton) uiObject;
                qRadioButton.reset();//from w  ww  .  j a va 2  s  .co m
                if (value != null) {
                    qRadioButton.setValue(value.toString());
                }

            } else if (uiObject instanceof CheckBox) {
                CheckBox checkBox = (CheckBox) uiObject;
                String checkedValue = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.CHECKED_VALUE_ATTRIBUTE_TAG);
                String unCheckedValue = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.UNCHECKED_VALUE_ATTRIBUTE_TAG);
                String checkedValueDomain = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.CHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG);
                String unCheckedValueDomain = DOM.getElementAttribute(checkBox.getElement(),
                        CheckBoxGVO.UNCHECKED_VALUE_DOMAIN_ATTRIBUTE_TAG);

                if (value != null) {
                    if (checkedValue != null && checkedValue.equals(value)) {
                        checkBox.setChecked(true);
                    } else if (unCheckedValue != null && unCheckedValue.equals(value)) {
                        checkBox.setChecked(false);
                    } else if (isInDomain(value.toString(), checkedValueDomain)) {
                        checkBox.setChecked(true);
                    } else if (isInDomain(value.toString(), unCheckedValueDomain)) {
                        checkBox.setChecked(false);
                    }
                } else {
                    checkBox.setChecked(false);
                }
            } else if (uiObject instanceof HTML) {
                HTML html = (HTML) uiObject;
                if (value != null) {
                    html.setHTML(value.toString());
                } else {
                    html.setHTML("");
                }
            } else if (uiObject instanceof PushButton) {
                ((PushButton) uiObject).getUpFace().setText(value.toString());
                ((PushButton) uiObject).getDownFace().setText(value.toString());
            } else if (uiObject instanceof RichTextArea) {
                RichTextArea richTextArea = (RichTextArea) uiObject;
                richTextArea.setHTML(value.toString());
            } else {
                HasText hasText = (HasText) uiObject;
                if (dataContainerGVO != null) {
                    if (dataContainerGVO.getKind() == DataContainerGVO.KIND_STRING) {
                        if (dataContainerGVO.getStringDataType() == DataContainerGVO.TYPE_DATE) {
                            if (uiObject instanceof QDatePicker) {
                                ((QDatePicker) uiObject).setValue(dataContainerGVO.getDateData());
                            }
                        } else {
                            hasText.setText(value.toString());
                            uiObject.setStyleName(uiObject.getStyleName().replaceAll("qafe_invalid_field",
                                    "qafe_valid_field"));
                        }
                    } else {
                        hasText.setText(value.toString());
                    }
                } else if (value != null) {
                    hasText.setText(value.toString());
                } else {
                    hasText.setText("");
                }
            }
        } else if (uiObject instanceof Frame) {
            Frame frame = (Frame) uiObject;
            if (value != null) {
                frame.setUrl(value.toString());
            } else {
                frame.setUrl("");
            }
        }

        if (uiObject instanceof ListBox) {
            ListBox listBox = (ListBox) uiObject;
            // If it is needed to populate data and select a data from dropdown it should be seperate calls.
            if (dataContainerGVO != null && dataContainerGVO.getListofDC() != null) {
                processListBox(uiObject, setValueGVO, dataContainerGVO);
            } else {
                processValue4ListBox(listBox, value, setValueGVO.getAction());
            }

        }

        if (uiObject instanceof Image) {
            Image image = (Image) uiObject;
            if (value != null) {
                image.setUrl(value.toString());
            }

        }

        if (uiObject instanceof QDatePicker) {
            QDatePicker qDatePicker = (QDatePicker) uiObject;
            if (dataContainerGVO != null) {
                qDatePicker.setValue(dataContainerGVO.getDateData(), true);
            }
        }

        if (uiObject instanceof QSliderBar) {
            QSliderBar slider = (QSliderBar) uiObject;
            slider.setValue(value);
        }

        if (uiObject instanceof HasDataGridMethods) {
            HasDataGridMethods dataGrid = (HasDataGridMethods) uiObject;
            List<DataContainerGVO> listOfDataMap = new ArrayList<DataContainerGVO>();
            if (dataContainerGVO.getKind() == DataContainerGVO.KIND_MAP) {
                listOfDataMap.add(new DataContainerGVO(dataContainerGVO.getDataMap()));
                dataGrid.insertData(listOfDataMap, false, setValueGVO.getSenderId(),
                        setValueGVO.getListenerType());
            } else if (dataContainerGVO.getKind() == DataContainerGVO.KIND_COLLECTION) {
                listOfDataMap = dataContainerGVO.getListofDC();
                dataGrid.insertData(listOfDataMap, false, setValueGVO.getSenderId(),
                        setValueGVO.getListenerType());
            } else if (dataContainerGVO.getKind() == DataContainerGVO.KIND_STRING) {
                String cellOnRowToSet = setValueGVO.getComponentId();
                listOfDataMap.add(new DataContainerGVO(dataContainerGVO.getDataString()));
                dataGrid.setDataToCell(new DataContainerGVO(dataContainerGVO.getDataString()), false,
                        setValueGVO.getSenderId(), cellOnRowToSet);
            }
            dataGrid.redraw();
        }
    }
}

From source file:com.totsp.gwittir.client.validator.StyleValidationFeedback.java

License:Open Source License

public void handleException(Object source, ValidationException exception) {
    UIObject object = (UIObject) source;
    if (this.styleName.equals(object.getStyleName())) {
        return;/*from   w w w.j  a  v a 2 s .  c o  m*/
    }
    String previousStyle = object.getStyleName() == null || object.getStyleName().length() == 0 ? "default"
            : object.getStyleName();
    if (!this.previousStyles.containsKey(source))
        this.previousStyles.put(source, previousStyle);
    Logger.getAnonymousLogger().log(Level.SPAM, "Previous style: " + previousStyle, null);
    object.setStyleName(this.styleName);
    Logger.getAnonymousLogger().log(Level.SPAM, "Current style: " + object.getStyleName(), null);
}

From source file:com.totsp.gwittir.client.validator.StyleValidationFeedback.java

License:Open Source License

public void resolve(Object source) {
    UIObject object = (UIObject) source;
    String previousStyle = (String) this.previousStyles.get(source);
    if (previousStyle != null) {
        GWT.log("Reverting to style:" + previousStyle, null);
        object.setStyleName(previousStyle);
        GWT.log(object.toString(), null);
        this.previousStyles.remove(source);
    }/*  www  .j  ava  2 s .  c o m*/
}