svnno****@sourc*****
svnno****@sourc*****
2008年 9月 16日 (火) 01:49:54 JST
Revision: 1922 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1922 Author: shin1 Date: 2008-09-16 01:49:54 +0900 (Tue, 16 Sep 2008) Log Message: ----------- TableModelにてListenerの使い方もかねたTestCaseを作成(既存の物を修正) diconに自動登録のための定義を記述(まだコメントアウト状態)。 Modified Paths: -------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/SetterInterceptor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModel.java artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core-aop.dicon artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java Added Paths: ----------- artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon Removed Paths: ------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeListener.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeSupport.java artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/SetterInterceptor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/SetterInterceptor.java 2008-09-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/SetterInterceptor.java 2008-09-15 16:49:54 UTC (rev 1922) @@ -51,6 +51,7 @@ Field field = declaringClass.getDeclaredField(fieldName); field.setAccessible(true); + System.out.println(declaringClass.getName() + "#" + field.getName() + " was changed!"); // Setter実行前の値を取得する。 // Object oldValue = field.get(invocation.getThis()); Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeListener.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeListener.java 2008-09-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeListener.java 2008-09-15 16:49:54 UTC (rev 1922) @@ -1,50 +0,0 @@ -/* - * 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.model; - -import java.util.List; - -import org.jiemamy.core.event.ModelChangeListener; -import org.jiemamy.core.event.ObservableCollectionChangeEvent; -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; - -/** - * TODO for shin1ogawa - * @author shin1ogawa - */ -public interface TableModelChangeListener extends ModelChangeListener { - - /** - * {@link TableModel}が保持する{@link CheckConstraintModel}のCollectionに対する変更を処理する。 - * @param event - */ - void checkCollectionChange(ObservableCollectionChangeEvent<List<CheckConstraintModel>, CheckConstraintModel> event); - - /** - * {@link TableModel}が保持する{@link ColumnModel}のCollectionに対する変更を処理する。 - * @param event - */ - void columnCollectionChange(ObservableCollectionChangeEvent<List<ColumnModel>, ColumnModel> event); - - /** - * {@link TableModel}が保持する{@link IndexModel}のCollectionに対する変更を処理する。 - * @param event - */ - void indexCollectionChange(ObservableCollectionChangeEvent<List<IndexModel>, IndexModel> event); - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeSupport.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeSupport.java 2008-09-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/event/model/TableModelChangeSupport.java 2008-09-15 16:49:54 UTC (rev 1922) @@ -1,173 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. Created on 2008/07/02 - * - * 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.model; - -import java.util.ArrayList; -import java.util.List; - -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.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からそれらを引き受ける。 - * @author shin1ogawa - */ -public class TableModelChangeSupport { - - /** TableModel自身のEventを監視するListenerのリスト */ - private List<TableModelChangeListener> listeners = new ArrayList<TableModelChangeListener>(); - - /** - * カラムのリストを監視するListener - * @see ObservableCollectionChangeListener - * @see #fireColumnsCollectionChangeEvent(ObservableCollectionChangeEvent) - */ - private ObservableCollectionChangeListener<List<ColumnModel>, ColumnModel> columnsCollectionChangeListener = - new ObservableCollectionChangeListener<List<ColumnModel>, ColumnModel>() { - - /** - * {@inheritDoc} - */ - public void collectionChanged(ObservableCollectionChangeEvent<List<ColumnModel>, ColumnModel> event) { - fireColumnsCollectionChangeEvent(event); - } - }; - - /** - * インデックスのリストを監視するListener - * @see ObservableCollectionChangeListener - * @see #fireIndexesCollectionChangeEvent(ObservableCollectionChangeEvent) - */ - private ObservableCollectionChangeListener<List<IndexModel>, IndexModel> indexCollectionChangeListener = - new ObservableCollectionChangeListener<List<IndexModel>, IndexModel>() { - - /** - * {@inheritDoc} - */ - public void collectionChanged(ObservableCollectionChangeEvent<List<IndexModel>, IndexModel> event) { - fireIndexesCollectionChangeEvent(event); - } - }; - - /** - * テーブルCHECK制約のリストを監視するListener - * @see ObservableCollectionChangeListener - * @see #fireChecksCollectionChangeEvent(ObservableCollectionChangeEvent) - */ - private ObservableCollectionChangeListener<List<CheckConstraintModel>, CheckConstraintModel> checksCollectionChangeListener = - new ObservableCollectionChangeListener<List<CheckConstraintModel>, CheckConstraintModel>() { - - /** - * {@inheritDoc} - */ - public void collectionChanged( - ObservableCollectionChangeEvent<List<CheckConstraintModel>, CheckConstraintModel> event) { - fireChecksCollectionChangeEvent(event); - } - }; - - /** - * TableModelの属性の変更Eventを処理するListener - * @see #fireModelChange(ModelChangeEvent) - */ - private ModelChangeListener tableModelChangeListener = new ModelChangeListener() { - - /** - * {@inheritDoc} - */ - public void modelChanged(ModelChangeEvent event) { - fireModelChange(event); - } - }; - - - /** - * コンストラクタ。 - * @param source {@link TableModel} - * @category instance creation - */ - public TableModelChangeSupport(TableModel source) { - source.addModelChangeListener(tableModelChangeListener); - ((ObservableList<ColumnModel>) source.getColumns()).addListener(columnsCollectionChangeListener); - ((ObservableList<IndexModel>) source.getIndexes()).addListener(indexCollectionChangeListener); - ((ObservableList<CheckConstraintModel>) source.getChecks()).addListener(checksCollectionChangeListener); - } - - /** - * TableModel自身のEventを監視するListenerを追加する。 - * @param l {@link TableModelChangeListener} - * @see #removeTableModelChangeListener(TableModelChangeListener) - */ - public void addTableModelChangeListener(TableModelChangeListener l) { - listeners.add(l); - } - - /** - * テーブルCHECK制約のリストを監視するListenerに通知されたEventをTableModelの監視Listenerへ通知する。 - * @param event {@link ObservableCollectionChangeEvent} - */ - public void fireChecksCollectionChangeEvent( - ObservableCollectionChangeEvent<List<CheckConstraintModel>, CheckConstraintModel> event) { - for (TableModelChangeListener l : listeners) { - l.checkCollectionChange(event); - } - } - - /** - * カラムのリストを監視するListenerに通知されたEventをTableModelの監視Listenerへ通知する。 - * @param event {@link ObservableCollectionChangeEvent} - */ - public void fireColumnsCollectionChangeEvent(ObservableCollectionChangeEvent<List<ColumnModel>, ColumnModel> event) { - for (TableModelChangeListener l : listeners) { - l.columnCollectionChange(event); - } - } - - /** - * インデックスのリストを監視するListenerに通知されたEventをTableModelの監視Listenerへ通知する。 - * @param event - */ - public void fireIndexesCollectionChangeEvent(ObservableCollectionChangeEvent<List<IndexModel>, IndexModel> event) { - for (TableModelChangeListener l : listeners) { - l.indexCollectionChange(event); - } - } - - /** - * TableModel自身を監視するListenerに通知されたEventをTableModelの監視Listenerへ通知する。 - * @param event {@link ModelChangeEvent} - */ - public void fireModelChange(ModelChangeEvent event) { - for (TableModelChangeListener l : listeners) { - l.modelChanged(event); - } - } - - /** - * TableModel自身のEventを監視するListenerを削除する。 - * @param l {@link TableModelChangeListener} - * @see #addTableModelChangeListener(TableModelChangeListener) - */ - public void removeTableModelChangeListener(TableModelChangeListener l) { - listeners.remove(l); - } -} 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-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModel.java 2008-09-15 16:49:54 UTC (rev 1922) @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; +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; @@ -43,7 +44,11 @@ /** テーブルCHECK制約のリスト */ private List<CheckConstraintModel> checks = ObservableList.decorate(new ArrayList<CheckConstraintModel>()); + /** Event通知系の処理を代行させるためのChangeSupport */ + private TableModelChangeSupport changeSupport = new TableModelChangeSupport(this); + + /** * コンストラクタ。 * @category instance creation @@ -132,4 +137,21 @@ void setIndexes(List<IndexModel> indexes) { this.indexes = indexes; } + + + /** + * Event通知系の処理を代行させるためのChangeSupportを取得します。 + * @return Event通知系の処理を代行させるためのChangeSupport + */ + public TableModelChangeSupport getChangeSupport() { + return changeSupport; + } + + /** + * Event通知系の処理を代行させるためのChangeSupportを設定します。 + * @param changeSupport Event通知系の処理を代行させるためのChangeSupport + */ + public void setChangeSupport(TableModelChangeSupport changeSupport) { + this.changeSupport = changeSupport; + } } Modified: artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core-aop.dicon =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core-aop.dicon 2008-09-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core-aop.dicon 2008-09-15 16:49:54 UTC (rev 1922) @@ -2,11 +2,12 @@ <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN" "http://www.seasar.org/dtd/components24.dtd"> <components> + <!-- ChangeEventを自動的に発火させるためのsetterInterceptor --> <component name="setterInterceptor" class="org.jiemamy.core.event.SetterInterceptor"/> <component class="org.jiemamy.core.model.node.TableModel" instance="prototype"> <aspect pointcut="set.*">setterInterceptor</aspect> </component> - <component class="org.jiemamy.core.model.typedef.ColumnModel" instance="prototype"> + <component class="org.jiemamy.core.model.typedef.ColumnModel" instance="prototype" autoBinding="none"> <aspect pointcut="set.*">setterInterceptor</aspect> </component> <component class="org.jiemamy.core.model.node.index.IndexModel" instance="prototype"> @@ -15,4 +16,20 @@ <component class="org.jiemamy.core.model.typedef.constraint.CheckConstraintModel" instance="prototype"> <aspect pointcut="set.*">setterInterceptor</aspect> </component> + + <!-- 自動登録されたModelへのsetterInterceptorの自動登録 --> + <!-- + <component class="org.seasar.framework.container.autoregister.AspectAutoRegister"> + <property name="interceptor">setterInterceptor</property> + <property name="pointcut">"set.*"</property> + <initMethod name="addClassPattern"> + <arg>"org.jiemamy.core.model"</arg> + <arg>".*Model"</arg> + </initMethod> + <initMethod name="addIgnoreClassPattern"> + <arg>"org.jiemamy.core.model"</arg> + <arg>"InheritanceColumnModel"</arg> + </initMethod> + </component> + --> </components> Deleted: artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon 2008-09-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon 2008-09-15 16:49:54 UTC (rev 1922) @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN" - "http://www.seasar.org/dtd/components24.dtd"> -<components> - <include path="jiemamy-core-aop.dicon"/> - - <!-- Jiemamy Model --> - <component class="org.jiemamy.core.model.RootModel" instance="prototype"/> - <component class="org.jiemamy.core.model.node.TableModel" instance="prototype"/> - <component class="org.jiemamy.core.model.node.ViewModel" instance="prototype"/> - <component class="org.jiemamy.core.model.node.StickyModel" instance="prototype"/> - <component class="org.jiemamy.core.model.connection.ForeignKeyModel" instance="prototype"/> - <component class="org.jiemamy.core.model.typedef.DomainModel" instance="prototype" autoBinding="none"/> - <component class="org.jiemamy.core.model.presentation.DiagramPresentationModel" instance="prototype"/> - <component class="org.jiemamy.core.model.dataset.InsertDataSetModel" instance="prototype"/> -</components> Added: artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon 2008-09-15 16:49:54 UTC (rev 1922) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN" + "http://www.seasar.org/dtd/components24.dtd"> +<components> + <include path="jiemamy-core-aop.dicon"/> + + <!-- Jiemamy Model --> + <component class="org.jiemamy.core.model.RootModel" instance="prototype"/> + <component class="org.jiemamy.core.model.node.ViewModel" instance="prototype"/> + <component class="org.jiemamy.core.model.node.StickyModel" instance="prototype"/> + <component class="org.jiemamy.core.model.connection.ForeignKeyModel" instance="prototype"/> + <component class="org.jiemamy.core.model.typedef.DomainModel" instance="prototype" autoBinding="none"/> + <component class="org.jiemamy.core.model.presentation.DiagramPresentationModel" instance="prototype"/> + <component class="org.jiemamy.core.model.dataset.InsertDataSetModel" instance="prototype"/> + + <!-- Modelの自動登録 --> + <!-- + <component class="org.seasar.framework.container.autoregister.FileSystemComponentAutoRegister"> + <property name="instanceDef"> + @org.seasar.framework.container.deployer.InstanceDefFactory @ PROTOTYPE + </property> + <initMethod name="addClassPattern"> + <arg>"org.jiemamy.core.model"</arg> + <arg>".*Model"</arg> + </initMethod> + <initMethod name="addIgnoreClassPattern"> + <arg>"org.jiemamy.core.model"</arg> + <arg>"InheritanceColumnModel"</arg> + </initMethod> + </component> + --> +</components> Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java 2008-09-15 14:56:29 UTC (rev 1921) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/model/node/TableModelTest.java 2008-09-15 16:49:54 UTC (rev 1922) @@ -1,24 +1,21 @@ /* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/06/29 - * + * 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. + * + * 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.model.node; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.util.ArrayList; import java.util.List; @@ -33,11 +30,14 @@ import org.jiemamy.core.event.ModelChangeEvent; import org.jiemamy.core.event.ObservableCollectionChangeEvent; -import org.jiemamy.core.event.model.TableModelChangeListener; +import org.jiemamy.core.event.SetterInterceptor; +import org.jiemamy.core.event.model.node.TableModelChangeListener; +import org.jiemamy.core.model.RootModel; 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.ObservableListTest; +import org.jiemamy.core.utils.debug.S2ContainerUtil; /** * {@link TableModel}のテストクラス。 @@ -54,6 +54,8 @@ @BeforeClass public static void setUpBeforeClass() { s2container = S2ContainerFactory.create("jiemamy-core.dicon"); + s2container.init(); + System.out.println(S2ContainerUtil.inspect(s2container)); } @@ -65,7 +67,7 @@ */ @Before public void setUp() { - listener = new TableModelChangeListenerImpl(); + listener = (new TableModelChangeListenerImpl()); } /** @@ -76,53 +78,68 @@ listener = null; } + @Test + @Ignore("") + public void test00_Componentの自動登録機能を確認する() { + System.out.println("0"); + assertNotNull(s2container.getComponent(RootModel.class)); + System.out.println("1"); + assertNotNull(s2container.getComponent(TableModel.class)); + System.out.println("2"); + assertNotNull(s2container.getComponent(ColumnModel.class)); + System.out.println("3"); + assertNotNull(s2container.getComponent(SetterInterceptor.class)); + System.out.println("4"); + } + /** - * TableModelが保持しているCollectionを取得し、その要素を直接操作する。 - * その操作結果が全て通知されるかどうかを確認する。 + * TableModelが保持しているCollectionを取得し、その要素を直接操作する。 その操作イベントが全て通知されるかどうかを確認する。 */ @Test - @Ignore("[CORE-59]でイベント処理が復活するまでSkipします") public void test01() { TableModel tableModel01 = (TableModel) s2container.getComponent(TableModel.class); - // それぞれのCollectionを取得する。 List<ColumnModel> columns = tableModel01.getColumns(); List<CheckConstraintModel> checks = tableModel01.getChecks(); List<IndexModel> indexes = tableModel01.getIndexes(); - // Test用のListenerを追加して監視を開始する。 - tableModel01.addModelChangeListener(listener); - // Test用のColumnModelを作成する。 - ColumnModel[] columnArray = ObservableListTest.newTestColumnModels(s2container); - // TableModelに対する操作を開始する。 - columns.add(columnArray[0]); - columns.add(columnArray[1]); - columns.add(columnArray[2]); - assertEquals(6, listener.columnsEvents.size()); // TableModel#columns - tableModel01.setBeginScript("begin script"); // TableModel - assertEquals(1, listener.tableEvents.size()); - columnArray[1].setName("changedName"); - assertEquals(7, listener.columnsEvents.size()); + tableModel01.getChangeSupport().addTableModelChangeListener(listener); + ColumnModel[] columnModels = ObservableListTest.newTestColumnModels(s2container); + // TableModelより取得したColumnModel用のCollectionに要素の追加を行う。 + listener.clear(); + columns.add(columnModels[0]); + columns.add(columnModels[1]); + columns.add(columnModels[2]); + assertEquals(6, listener.columnsEvents.size()); // 3*2(before/after)=6 assertEquals(0, listener.checksEvents.size()); assertEquals(0, listener.indexesEvents.size()); - assertEquals(1, listener.tableEvents.size()); - // - listener.clear(); - CheckConstraintModel check01 = (CheckConstraintModel) s2container.getComponent(CheckConstraintModel.class); - checks.add(check01); // check(BEFORE_ADD,AFTER_ADD) - check01.setName("check_changedName"); // check - check01.setExpression("check_expression"); // check - IndexModel index01 = (IndexModel) s2container.getComponent(IndexModel.class); - indexes.add(index01); // index(BEFORE_ADD,AFTER_ADD) - index01.setName("index01"); // index - assertEquals(0, listener.columnsEvents.size()); - assertEquals(4, listener.checksEvents.size()); - assertEquals(3, listener.indexesEvents.size()); assertEquals(0, listener.tableEvents.size()); - // Option + // TableModelの属性を変更する。 listener.clear(); + tableModel01.setBeginScript("begin script"); assertEquals(0, listener.columnsEvents.size()); assertEquals(0, listener.checksEvents.size()); assertEquals(0, listener.indexesEvents.size()); + assertEquals(1, listener.tableEvents.size()); // TableModelの属性変更イベント + // TableModelが保持するColumnModel用Collectionの中の要素に対して変更操作 + listener.clear(); + columnModels[1].setName("changedName"); + assertEquals(1, listener.columnsEvents.size()); // CollectionChangeEventとして発火される。 + assertEquals(0, listener.checksEvents.size()); + assertEquals(0, listener.indexesEvents.size()); assertEquals(0, listener.tableEvents.size()); + + // 上記ColumnModel用Collectionに対する操作を他のCollectionに対しても行う。 + listener.clear(); + CheckConstraintModel check01 = (CheckConstraintModel) s2container.getComponent(CheckConstraintModel.class); + checks.add(check01); + check01.setName("check_changedName"); + check01.setExpression("check_expression"); + IndexModel index01 = (IndexModel) s2container.getComponent(IndexModel.class); + indexes.add(index01); + index01.setName("index01"); + assertEquals(0, listener.columnsEvents.size()); + assertEquals(4, listener.checksEvents.size()); // checkの追加(before,after)+属性変更*2 + assertEquals(3, listener.indexesEvents.size()); // indexの追加(before,after)+属性変更*1 + assertEquals(0, listener.tableEvents.size()); } @@ -197,6 +214,5 @@ })); tableEvents.add(event); } - } }