本文整理汇总了Java中javafx.collections.ObservableList.removeListener方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableList.removeListener方法的具体用法?Java ObservableList.removeListener怎么用?Java ObservableList.removeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.collections.ObservableList
的用法示例。
在下文中一共展示了ObservableList.removeListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Bind the content of <code>list2</code> in <code>list1</code> using <code>mapper</code> to convert each element.
*
* @param list1
* destination list
* @param list2
* source observable list
* @param mapper
* list elements mapper from type E to the type R
* @param <E>
* type of elements to bind in the source list
* @param <R>
* type of elements binded in the destination list
*/
public static <E, R> void bind(final List<R> list1, final ObservableList<? extends E> list2,
final Function<E, R> mapper)
{
final IFXListContentBinding<E, R> binding = new IFXListContentBinding<>(list1, mapper);
final List<R> convertedList = list2.stream()
.map(mapper)
.collect(Collectors.toCollection(() -> new ArrayList<>(list2.size())));
if (list1 instanceof ObservableList)
{
((ObservableList<R>) list1).setAll(convertedList);
}
else
{
list1.clear();
list1.addAll(convertedList);
}
list2.removeListener(binding);
list2.addListener(binding);
}
示例2: onChanged
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@Override
public void onChanged(Change<? extends F> change) {
if (updating.get()) {
return;
}
ObservableList<F> sourceList = this.sourceList.get();
ObservableList<T> targetList = this.targetList.get();
if (sourceList == null || targetList == null) {
if (sourceList != null) {
sourceList.removeListener(this);
}
return;
}
if (updating.get()) {
return;
}
updating.set(true);
while (change.next()) {
if (change.wasPermutated()) {
targetList.remove(change.getFrom(), change.getTo());
targetList.addAll(change.getFrom(),
Lists.transform(change.getList().subList(change.getFrom(), change.getTo()), function::apply));
} else {
if (change.wasRemoved()) {
targetList.remove(change.getFrom(), change.getFrom() + change.getRemovedSize());
}
if (change.wasAdded()) {
targetList.addAll(change.getFrom(), Lists.transform(change.getAddedSubList(), function::apply));
}
}
}
updating.set(false);
}
示例3: bind
import javafx.collections.ObservableList; //导入方法依赖的package包/类
public static <T, U> void bind(List<T> boundList, ObservableList<U> sourceList, Function<U, T> mapper) {
ListSynchronizer<T, U> listener = new ListSynchronizer<>(boundList, mapper);
sourceList.removeListener(listener);
sourceList.addListener(listener);
boundList.clear();
boundList.addAll(map(sourceList, mapper));
}
示例4: run
import javafx.collections.ObservableList; //导入方法依赖的package包/类
@Override
public void run(){
ObservableList<Connection> cons = cdh.getConnectionList();
cons.addListener(clcli);
while(mgr != null){
try {
synchronized(cons){
while(cdh.isFree()){
Log.log("ConnectionManager#run()","Waiting on cdh.");
cons.wait();
}
if(wasInterrupted && !cdh.isFree()){
interruptThread();
}
if(cons.size() > 0){
for(int i = 0; i < cons.size(); i++){
Connection con = cons.get(i);
if(con != null){
if( con.getState() == com.neology.net.states.State.CLOSED){
con.close();
cons.remove(i);
}else{
if( con.getState() == com.neology.net.states.State.OPENED){
Established e = new Established();
con.changeState(e);
con.establish();
cdh.addConnectionName(con.getTranportInstance().getIp().split(":")[0]);
}
}
}
}
}
cdh.setFree(true);
cons.notifyAll();
}
} catch (InterruptedException ex) {
Logger.getLogger(ConnectionManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
cons.removeListener(clcli);
mgr = null;
}
示例5: addRemoveCollectionListener
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Adds/Removes the {@link FieldProperty} as a collection listener
*
* @param observable
* the {@link Observable} collection/map to listen for
* changes on
* @param add
* true to add, false to remove
*/
protected void addRemoveCollectionListener(final Observable observable,
final boolean add) {
final boolean isCol = getCollectionObservable() == observable;
if (isCol
&& ((this.isCollectionListening && add) || (this.isCollectionListening && !add))) {
return;
}
Boolean change = null;
if (observable instanceof ObservableList) {
final ObservableList<?> ol = (ObservableList<?>) observable;
if (add) {
ol.addListener(this);
change = true;
} else {
ol.removeListener(this);
change = false;
}
} else if (observable instanceof ObservableSet) {
final ObservableSet<?> os = (ObservableSet<?>) observable;
if (add) {
os.addListener(this);
change = true;
} else {
os.removeListener(this);
change = false;
}
} else if (observable instanceof ObservableMap) {
final ObservableMap<?, ?> om = (ObservableMap<?, ?>) observable;
if (add) {
om.addListener(this);
change = true;
} else {
om.removeListener(this);
change = false;
}
} else if (observable == null) {
throw new IllegalStateException(String.format(
"Observable collection/map bound to %1$s (item path: %2$s) "
+ "has been garbage collected",
this.fieldHandle.getFieldName(),
this.collectionItemPath, observable,
this.getFieldType()));
} else {
throw new UnsupportedOperationException(String.format(
"%1$s (item path: %2$s) of type \"%4$s\" "
+ "must be bound to a supported "
+ "observable collection/map type... "
+ "Found observable: %3$s",
this.fieldHandle.getFieldName(),
this.collectionItemPath, observable,
this.getFieldType()));
}
if (isCol && change != null) {
this.isCollectionListening = change;
}
}
示例6: unbind
import javafx.collections.ObservableList; //导入方法依赖的package包/类
/**
* Un-bind <code>list1</code> of <code>list2</code>.
*
* @param list1
* destination list
* @param list2
* source observable list
*/
public static <E, R> void unbind(final List<R> list1, final ObservableList<? extends E> list2)
{
list2.removeListener(new IFXListContentBinding<>(list1, null));
}