@Override
  public void doSetValue(Object aValue) {
    Object oldValue = doGetValue();
    String[] nameValues = ((String) aValue).split(" "); // $NON-NLS-1$

    try {
      myIsUpdating = true;
      if (nameValues.length == 3) {
        for (int i = 0; i < 3; i++) {
          myObservableValues[i].setValue(nameValues[i]);
        }
      } else if (nameValues.length == 2) {
        myObservableValues[0].setValue(nameValues[0]);
        myObservableValues[1].setValue(""); // $NON-NLS-1$
        myObservableValues[2].setValue(nameValues[1]);
      } else if (nameValues.length == 1) {
        myObservableValues[0].setValue(nameValues[0]);
        myObservableValues[1].setValue(""); // $NON-NLS-1$
        myObservableValues[2].setValue(""); // $NON-NLS-1$
      } else {
        for (int i = 0; i < 3; i++) {
          myObservableValues[i].setValue(""); // $NON-NLS-1$
        }
      }
    } finally {
      myIsUpdating = false;
    }
    doGetValue();
    fireValueChange(Diffs.createValueDiff(oldValue, aValue));
  }
 public void doSetValue(Object value) {
   updating = true;
   try {
     Object oldValue = doGetValue();
     Method writeMethod = propertyDescriptor.getWriteMethod();
     if (!writeMethod.isAccessible()) {
       writeMethod.setAccessible(true);
     }
     writeMethod.invoke(object, new Object[] {value});
     fireValueChange(Diffs.createValueDiff(oldValue, doGetValue()));
   } catch (InvocationTargetException e) {
     /*
      * InvocationTargetException wraps any exception thrown by the
      * invoked method.
      */
     throw new RuntimeException(e.getCause());
   } catch (Exception e) {
     if (BeansObservables.DEBUG) {
       Policy.getLog()
           .log(
               new Status(
                   IStatus.WARNING,
                   Policy.JFACE_DATABINDING,
                   IStatus.OK,
                   "Could not change value of " + object + "." + propertyDescriptor.getName(),
                   e)); //$NON-NLS-1$ //$NON-NLS-2$
     }
   } finally {
     updating = false;
   }
 }
Example #3
0
 public boolean add(Object o) {
   getterCalled();
   boolean changed = wrappedSet.add(o);
   if (changed)
     fireSetChange(Diffs.createSetDiff(Collections.singleton(o), Collections.EMPTY_SET));
   return changed;
 }
 public boolean addChild(int position, E element) {
   ListDiffEntry diffentry = Diffs.createListDiffEntry(position, true, element);
   boolean res = elements.add(element);
   final ListDiff diff = Diffs.createListDiff(diffentry);
   Realm realm = getRealm();
   Assert.isNotNull(realm, REALM_MUST_NOT_BE_NULL);
   realm.exec(
       new Runnable() {
         @Override
         public void run() {
           if (!isDisposed()) {
             fireListChange(diff);
           }
         }
       });
   return res;
 }
 @Override
 protected void doSetValue(Object value) {
   Object oldValue = this.value;
   if (overrideValue != null) value = overrideValue;
   this.value = value;
   stale = false;
   fireValueChange(Diffs.createValueDiff(oldValue, value));
 }
 @Override
 public void focusLost(FocusEvent e) {
   if (!updating) {
     Date newSelection = CDateTimeObservableValue.this.dateTime.getSelection();
     fireValueChange(Diffs.createValueDiff(currentSelection, newSelection));
     currentSelection = newSelection;
   }
 }
Example #7
0
 public void clear() {
   getterCalled();
   if (!wrappedSet.isEmpty()) {
     Set removals = wrappedSet;
     wrappedSet = new IdentitySet();
     fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removals));
   }
 }
 public boolean removeChild(E element) {
   final int index = elements.indexOf(element);
   ListDiffEntry diffentry = Diffs.createListDiffEntry(index, false, element);
   boolean res = elements.remove(element);
   final ListDiff diff = Diffs.createListDiff(diffentry);
   Realm realm = getRealm();
   Assert.isNotNull(realm, REALM_MUST_NOT_BE_NULL);
   realm.exec(
       new Runnable() {
         @Override
         public void run() {
           if (!isDisposed()) {
             fireListChange(diff);
           }
         }
       });
   return res;
 }
 @Override
 public void handleChange(final ChangeEvent event) {
   if (!this.setting) {
     final Object newValue = calculate();
     final Object oldValue = this.value;
     if ((oldValue != null) ? !oldValue.equals(newValue) : null != newValue) {
       fireValueChange(Diffs.createValueDiff(oldValue, this.value = newValue));
     }
   }
 }
Example #10
0
 public boolean addAll(Collection c) {
   getterCalled();
   Set additions = new IdentitySet();
   for (Iterator iterator = c.iterator(); iterator.hasNext(); ) {
     Object element = iterator.next();
     if (wrappedSet.add(element)) additions.add(element);
   }
   boolean changed = !additions.isEmpty();
   if (changed) fireSetChange(Diffs.createSetDiff(additions, Collections.EMPTY_SET));
   return changed;
 }
Example #11
0
 public boolean removeAll(Collection c) {
   getterCalled();
   Set removals = new IdentitySet();
   for (Iterator iterator = c.iterator(); iterator.hasNext(); ) {
     Object element = iterator.next();
     if (wrappedSet.remove(element)) removals.add(element);
   }
   boolean changed = !removals.isEmpty();
   if (changed) fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removals));
   return changed;
 }
 @Override
 protected void doSetValue(Object value) {
   if (value instanceof Date && !dateTime.isDisposed()) {
     Date oldValue;
     Date newValue;
     try {
       updating = true;
       oldValue = dateTime.getSelection();
       newValue = (Date) value;
       dateTime.setSelection(newValue);
       currentSelection = newValue;
       fireValueChange(Diffs.createValueDiff(oldValue, newValue));
     } finally {
       updating = false;
     }
   }
 }
 @Override
 public void doSetValue(Object value) {
   final Object oldValue = doGetValue();
   if (attribute.equals(Constants.ATTR_IMAGE)) {
     item.setImage((Image) value);
   } else if (attribute.equals(Constants.ATTR_TEXT)) {
     item.setText((String) value);
   } else if (attribute.equals(Constants.ATTR_TOOLTIP)) {
     if (item instanceof TableColumn) {
       ((TableColumn) item).setToolTipText((String) value);
     }
     if (item instanceof TreeColumn) {
       ((TreeColumn) item).setToolTipText((String) value);
     }
     if (item instanceof ToolItem) {
       ((ToolItem) item).setToolTipText((String) value);
     }
     if (item instanceof TabItem) {
       ((TabItem) item).setToolTipText((String) value);
     }
   } else if (attribute.equals(Constants.ATTR_ALIGNMENT)) {
     if (item instanceof TableColumn) {
       ((TableColumn) item).setAlignment((Integer) value);
     }
     if (item instanceof TreeColumn) {
       ((TreeColumn) item).setAlignment((Integer) value);
     }
   } else if (attribute.equals(Constants.ATTR_WIDTH)) {
     if (item instanceof TableColumn) {
       ((TableColumn) item).setWidth((Integer) value);
     }
     if (item instanceof TreeColumn) {
       ((TreeColumn) item).setWidth((Integer) value);
     }
     if (item instanceof ToolItem) {
       ((ToolItem) item).setWidth((Integer) value);
     }
   } else if (attribute.equals(Constants.ATTR_ENABLED)) {
     if (item instanceof ToolItem) {
       ((ToolItem) item).setEnabled(value == Boolean.TRUE);
     }
   }
   fireValueChange(Diffs.createValueDiff(oldValue, value));
 }
Example #14
0
 public boolean retainAll(Collection c) {
   getterCalled();
   Set removals = new IdentitySet();
   Object[] toRetain = c.toArray();
   outer:
   for (Iterator iterator = wrappedSet.iterator(); iterator.hasNext(); ) {
     Object element = iterator.next();
     // Cannot rely on c.contains(element) because we must compare
     // elements using IElementComparer.
     for (int i = 0; i < toRetain.length; i++) {
       if (element == toRetain[i]) continue outer;
     }
     iterator.remove();
     removals.add(element);
   }
   boolean changed = !removals.isEmpty();
   if (changed) fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removals));
   return changed;
 }
 /** Selection changed... */
 protected void handleSelectionChanged() {
   final Object newValue = doGetValue();
   if (Util.equals(myCurrentValue, newValue)) return;
   fireValueChange(Diffs.createValueDiff(myCurrentValue, myCurrentValue = newValue));
 }
 public void handleChange(ChangeEvent event) {
   fireValueChange(Diffs.createValueDiff(currentValue, doGetValue()));
 }