当前位置: 首页>>代码示例>>Java>>正文


Java NumberToStringConverter类代码示例

本文整理汇总了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;
				}
			}
		}
	});
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:37,代码来源:CassandraDataAdapterComposite.java

示例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();
}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:46,代码来源:ConfigCapacityComposite.java


注:本文中的org.eclipse.core.databinding.conversion.NumberToStringConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。