/** {@inheritDoc} */
  @Override
  public void refresh(final Resource resource) {
    this.dcdResource = resource;

    final DeviceConfiguration dcd = ModelUtil.getDeviceConfiguration(this.dcdResource);

    setEditable(!getPage().getEditingDomain().isReadOnly(this.dcdResource));

    for (final Binding binding : this.bindings) {
      binding.dispose();
    }
    this.bindings.clear();

    final SoftPkg model = getSoftPkg();
    if (model == null) {
      return;
    }

    final DataBindingContext context = this.getPage().getEditor().getDataBindingContext();

    this.bindings.add(
        context.bindValue(
            WidgetProperties.text(SWT.Modify)
                .observeDelayed(
                    SCAFormEditor.getFieldBindingDelay(), this.client.getIdEntry().getText()),
            EMFEditObservables.observeValue(
                getEditingDomain(), dcd, DcdPackage.Literals.DEVICE_CONFIGURATION__ID),
            new EMFEmptyStringToNullUpdateValueStrategy(),
            null));

    this.bindings.add(
        context.bindValue(
            WidgetProperties.text(SWT.Modify)
                .observeDelayed(
                    SCAFormEditor.getFieldBindingDelay(), this.client.getNameEntry().getText()),
            EMFEditObservables.observeValue(
                getEditingDomain(), dcd, DcdPackage.Literals.DEVICE_CONFIGURATION__NAME),
            new EMFEmptyStringToNullUpdateValueStrategy(),
            null));

    this.bindings.add(
        context.bindValue(
            WidgetProperties.text(SWT.Modify)
                .observeDelayed(
                    SCAFormEditor.getFieldBindingDelay(),
                    this.client.getDescriptionEntry().getText()),
            EMFEditObservables.observeValue(
                getEditingDomain(), dcd, DcdPackage.Literals.DEVICE_CONFIGURATION__DESCRIPTION),
            new EMFEmptyStringToNullUpdateValueStrategy(),
            null));

    this.client.setEditable(SCAEditorUtil.isEditableResource(getPage(), this.dcdResource));
  }
 /** Disposes of this wizard page support object, removing any listeners it may have attached. */
 public void dispose() {
   aggregateStatus.dispose();
   if (!uiChanged) {
     for (Iterator it = dbc.getBindings().iterator(); it.hasNext(); ) {
       Binding binding = (Binding) it.next();
       binding.getTarget().removeChangeListener(uiChangeListener);
     }
     dbc.getBindings().removeListChangeListener(bindingsListener);
   }
   aggregateStatus = null;
   dbc = null;
   uiChangeListener = null;
   bindingsListener = null;
   wizardPage = null;
 }
  @Override
  public void handleChange(ChangeEvent arg0) {

    for (Object o : bindingValidationContext.getDataBindingContext().getBindings()) {

      Binding binding = (Binding) o;
      IStatus status = (IStatus) binding.getValidationStatus().getValue();
      Control control = null;

      if (binding.getTarget() instanceof ISWTObservable) {
        ISWTObservable swtObservable = (ISWTObservable) binding.getTarget();
        control = (Control) swtObservable.getWidget();
      }

      ControlDecoration decoration = bindingValidationContext.getDecoratorMap().get(control);

      if (decoration != null) {
        if (status.isOK()) {
          decoration.hide();
        } else {
          decoration.setDescriptionText(status.getMessage());
          decoration.show();
        }
      }
    }
  }
 protected void handleUIChanged() {
   uiChanged = true;
   if (currentStatus != null) {
     handleStatusChanged();
   }
   dbc.getBindings().removeListChangeListener(bindingsListener);
   for (Iterator it = dbc.getBindings().iterator(); it.hasNext(); ) {
     Binding binding = (Binding) it.next();
     binding.getTarget().removeChangeListener(uiChangeListener);
   }
 }
 public void handleListChange(ListChangeEvent event) {
   ListDiff diff = event.diff;
   ListDiffEntry[] differences = diff.getDifferences();
   for (int i = 0; i < differences.length; i++) {
     ListDiffEntry listDiffEntry = differences[i];
     Binding binding = (Binding) listDiffEntry.getElement();
     if (listDiffEntry.isAddition()) {
       binding.getTarget().addChangeListener(uiChangeListener);
     } else {
       binding.getTarget().removeChangeListener(uiChangeListener);
     }
   }
 }
 private void recompute() {
   if (isDirty) {
     Map newContents = new HashMap();
     for (Iterator it = bindings.iterator(); it.hasNext(); ) {
       Binding binding = (Binding) it.next();
       IObservableValue validationError = binding.getValidationStatus();
       dependencies.add(validationError);
       validationError.addChangeListener(markDirtyChangeListener);
       IStatus validationStatusValue = (IStatus) validationError.getValue();
       newContents.put(binding, validationStatusValue);
     }
     wrappedMap.putAll(newContents);
     isDirty = false;
   }
 }
  protected void init() {
    aggregateStatus =
        new AggregateValidationStatus(dbc.getBindings(), AggregateValidationStatus.MAX_SEVERITY);
    aggregateStatus.addValueChangeListener(
        new IValueChangeListener() {
          public void handleValueChange(ValueChangeEvent event) {

            currentStatus = (IStatus) event.diff.getNewValue();
            handleStatusChanged();
          }
        });
    currentStatus = (IStatus) aggregateStatus.getValue();
    handleStatusChanged();
    dbc.getBindings().addListChangeListener(bindingsListener);
    for (Iterator it = dbc.getBindings().iterator(); it.hasNext(); ) {
      Binding binding = (Binding) it.next();
      binding.getTarget().addChangeListener(uiChangeListener);
    }
  }
Ejemplo n.º 8
0
 @Override
 public void pingBinding() {
   if (_binding != null) {
     _binding.validateTargetToModel();
   }
 }
 void dispose() {
   target.dispose();
   model.dispose();
   binding.dispose();
 }