1 11 12 package org.eclipse.jface.internal.databinding.provisional; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.jface.internal.databinding.provisional.observable.value.IObservableValue; 18 import org.eclipse.jface.internal.databinding.provisional.validation.ValidationError; 19 20 27 public abstract class Binding { 28 29 private List bindingEventListeners = new ArrayList (); 30 31 protected final DataBindingContext context; 32 33 36 public Binding(DataBindingContext context) { 37 this.context = context; 38 } 39 40 47 public void addBindingEventListener(IBindingListener listener) { 48 bindingEventListeners.add(listener); 49 } 50 51 60 protected ValidationError fireBindingEvent(BindingEvent event) { 61 ValidationError result = null; 62 IBindingListener[] listeners = (IBindingListener[]) bindingEventListeners 63 .toArray(new IBindingListener[bindingEventListeners.size()]); 64 for (int i = 0; i < listeners.length; i++) { 65 IBindingListener listener = listeners[i]; 66 result = listener.bindingEvent(event); 67 if (result != null) 68 break; 69 } 70 if (result == null) 71 result = context.fireBindingEvent(event); 72 return result; 73 } 74 75 79 public abstract IObservableValue getPartialValidationError(); 80 81 85 public abstract IObservableValue getValidationError(); 86 87 95 public void removeBindingEventListener(IBindingListener listener) { 96 bindingEventListeners.remove(listener); 97 } 98 99 102 public abstract void updateModelFromTarget(); 103 104 107 public abstract void updateTargetFromModel(); 108 109 } 110 | Popular Tags |