Java 类com.google.gwt.user.client.ui.HasValue 实例源码

项目:ephesoft    文件:ValidatorFactory.java   
public static Validator getValidator(DataType dataType, HasValue<String> value) {
    Validator validator = null;
    switch (dataType) {
        case DATE:
            validator = new DateFormatValidator(value);
            break;

        case DOUBLE:
        case FLOAT:
            validator = new NumberValidator(value, true);
            break;

        case LONG:
        case INTEGER:
            validator = new NumberValidator(value, false);
            break;

        case STRING:
            break;

        default:
            break;
    }

    return validator;
}
项目:google-apis-explorer    文件:FieldsEditor.java   
public FieldsEditor(ApiService service, String key) {
  super("");

  this.service = service;
  this.key = key;
  root = new CheckBox(key.isEmpty() ? "Select all/none" : key);
  root.setValue(false);
  root.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
    @Override
    public void onValueChange(ValueChangeEvent<Boolean> event) {
      for (HasValue<Boolean> checkBox : children.values()) {
        checkBox.setValue(event.getValue(), true);
      }
    }
  });
  add(root);
}
项目:qafe-platform    文件:RendererHelper.java   
private static Object getData(UIObject ui) {
    if (ui instanceof HasValue) {
        return ((HasValue)ui).getValue();
    } else if (ui instanceof HasText) {
        return ((HasText)ui).getText();
    } else if (ui instanceof HasData) {
        return ((HasData)ui).getData();
    } else if (ui instanceof ListBox) {
        ListBox listBox = (ListBox) ui;
        if(listBox.getSelectedIndex() > 0) {
            return listBox.getValue(listBox.getSelectedIndex());
        }
    } else if (ui instanceof ValueSpinner) {
        ValueSpinner spinner = (ValueSpinner) ui;
        return spinner.getTextBox().getValue();
    }
    return null;
}
项目:gwt-traction    文件:UTCDateTimeRangeController.java   
/**
 * Creates a controller that will manage the date/time range
 * consisting of 2 date/time controls and an optional
 * allDayCheckbox.
 */
public UTCDateTimeRangeController(UTCDateBox startDate, UTCTimeBox startTime, UTCDateBox endDate, UTCTimeBox endTime, HasValue<Boolean> allDayCheckbox) {
    this.startDate = startDate;
    this.startTime = startTime;
    this.endDate = endDate;
    this.endTime = endTime;
    this.allDayCheckbox = allDayCheckbox;
    updateInterval();

    // attach the event handlers
    if (allDayCheckbox != null) {
        allDayCheckbox.addValueChangeHandler(new AllDayCheckboxHandler());
    }

    StartDateTimeHandler startHandler = new StartDateTimeHandler();
    EndDateTimeHandler endHandler = new EndDateTimeHandler();

    startDate.addValueChangeHandler(startHandler);
    startTime.addValueChangeHandler(startHandler);

    endDate.addValueChangeHandler(endHandler);
    endTime.addValueChangeHandler(endHandler);
}
项目:ephesoft    文件:RegExValidator.java   
public RegExValidator(final RegExValidatableWidget<?> validatableWidget, final HasValue<String> value, final boolean isMandatory,
        final boolean isMultiplePattern, final boolean isPatternValidator, final String patternDelimiter,
        final DCMARemoteServiceAsync remoteServiceAsync) {
    this._value = value;
    this.validatableWidget = validatableWidget;
    this.isMandatory = isMandatory;
    this.isMultiplePattern = isMultiplePattern;
    this.isOnlyPatternValidator = isPatternValidator;
    this.patternDelimiter = patternDelimiter;
    this.remoteService = remoteServiceAsync;
}
项目:gwt-material    文件:MaterialCollectionItem.java   
@Override
protected void onLoad() {
    super.onLoad();

    HandlerRegistration handlerRegistration = addClickHandler(event -> {
        // Stop propagation of event when checkbox / other elements has
        // been clicked to avoid duplicate events.
        if (Element.as(event.getNativeEvent().getEventTarget()) != getElement()) {
            if (getType() == CollectionType.CHECKBOX) {
                event.stopPropagation();
                event.preventDefault();
            }
        }
        for (Widget w : MaterialCollectionItem.this) {
            if (w instanceof MaterialCollectionSecondary) {
                for (Widget a : (MaterialCollectionSecondary) w) {
                    if (a instanceof HasValue) {
                        try {
                            @SuppressWarnings("unchecked")
                            HasValue<Boolean> cb = (HasValue<Boolean>) a;
                            if (cb.getValue()) {
                                cb.setValue(false);
                            } else {
                                cb.setValue(true);
                            }
                        } catch (ClassCastException ex) {
                            // Ignore non-boolean has value handlers.
                        }
                    }
                }
            }
        }
    });
    registerHandler(handlerRegistration);

    JsMaterialElement.initDismissableCollection();
}
项目:gwt-material    文件:WidgetTestCase.java   
public static <H extends HasValueChangeHandlers & HasValue & HasEnabled & HasAttachHandlers> void checkValueChangeEvent(
        H widget, Object value, Object secondValue) {
    assertNotSame(value, secondValue);
    // Widget must be enabled before firing the event
    widget.setEnabled(true);
    assertTrue(widget.isEnabled());
    // Ensure the widget is attached to the root panel
    assertTrue(widget.isAttached());
    // Register value change handler that listens when the widget
    // set the value
    final boolean[] isValueChanged = {false};
    widget.addValueChangeHandler(event -> isValueChanged[0] = true);
    // By default setValue(boolean) will not fire the value change event.
    widget.setValue(value);
    assertEquals(value, widget.getValue());
    // Expected result : false
    assertFalse(isValueChanged[0]);
    // Calling setValue(value, fireEvents) with fireEvents set to false
    widget.setValue(secondValue, false);
    // Expected result : secondValue
    assertEquals(secondValue, widget.getValue());
    // Expected result : false
    assertFalse(isValueChanged[0]);
    // Calling setValue(value, fireEvents) with fireEvents set to true
    widget.setValue(value, true);
    // Expected result : true
    assertTrue(isValueChanged[0]);
    // Expected result : value
    assertEquals(value, widget.getValue());
}
项目:google-apis-explorer    文件:FieldsEditor.java   
/**
 * Returns this field's checked value, or if it has children, whether all its
 * children are checked.
 */
@Override
public Boolean getValue() {
  if (children.isEmpty()) {
    return root.getValue();
  }

  return Iterables.all(children.entrySet(),
      new Predicate<Map.Entry<String, HasValue<Boolean>>>() {
        @Override
        public boolean apply(Entry<String, HasValue<Boolean>> input) {
          return input.getValue().getValue();
        }
      });
}
项目:google-apis-explorer    文件:FieldsEditor.java   
/**
 * Sets this field's checked value, and all of its childrens' if it has any.
 */
@Override
public void setValue(Boolean value) {
  for (HasValue<Boolean> hasValue : children.values()) {
    hasValue.setValue(value);
  }
  this.root.setValue(value);
}
项目:platypus-js    文件:PlatypusWindow.java   
private void gatherForm(Map<String, String> aFormData, HasWidgets aContainer) {
    Iterator<Widget> widgets = aContainer.iterator();
    while (widgets.hasNext()) {
        Widget w = widgets.next();
        if (w instanceof HasValue<?> && w instanceof HasJsName) {
            String name = ((HasJsName) w).getJsName();
            Object value = ((HasValue<Object>) w).getValue();
            if (name != null && !name.isEmpty() && (value == null || value instanceof String || value instanceof Number)) {
                aFormData.put(name, value != null ? value.toString() : null);
            }
        }
        if (w instanceof HasWidgets)
            gatherForm(aFormData, (HasWidgets) w);
    }
}
项目:platypus-js    文件:RadioGroup.java   
public void add(HasValue<Boolean> aItem) {
    if (!grouped.contains(aItem)) {
        if (aItem instanceof HasName) {
            ((HasName) aItem).setName(groupName);
        }
        groupedHandlers.put(aItem, aItem.addValueChangeHandler(this));
        grouped.add(aItem);
    }
}
项目:platypus-js    文件:RadioGroup.java   
public boolean remove(HasValue<Boolean> aItem) {
    HandlerRegistration handler = groupedHandlers.get(aItem);
    if (handler != null) {
        handler.removeHandler();
    }
    if (aItem instanceof HasName) {
        ((HasName) aItem).setName("");
    }
    return grouped.remove(aItem);
}
项目:platypus-js    文件:ButtonGroup.java   
public HasPublished getChild(int i) {
    HasValue<Boolean> child = super.get(i);
    if (child instanceof HasPublished)
        return (HasPublished) child;
    else
        return null;
}
项目:platypus-js    文件:PlatypusHtmlEditor.java   
private void placeWidgetToMenu(Widget aWidget, ButtonGroup aBtnGroup, String aStyleName) {
    aWidget.getElement().getStyle().setWidth(elementWidth, Style.Unit.PX);
    aWidget.getElement().getStyle().setHeight(elementHeight, Style.Unit.PX);
    if (aStyleName != null && !aStyleName.isEmpty()) {
        aWidget.addStyleName(aStyleName);
    }
    if (aBtnGroup != null) {
        if (aWidget instanceof HasValue) {
            aBtnGroup.add((HasValue<Boolean>) aWidget);
        }
    }
    toolBar.add(aWidget);
}
项目:gwt-bean-validators    文件:AbstractDecorator.java   
@SuppressWarnings("unchecked")
@Override
public void setValue(final T pvalue, final boolean pfireEvents) {
  if (this.contents.getWidget() instanceof TakesValue<?>) {
    this.clearErrors();
    if (this.contents.getWidget() instanceof HasValue<?>) {
      ((HasValue<T>) this.contents.getWidget()).setValue(pvalue, pfireEvents);
    } else {
      ((TakesValue<T>) this.contents.getWidget()).setValue(pvalue);
    }
  }
}
项目:turbogwt-databind    文件:ViewEngine.java   
@Override
public <F> Registration bind(final String id, final HasValue<F> widget, Strategy strategy) {
    assert widget instanceof IsWidget : "HasValue parameter must be of type IsWidget";

    // Add update handler
    HandlerRegistration handlerRegistration = strategy.bind((IsWidget) widget, new Command() {
        @Override
        public void execute() {
            fireValueChangeEvent(id, widget);
        }
    });

    if (bindings.containsKey(id)) {
        // If id were already bound, then update the binding
        WidgetBinding widgetBinding = bindings.get(id);
        if (widgetBinding.widgetHandlerRegistration != null) {
            // Remove previous existing handler avoiding memory leak
            widgetBinding.widgetHandlerRegistration.removeHandler();
        }
        widgetBinding.widget = widget;
        widgetBinding.widgetHandlerRegistration = handlerRegistration;
    } else {
        WidgetBinding widgetBinding = new WidgetBinding(widget, handlerRegistration);
        bindings.put(id, widgetBinding);
    }
    return BinderRegistration.of(this, id);
}
项目:turbogwt-databind    文件:DatabindViewEngineTest.java   
public void testBindWidget() {
    doTestBindWidget(new BindWidgetCallback() {
        @Override
        public HandlerRegistration bind(ViewEngine engine, String propertyId, IsWidget widget) {
            return engine.bind(propertyId, (HasValue<?>) widget, Strategy.ON_CHANGE);
        }
    });
}
项目:kaa    文件:ConfigFormStructView.java   
@Override
protected HasValue<RecordField> createBody(HasErrorMessage hasErrorMessage) {
  RecordPanel field = new RecordPanel(
      Utils.constants.configurationBody(), hasErrorMessage, false, false);
  configurationFormDataLoader = new ConfigurationFormDataLoader();
  field.setFormDataLoader(configurationFormDataLoader);
  field.getRecordWidget().setForceNavigation(true);
  field.setPreferredHeightPx(200);
  return field;
}
项目:empiria.player    文件:ReplacingChangeHandler.java   
public <T extends IsWidget & HasValue<String>> void init(Wrapper<T> textBox, ExpressionReplacer expressionReplacer) {
    this.textBox = textBox.getInstance();
    this.expressionReplacer = expressionReplacer;
    eventRegistrar.registerInputHandler(textBox.getInstance(), listener);
}
项目:gwt-editor-apt    文件:EditorProcessingContext.java   
private boolean isInstanceOfHasValue(VariableElement variableElement) {
  return types.isAssignable(variableElement.asType(),
                            types.erasure(requireType(elements,
                                                      HasValue.class).asType()));
}
项目:ephesoft    文件:FileNameValidator.java   
public FileNameValidator(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:FileNameValidator.java   
public void setValue(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:RegExValidator.java   
public RegExValidator(final RegExValidatableWidget<?> validatableWidget, final String pattern, final HasValue<String> value,
        final DCMARemoteServiceAsync remoteServiceAsync) {
    this(validatableWidget, value, true, false, false, null, remoteServiceAsync);
    this.pattern = pattern;
}
项目:ephesoft    文件:SuggestBoxValidator.java   
public SuggestBoxValidator(HasValue<String> value, Collection<String> suggestValues) {
    this.value = value;
    this.suggestValues = suggestValues;
}
项目:ephesoft    文件:SuggestBoxValidator.java   
public void setValue(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:EmptyStringValidator.java   
public EmptyStringValidator(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:EmptyStringValidator.java   
public void setValue(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:DateFormatValidator.java   
public DateFormatValidator(HasValue<String> value) {
    this("dd/MM/yyyy", value);
}
项目:ephesoft    文件:DateFormatValidator.java   
public DateFormatValidator(String pattern, HasValue<String> value) {
    format = DateTimeFormat.getFormat(pattern);
    this.value = value;
}
项目:ephesoft    文件:DateFormatValidator.java   
public void setValue(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:PatternValidator.java   
public PatternValidator(HasValue<String> value, List<String> patternStr) {
    this.value = value;
    this.patternStr = patternStr;
}
项目:ephesoft    文件:PatternValidator.java   
public void setValue(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:NumberValidator.java   
public NumberValidator(HasValue<String> value) {
    this.value = value;
}
项目:ephesoft    文件:NumberValidator.java   
public NumberValidator(HasValue<String> value, boolean isFloat) {
    this.value = value;
    this.isFloat = isFloat;
}
项目:ephesoft    文件:NumberValidator.java   
public NumberValidator(HasValue<String> value, boolean isFloat, boolean skipNullCheck) {
    this.value = value;
    this.isFloat = isFloat;
    this.skipNullCheck = skipNullCheck;
}
项目:ephesoft    文件:NumberValidator.java   
public NumberValidator(HasValue<String> value, boolean isFloat, boolean skipNullCheck, boolean isOnlyPositive) {
    this.value = value;
    this.isFloat = isFloat;
    this.skipNullCheck = skipNullCheck;
    this.isOnlyPositive = isOnlyPositive;
}
项目:ephesoft    文件:NumberValidator.java   
public void setValue(HasValue<String> value) {
    this.value = value;
}
项目:sandbox-frame    文件:ChangeKaaHostViewImpl.java   
@Override
public HasValue<String> getKaaHost() {
    return kaaHost;
}
项目:che    文件:ShowWelcomePreferencePageViewImpl.java   
@Override
public HasValue<Boolean> welcomeField() {
  return showWelcome;
}
项目:Databind    文件:ValuePropertyAdapter.java   
@SuppressWarnings("unchecked")
public ValuePropertyAdapter(HasValue<?> hasValue) {
    this.hasValue = (HasValue<Object>) hasValue;
}