Package org.eclipse.core.databinding.observable.value

Examples of org.eclipse.core.databinding.observable.value.IObservableValue


      }

      if (!(bindingTarget instanceof IObservableValue)) {
        return;
      }
      IObservableValue observableValue = (IObservableValue) bindingTarget;
      observableValue.addChangeListener(changeListener);
    }
    changeListener.doHandleChange(false);
  }
View Full Code Here


        continue;
      }
      String eventPropertyName = IEventConstants.getEventPropertyName(name);
      IProperty eventProperty = metaclass.findProperty(eventPropertyName);

      IObservableValue value = manager.getValue(eventProperty);
      if (value != null) {
        value.setValue(false);
      }
    }
  }
View Full Code Here

              realValue = converter.convert(value);           
            }
          }
          Object newValue = event.getSource();
          if (newValue instanceof IObservableValue) {
            IObservableValue observableValue = (IObservableValue) newValue;
            newValue = observableValue.getValue();
          }
          if (newValue != null) {
            IConverter newConverter = XWT.findConvertor(newValue.getClass(), valueType);
            if (newConverter != null) {
              newValue = newConverter.convert(newValue);           
View Full Code Here

  /**
   * Get bind value of two bindings.
   */
  public Object getValue(Class<?> targetType) {
    IObservableValue targetWidget = null;
    Object target = getControl();
    if (target != null) {
      targetWidget = ScopeManager.observeValue(target, target,
          getTargetProperty(), getUpdateSourceTrigger());
    }
    if (source == null) {
      return null;
    }

    Object control = UserData.getWidget(source);
    if (control == null) {
      control = getControl();
    }

    IObservableValue sourceWidget = ScopeManager.observeValue(control, source,
        getSourceProperty(), getUpdateSourceTrigger());

    if (targetWidget == null) {
      if (sourceWidget != null) {
        if (targetType != null && !targetType.isInstance(sourceWidget)) {
          return sourceWidget;     
        }
        Object value = sourceWidget.getValue();
        while(value instanceof IObservableValue) {
          value = ((IObservableValue)value).getValue();
        }
        IValueConverter converter = getConverter();
        if (converter != null) {
          value = converter.convert(value);
        }
        return value;
      }
      return source;
    }

    IBindingContext dataBindingContext = getDataBindingContext();
    BindingGate bindingGate = new BindingGate(dataBindingContext);
    bindingGate.bind(sourceWidget, targetWidget, this);
    if (sourceWidget != null) {
      if (targetType != null && !targetType.isInstance(sourceWidget)) {
        return sourceWidget;     
      }
      // convert to final value
      Object value = sourceWidget.getValue();
      while(value instanceof IObservableValue) {
        value = ((IObservableValue)value).getValue();
      }
      IValueConverter converter = getConverter();
      if (converter != null) {
View Full Code Here

  }
 
  public void changeValueHandle(Object object, Event event){
    // TODO the cast is not clean.
    EventProperty property = (EventProperty) object;
    IObservableValue value = map.get(property.getName());
    if (value != null) {
      Boolean oldValue = (Boolean) value.getValue();
      if (oldValue == null) {
        oldValue = false;
      }
      value.setValue(!oldValue);
    }
   
    IMetaclass metaclass = XWT.getMetaclass(host);
   
    // TODO this conversion should be simplied
View Full Code Here

    case ScopeManager.AUTO:
      if (propertyTypeClass != null
          && (propertyTypeClass.isArray() || List.class
              .isAssignableFrom(propertyTypeClass))) {
        if (data instanceof IObservableValue) {
          IObservableValue observable = (IObservableValue) data;
          return observeDetailList(observable, type, path,
              propertyType);
        }
        return observeList(data, path);
      } else if (propertyTypeClass != null
          && (Set.class.isAssignableFrom(propertyTypeClass))) {
        if (data instanceof IObservableValue) {
          IObservableValue observable = (IObservableValue) data;
          return observeDetailSet(observable, type, path,
              propertyType);
        }
        return observeSet(data, path);
      } else {
        if (data instanceof IObservableValue) {
          IObservableValue observable = (IObservableValue) data;
          return observeDetailValue(observable, type, path,
              propertyType);
        }
        return observeValue(data, path);
      }
    case ScopeManager.VALUE:
      if (data instanceof IObservableValue) {
        IObservableValue observable = (IObservableValue) data;
        return observeDetailValue(observable, type, path, propertyType);
      }
      return observeValue(data, path);
    case ScopeManager.COLLECTION:
      if (propertyTypeClass != null
          && Set.class.isAssignableFrom(propertyTypeClass)) {
        if (data instanceof IObservableValue) {
          IObservableValue observable = (IObservableValue) data;
          return observeDetailSet(observable, type, path,
              propertyType);
        }
        return observeSet(data, path);
      }
      if (data instanceof IObservableValue) {
        IObservableValue observable = (IObservableValue) data;
        return observeDetailList(observable, type, path, propertyType);
      }
      return observeList(data, path);
    case ScopeManager.SET:
      if (data instanceof IObservableValue) {
        IObservableValue observable = (IObservableValue) data;
        return observeDetailSet(observable, type, path, propertyType);
      }
      return observeSet(data, path);
    case ScopeManager.LIST:
      if (data instanceof IObservableValue) {
        IObservableValue observable = (IObservableValue) data;
        return observeDetailList(observable, type, path, propertyType);
      }
      return observeList(data, path);
    }
    return null;
View Full Code Here

  }

  public static Class<?> toType(Object target) {
    Class<?> type = null;
    if (target instanceof IObservableValue) {
      IObservableValue value = (IObservableValue) target;
      Object valueType = value.getValueType();
      if (valueType instanceof Class<?>) {
        type = (Class<?>) valueType;
      } else {
        System.out.println();
      }
View Full Code Here

      String propertyName, UpdateSourceTrigger updateSourceTrigger) {
    if (object instanceof Viewer) {
      if ("input".equals(propertyName)) {
        Viewer viewer = (Viewer) object;
        SimpleValueProperty property = (SimpleValueProperty) ViewerProperties.input();
        IObservableValue observableValue = new SimplePropertyObservableValue(XWT.getRealm(), viewer, property);
        return new TypedViewerObservableValueDecorator(observableValue, viewer);
      }
      else if ("singleSelection".equals(propertyName)) {
        Viewer viewer = (Viewer) object;
        SimpleValueProperty property = (SimpleValueProperty) ViewerProperties.singleSelection();
        IObservableValue observableValue = new SimplePropertyObservableValue(XWT.getRealm(), viewer, property);
        return new TypedViewerObservableValueDecorator(observableValue, viewer);
      }
      return observePropertyValue((Viewer) object, propertyName, updateSourceTrigger);
    } else if (object instanceof MenuItem) {
      //
View Full Code Here

          event = SWT.Modify;
          break;
        default:
          throw new IllegalStateException("UpdateSourceTrigger of value " + updateSourceTrigger.name());
        }
        IObservableValue observableValue = SWTObservables.observeText(
            control, event);
        if (observableValue != null) {
          return observableValue;
        }
      }
      // widget button is not supported at 3.4 version.
      if (SWT.getVersion() == 3449 && control instanceof Button) {
        return null;
      }
      try {
        IObservableValue observableValue = SWTObservables
            .observeText(control);
        if (observableValue != null) {
          return observableValue;
        }
      } catch (IllegalArgumentException e) {
        throw new XWTException(e);
      }
    } else {
      if (propertyName == null) {
        return null;
      }
      String getterName = "observe"
          + propertyName.substring(0, 1).toUpperCase()
          + propertyName.substring(1);
      Method method;
      try {
        method = SWTObservables.class.getMethod(getterName,
            CONTROL_ARGUMENT_TYPES);
        if (method == null) {
          for (Method element : SWTObservables.class.getMethods()) {
            if (element.getParameterTypes().length != 0) {
              continue;
            }
            if (element.getName().equalsIgnoreCase(getterName)) {
              method = element;
              break;
            }
          }
        }
        if (method != null) {
          IObservableValue observableValue = (IObservableValue) method
              .invoke(null, control);
          if (observableValue != null) {
            return observableValue;
          }
        }
View Full Code Here

  protected DataBindingContext initDataBindings() {
   
    DataBindingContext bindingContext = super.initDataBindings();
   
    //
    IObservableValue observeTextRepositoryDestinationTextObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(repositoryDestinationText);
    IObservableValue managedConnectionFactoryRepositoryDestObserveValue = EMFEditProperties.value(editingDomain, FeaturePath.fromList(Literals.DESTINATION_DATA_STORE_ENTRY__VALUE, Literals.DESTINATION_DATA__REPOSITORY_DEST)).observe(destinationDataStoreEntry);
    bindingContext.bindValue(observeTextRepositoryDestinationTextObserveWidget, managedConnectionFactoryRepositoryDestObserveValue, null, null);
    //
    IObservableValue observeTextRepositoryUserTextObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(repositoryUserText);
    IObservableValue managedConnectionFactoryRepositoryUserObserveValue = EMFEditProperties.value(editingDomain, FeaturePath.fromList(Literals.DESTINATION_DATA_STORE_ENTRY__VALUE, Literals.DESTINATION_DATA__REPOSITORY_USER)).observe(destinationDataStoreEntry);
    bindingContext.bindValue(observeTextRepositoryUserTextObserveWidget, managedConnectionFactoryRepositoryUserObserveValue, null, null);
    //
    IObservableValue observeTextRepositoryPasswordTextObserveWidget = WidgetProperties.text(SWT.FocusOut).observe(repositoryPasswordText);
    IObservableValue managedConnectionFactoryRepositoryPasswdObserveValue = EMFEditProperties.value(editingDomain, FeaturePath.fromList(Literals.DESTINATION_DATA_STORE_ENTRY__VALUE, Literals.DESTINATION_DATA__REPOSITORY_PASSWD)).observe(destinationDataStoreEntry);
    bindingContext.bindValue(observeTextRepositoryPasswordTextObserveWidget, managedConnectionFactoryRepositoryPasswdObserveValue, null, null);
    //
    IObservableValue observeSelectionRespositorySncBtnObserveWidget = WidgetProperties.selection().observe(respositorySncBtn);
    IObservableValue managedConnectionFactoryRepositorySncObserveValue = EMFEditProperties.value(editingDomain, FeaturePath.fromList(Literals.DESTINATION_DATA_STORE_ENTRY__VALUE, Literals.DESTINATION_DATA__REPOSITORY_SNC)).observe(destinationDataStoreEntry);
    UpdateValueStrategy strategy_15 = new UpdateValueStrategy();
    strategy_15.setConverter(new Boolean2StringConverter());
    UpdateValueStrategy repositorySncModelStrategy = new UpdateValueStrategy();
    repositorySncModelStrategy.setConverter(new String2BooleanConverter());
    bindingContext.bindValue(observeSelectionRespositorySncBtnObserveWidget, managedConnectionFactoryRepositorySncObserveValue, strategy_15, repositorySncModelStrategy);
    //
    IObservableValue observeSelectionRepositoryRoundtripOptimizationBtnObserveWidget = WidgetProperties.selection().observe(repositoryRoundtripOptimizationBtn);
    IObservableValue managedConnectionFactoryRepositoryRoundtripOptimizationObserveValue = EMFEditProperties.value(editingDomain, FeaturePath.fromList(Literals.DESTINATION_DATA_STORE_ENTRY__VALUE, Literals.DESTINATION_DATA__REPOSITORY_ROUNDTRIP_OPTIMIZATION)).observe(destinationDataStoreEntry);
    UpdateValueStrategy strategy_16 = new UpdateValueStrategy();
    strategy_16.setConverter(new Boolean2StringConverter());
    UpdateValueStrategy repositoryRoundtripOptimizationModelStrategy = new UpdateValueStrategy();
    repositoryRoundtripOptimizationModelStrategy.setConverter(new String2BooleanConverter());
    bindingContext.bindValue(observeSelectionRepositoryRoundtripOptimizationBtnObserveWidget, managedConnectionFactoryRepositoryRoundtripOptimizationObserveValue, strategy_16, repositoryRoundtripOptimizationModelStrategy);
View Full Code Here

TOP

Related Classes of org.eclipse.core.databinding.observable.value.IObservableValue

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.