Package org.eclipse.core.databinding

Examples of org.eclipse.core.databinding.DataBindingContext


  }
 
  private void bindValues() {
    // The DataBindingContext object will manage the databindings
    // Lets bind it
    DataBindingContext ctx = new DataBindingContext();
       
    minInstancesTextObservable = WidgetProperties.text(SWT.Modify).observe(this.minInstances);
    minInstancesModelObservable = BeanProperties.value("minInstances").observe(this.formModel);
   
    maxInstancesTextObservable = WidgetProperties.text(SWT.Modify).observe(this.maxInstances);
    maxInstancesModelObservable = BeanProperties.value("maxInstances").observe(this.formModel);
   
    // Add a validator for number only
    IValidator optionalNumbersOnlyValidator = new IValidator() {
      @Override
      public IStatus validate(Object value) {
        String s = String.valueOf(value);
       
        if (s.trim().length()<1) return ValidationStatus.ok();
        if (s.matches("\\d*")) return ValidationStatus.ok();

        return ValidationStatus.error("Please enter a valid number of instances...");
      }
    };

    // now the validator for consistancy
    IValidator instancesValidator = new IValidator() {
      @Override
      public IStatus validate(Object value) {
        String smin = (String)minInstancesTextObservable.getValue();
        String smax = (String)maxInstancesTextObservable.getValue();
        Integer min = smin.trim().length()>0 ? Integer.parseInt(smin) : null;
        Integer max = smax.trim().length()>0 ? Integer.parseInt(smax) : null;
               
        if (min != null && max != null) {
          // check if valid
          if (min > max) return ValidationStatus.error("The maximum instances count can't be lower than the minimum count!");
        }
       
        return ValidationStatus.ok();
      }
    };
   
   

    UpdateValueStrategy targetToModel = new UpdateValueStrategy(false,  UpdateValueStrategy.POLICY_UPDATE);
    targetToModel.setAfterGetValidator(optionalNumbersOnlyValidator);
    targetToModel.setBeforeSetValidator(instancesValidator);
    targetToModel.setConverter(new IConverter() {
      @Override
      public Object getToType() {
        return new BigInteger("-1");
      }
     
      @Override
      public Object getFromType() {
        return new String();
      }
     
      @Override
      public Object convert(Object fromObject) {
        if (fromObject instanceof String) {
          String s = (String)fromObject;
          if (s.trim().length() > 0) {
            try {
              return new BigInteger(s);
            } catch (NumberFormatException ex) {
              // no number
            }
          }
        }
        return null;
      }
    });
   
    UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
   
    minInstancesBinding = ctx.bindValue(minInstancesTextObservable, minInstancesModelObservable, targetToModel, modelToTarget);
    ControlDecorationSupport.create(minInstancesBinding, SWT.TOP | SWT.RIGHT);
   
    maxInstancesBinding = ctx.bindValue(maxInstancesTextObservable, maxInstancesModelObservable, targetToModel, modelToTarget);
    ControlDecorationSupport.create(maxInstancesBinding, SWT.TOP | SWT.RIGHT);
  }
View Full Code Here


    idoc3ImportSettings.setBundleDeployLocation(ImportUtils.getDefaultDeployLocation());
    idoc3ImportSettings.setBundleName(SAP_I_DOC_LIBRARY_VERSION_3);
    idoc3ImportSettings.setBundleVendor(RED_HAT_INC);
    idoc3ImportSettings.setRequiredExecutionEnvironmentIndex(executionEnvironmentIndex);
   
    context = new DataBindingContext();
    downloadPage = new DownloadPage();
    jco3ArchiveSelectionPage = new JCo3ArchiveSelectionPage(context, jco3ImportSettings);
    idoc3ArchiveSelectionPage = new IDoc3ArchiveSelectionPage(context, idoc3ImportSettings);
  }
View Full Code Here

  protected Point getInitialSize() {
    return new Point(550, 189);
  }
 
  protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    //
    IObservableValue observeTextServerNameTextObserveWidget = WidgetProperties.text(SWT.Modify).observe(serverNameText);
    IObservableValue serverDataServerNameObserveValue = EMFEditProperties.value(editingDomain, Literals.SERVER_DATA_STORE_ENTRY__KEY).observe(serverDataStoreEntry);
    bindingContext.bindValue(observeTextServerNameTextObserveWidget, serverDataServerNameObserveValue, null, null);
    //
    return bindingContext;
  }
View Full Code Here

    setWindowTitle(Messages.SapConnectionConfigurationExportWizard_WindowTitle);
    setNeedsProgressMonitor(true);
   
    exportSettings = new SapConnectionConfigurationExportSettings();
   
    context = new DataBindingContext();
    exportPage = new SapConnectionConfigurationExportPage(context, exportSettings);
  }
View Full Code Here

  protected Point getInitialSize() {
    return new Point(550, 189);
  }
 
  protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    //
    IObservableValue observeTextDestinationNameTextObserveWidget = WidgetProperties.text(SWT.Modify).observe(destinationNameText);
    IObservableValue destinationDataDestinationNameObserveValue = EMFEditProperties.value(editingDomain, Literals.DESTINATION_DATA_STORE_ENTRY__KEY).observe(destinationDataStoreEntry);
    bindingContext.bindValue(observeTextDestinationNameTextObserveWidget, destinationDataDestinationNameObserveValue, null, null);
    //
    return bindingContext;
  }
View Full Code Here

  /**
   *
   */
  public DetailsSection() {
    bindingContext = new DataBindingContext();
  }
View Full Code Here

   * @param style
   */
  public AbstractBpmn2PropertiesComposite(Composite parent, int style) {
    super(parent, style);
    this.parent = parent;
    bindingContext = new DataBindingContext();
    addDisposeListener(new DisposeListener() {
      @Override
      public void widgetDisposed(DisposeEvent e) {
        toolkit.dispose();
      }
View Full Code Here

    }
    preferences.flush();
  }

  protected DataBindingContext initDataBindings() {
    DataBindingContext bindingContext = new DataBindingContext();
    //
    checkboxTreeViewer.setContentProvider(new ITreeContentProvider() {

      @Override
      public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
View Full Code Here

        //
        // Bind UI
        //

        DataBindingContext context = getBindingContext();

        // multi validator (to and from portfolio must not be identical)
        MultiValidator validator = new MultiValidator()
        {
            @Override
            protected IStatus validate()
            {
                Object from = observableFrom.getValue();
                Object to = observableTo.getValue();

                return from != null && to != null && from != to ? ValidationStatus.ok() : ValidationStatus
                                .error(Messages.MsgPortfolioMustBeDifferent);
            }
        };
        context.addValidationStatusProvider(validator);

        context.bindValue(validator.observeValidatedValue(observableFrom), //
                        BeansObservables.observeValue(getModel(), "portfolioFrom")); //$NON-NLS-1$

        context.bindValue(validator.observeValidatedValue(observableTo), //
                        BeansObservables.observeValue(getModel(), "portfolioTo")); //$NON-NLS-1$

    }
View Full Code Here

        tableViewer.setLabelProvider(new TransactionLabelProvider());
        tableViewer.setContentProvider(new SimpleListContentProvider());

        // bindings

        DataBindingContext context = new DataBindingContext();

        context.bindValue(SWTObservables.observeSelection(checkbox), //
                        BeansObservables.observeValue(model, "changeTransactions")); //$NON-NLS-1$

        checkbox.addSelectionListener(new SelectionAdapter()
        {
            @Override
View Full Code Here

TOP

Related Classes of org.eclipse.core.databinding.DataBindingContext

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.