Package org.eclipse.core.databinding.conversion

Examples of org.eclipse.core.databinding.conversion.IConverter


    myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortRadioGroup), BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER),
        null, null);

    UpdateValueStrategy fetchSpecEmpty = new UpdateValueStrategy();
    fetchSpecEmpty.setConverter(new IConverter() {
      public Object convert(final Object fromObject) {
        boolean result = fromObject != null && ((List<?>) fromObject).size() > 0;
        if (!myHasDetailButton.getSelection()) {
          return result;
        }
View Full Code Here


      IObservableValue destination) {
    Object sourceType = source.getValueType();
    Object destinationType = destination.getValueType();
    if (provideDefaults && sourceType != null && destinationType != null) {
      if (converter == null) {
        IConverter converter = createConverter(sourceType,
            destinationType);
        defaultedConverter = (converter != null);
        setConverter(converter);
      }

      if (afterGetValidator == null) {
        afterGetValidator = createValidator(sourceType, destinationType);
      }
    }
    if (converter != null) {
      if (sourceType != null) {
        checkAssignable(converter.getFromType(), sourceType,
            "converter does not convert from type " + sourceType); //$NON-NLS-1$
      }
      if (destinationType != null) {
        checkAssignable(destinationType, converter.getToType(),
            "converter does not convert to type " + destinationType); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

      } else if (converterOrClassname instanceof String) {
        String classname = (String) converterOrClassname;
        Class converterClass;
        try {
          converterClass = Class.forName(classname);
          IConverter result = (IConverter) converterClass
              .newInstance();
          converterMap.put(key, result);
          return result;
        } catch (Exception e) {
          Policy
View Full Code Here

      IObservableValue destination) {
    Object sourceType = source.getValueType();
    Object destinationType = destination.getValueType();
    if (provideDefaults && sourceType != null && destinationType != null) {
      if (converter == null) {
        IConverter converter = createConverter(sourceType,
            destinationType);
        defaultedConverter = (converter != null);
        setConverter(converter);
      }

      if (afterGetValidator == null) {
        afterGetValidator = createValidator(sourceType, destinationType);
      }
    }
    if (converter != null) {
      if (sourceType != null) {
        checkAssignable(converter.getFromType(), sourceType,
            "converter does not convert from type " + sourceType); //$NON-NLS-1$
      }
      if (destinationType != null) {
        checkAssignable(converter.getToType(), destinationType,
            "converter does not convert to type " + destinationType); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

      } else if (converterOrClassname instanceof String) {
        String classname = (String) converterOrClassname;
        Class converterClass;
        try {
          converterClass = Class.forName(classname);
          IConverter result = (IConverter) converterClass
              .newInstance();
          converterMap.put(key, result);
          return result;
        } catch (Exception e) {
          Policy
View Full Code Here

      Object data = tableItem.getData();
      PropertyDescriptor descriptor = getDescriptor(data, property);
      if (descriptor != null) {
        try {
          Class<?> type = descriptor.getPropertyType();
          IConverter converter = XWT.findConvertor(value.getClass(), type);
          if (converter != null) {
            Object newValue = converter.convert(value);
            descriptor.getWriteMethod().invoke(data, newValue);
            tableViewer.refresh(data);
          } else {
            throw new XWTException("Converter doesn't exist from \"" + value.getClass().getName() + "\" to \"" + type.getName());
          }
View Full Code Here

    }
  }

  public void registerConvertor(Class<?> converterType, String methodName,
      boolean value) {
    IConverter converter = loadConvertor(converterType, methodName, value);
    if (converter != null) {
      registerConvertor(converter);
    }
  }
View Full Code Here

  }

  public void registerConvertor(ValueConvertorRegister convertorRegister,
      Class<?> source, Class<?> target, Class<?> converterType,
      String methodName, boolean value) {
    IConverter converter = loadConvertor(converterType, methodName, value);
    if (converter != null) {
      convertorRegister.register(source, target, converter);
    }
  }
View Full Code Here

  public ConverterService getConverterService() {
    ConverterService service = (ConverterService) getService(ConverterService.class);
    if (service == null) {
      service = new ConverterService();
      registerService(ConverterService.class, service);
      service.register(Object.class, new IConverter() {
        public Object convert(Object fromObject) {
          return null;
        }

        public Object getFromType() {
View Full Code Here

  class ConverterService {
    protected Map<Class<?>, IConverter> converters = new HashMap<Class<?>, IConverter>();

    public IConverter getConverter(Class<?> type) {
      IConverter converter = converters.get(type);
      if (converter != null) {
        return converter;
      }

      return null;
View Full Code Here

TOP

Related Classes of org.eclipse.core.databinding.conversion.IConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.