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


Java IValidator类代码示例

本文整理汇总了Java中org.eclipse.core.databinding.validation.IValidator的典型用法代码示例。如果您正苦于以下问题:Java IValidator类的具体用法?Java IValidator怎么用?Java IValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IValidator类属于org.eclipse.core.databinding.validation包,在下文中一共展示了IValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addDataBinder

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
private void addDataBinder(Widget toObserve, IValidator validator, Class<?> observableClass,
        String propertyName, Object observedProperty, boolean textDecorationEnabled) {
    IObservableValue textObservable = WidgetProperties.text(SWT.Modify).observe(toObserve);
    UpdateValueStrategy strategy = new UpdateValueStrategy();
    strategy.setBeforeSetValidator(validator);

    ValidationStatusProvider binding = this.ctx.bindValue(textObservable,
        PojoProperties.value(observableClass, propertyName).observe(observedProperty), strategy,
        null);
    if (textDecorationEnabled) {
        ControlDecorationSupport.create(binding, SWT.LEFT);
    }
    final IObservableValue errorObservable = WidgetProperties.text()
            .observe(this.addDialog.getErrorLabel());

    ctx.bindValue(errorObservable, new AggregateValidationStatus(ctx.getBindings(),
            AggregateValidationStatus.MAX_SEVERITY),
        null, null);

}
 
开发者ID:apache,项目名称:ant-ivyde,代码行数:21,代码来源:SecuritySetupController.java

示例2: setupTextFieldDataBinding

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
 * Binds a {@link Text} field with a property of the {@link DeployPreferences deploy
 * preferences model} given to the panel.
 *
 * Unlike {@link #setupFileFieldDataBinding}, {@code setAfterGetValidator} is always enforced
 * regardless of the panel's validation mode.
 *
 * @see #setupTextFieldDataBinding
 */
private void setupTextFieldDataBinding(Text text, String modelPropertyName,
    IValidator afterGetValidator) {
  ISWTObservableValue textValue = WidgetProperties.text(SWT.Modify).observe(text);
  IObservableValue modelValue = PojoProperties.value(modelPropertyName).observe(model);

  bindingContext.bindValue(textValue, modelValue,
      new UpdateValueStrategy().setAfterGetValidator(afterGetValidator),
      new UpdateValueStrategy().setAfterGetValidator(afterGetValidator));
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:19,代码来源:AppEngineDeployPreferencesPanel.java

示例3: aggregateStatus

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
 * aggregates the validation status for binding context and displays message
 * in title area
 */
protected void aggregateStatus() {
	final AggregateValidationStatus aggregateValidationStatus = BindingHelper
			.aggregateValidationStatus(bindingContext);
	bindingContext.bindValue(validationStatus, aggregateValidationStatus,
			new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
			new UpdateValueStrategy().setAfterConvertValidator(new IValidator() {

				@Override
				public IStatus validate(final Object value) {
					final Status status = (Status) value;
					switch (status.getSeverity()) {
					case IStatus.OK:
						setMessage("", IMessageProvider.NONE);//$NON-NLS-1$
						break;
					case IStatus.INFO:
						setMessage(status.getMessage(), IMessageProvider.INFORMATION);
						break;
					case IStatus.WARNING:
						setMessage(status.getMessage(), IMessageProvider.WARNING);
						break;
					case IStatus.ERROR:
						setMessage(status.getMessage(), IMessageProvider.ERROR);
						break;
					}
					return Status.OK_STATUS;
				}
			}));
	bindingContext.bindValue(SWTObservables.observeEnabled(getButton(IDialogConstants.OK_ID)),
			new StatusAsObservable(aggregateValidationStatus), null, null);
}
 
开发者ID:FI13,项目名称:afbb-bibo,代码行数:35,代码来源:AbstractDialog.java

示例4: getValidator

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
public IValidator getValidator()
{
  IValidator validator = new IValidator()
  {
    @Override
    public IStatus validate(Object value)
    {
      if (value instanceof String)
      {
        String string = (String) value;
        
        try
        {
          validateValue(string);
          
          msg.setText("");
          
          return Status.OK_STATUS;
        }
        catch(Exception e)
        {
          msg.setText(getMessage());

          return ValidationStatus.error(e.getLocalizedMessage());
        }          
      }
      else
      {
        throw new RuntimeException("Not supposed to be called for non-strings.");
      }
    }
  };
  
  return validator;
}
 
开发者ID:terraframe,项目名称:Runway-SDK,代码行数:36,代码来源:ValidateTextWidget.java

示例5: TopicStringCellEditor

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
public TopicStringCellEditor(TableViewer viewer) {
	super(viewer);
	this.cellEditor = new TextCellEditor(viewer.getTable());
	final IValidator validator = Validators.decorate(Validators.subscribeTopic, cellEditor.getControl());
	this.cellEditor.setValidator(new ICellEditorValidator() {
		@Override
		public String isValid(Object value) {
			IStatus status = validator.validate(value);
			return (status == null || status.isOK()) ? null : status.getMessage();
		}
	});
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:13,代码来源:TopicStringCellEditor.java

示例6: ServerUriCellEditor

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
public ServerUriCellEditor(TableViewer viewer) {
	super(viewer);
	this.cellEditor = new TextCellEditor(viewer.getTable());
	final IValidator validator = Validators.decorate(Validators.serverUri, cellEditor.getControl());
	this.cellEditor.setValidator(new ICellEditorValidator() {
		@Override
		public String isValid(Object value) {
			IStatus status = validator.validate(value);
			return (status == null || status.isOK()) ? null : status.getMessage();
		}
	});
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:13,代码来源:ServerUriCellEditor.java

示例7: bindText

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
 * Returns an observable observing the text attribute of the provided <code>control</code>. The supported types
 * are:
 * <ul>
 * <li>org.eclipse.swt.widgets.Text</li>
 * <li>org.eclipse.swt.custom.StyledText (as of 1.3)</li>
 * </ul>
 * 
 * @param control
 * @param event event type to register for change events {@literal SWT.FocusOut  SWT.Modify or SWT.NONE}
 * @param bean
 * @param propertyName
 * @param validator
 * @param converter
 * @return binding
 * @throws IllegalArgumentException if <code>control</code> type is unsupported
 */
public DecoratedBinding bindText(Control control, int event, Object bean, String propertyName,
		IValidator validator, IConverter targetToModelConverter, IConverter modelToTargetConverter) {

	// IObservableValue widgetValue =
	// WidgetProperties.text(SWT.Modify).observe(serverUriText);
	// IObservableValue modelValuea = BeanProperties.value(Connection.class,
	// "serverURI").observe(connection);

	// observe
	IObservableValue widgetValue = SWTObservables.observeText(control, event);
	IObservableValue modelValue = BeansObservables.observeValue(bean, propertyName);

	UpdateValueStrategy targetToModel = new UpdateValueStrategy();
	UpdateValueStrategy modelToTarget = new UpdateValueStrategy();

	// targetToModel
	// validator
	if (validator != null) {
		targetToModel.setBeforeSetValidator(validator);
	}
	// converter
	if (targetToModelConverter != null) {
		targetToModel.setConverter(targetToModelConverter);
	}

	// modelToTarget
	if (modelToTargetConverter != null) {
		modelToTarget.setConverter(modelToTargetConverter);
	}

	Binding bindValue = context.bindValue(widgetValue, modelValue, targetToModel, modelToTarget);

	// decoration
	ControlDecorationSupport decorationSupport = ControlDecorationSupport.create(bindValue, SWT.TOP | SWT.LEFT);

	return new DecoratedBinding(bindValue, decorationSupport);
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:55,代码来源:DataBindings.java

示例8: initializeBindings

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
private DataBindingContext initializeBindings()
{
	EMFUpdateValueStrategy us = new EMFUpdateValueStrategy();
	us.setBeforeSetValidator(new IValidator()
	{

		@Override
		public IStatus validate(Object value)
		{
			if (value instanceof String)
			{
				if (value.toString().trim().length() > 0)
				{
					return ValidationStatus.ok();
				}
			}
			return ValidationStatus.error("Content must be at least one character");
		}
	});

	DataBindingContext bindingContext = new DataBindingContext();

	FeaturePath feature = FeaturePath.fromList(BtsmodelPackage.Literals.BTS_PROJECT__DB_CONNECTION,
			BtsmodelPackage.Literals.BTSDB_CONNECTION__TYPE);

	IObservableValue model = EMFProperties.value(feature).observe(project);
	Binding binding = bindingContext.bindValue(
			WidgetProperties.text(SWT.Modify).observeDelayed(400, txtConnectiontype), model, null, null);
	bindingContext.addValidationStatusProvider(binding);

	FeaturePath feature2 = FeaturePath.fromList(BtsmodelPackage.Literals.BTS_PROJECT__DB_CONNECTION,
			BtsmodelPackage.Literals.BTSDB_CONNECTION__MASTER_SERVER);
	IObservableValue model2 = EMFProperties.value(feature2).observe(project);
	Binding binding2 = bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observeDelayed(400, text),
			model2, null, null);
	bindingContext.addValidationStatusProvider(binding2);

	FeaturePath feature3 = FeaturePath.fromList(BtsmodelPackage.Literals.BTS_PROJECT__DB_CONNECTION,
			BtsmodelPackage.Literals.BTSDB_CONNECTION__DB_PATH);
	IObservableValue model3 = EMFProperties.value(feature3).observe(project);
	Binding binding3 = bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observeDelayed(400, textdbPath),
			model3, null, null);
	bindingContext.addValidationStatusProvider(binding3);

	return bindingContext;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:47,代码来源:ProjectConnectionPage.java

示例9: initializeBindings

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
private DataBindingContext initializeBindings()
{
	EMFUpdateValueStrategy us = new EMFUpdateValueStrategy();
	context = StaticAccessController.getContext();
	sync = context.get(UISynchronize.class);
	editingDomainController = context.get(EditingDomainController.class);
	permisionsController = context.get(PermissionsAndExpressionsEvaluationController.class);
	us.setBeforeSetValidator(new IValidator()
	{

		@Override
		public IStatus validate(Object value)
		{
			if (value instanceof String)
			{
				if (value.toString().trim().length() > 0)
				{
					return ValidationStatus.ok();
				}
			}
			return ValidationStatus.error("Content must be at least one character");
		}
	});

	DataBindingContext bindingContext = new DataBindingContext();

	IObservableValue model = EMFProperties.value(
			BtsmodelPackage.Literals.BTS_PROJECT_DB_COLLECTION__COLLECTION_NAME).observe(collection);
	Binding binding = bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observeDelayed(400, text), model,
			us, null);
	bindingContext.addValidationStatusProvider(binding);
	ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT);

	IObservableValue model2 = EMFProperties.value(BtsmodelPackage.Literals.BTS_PROJECT_DB_COLLECTION__SYNCHRONIZED)
			.observe(collection);
	Binding binding2 = bindingContext.bindValue(
			WidgetProperties.selection().observeDelayed(0, btnSyncronizeCollection), model2, null, null);
	bindingContext.addValidationStatusProvider(binding2);
	ControlDecorationSupport.create(binding2, SWT.TOP | SWT.LEFT);

	IObservableValue model3 = EMFProperties.value(BtsmodelPackage.Literals.BTS_PROJECT_DB_COLLECTION__INDEXED)
			.observe(collection);
	Binding binding3 = bindingContext.bindValue(
			WidgetProperties.selection().observeDelayed(0, btnIndexCollectionFor), model3, null, null);
	bindingContext.addValidationStatusProvider(binding3);
	ControlDecorationSupport.create(binding2, SWT.TOP | SWT.LEFT);

	btnSyncronizeCollection.setEnabled(permisionsController.authenticatedUserMaySyncDBColl(text.getText()));

	return bindingContext;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:52,代码来源:EditDBCollectionDialog.java

示例10: createBinding

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
private void createBinding() throws ConnectException {
	initBinding();
	final AggregateValidationStatus aggregateValidationStatus = BindingHelper
			.aggregateValidationStatus(bindingContext);
	bindingContext.bindValue(validationStatus, aggregateValidationStatus,
			new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
			new UpdateValueStrategy().setAfterConvertValidator(new IValidator() {

				@Override
				public IStatus validate(final Object value) {
					final Status status = (Status) value;
					if (OK.equals(status.getMessage())) {
						setMessage(EMPTY_STRING, null);
					} else {
						final String newMessage = status.getMessage();
						Image newImage = null;
						if (newMessage != null) {
							switch (status.getSeverity()) {
							case IMessageProvider.NONE:
								break;
							case IMessageProvider.INFORMATION:
								newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
								break;
							case IMessageProvider.WARNING:
								newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
								break;
							case IMessageProvider.ERROR:
								newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
								break;
							case IStatus.ERROR:
								newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
								break;
							}
						}
						setMessage(newMessage, newImage);
					}
					return Status.OK_STATUS;
				}

			}));
}
 
开发者ID:FI13,项目名称:afbb-bibo,代码行数:42,代码来源:AbstractView.java

示例11: ValidatorStatusProvider

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
public ValidatorStatusProvider(IValidator validator, BFormInstance<?, ?> formInstance, DataBindingContext context) {
	this.validator = validator;
	this.formInstance = formInstance;
	this.context = context;
}
 
开发者ID:frincon,项目名称:abstractform,代码行数:6,代码来源:ValidatorStatusProvider.java

示例12: DecoratedValidator

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
 * @param validator
 * @param decoration
 */
protected DecoratedValidator(IValidator validator, ControlDecoration decoration) {
	this.validator = validator;
	this.decoration = decoration;
	this.decoration.setMarginWidth(10);
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:10,代码来源:DataBindings.java

示例13: bind

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
    * Bind.
    * 
    * @param textWidget
    *            the text widget
    * @param bean
    *            the bean
    * @param property
    *            the property
    * @param validator
    *            the validator
    */
   private void bind(Text textWidget, Object bean, String property, IValidator validator) {
UpdateValueStrategy targetToModel = null;
if (validator != null) {
    targetToModel = new UpdateValueStrategy().setAfterConvertValidator(validator);
}
_dbc.bindValue(SWTObservables.observeText(textWidget, SWT.Modify), BeansObservables.observeValue(bean, property), targetToModel, null);
   }
 
开发者ID:synergynet,项目名称:synergyview,代码行数:20,代码来源:NewAttributeWizardPage.java

示例14: bind

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
    * Bind.
    * 
    * @param textWidget
    *            the text widget
    * @param bean
    *            the bean
    * @param property
    *            the property
    * @param validator
    *            the validator
    */
   private void bind(Text textWidget, Object bean, String property, IValidator validator) {
UpdateValueStrategy targetToModel = null;
if (validator != null) {
    targetToModel = new UpdateValueStrategy().setAfterConvertValidator(validator);
}
dbc.bindValue(SWTObservables.observeText(textWidget, SWT.Modify), BeansObservables.observeValue(bean, property), targetToModel, null);
   }
 
开发者ID:synergynet,项目名称:synergyview,代码行数:20,代码来源:NewCollectionWizardPage.java

示例15: decorate

import org.eclipse.core.databinding.validation.IValidator; //导入依赖的package包/类
/**
 * @param validator
 * @param control
 */
public static IValidator decorate(IValidator validator, Control control) {
	return new DecoratedValidator(validator, control);
}
 
开发者ID:gulliverrr,项目名称:hestia-engine-dev,代码行数:8,代码来源:DataBindings.java


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