Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.beans.property; 027 028import javafx.beans.binding.Bindings; 029import javafx.beans.value.WritableListValue; 030import javafx.collections.ObservableList; 031 032/** 033 * This class provides a full implementation of a {@link Property} wrapping a 034 * {@link javafx.collections.ObservableList}. 035 * 036 * The value of a {@code ListProperty} can be get and set with {@link #get()}, 037 * {@link #getValue()}, {@link #set(Object)}, and {@link #setValue(ObservableList)}. 038 * 039 * A property can be bound and unbound unidirectional with 040 * {@link #bind(javafx.beans.value.ObservableValue)} and {@link #unbind()}. Bidirectional bindings 041 * can be created and removed with {@link #bindBidirectional(Property)} and 042 * {@link #unbindBidirectional(Property)}. 043 * 044 * The context of a {@code ListProperty} can be read with {@link #getBean()} 045 * and {@link #getName()}. 046 * 047 * @see javafx.collections.ObservableList 048 * @see javafx.beans.value.ObservableListValue 049 * @see javafx.beans.value.WritableListValue 050 * @see ReadOnlyListProperty 051 * @see Property 052 * 053 * @param <E> the type of the {@code List} elements 054 */ 055public abstract class ListProperty<E> extends ReadOnlyListProperty<E> implements 056 Property<ObservableList<E>>, WritableListValue<E> { 057 /** 058 * {@inheritDoc} 059 */ 060 @Override 061 public void setValue(ObservableList<E> v) { 062 set(v); 063 } 064 065 /** 066 * {@inheritDoc} 067 */ 068 @Override 069 public void bindBidirectional(Property<ObservableList<E>> other) { 070 Bindings.bindBidirectional(this, other); 071 } 072 073 /** 074 * {@inheritDoc} 075 */ 076 @Override 077 public void unbindBidirectional(Property<ObservableList<E>> other) { 078 Bindings.unbindBidirectional(this, other); 079 } 080 081 /** 082 * Returns a string representation of this {@code ListProperty} object. 083 * @return a string representation of this {@code ListProperty} object. 084 */ 085 @Override 086 public String toString() { 087 final Object bean = getBean(); 088 final String name = getName(); 089 final StringBuilder result = new StringBuilder( 090 "ListProperty ["); 091 if (bean != null) { 092 result.append("bean: ").append(bean).append(", "); 093 } 094 if ((name != null) && (!name.equals(""))) { 095 result.append("name: ").append(name).append(", "); 096 } 097 result.append("value: ").append(get()).append("]"); 098 return result.toString(); 099 } 100}