當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。