Example usage for com.google.gwt.user.client.ui HasText getText

List of usage examples for com.google.gwt.user.client.ui HasText getText

Introduction

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

Prototype

String getText();

Source Link

Document

Gets this object's text.

Usage

From source file:com.google.zxing.web.generator.client.CalendarEventGenerator.java

License:Apache License

private static Date getDateFromTextBox(HasText textBox) throws GeneratorException {
    DateTimeFormat extractTime = DateTimeFormat.getFormat("HHmm");
    try {/*from  w  w  w . j  a va  2  s . co m*/
        return extractTime.parseStrict(textBox.getText());
    } catch (IllegalArgumentException iae) {
        throw new GeneratorException("Invalid time");
    }
}

From source file:com.google.zxing.web.generator.client.WifiGenerator.java

License:Apache License

private static String parseTextField(String name, HasText textBox) throws GeneratorException {
    String input = textBox.getText();
    if (input.isEmpty()) {
        return "";
    }/* w w w. j  ava2 s  .  c  o m*/
    if (input.contains("\n")) {
        throw new GeneratorException(name + " field must not contain \\n characters.");
    }
    return input.replaceAll("([\\\\:;])", "\\\\$1");
}

From source file:com.qualogy.qafe.gwt.client.component.CellRendererHelper.java

License:Apache License

private static void handleSetModifiedForValueChangeEvent(final HasDataGridMethods parentWidget,
        final DataContainerGVO rowValue, final ColumnDefinition<DataContainerGVO, String> columnDef,
        final UIObject uiObject, GwtEvent event) {
    Object value = null;/*  w  w w  .ja v a  2  s  .  c o m*/

    // TODO
    if (event instanceof ValueChangeEvent) {
        ValueChangeEvent valueChangeEvent = (ValueChangeEvent) event;
        value = valueChangeEvent.getValue();
    }

    Object source = event.getSource();
    if (source instanceof CheckBox) {
        CheckBox checkBox = (CheckBox) source;
        if ((Boolean) value) {
            String attributeValue = DOM.getElementAttribute(checkBox.getElement(),
                    CheckBoxGVO.CHECKED_VALUE_ATTRIBUTE_TAG);
            if (attributeValue != null && attributeValue.length() > 0) {
                value = attributeValue;
            }
        } else {
            String attributeValue = DOM.getElementAttribute(checkBox.getElement(),
                    CheckBoxGVO.UNCHECKED_VALUE_ATTRIBUTE_TAG);
            if (attributeValue != null && attributeValue.length() > 0) {
                value = attributeValue;
            }
        }
    } else if (source instanceof QTextField) {
        /**
         * When database column type is NUMBER(5,2) type which is accepting decimal values, If we pass string type with decimal value to the jdbc template it is giving exception.
         * So the type of the textfield should be considered.
         * This is now applicable only for textfield, same issue can come in any inputfield. But we dont have an option to set type to other components now.
         */
        String type = DOM.getElementAttribute(uiObject.getElement(), TextFieldGVO.REGEXPTYPE);
        QTextField textField = (QTextField) source;
        if (TextFieldGVO.TYPE_DOUBLE.equals(type)) {
            value = new Double(value.toString());
        } else if (TextFieldGVO.TYPE_INTEGER.equals(type)) {
            try {
                value = new Integer(value.toString());
            } catch (Exception e) {
                value = new Double(value.toString());
            }
        }
    }
    if (value == null) {
        if (source instanceof HasText) {
            HasText hasText = (HasText) source;
            value = hasText.getText();
        } else if (source instanceof HasData) {
            HasData hasData = (HasData) source;
            value = hasData.getData();
        }
    }
    handleSetModified(parentWidget, rowValue, columnDef, uiObject, value);
}

From source file:com.qualogy.qafe.gwt.client.ui.renderer.TextFieldRenderer.java

License:Apache License

private void handleValueAttribute(TextFieldGVO gvo, UIObject uiObject) {
    String value = gvo.getValue();
    if ((value != null) && (value.length() > 0)) {
        if (uiObject instanceof HasData) {
            HasData hasData = (HasData) uiObject;
            hasData.setData(value, SetValueGVO.ACTION_ADD, null);
        } else if (uiObject instanceof HasText) {
            HasText hasText = (HasText) uiObject;
            String oldValue = hasText.getText();
            hasText.setText(value);/*from w  ww .  j a  va  2s .  com*/
            doDataChange(gvo, uiObject, oldValue, hasText.getText());
        }
    }
}

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

License:Apache License

public void execute(BuiltInFunctionGVO builtInFunction) {
    if (builtInFunction instanceof CopyGVO) {
        CopyGVO copy = (CopyGVO) builtInFunction;

        List<UIObject> uiObjectsFrom = null;
        if (copy.getFromGVO().getComponentIdUUID() != null) {
            uiObjectsFrom = RendererHelper.getComponent(copy.getFromGVO().getComponentIdUUID());
        } else {//ww w  .j  a  va2 s  .  co m
            uiObjectsFrom = RendererHelper.getNamedComponent(copy.getFromGVO().getComponentName());
        }

        List<UIObject> uiObjectsTo = null;
        if (copy.getToGVO().getComponentIdUUID() != null) {
            uiObjectsTo = RendererHelper.getComponent(copy.getToGVO().getComponentIdUUID());
        } else {
            uiObjectsTo = RendererHelper.getNamedComponent(copy.getToGVO().getComponentName());
        }

        if (uiObjectsTo != null && uiObjectsFrom != null) {
            if (uiObjectsTo.size() == uiObjectsFrom.size()) {
                for (int i = 0; i < uiObjectsTo.size(); i++) {
                    UIObject uiObjectFrom = uiObjectsFrom.get(i);
                    UIObject uiObjectTo = uiObjectsTo.get(i);

                    if (uiObjectFrom instanceof HasText) {
                        HasText hasTextFrom = (HasText) uiObjectFrom;
                        String fromValue = hasTextFrom.getText();
                        if (uiObjectTo instanceof HasText) {
                            HasText hasTextTo = (HasText) uiObjectTo;
                            hasTextTo.setText(fromValue);
                        }
                    }

                }
            }
        }
    }
    FunctionsExecutor.setProcessedBuiltIn(true);
}

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

License:Apache License

private static String getValue(HasText hasText) {
    String value = hasText.getText();
    if (hasText instanceof UIObject) {
        handleSimpleValue((UIObject) hasText, value);
    }/*from   www  .  j a  v a  2s.c om*/
    return value;
}

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

License:Apache License

private void copy(CopyGVO copyGVO, UIObject sender, String appId, String windowId, String eventSessionId) {
    String toKey = generateId(copyGVO.getTo(), windowId, appId, eventSessionId);
    String fromKey = generateId(copyGVO.getFrom(), windowId, appId, eventSessionId);

    List<UIObject> uiObjectsFrom = getUIObjects(fromKey);
    if (uiObjectsFrom == null) {
        return;//www.jav  a2 s. c om
    }

    List<UIObject> uiObjectsTo = getUIObjects(toKey);
    if (uiObjectsTo == null) {
        return;
    }
    if (uiObjectsTo.size() == uiObjectsFrom.size()) {
        for (int i = 0; i < uiObjectsTo.size(); i++) {
            UIObject uiObjectFrom = uiObjectsFrom.get(i);
            UIObject uiObjectTo = uiObjectsTo.get(i);

            if (uiObjectFrom instanceof HasText) {
                HasText hasTextFrom = (HasText) uiObjectFrom;
                String fromValue = hasTextFrom.getText();
                if (uiObjectTo instanceof HasText) {
                    HasText hasTextTo = (HasText) uiObjectTo;
                    hasTextTo.setText(fromValue);
                }
            }

        }
    }
}

From source file:com.threerings.gwt.ui.Bindings.java

License:Open Source License

/**
 * Binds the specified string value to the supplied text-having widget. The binding is one-way,
 * in that only changes to the value will be reflected in the text-having widget. It is
 * expected that no other changes will be made to the widget.
 *//*w ww .  j av  a 2 s .  co  m*/
public static void bindLabel(final Value<String> value, final HasText target) {
    value.addListenerAndTrigger(new Value.Listener<String>() {
        public void valueChanged(String value) {
            // avoid updating the target if the value is already the same; in the case where
            // the target is a TextBox, setting the text will move the cursor to the end of the
            // text, which is annoying if a value is being updated on every character edit
            if (!target.getText().equals(value)) {
                target.setText(value);
            }
        }
    });
}

From source file:de.uni_koeln.spinfo.maalr.webapp.ui.common.client.LemmaEditorWidget.java

License:Apache License

/**
 * Copies the values from the editor into the given
 * {@link LemmaVersion}.//  w  w  w.j ava  2 s  .c om
 * @param lemma must not be <code>null</code>.
 */
public void updateFromEditor(LemmaVersion lemma) {
    List<String> toSet = new ArrayList<String>();
    toSet.addAll(description.getEditorFields(true));
    toSet.addAll(description.getEditorFields(false));
    for (String key : toSet) {
        HasText field = fields.get(key);
        if (field != null) {
            String text = field.getText();
            if (text != null && text.trim().length() > 0) {
                lemma.putEntryValue(key, text.trim());
            } else {
                lemma.removeEntryValue(key);
            }
        }
    }
}

From source file:org.kuali.student.common.ui.client.configurable.mvc.binding.HasTextBinding.java

License:Educational Community License

@Override
public void setModelValue(HasText object, DataModel model, String path) {
    try {/*from  w  w w.  j  a v  a  2  s.  com*/
        QueryPath qPath = QueryPath.parse(path);
        DataType type = model.getType(qPath);

        String newValue = null;
        if (object.getText() != null) {
            newValue = object.getText().trim();
        }

        //If both model value is null and widget value is null or is empty no need to update model, so skip update
        boolean skipUpdatingModel = model.get(qPath) == null && (newValue == null || newValue.isEmpty());

        if (!skipUpdatingModel) {
            try {
                switch (type) {
                case STRING:
                    if (!nullsafeEquals(model.get(qPath), newValue)) {
                        model.set(qPath, newValue);
                        setDirtyFlag(model, qPath);
                    }
                    break;
                case INTEGER:
                    if (newValue != null && newValue.isEmpty()) {
                        Integer value = null;
                        model.set(qPath, value);
                        setDirtyFlag(model, qPath);
                    } else {
                        int intValue = Integer.parseInt(newValue);
                        if (!nullsafeEquals(model.get(qPath), intValue)) {
                            model.set(qPath, intValue);
                            setDirtyFlag(model, qPath);
                        }
                    }
                    break;
                case LONG:
                    long longValue = Long.parseLong(newValue);
                    if (!nullsafeEquals(model.get(qPath), longValue)) {
                        model.set(qPath, longValue);
                        setDirtyFlag(model, qPath);
                    }
                    break;
                case FLOAT:
                    float floatValue = Float.parseFloat(newValue);
                    if (!nullsafeEquals(model.get(qPath), floatValue)) {
                        model.set(qPath, floatValue);
                        setDirtyFlag(model, qPath);
                    }
                    break;
                case DOUBLE:
                    double doubleValue = Double.parseDouble(newValue);
                    if (!nullsafeEquals(model.get(qPath), doubleValue)) {
                        model.set(qPath, doubleValue);
                        setDirtyFlag(model, qPath);
                    }
                    break;
                case BOOLEAN:
                    if (newValue.equalsIgnoreCase("true") || newValue.equalsIgnoreCase("false")) {
                        boolean booleanValue = Boolean.parseBoolean(newValue);
                        if (!nullsafeEquals(model.get(qPath), booleanValue)) {
                            model.set(qPath, booleanValue);
                            setDirtyFlag(model, qPath);
                        }
                    } else {
                        throw new UnsupportedOperationException(
                                "BooleanTypes can only be set with true or false");
                    }
                    break;
                case DATE:
                    Date dateValue = dateParser.parseDate(newValue);
                    if (!nullsafeEquals(model.get(qPath), dateValue)) {
                        model.set(qPath, dateValue);
                        setDirtyFlag(model, qPath);
                    }
                    break;
                }
            } catch (Exception e) {
                GWT.log("Unable to coerce type for " + path + ", falling back to String", e);
                model.set(qPath, newValue);
            }
        }
    } catch (Exception e) {
        GWT.log("Error setting model value for: " + path, e);
    }
}