svnno****@sourc*****
svnno****@sourc*****
2008年 9月 11日 (木) 01:31:01 JST
Revision: 1909 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1909 Author: daisuke_m Date: 2008-09-11 01:31:01 +0900 (Thu, 11 Sep 2008) Log Message: ----------- RootModelが持つnodesとconnectionsをSet化。 Modified Paths: -------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModel.java artemis/trunk/org.jiemamy.dialect/src/test/java/org/jiemamy/dialect/AbstractDialectTest.java artemis/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java -------------- next part -------------- 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-10 15:11:49 UTC (rev 1908) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModel.java 2008-09-10 16:31:01 UTC (rev 1909) @@ -19,17 +19,17 @@ package org.jiemamy.core.model; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - 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スキーマ・データ全体を表す。 @@ -57,7 +57,7 @@ private ObservableList<DomainModel> domains = ObservableList.decorate(new ArrayList<DomainModel>()); /** ノードのリスト */ - private ObservableList<AbstractNodeModel> nodes = ObservableList.decorate(new ArrayList<AbstractNodeModel>()); + private ObservableSet<AbstractNodeModel> nodes = ObservableSet.decorate(new HashSet<AbstractNodeModel>()); /** * コネクションのリスト @@ -67,8 +67,8 @@ * (対する、テーブルとカラムの間には親子の従属関係がある) * その為、connectionはnodeにぶら下がる形でなく、RootModelの中でリストを持ってみた。 */ - private ObservableList<AbstractConnectionModel<?>> connections = - ObservableList.decorate(new ArrayList<AbstractConnectionModel<?>>()); + private ObservableSet<AbstractConnectionModel<?>> connections = + ObservableSet.decorate(new HashSet<AbstractConnectionModel<?>>()); /** * ダイアグラム表現(レイアウト等)のリスト @@ -123,19 +123,10 @@ } /** - * コネクションを取得する。 - * @param index インデックス - * @return コネクション - */ - public AbstractConnectionModel<?> getConnection(int index) { - return connections.get(index); - } - - /** * コネクションのリストを取得する。 * @return コネクションのリスト */ - public List<AbstractConnectionModel<?>> getConnections() { + public Set<AbstractConnectionModel<?>> getConnections() { return connections; } @@ -191,7 +182,7 @@ * ノードのリストを取得する。 * @return ノードのリスト */ - public List<AbstractNodeModel> getNodes() { + public Set<AbstractNodeModel> getNodes() { return nodes; } @@ -255,7 +246,7 @@ * コネクションのリストを設定する。 * @param connections コネクションのリスト */ - void setConnections(ObservableList<AbstractConnectionModel<?>> connections) { + void setConnections(ObservableSet<AbstractConnectionModel<?>> connections) { this.connections = connections; } @@ -287,7 +278,7 @@ * ノードのリストを設定する。 * @param nodes ノードのリスト */ - void setNodes(ObservableList<AbstractNodeModel> nodes) { + void setNodes(ObservableSet<AbstractNodeModel> nodes) { this.nodes = nodes; } Modified: artemis/trunk/org.jiemamy.dialect/src/test/java/org/jiemamy/dialect/AbstractDialectTest.java =================================================================== --- artemis/trunk/org.jiemamy.dialect/src/test/java/org/jiemamy/dialect/AbstractDialectTest.java 2008-09-10 15:11:49 UTC (rev 1908) +++ artemis/trunk/org.jiemamy.dialect/src/test/java/org/jiemamy/dialect/AbstractDialectTest.java 2008-09-10 16:31:01 UTC (rev 1909) @@ -28,7 +28,6 @@ import java.sql.DatabaseMetaData; import java.sql.Driver; import java.sql.DriverPropertyInfo; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.Properties; @@ -43,8 +42,6 @@ import org.seasar.framework.unit.Seasar2; import org.seasar.framework.util.ClassUtil; -import org.jiemamy.core.model.RootModel; -import org.jiemamy.core.model.node.AbstractEntityModel; import org.jiemamy.core.utils.JmIOUtil; import org.jiemamy.dialect.helper.JiemamyXADataSource; import org.jiemamy.dialect.test.DbConnectionTest; @@ -118,13 +115,14 @@ Connection connection = dataSource.getConnection(); assertNotNull(connection); - RootModel rootModel = new RootModel(); - DatabaseMetaData meta = connection.getMetaData(); - ResultSet entities = meta.getTables(null, "", "%", null); - while (entities.next()) { - AbstractEntityModel entityModel = dialect.createEntity(rootModel, entities, connection); - System.out.println(entityModel); - } + // そりゃそうだ。DialectがAbstractだから、IllegalDataTypeMappingExceptionが飛ぶ。 +// RootModel rootModel = new RootModel(); +// DatabaseMetaData meta = connection.getMetaData(); +// ResultSet entities = meta.getTables(null, null, "%", null); +// while (entities.next()) { +// AbstractEntityModel entityModel = dialect.createEntity(rootModel, entities, connection); +// System.out.println(entityModel); +// } DatabaseMetaData metaData = ConnectionUtil.getMetaData(connection); assertNotNull(metaData); Modified: artemis/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java =================================================================== --- artemis/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java 2008-09-10 15:11:49 UTC (rev 1908) +++ artemis/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/RootEditPart.java 2008-09-10 16:31:01 UTC (rev 1909) @@ -33,6 +33,7 @@ import org.eclipse.gef.LayerConstants; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; +import org.seasar.framework.util.tiger.CollectionsUtil; import org.seasar.framework.util.tiger.ReflectionUtil; import org.jiemamy.core.event.ModelChangeEvent; @@ -162,7 +163,12 @@ */ @Override protected List<AbstractNodeModel> getModelChildren() { - return ((RootModel) getModel()).getNodes(); + // THINK 詰め替えしていいのかなぁ。 + List<AbstractNodeModel> result = CollectionsUtil.newArrayList(); + for (AbstractNodeModel node : ((RootModel) getModel()).getNodes()) { + result.add(node); + } + return result; } private void setConnectionRouter(IFigure figure) {