本文整理汇总了Java中org.eclipse.core.databinding.conversion.NumberToStringConverter类的典型用法代码示例。如果您正苦于以下问题:Java NumberToStringConverter类的具体用法?Java NumberToStringConverter怎么用?Java NumberToStringConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NumberToStringConverter类属于org.eclipse.core.databinding.conversion包,在下文中一共展示了NumberToStringConverter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindWidgets
import org.eclipse.core.databinding.conversion.NumberToStringConverter; //导入依赖的package包/类
@Override
protected void bindWidgets(DataAdapter dataAdapter) {
bindingContext.bindValue(
SWTObservables.observeText(hostname, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "hostname")); //$NON-NLS-1$
bindingContext.bindValue(
SWTObservables.observeText(keyspace, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "keyspace")); //$NON-NLS-1$
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
numberFormat.setGroupingUsed(false);
IConverter targetToModelConverter = StringToNumberConverter.toInteger(numberFormat, true);
IConverter modelToTargetConverter = NumberToStringConverter.fromInteger(numberFormat, true);
bindingContext.bindValue(
SWTObservables.observeText(port, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "port"),
new UpdateValueStrategy().setConverter(targetToModelConverter),
new UpdateValueStrategy().setConverter(modelToTargetConverter)); //$NON-NLS-1$
bindingContext.bindValue(
SWTObservables.observeText(username, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "username")); //$NON-NLS-1$
bindingContext.bindValue(
SWTObservables.observeText(password, SWT.Modify),
PojoObservables.observeValue(dataAdapter, "password")); //$NON-NLS-1$
port.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
for (char c : e.text.toCharArray()){
if (!Character.isDigit(c)) {
e.doit = false;
return;
}
}
}
});
}
示例2: refresh
import org.eclipse.core.databinding.conversion.NumberToStringConverter; //导入依赖的package包/类
@Override
public void refresh() {
super.refresh();
List<ValueProvider> nestedIntValProviders
= alternative.getVariationValueProviders(ExperimentsPackage.Literals.NESTED_INTERVALS_LONG_VALUE_PROVIDER);
if(nestedIntValProviders.isEmpty()){
textMaxValue.setEnabled(false);
textMinValue.setEnabled(false);
return;
}
NestedIntervalsLongValueProvider valueProvider = (NestedIntervalsLongValueProvider)nestedIntValProviders.get(0);
//data binding
if(bindingContext != null){
bindingContext.dispose();
bindingContext = null;
}
bindingContext = new DataBindingContext();
UpdateValueStrategy t2mStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
t2mStrategy.setConverter(StringToNumberConverter.toLong(true));
UpdateValueStrategy m2tStrategy = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE);
m2tStrategy.setConverter(NumberToStringConverter.fromLong(true));
IObservableValue minValObs = EMFEditProperties.value(alternative.getEditingDomain(),
ExperimentsPackage.Literals.NESTED_INTERVALS_LONG_VALUE_PROVIDER__MIN_VALUE).observe(valueProvider);
IObservableValue maxValObs = EMFEditProperties.value(alternative.getEditingDomain(),
ExperimentsPackage.Literals.NESTED_INTERVALS_LONG_VALUE_PROVIDER__MAX_VALUE).observe(valueProvider);
Binding minValBind = bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(textMinValue),
minValObs, t2mStrategy, m2tStrategy);
Binding maxValBind = bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(textMaxValue),
maxValObs, t2mStrategy, m2tStrategy);
ControlDecorationSupport.create(minValBind, SWT.TOP | SWT.LEFT);
ControlDecorationSupport.create(maxValBind, SWT.TOP | SWT.LEFT);
bindingContext.updateTargets();
}