svnno****@sourc*****
svnno****@sourc*****
2008年 9月 17日 (水) 01:52:28 JST
Revision: 1926 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1926 Author: shin1 Date: 2008-09-17 01:52:28 +0900 (Wed, 17 Sep 2008) Log Message: ----------- [CORE-55]を解決。ObservableCollection系のパッケージの移動。 Modified Paths: -------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/RootModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/InsertDataSetModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/RecordModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/AbstractNodeModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/TableModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/presentation/DiagramPresentationModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/typedef/constraint/ConstraintSetModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/InsertDataSetModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/RecordModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/index/IndexModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModel.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableListTest.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableMapTest.java Added Paths: ----------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableList.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableMap.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableSet.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/package-info.java Removed Paths: ------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/CollectionUtil.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/collectionimpl/ -------------- next part -------------- Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableList.java (from rev 1923, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/collectionimpl/ObservableList.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableList.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableList.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -0,0 +1,453 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/06/29 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.core.event.collectionimpl; + +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +import org.seasar.framework.util.tiger.CollectionsUtil; + +import org.jiemamy.core.event.ModelChangeEvent; +import org.jiemamy.core.event.ModelChangeListener; +import org.jiemamy.core.event.Observable; +import org.jiemamy.core.event.ObservableCollectionChangeEvent; +import org.jiemamy.core.event.ObservableCollectionChangeListener; + +/** + * {@link ObservableCollectionChangeEvent}を通知する{@link List}の実装。。 + * add/remove等の更新系メソッド全てで{@link ObservableCollectionChangeEvent}を通知する。 + * また、保持する要素が{@link Observable}の場合は、要素の{@link ModelChangeEvent}も監視し、 + * {@link ObservableCollectionChangeEvent}にラップして通知する。 + * + * @param <T> 保持する要素の型. + * @author shin1ogawa + */ + @ SuppressWarnings("serial") +public class ObservableList<T> extends AbstractList<T> implements List<T> { + + /** + * Listの実装をdecorateした{@link ObservableList}を返す。 + * @param <T> + * @param list + * @return {@link ObservableList} + */ + public static <T>ObservableList<T> decorate(List<T> list) { + return new ObservableList<T>(list); + } + + + private transient List<ObservableCollectionChangeListener<List<T>, T>> listeners = CollectionsUtil.newArrayList(); + + private transient ModelChangeListener modelChangeListener; + + private List<T> list; + + + /** + * コンストラクタ。 + * Listの実装を指定しない場合は{@link java.util.ArrayList}を使用する。 + * @category instance creation + */ + public ObservableList() { + this.list = new ArrayList<T>(); + modelChangeListener = new ModelChangeListenerImpl(this); + } + + /** + * コンストラクタ。 + * @param list 使用するListの実装 + * @category instance creation + */ + public ObservableList(List<T> list) { + this.list = list; + modelChangeListener = new ModelChangeListenerImpl(this); + } + + /** + * {@inheritDoc} + */ + @Override + public void add(int index, T element) { + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.BEFORE_ADD, + this, index, element)); + list.add(index, element); + // 要素に対する監視を開始する。 + if (element instanceof Observable) { + Observable observable = (Observable) element; + observable.addModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_ADD, + this, index, element)); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean add(T o) { + int index = list.size(); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.BEFORE_ADD, + this, index, o)); + boolean result = list.add(o); + // 要素に対する監視を開始する。 + if (o instanceof Observable) { + Observable observable = (Observable) o; + observable.addModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_ADD, + this, index, o)); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean addAll(Collection<? extends T> c) { + if (c != null && c.size() > 0) { + // add(T)に展開する。 + for (T element : c) { + add(element); + } + return true; + } else { + return false; + } + } + + /** + * Listの実装のaddAll()を直接呼び出す訳ではなく、{@link #add(Object)}に展開する。 + * {@inheritDoc} + */ + @Override + public boolean addAll(int index, Collection<? extends T> collection) { + if (collection != null && collection.size() > 0) { + for (T element : collection) { + add(index++, element); + } + return true; + } else { + return false; + } + } + + /** + * Eventを監視するListenerを追加する。 + * @param l {@link ObservableCollectionChangeListener} + */ + public void addListener(ObservableCollectionChangeListener<List<T>, T> l) { + // FIXME lazy instance creationせずに済む方法はないか? + if (listeners == null) { + listeners = CollectionsUtil.newArrayList(); + } + listeners.add(l); + } + + /** + * {@inheritDoc} + */ + @Override + public void clear() { + int index = 0; + // Eventを通知するために一旦別のListへ格納し直す。 + ArrayList<T> removedList = new ArrayList<T>(list.size()); + Iterator<T> iterator = list.iterator(); + while (iterator.hasNext()) { + T element = iterator.next(); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>( + ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, this, index, element)); + removedList.add(element); + index++; + } + list.clear(); + iterator = removedList.iterator(); + index = 0; + while (iterator.hasNext()) { + T element = iterator.next(); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>( + ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, this, index, element)); + index++; + } + removedList.clear(); // 用済みなので破棄する。 + } + + /** + * {@inheritDoc} + */ + @Override + public boolean contains(Object o) { + return list.contains(o); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean containsAll(Collection<?> c) { + return list.containsAll(c); + } + + /** + * {@inheritDoc} + */ + @Override + public T get(int index) { + return list.get(index); + } + + /** + * {@inheritDoc} + */ + @Override + public int indexOf(Object o) { + return list.indexOf(o); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isEmpty() { + return list.isEmpty(); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator<T> iterator() { + return list.iterator(); + } + + /** + * {@inheritDoc} + */ + @Override + public int lastIndexOf(Object o) { + return list.lastIndexOf(o); + } + + /** + * {@inheritDoc} + */ + @Override + public ListIterator<T> listIterator() { + return list.listIterator(); + } + + /** + * {@inheritDoc} + */ + @Override + public ListIterator<T> listIterator(int index) { + return list.listIterator(index); + } + + /** + * {@inheritDoc} + */ + @Override + public T remove(int index) { + T element = list.get(index); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>( + ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, this, index, element)); + T result = list.remove(index); + // 要素に対する監視をやめる。 + if (element instanceof Observable) { + ((Observable) element).removeModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, + this, index, result)); + return result; + } + + /** + * {@inheritDoc} + * THINK 指定された要素の存在チェックは行わずにbeforeRemoveを発生させる事になるが? + */ + @Override + @SuppressWarnings("unchecked") + public boolean remove(Object o) { + int index = list.indexOf(o); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>( + ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, this, index, (T) o)); + boolean result = list.remove(o); + // 要素に対する監視をやめる。 + if (o instanceof Observable) { + ((Observable) o).removeModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, + this, index, (T) o)); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean removeAll(Collection<?> c) { + List<Object> removeList = new ArrayList<Object>(); + Iterator<?> iterator = iterator(); + while (iterator.hasNext()) { + Object next = iterator.next(); + if (c.contains(next)) { + removeList.add(next); + } + } + if (!removeList.isEmpty()) { + for (Object o : removeList) { + remove(o); + } + removeList.clear(); + return true; + } else { + return false; + } + } + + /** + * Eventの監視をやめたいListenerを削除する。 + * @param l + */ + public void removeListener(ObservableCollectionChangeListener<List<T>, T> l) { + listeners.remove(l); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean retainAll(Collection<?> c) { + return list.retainAll(c); + } + + /** + * {@link ObservableCollectionChangeEvent}は以下の法則で通知する。 + * <ol> + * <li>BEFORE_SET:元々indexの位置に存在していた要素</li> + * <li>AFTER_SET:新しくindexの位置に設定された要素</li> + * </ol> + * @see java.util.ArrayList#set(int, java.lang.Object) + * @param index + * @param element + * @return T + */ + @Override + public T set(int index, T element) { + T oldElement = list.get(index); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.BEFORE_SET, + this, index, oldElement)); + T result = list.set(index, element); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_SET, + this, index, element)); + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public int size() { + return list.size(); + } + + /** + * {@inheritDoc} + */ + @Override + public List<T> subList(int fromIndex, int toIndex) { + return list.subList(fromIndex, toIndex); + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] toArray() { + return list.toArray(); + } + + /** + * {@inheritDoc} + */ + @Override + public <U>U[] toArray(U[] a) { + return list.toArray(a); + } + + @Override + protected void removeRange(int fromIndex, int toIndex) { + for (int i = fromIndex; i <= toIndex; i++) { + // #remove(int)に展開する。 + remove(i); + } + } + + /** + * 全てのObserver({@link #listeners})に対してEventを通知する。 + * @param event + */ + private void fireChange(ObservableCollectionChangeEvent<List<T>, T> event) { + // FIXME lazy instance creationせずに済む方法はないか? + if (listeners == null) { + listeners = new ArrayList<ObservableCollectionChangeListener<List<T>, T>>(); + } + + for (ObservableCollectionChangeListener<List<T>, T> listener : listeners) { + listener.collectionChanged(event); + } + } + + + /** + * 要素に対する変更を監視する。 + * Eventを受けた場合は<code>ModelCollectionChangeEvent.Timing.modelChanged</code> + * という種類の{@link ModelChangeEvent}として通知する。 + * + * @author shin1ogawa + */ + class ModelChangeListenerImpl implements ModelChangeListener { + + private List<T> list; + + + /** + * コンストラクタ。 + * @param list + * @category instance creation + */ + public ModelChangeListenerImpl(List<T> list) { + this.list = list; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public void modelChanged(ModelChangeEvent e) { + int index = this.list.indexOf(e.getSource()); + fireChange(new ObservableCollectionChangeEvent<List<T>, T>( + ObservableCollectionChangeEvent.Timing.COLLECTION_CHANGED, list, index, (T) e.getSource())); + } + } +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableList.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableMap.java (from rev 1923, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/collectionimpl/ObservableMap.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableMap.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableMap.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -0,0 +1,276 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/07/03 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.core.event.collectionimpl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.seasar.framework.util.tiger.CollectionsUtil; + +import org.jiemamy.core.event.ModelChangeEvent; +import org.jiemamy.core.event.ModelChangeListener; +import org.jiemamy.core.event.ObservableCollectionChangeEvent; +import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.model.AbstractModel; +import org.jiemamy.core.model.JiemamyModel; + +/** + * {@link ObservableCollectionChangeEvent}を通知する{@link Map}の実装。。 + * put/remove等の更新系メソッド全てで{@link ObservableCollectionChangeEvent}を通知する。 + * また、保持する要素のModelChangeEventも把握し{@link ObservableCollectionChangeEvent}にラップして通知する。 + * + * @author shin1ogawa + * @param <K> Keyとして使用する型 + * @param <V> Valueとして使用する型 + */ + @ SuppressWarnings("serial") +public class ObservableMap<K, V> implements Map<K, V> { + + /** + * Mapの実装をdecorateした{@link ObservableList}を返す。 + * @param <K> + * @param <V> + * @param map + * @return {@link ObservableMap} + */ + public static <K, V>ObservableMap<K, V> decorate(Map<K, V> map) { + return new ObservableMap<K, V>(map); + } + + + transient List<ObservableCollectionChangeListener<Map<K, V>, V>> listeners = CollectionsUtil.newArrayList(); + + transient ModelChangeListener modelChangeListener; + + private Map<K, V> map; + + + /** + * コンストラクタ。 + * Mapの実装を指定しない場合は{@link HashMap}を使用する。 + * @category instance creation + */ + public ObservableMap() { + this.map = new HashMap<K, V>(); + modelChangeListener = new ModelChangeListenerImpl(this); + } + + /** + * コンストラクタ。 + * @param map 使用するMapの実装 + * @category instance creation + */ + public ObservableMap(Map<K, V> map) { + this.map = map; + modelChangeListener = new ModelChangeListenerImpl(this); + } + + /** + * Eventを監視するListenerを追加する。 + * @param l {@link ObservableCollectionChangeListener} + */ + public void addListener(ObservableCollectionChangeListener<Map<K, V>, V> l) { + // FIXME lazy instance creationせずに済む方法はないか? + if (listeners == null) { + listeners = CollectionsUtil.newArrayList(); + } + listeners.add(l); + } + + /** + * {@inheritDoc} + */ + public void clear() { + ArrayList<V> removedList = new ArrayList<V>(size()); + int index = 0; + for (V value : map.values()) { + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>( + ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, this, index++, value)); + removedList.add(value); + } + map.clear(); + index = 0; + for (V value : removedList) { + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>( + ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, this, index++, value)); + if (value instanceof JiemamyModel) { + AbstractModel abstractModel = (AbstractModel) value; + abstractModel.removeModelChangeListener(modelChangeListener); + } + } + removedList.clear(); + } + + /** + * {@inheritDoc} + */ + public boolean containsKey(Object key) { + return map.containsKey(key); + } + + /** + * {@inheritDoc} + */ + public boolean containsValue(Object value) { + return map.containsValue(value); + } + + /** + * {@inheritDoc} + */ + public Set<java.util.Map.Entry<K, V>> entrySet() { + return map.entrySet(); + } + + /** + * {@inheritDoc} + */ + public V get(Object key) { + return map.get(key); + } + + /** + * {@inheritDoc} + */ + public boolean isEmpty() { + return map.isEmpty(); + } + + /** + * {@inheritDoc} + */ + public Set<K> keySet() { + return map.keySet(); + } + + /** + * {@inheritDoc} + */ + public V put(K key, V value) { + int index = size() - 1; + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>(ObservableCollectionChangeEvent.Timing.BEFORE_ADD, + this, index, value)); + V result = map.put(key, value); + if (value instanceof JiemamyModel) { + AbstractModel abstractModel = (AbstractModel) value; + abstractModel.addModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>(ObservableCollectionChangeEvent.Timing.AFTER_ADD, + this, index, value)); + return result; + } + + /** + * {@inheritDoc} + */ + public void putAll(Map<? extends K, ? extends V> m) { + // put(K, V)に展開する。 + if (m != null && m.size() > 0) { + for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) { + put(e.getKey(), e.getValue()); + } + } + } + + /** + * {@inheritDoc} + */ + public V remove(Object key) { +// int index = map.indexOf(key); + int index = -1; + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>( + ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, this, index, get(key))); + V result = map.remove(key); + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>( + ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, this, index, result)); + if (result instanceof JiemamyModel) { + AbstractModel abstractModel = (AbstractModel) result; + abstractModel.removeModelChangeListener(modelChangeListener); + } + return result; + } + + /** + * {@inheritDoc} + */ + public int size() { + return map.size(); + } + + /** + * {@inheritDoc} + */ + public Collection<V> values() { + return map.values(); + } + + /** + * 全てのObserver({@link #listeners})に対してEventを通知する。 + * THINK かなり内部的なclassなので、このclassのfireChange()はprivateでも良いのではないか? + * @param event + */ + private void fireChange(ObservableCollectionChangeEvent<Map<K, V>, V> event) { + // FIXME lazy instance creationせずに済む方法はないか? + if (listeners == null) { + listeners = CollectionsUtil.newArrayList(); + } + for (ObservableCollectionChangeListener<Map<K, V>, V> listener : listeners) { + listener.collectionChanged(event); + } + } + + + /** + * 要素に対する変更を監視する。 + * Eventを受けた場合は<code>ModelCollectionChangeEvent.Timing.modelChanged</code> + * という種類の{@link ModelChangeEvent}として通知する。 + * + * @author shin1ogawa + */ + class ModelChangeListenerImpl implements ModelChangeListener { + + Map<K, V> list; + + + /** + * コンストラクタ。 + * @param list + * @category instance creation + */ + public ModelChangeListenerImpl(Map<K, V> list) { + this.list = list; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public void modelChanged(ModelChangeEvent e) { +// int index = indexOf(e.getSource()); + int index = -1; + fireChange(new ObservableCollectionChangeEvent<Map<K, V>, V>( + ObservableCollectionChangeEvent.Timing.COLLECTION_CHANGED, list, index, (V) e.getSource())); + } + } + +} Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableSet.java (from rev 1923, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/collectionimpl/ObservableSet.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableSet.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableSet.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -0,0 +1,299 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/07/28 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.core.event.collectionimpl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.jiemamy.core.event.ModelChangeEvent; +import org.jiemamy.core.event.ModelChangeListener; +import org.jiemamy.core.event.Observable; +import org.jiemamy.core.event.ObservableCollectionChangeEvent; +import org.jiemamy.core.event.ObservableCollectionChangeListener; + +/** + * {@link ObservableCollectionChangeEvent}を通知する{@link java.util.Set}の実装。。 + * add/remove等の更新系メソッド全てで{@link ObservableCollectionChangeEvent}を通知する。 + * また、保持する要素が{@link Observable}の場合は、要素の{@link ModelChangeEvent}も監視し、 + * {@link ObservableCollectionChangeEvent}にラップして通知する。 + * + * @param <T> 保持する要素の型. + * @author shin1ogawa + */ +public class ObservableSet<T> implements Set<T> { + + /** + * Setの実装をdecorateした{@link ObservableSet}を返す。 + * @param <T> + * @param set + * @return {@link ObservableList} + */ + public static <T>ObservableSet<T> decorate(Set<T> set) { + return new ObservableSet<T>(set); + } + + + private Set<T> set; + + private transient List<ObservableCollectionChangeListener<Set<T>, T>> listeners = + new ArrayList<ObservableCollectionChangeListener<Set<T>, T>>(); + + private transient ModelChangeListener modelChangeListener; + + + /** + * コンストラクタ。 + * Setの実装を指定しない場合は{@link HashSet}を使用する。 + * @category instance creation + */ + public ObservableSet() { + this.set = new HashSet<T>(); + modelChangeListener = new ModelChangeListenerImpl(this); + } + + /** + * コンストラクタ。 + * @param set 使用するSetの実装 + * @category instance creation + */ + public ObservableSet(Set<T> set) { + this.set = set; + modelChangeListener = new ModelChangeListenerImpl(this); + } + + /** + * {@inheritDoc} + */ + public boolean add(T o) { + int index = -1; + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>(ObservableCollectionChangeEvent.Timing.BEFORE_ADD, + this, index, o)); + // 要素に対する監視を開始する。 + boolean result = set.add(o); + if (o instanceof Observable) { + Observable observable = (Observable) o; + observable.addModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_ADD, + this, index, o)); + return result; + } + + /** + * {@inheritDoc} + */ + public boolean addAll(Collection<? extends T> c) { + if (c != null && c.size() > 0) { + // add(T)に展開する。 + for (T element : c) { + add(element); + } + return true; + } else { + return false; + } + } + + /** + * Eventを監視するListenerを追加する。 + * @param l {@link ObservableCollectionChangeListener} + */ + public void addListener(ObservableCollectionChangeListener<Set<T>, T> l) { + listeners.add(l); + } + + /** + * {@inheritDoc} + */ + public void clear() { + int index = -1; + // Eventを通知するために一旦別のListへ格納し直す。 + ArrayList<T> removedList = new ArrayList<T>(set.size()); + Iterator<T> iterator = set.iterator(); + while (iterator.hasNext()) { + T element = iterator.next(); + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>( + ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, this, index, element)); + removedList.add(element); + } + set.clear(); + iterator = removedList.iterator(); + index = 0; + while (iterator.hasNext()) { + T element = iterator.next(); + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>( + ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, this, index, element)); + index++; + } + removedList.clear(); // 用済みなので破棄する。 + } + + /** + * {@inheritDoc} + */ + public boolean contains(Object o) { + return set.contains(o); + } + + /** + * {@inheritDoc} + */ + public boolean containsAll(Collection<?> c) { + return set.containsAll(c); + } + + /** + * {@inheritDoc} + */ + public boolean isEmpty() { + return set.isEmpty(); + } + + /** + * {@inheritDoc} + */ + public Iterator<T> iterator() { + return set.iterator(); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public boolean remove(Object o) { + int index = -1; + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>(ObservableCollectionChangeEvent.Timing.BEFORE_REMOVE, + this, index, (T) o)); + boolean result = set.remove(o); + // 要素に対する監視をやめる。 + if (o instanceof Observable) { + Observable observable = (Observable) o; + observable.removeModelChangeListener(modelChangeListener); + } + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>(ObservableCollectionChangeEvent.Timing.AFTER_REMOVE, + this, index, (T) o)); + return result; + } + + /** + * {@inheritDoc} + */ + public boolean removeAll(Collection<?> c) { + List<Object> removeList = new ArrayList<Object>(); + Iterator<?> iterator = iterator(); + while (iterator.hasNext()) { + Object next = iterator.next(); + if (c.contains(next)) { + removeList.add(next); + } + } + if (!removeList.isEmpty()) { + for (Object o : removeList) { + remove(o); + } + removeList.clear(); + return true; + } else { + return false; + } + } + + /** + * Eventの監視をやめたいListenerを削除する。 + * @param l + */ + public void removeListener(ObservableCollectionChangeListener<Set<T>, T> l) { + listeners.remove(l); + } + + /** + * {@inheritDoc} + */ + public boolean retainAll(Collection<?> c) { + return set.retainAll(c); + } + + /** + * {@inheritDoc} + */ + public int size() { + return set.size(); + } + + /** + * {@inheritDoc} + */ + public Object[] toArray() { + return set.toArray(); + } + + /** + * {@inheritDoc} + */ + public <U>U[] toArray(U[] a) { + return set.toArray(a); + } + + /** + * 全てのObserver({@link #listeners})に対してEventを通知する。 + * @param event + */ + private void fireChange(ObservableCollectionChangeEvent<Set<T>, T> event) { + for (ObservableCollectionChangeListener<Set<T>, T> listener : listeners) { + listener.collectionChanged(event); + } + } + + + /** + * 要素に対する変更を監視する。 + * Eventを受けた場合は<code>ModelCollectionChangeEvent.Timing.modelChanged</code> + * という種類の{@link ModelChangeEvent}として通知する。 + * + * @author shin1ogawa + */ + class ModelChangeListenerImpl implements ModelChangeListener { + + private Set<T> set; + + + /** + * コンストラクタ。 + * @param set + * @category instance creation + */ + public ModelChangeListenerImpl(Set<T> set) { + this.set = set; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public void modelChanged(ModelChangeEvent e) { + int index = -1; + fireChange(new ObservableCollectionChangeEvent<Set<T>, T>( + ObservableCollectionChangeEvent.Timing.COLLECTION_CHANGED, set, index, (T) e.getSource())); + } + } +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/ObservableSet.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/package-info.java (from rev 1923, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/collectionimpl/package-info.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/package-info.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/package-info.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -0,0 +1,7 @@ +/** + * JiemamyのModelを保持するためのCollectionの実装Class用のパッケージ。 + * 実装されたCollectionは自身の要素に対する操作をEventとして通知する事ができる必要がある。 + * @author shin1ogawa + */ +package org.jiemamy.core.event.collectionimpl; + Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/collectionimpl/package-info.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/RootModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/RootModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/RootModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,11 +21,11 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.RootModel; import org.jiemamy.core.model.dataset.InsertDataSetModel; import org.jiemamy.core.model.presentation.DiagramPresentationModel; import org.jiemamy.core.model.typedef.DomainModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、RootModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/InsertDataSetModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/InsertDataSetModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/InsertDataSetModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -22,9 +22,9 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.dataset.InsertDataSetModel; import org.jiemamy.core.model.node.AbstractEntityModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、InsertDataSetModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/RecordModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/RecordModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/dataset/RecordModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -22,9 +22,9 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.dataset.RecordModel; import org.jiemamy.core.model.typedef.ColumnModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、RecordModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/AbstractNodeModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/AbstractNodeModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/AbstractNodeModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,9 +21,9 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.connection.AbstractConnectionModel; import org.jiemamy.core.model.node.AbstractNodeModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、AbstractNodeModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/TableModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/TableModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/node/TableModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,11 +21,11 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.node.TableModel; import org.jiemamy.core.model.node.index.IndexModel; import org.jiemamy.core.model.typedef.ColumnModel; import org.jiemamy.core.model.typedef.constraint.CheckConstraintModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、TableModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/presentation/DiagramPresentationModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/presentation/DiagramPresentationModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/presentation/DiagramPresentationModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -22,10 +22,10 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.connection.AbstractConnectionModel; import org.jiemamy.core.model.node.AbstractNodeModel; import org.jiemamy.core.model.presentation.DiagramPresentationModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、DiagramPresentationModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/typedef/constraint/ConstraintSetModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/typedef/constraint/ConstraintSetModelChangeSupport.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/typedef/constraint/ConstraintSetModelChangeSupport.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -26,8 +26,8 @@ import org.jiemamy.core.event.ModelChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.typedef.constraint.ConstraintSetModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; /** * Event関連の処理をModel内に直接記述するとModelのSourceの可読性が低くなるため、ConstraintSetModelからそれらを引き受ける。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -23,13 +23,13 @@ import java.util.List; import java.util.Set; +import org.jiemamy.core.event.collectionimpl.ObservableList; +import org.jiemamy.core.event.collectionimpl.ObservableSet; import org.jiemamy.core.model.connection.AbstractConnectionModel; import org.jiemamy.core.model.dataset.InsertDataSetModel; import org.jiemamy.core.model.node.AbstractNodeModel; import org.jiemamy.core.model.presentation.DiagramPresentationModel; import org.jiemamy.core.model.typedef.DomainModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; -import org.jiemamy.core.utils.collectionimpl.ObservableSet; /** * 1つのDBスキーマ・データ全体を表す。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,11 +21,11 @@ import java.util.ArrayList; import java.util.List; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.node.AbstractEntityModel; import org.jiemamy.core.model.node.TableModel; import org.jiemamy.core.model.typedef.ColumnModel; import org.jiemamy.core.utils.ForEachUtil; -import org.jiemamy.core.utils.collectionimpl.ObservableList; import org.jiemamy.core.utils.processor.SetDefaultColumnsProcessor; import org.jiemamy.core.utils.visitor.impl.PrimaryKeyVisitor; Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/InsertDataSetModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/InsertDataSetModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/InsertDataSetModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -22,9 +22,9 @@ import java.util.List; import java.util.Map; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.AbstractModel; import org.jiemamy.core.model.node.AbstractEntityModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; /** * INSERT文用データセット。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/RecordModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/RecordModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/dataset/RecordModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,9 +21,9 @@ import java.util.HashMap; import java.util.Map; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.AbstractModel; import org.jiemamy.core.model.typedef.ColumnModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; /** * レコード(INSERT文1つ分)モデル。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,9 +21,9 @@ import java.util.ArrayList; import java.util.List; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.AbstractModel; import org.jiemamy.core.model.connection.AbstractConnectionModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; /** * ノード(Table, View等)のAbstractモデル。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,11 +21,11 @@ import java.util.ArrayList; import java.util.List; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.event.model.node.TableModelChangeSupport; import org.jiemamy.core.model.node.index.IndexModel; import org.jiemamy.core.model.typedef.ColumnModel; import org.jiemamy.core.model.typedef.constraint.CheckConstraintModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; /** * テーブルモデル。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/index/IndexModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/index/IndexModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/index/IndexModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.List; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.AbstractModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; /** * インデックスモデル。 Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModel.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModel.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -24,11 +24,11 @@ import java.util.Map; import java.util.Set; +import org.jiemamy.core.event.collectionimpl.ObservableMap; +import org.jiemamy.core.event.collectionimpl.ObservableSet; import org.jiemamy.core.model.AbstractModel; import org.jiemamy.core.model.connection.AbstractConnectionModel; import org.jiemamy.core.model.node.AbstractNodeModel; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; -import org.jiemamy.core.utils.collectionimpl.ObservableSet; /** * ダイアグラム表現(レイアウト等)モデル。 Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/CollectionUtil.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/CollectionUtil.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/CollectionUtil.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -1,56 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/06/28 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.core.utils; - -import org.jiemamy.core.model.JiemamyModel; -import org.jiemamy.core.utils.collectionimpl.ObservableList; -import org.jiemamy.core.utils.collectionimpl.ObservableMap; - -/** - * Collection用Utilities. - * - * TODO staticメソッド decorate として再実装される予定。 - * @author shin1ogawa - */ -public class CollectionUtil { - - /** - * 空のModel用Listを返す。 - * @param <T> - * @return 新しく生成された空のModel用List. - */ - @Deprecated - public static <T extends JiemamyModel>ObservableList<T> newModelList() { - return new ObservableList<T>(); - } - - /** - * 空のModel用Mapを返す。 - * @param <K> - * @param <V> - * @return 新しく生成された空のModel用Map. - */ - @Deprecated - public static <K, V>ObservableMap<K, V> newModelMap() { - return new ObservableMap<K, V>(); - } - - private CollectionUtil() { - } -} Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableListTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableListTest.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableListTest.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -36,6 +36,7 @@ import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent.Timing; +import org.jiemamy.core.event.collectionimpl.ObservableList; import org.jiemamy.core.model.typedef.ColumnModel; import org.jiemamy.core.model.typedef.datatype.DataType; import org.jiemamy.core.model.typedef.datatype.impl.IntegerDataTypeMock; Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableMapTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableMapTest.java 2008-09-16 16:31:59 UTC (rev 1925) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/collectionimpl/ObservableMapTest.java 2008-09-16 16:52:28 UTC (rev 1926) @@ -36,6 +36,7 @@ import org.jiemamy.core.event.ObservableCollectionChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeListener; import org.jiemamy.core.event.ObservableCollectionChangeEvent.Timing; +import org.jiemamy.core.event.collectionimpl.ObservableMap; import org.jiemamy.core.model.typedef.ColumnModel; import org.jiemamy.core.model.typedef.datatype.DataType; import org.jiemamy.core.model.typedef.datatype.impl.IntegerDataTypeMock;