1 11 12 package org.eclipse.core.databinding.observable; 13 14 import java.util.List ; 15 import java.util.Set ; 16 17 import org.eclipse.core.databinding.observable.list.IListChangeListener; 18 import org.eclipse.core.databinding.observable.list.IObservableList; 19 import org.eclipse.core.databinding.observable.list.ObservableList; 20 import org.eclipse.core.databinding.observable.set.IObservableSet; 21 import org.eclipse.core.databinding.observable.set.ISetChangeListener; 22 import org.eclipse.core.databinding.observable.set.ObservableSet; 23 import org.eclipse.core.internal.databinding.observable.EmptyObservableList; 24 import org.eclipse.core.internal.databinding.observable.EmptyObservableSet; 25 import org.eclipse.core.internal.databinding.observable.ProxyObservableSet; 26 import org.eclipse.core.internal.databinding.observable.UnmodifiableObservableList; 27 28 34 public class Observables { 35 40 public static IObservableList unmodifiableObservableList( 41 IObservableList list) { 42 if (list == null) { 43 throw new IllegalArgumentException ( 44 "Parameter " + list + " was null."); } 46 47 return new UnmodifiableObservableList(list); 48 } 49 50 56 public static IObservableList emptyObservableList() { 57 return new EmptyObservableList(Realm.getDefault()); 58 } 59 60 67 public static IObservableList emptyObservableList(Realm realm) { 68 return new EmptyObservableList(realm); 69 } 70 71 77 public static IObservableSet emptyObservableSet() { 78 return new EmptyObservableSet(Realm.getDefault()); 79 } 80 81 88 public static IObservableSet emptyObservableSet(Realm realm) { 89 return new EmptyObservableSet(realm); 90 } 91 92 96 public static IObservableSet staticObservableSet(Set set) { 97 return new ObservableSet(Realm.getDefault(), set, Object .class) { 98 public void addChangeListener(IChangeListener listener) { 99 } 100 101 public void addStaleListener(IStaleListener listener) { 102 } 103 104 public void addSetChangeListener(ISetChangeListener listener) { 105 } 106 }; 107 } 108 109 114 public static IObservableSet staticObservableSet(Realm realm, Set set) { 115 return new ObservableSet(realm, set, Object .class) { 116 public void addChangeListener(IChangeListener listener) { 117 } 118 119 public void addStaleListener(IStaleListener listener) { 120 } 121 122 public void addSetChangeListener(ISetChangeListener listener) { 123 } 124 }; 125 } 126 127 136 public static IObservableSet proxyObservableSet(IObservableSet target) { 137 return new ProxyObservableSet(target); 138 } 139 140 144 public static IObservableList staticObservableList(List list) { 145 return staticObservableList(Realm.getDefault(), list); 146 } 147 148 153 public static IObservableList staticObservableList(Realm realm, List list) { 154 return new ObservableList(realm, list, Object .class) { 155 public void addChangeListener(IChangeListener listener) { 156 } 157 158 public void addStaleListener(IStaleListener listener) { 159 } 160 161 public void addListChangeListener(IListChangeListener listener) { 162 } 163 }; 164 } 165 } 166 | Popular Tags |