本文整理匯總了Java中com.google.gwt.user.client.ui.HasValue類的典型用法代碼示例。如果您正苦於以下問題:Java HasValue類的具體用法?Java HasValue怎麽用?Java HasValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HasValue類屬於com.google.gwt.user.client.ui包,在下文中一共展示了HasValue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getValidator
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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;
}
示例2: FieldsEditor
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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);
}
示例3: getData
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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;
}
示例4: UTCDateTimeRangeController
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
/**
* 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);
}
示例5: RegExValidator
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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;
}
示例6: onLoad
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
@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();
}
示例7: checkValueChangeEvent
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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());
}
示例8: getValue
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
/**
* 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();
}
});
}
示例9: setValue
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
/**
* 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);
}
示例10: gatherForm
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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);
}
}
示例11: add
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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);
}
}
示例12: remove
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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);
}
示例13: getChild
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
public HasPublished getChild(int i) {
HasValue<Boolean> child = super.get(i);
if (child instanceof HasPublished)
return (HasPublished) child;
else
return null;
}
示例14: placeWidgetToMenu
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
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);
}
示例15: setValue
import com.google.gwt.user.client.ui.HasValue; //導入依賴的package包/類
@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);
}
}
}