svnno****@sourc*****
svnno****@sourc*****
2009年 3月 17日 (火) 01:53:01 JST
Revision: 2880 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2880 Author: daisuke_m Date: 2009-03-17 01:53:01 +0900 (Tue, 17 Mar 2009) Log Message: ----------- 外部キー編集ダイアログを、facadeを経由しない直接操作で実装。 Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/AbstractMovePositionCommand.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/MoveBendpointCommand.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/facade/JiemamyFacade.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/ElementReference.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexColumnCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexColumnCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/UpdateKeyColumnCommand.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexToTableCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexFromTableCommand.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java 2009-03-16 14:32:22 UTC (rev 2879) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -44,6 +44,7 @@ import org.jiemamy.editcommand.impl.RemoveDomainFromRootCommand; import org.jiemamy.editcommand.impl.RemoveEntityFromRootCommand; import org.jiemamy.editcommand.impl.SwapListElementCommand; +import org.jiemamy.editcommand.impl.UpdateKeyColumnCommand; import org.jiemamy.exception.JiemamyRuntimeException; import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.JiemamyElement; @@ -52,6 +53,7 @@ import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.ColumnRef; import org.jiemamy.model.attribute.ColumnRefImpl; +import org.jiemamy.model.attribute.constraint.KeyConstraint; import org.jiemamy.model.dataset.DataSetModel; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; @@ -241,6 +243,19 @@ } /** + * TODO for daisuke + * + * @param command コマンド + */ + public void process(UpdateKeyColumnCommand command) { + KeyConstraint keyConstraint = command.getKeyConstraint(); + keyConstraint.getKeyColumns().set(command.getIndex(), command.getNewRef()); + + // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 + eventBroker.fireCommandProcessed(command); + } + + /** * {@link RootModel}に{@link JiemamyElement}を追加するEDITコマンドを実行する。 * * @param <P> Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -43,6 +43,17 @@ super(rootModel, domainModel); } + /** + * インスタンスを生成する。 + * + * @param rootModel + * @param domainModel + * @param index + */ + public AddDomainToRootCommand(RootModel rootModel, DomainModel domainModel, int index) { + super(rootModel, domainModel, index); + } + public Command getNegateCommand() { return new RemoveDomainFromRootCommand(getTarget(), getElement()); } Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexColumnCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexColumnCommand.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexColumnCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -0,0 +1,67 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/16 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.editcommand.Command; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexColumnModel; +import org.jiemamy.model.index.IndexModel; + +/** + * {@link TableModel}に{@link IndexModel}を追加するEDITコマンド。 + * + * @see RemoveIndexCommand + * @author daisuke + */ +public class AddIndexColumnCommand extends AbstractAddToCollectionCommand<IndexModel, IndexColumnModel> { + + /** + * インスタンスを生成する。 + * + * @param tableModel 追加される{@link TableModel} + * @param indexModel 追加する{@link DomainModel} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public AddIndexColumnCommand(IndexModel tableModel, IndexColumnModel indexModel) { + super(tableModel, indexModel); + } + + /** + * インスタンスを生成する。 + * + * @param tableModel 追加される{@link TableModel} + * @param index + * @param indexModel 追加する{@link DomainModel} + */ + public AddIndexColumnCommand(IndexModel tableModel, int index, IndexColumnModel indexModel) { + super(tableModel, indexModel, index); + } + + public Command getNegateCommand() { + return new RemoveIndexColumnCommand(getTarget(), getElement()); + } + + @Override + public Collection<? super IndexColumnModel> getTargetCollection() { + return getTarget().getColumns(); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexColumnCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexCommand.java (from rev 2878, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexToTableCommand.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexCommand.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -0,0 +1,66 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/16 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.editcommand.Command; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexModel; + +/** + * {@link TableModel}に{@link IndexModel}を追加するEDITコマンド。 + * + * @see RemoveIndexCommand + * @author daisuke + */ +public class AddIndexCommand extends AbstractAddToCollectionCommand<TableModel, IndexModel> { + + /** + * インスタンスを生成する。 + * + * @param tableModel 追加される{@link TableModel} + * @param indexModel 追加する{@link DomainModel} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public AddIndexCommand(TableModel tableModel, IndexModel indexModel) { + super(tableModel, indexModel); + } + + /** + * インスタンスを生成する。 + * + * @param tableModel 追加される{@link TableModel} + * @param index + * @param indexModel 追加する{@link DomainModel} + */ + public AddIndexCommand(TableModel tableModel, int index, IndexModel indexModel) { + super(tableModel, indexModel, index); + } + + public Command getNegateCommand() { + return new RemoveIndexCommand(getTarget(), getElement()); + } + + @Override + public Collection<? super IndexModel> getTargetCollection() { + return getTarget().getIndexes(); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexToTableCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexToTableCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddIndexToTableCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -1,66 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/03/16 - * - * 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.editcommand.impl; - -import java.util.Collection; - -import org.jiemamy.editcommand.Command; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.index.IndexModel; - -/** - * {@link TableModel}に{@link IndexModel}を追加するEDITコマンド。 - * - * @see RemoveIndexFromTableCommand - * @author daisuke - */ -public class AddIndexToTableCommand extends AbstractAddToCollectionCommand<TableModel, IndexModel> { - - /** - * インスタンスを生成する。 - * - * @param tableModel 追加される{@link TableModel} - * @param indexModel 追加する{@link DomainModel} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public AddIndexToTableCommand(TableModel tableModel, IndexModel indexModel) { - super(tableModel, indexModel); - } - - /** - * インスタンスを生成する。 - * - * @param tableModel 追加される{@link TableModel} - * @param index - * @param indexModel 追加する{@link DomainModel} - */ - public AddIndexToTableCommand(TableModel tableModel, int index, IndexModel indexModel) { - super(tableModel, indexModel, index); - } - - public Command getNegateCommand() { - return new RemoveIndexFromTableCommand(getTarget(), getElement()); - } - - @Override - public Collection<? super IndexModel> getTargetCollection() { - return getTarget().getIndexes(); - } -} Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexColumnCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexColumnCommand.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexColumnCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -0,0 +1,55 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/16 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.editcommand.Command; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexColumnModel; +import org.jiemamy.model.index.IndexModel; + +/** + * {@link TableModel}から{@link IndexModel}を削除するEDITコマンド。 + * + * @see AddIndexCommand + * @author daisuke + */ +public class RemoveIndexColumnCommand extends AbstractRemoveFromCollectionCommand<IndexModel, IndexColumnModel> { + + /** + * インスタンスを生成する。 + * + * @param indexModel + * @param indexColumnModel 削除されるインデックス + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public RemoveIndexColumnCommand(IndexModel indexModel, IndexColumnModel indexColumnModel) { + super(indexModel, indexColumnModel); + } + + public Command getNegateCommand() { + return new AddIndexColumnCommand(getTarget(), getElement()); + } + + @Override + public Collection<? super IndexColumnModel> getTargetCollection() { + return getTarget().getColumns(); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexColumnCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexCommand.java (from rev 2878, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexFromTableCommand.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexCommand.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -0,0 +1,54 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/16 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.editcommand.Command; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexModel; + +/** + * {@link TableModel}から{@link IndexModel}を削除するEDITコマンド。 + * + * @see AddIndexCommand + * @author daisuke + */ +public class RemoveIndexCommand extends AbstractRemoveFromCollectionCommand<TableModel, IndexModel> { + + /** + * インスタンスを生成する。 + * + * @param tableModel + * @param indexModel 削除されるインデックス + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public RemoveIndexCommand(TableModel tableModel, IndexModel indexModel) { + super(tableModel, indexModel); + } + + public Command getNegateCommand() { + return new AddIndexCommand(getTarget(), getElement()); + } + + @Override + public Collection<? super IndexModel> getTargetCollection() { + return getTarget().getIndexes(); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexFromTableCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexFromTableCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/RemoveIndexFromTableCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -1,54 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/03/16 - * - * 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.editcommand.impl; - -import java.util.Collection; - -import org.jiemamy.editcommand.Command; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.index.IndexModel; - -/** - * {@link TableModel}から{@link IndexModel}を削除するEDITコマンド。 - * - * @see AddIndexToTableCommand - * @author daisuke - */ -public class RemoveIndexFromTableCommand extends AbstractRemoveFromCollectionCommand<TableModel, IndexModel> { - - /** - * インスタンスを生成する。 - * - * @param tableModel - * @param indexModel 削除されるインデックス - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public RemoveIndexFromTableCommand(TableModel tableModel, IndexModel indexModel) { - super(tableModel, indexModel); - } - - public Command getNegateCommand() { - return new AddIndexToTableCommand(getTarget(), getElement()); - } - - @Override - public Collection<? super IndexModel> getTargetCollection() { - return getTarget().getIndexes(); - } -} Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/UpdateKeyColumnCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/UpdateKeyColumnCommand.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/UpdateKeyColumnCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -0,0 +1,102 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/03/16 + * + * 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.editcommand.impl; + +import org.jiemamy.editcommand.Command; +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.attribute.constraint.KeyConstraint; + +/** + * リスト要素の入れ替えを行うEDITコマンドクラス。 + * + * @author daisuke + */ +public class UpdateKeyColumnCommand extends AbstractCommand { + + private final KeyConstraint keyConstraint; + + private final int index; + + private final ColumnRef newRef; + + private final ColumnRef oldRef; + + + /** + * インスタンスを生成する。 + * + * @param keyConstraint + * @param index + * @param columnModel + */ + public UpdateKeyColumnCommand(KeyConstraint keyConstraint, int index, ColumnModel columnModel) { + this.keyConstraint = keyConstraint; + this.index = index; + newRef = keyConstraint.getJiemamy().getFactory().newReference(columnModel); + oldRef = keyConstraint.getKeyColumns().get(index); + } + + /** + * インスタンスを生成する。 + * + * @param keyConstraint + * @param index + * @param newRef + */ + public UpdateKeyColumnCommand(KeyConstraint keyConstraint, int index, ColumnRef newRef) { + this.keyConstraint = keyConstraint; + this.index = index; + this.newRef = newRef; + oldRef = keyConstraint.getKeyColumns().get(index); + } + + /** + * TODO for daisuke + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * TODO for daisuke + * @return the keyConstraint + */ + public KeyConstraint getKeyConstraint() { + return keyConstraint; + } + + public Command getNegateCommand() { + return new UpdateKeyColumnCommand(keyConstraint, index, oldRef); + } + + /** + * TODO for daisuke + * @return the newRef + */ + public ColumnRef getNewRef() { + return newRef; + } + + public JiemamyElement getTarget() { + return keyConstraint; + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/UpdateKeyColumnCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-03-16 14:32:22 UTC (rev 2879) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -30,20 +30,27 @@ import org.jiemamy.editcommand.CommandProcessorImpl; import org.jiemamy.editcommand.impl.AddAttributeCommand; import org.jiemamy.editcommand.impl.AddColumnToColumnRefListCommand; +import org.jiemamy.editcommand.impl.AddDomainToRootCommand; import org.jiemamy.editcommand.impl.AddEntityToRootCommand; -import org.jiemamy.editcommand.impl.AddIndexToTableCommand; +import org.jiemamy.editcommand.impl.AddIndexColumnCommand; +import org.jiemamy.editcommand.impl.AddIndexCommand; import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; import org.jiemamy.editcommand.impl.RemoveColumnFromColumnRefListCommand; +import org.jiemamy.editcommand.impl.RemoveDomainFromRootCommand; import org.jiemamy.editcommand.impl.RemoveEntityFromRootCommand; -import org.jiemamy.editcommand.impl.RemoveIndexFromTableCommand; +import org.jiemamy.editcommand.impl.RemoveIndexColumnCommand; +import org.jiemamy.editcommand.impl.RemoveIndexCommand; import org.jiemamy.editcommand.impl.SwapListElementCommand; +import org.jiemamy.editcommand.impl.UpdateKeyColumnCommand; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.ForeignKey; import org.jiemamy.model.attribute.constraint.KeyConstraint; +import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexColumnModel; import org.jiemamy.model.index.IndexModel; import org.jiemamy.utils.ArrayEssentialStack; import org.jiemamy.utils.CollectionsUtil; @@ -96,6 +103,19 @@ undoStack.push(command.getNegateCommand()); } + public void addDomain(DomainModel domainModel) { + AddDomainToRootCommand command = new AddDomainToRootCommand(jiemamy.getFactory().getRootModel(), domainModel); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + + public void addDomain(DomainModel domainModel, int index) { + AddDomainToRootCommand command = + new AddDomainToRootCommand(jiemamy.getFactory().getRootModel(), domainModel, index); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + public void addEntity(EntityModel entityModel) { AddEntityToRootCommand command = new AddEntityToRootCommand(jiemamy.getFactory().getRootModel(), entityModel); command.execute(getCommandProcessor()); @@ -103,17 +123,29 @@ } public void addIndex(TableModel tableModel, IndexModel indexModel) { - AddIndexToTableCommand command = new AddIndexToTableCommand(tableModel, indexModel); + AddIndexCommand command = new AddIndexCommand(tableModel, indexModel); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); } public void addIndex(TableModel tableModel, int index, IndexModel indexModel) { - AddIndexToTableCommand command = new AddIndexToTableCommand(tableModel, index, indexModel); + AddIndexCommand command = new AddIndexCommand(tableModel, index, indexModel); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); } + public void addIndexColumn(IndexModel indexModel, IndexColumnModel indexColumnModel) { + AddIndexColumnCommand command = new AddIndexColumnCommand(indexModel, indexColumnModel); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + + public void addIndexColumn(IndexModel indexModel, int index, IndexColumnModel indexColumnModel) { + AddIndexColumnCommand command = new AddIndexColumnCommand(indexModel, index, indexColumnModel); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + public void addKeyColumn(KeyConstraint keyConstraint, ColumnModel columnModel) { AddColumnToColumnRefListCommand command = new AddColumnToColumnRefListCommand(keyConstraint, keyConstraint.getKeyColumns(), columnModel); @@ -133,6 +165,13 @@ undoStack.push(command.getNegateCommand()); } + public void removeDomain(DomainModel domainModel) { + RemoveDomainFromRootCommand command = + new RemoveDomainFromRootCommand(jiemamy.getFactory().getRootModel(), domainModel); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + public void removeEntity(EntityModel entityModel) { if (entityModel instanceof TableModel) { TableModel tableModel = (TableModel) entityModel; @@ -157,11 +196,17 @@ } public void removeIndex(TableModel tableModel, IndexModel indexModel) { - RemoveIndexFromTableCommand command = new RemoveIndexFromTableCommand(tableModel, indexModel); + RemoveIndexCommand command = new RemoveIndexCommand(tableModel, indexModel); command.execute(getCommandProcessor()); undoStack.push(command.getNegateCommand()); } + public void removeIndexColumn(IndexModel indexModel, IndexColumnModel indexColumnModel) { + RemoveIndexColumnCommand command = new RemoveIndexColumnCommand(indexModel, indexColumnModel); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + public void removeKeyColumn(KeyConstraint keyConstraint, ColumnModel columnModel) { RemoveColumnFromColumnRefListCommand command = new RemoveColumnFromColumnRefListCommand(keyConstraint, keyConstraint.getKeyColumns(), columnModel); @@ -217,6 +262,12 @@ undoStack.push(command.getNegateCommand()); } + public void updateKeyColumn(ForeignKey foreignKey, int index, ColumnModel columnModel) { + Command command = new UpdateKeyColumnCommand(foreignKey, index, columnModel); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + } + /** * Commandを処理するための{@link CommandProcessor}を返す。 * Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java 2009-03-16 14:32:22 UTC (rev 2879) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -66,6 +66,28 @@ referenceId = decl.getId(); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + AbstractElementReference<?> other = (AbstractElementReference<?>) obj; + if (referenceId == null) { + if (other.referenceId != null) { + return false; + } + } else if (!referenceId.equals(other.referenceId)) { + return false; + } + return true; + } + public Jiemamy getJiemamy() { return jiemamy; } @@ -75,6 +97,14 @@ } @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((referenceId == null) ? 0 : referenceId.hashCode()); + return result; + } + + @Override public String toString() { ReflectionToStringBuilder toStringBuilder = new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/AbstractMovePositionCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/AbstractMovePositionCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/AbstractMovePositionCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -18,13 +18,14 @@ */ package org.jiemamy.eclipse.editor.command; -import java.util.ArrayList; import java.util.List; import org.eclipse.gef.commands.Command; +import org.jiemamy.JiemamyViewProperty.NodeProfileProperty; import org.jiemamy.eclipse.editor.JiemamyEditor; import org.jiemamy.eclipse.utils.EditorUtil; +import org.jiemamy.facade.JiemamyViewFacade; import org.jiemamy.model.ConnectionProfile; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; @@ -47,14 +48,18 @@ /** ダイアグラムエディタのインデックス(エディタ内のタブインデックス) */ private int diagramIndex; + private final JiemamyViewFacade jiemamyFacade; + /** * インスタンスを生成する。 * * @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス) + * @param jiemamyFacade */ - public AbstractMovePositionCommand(int diagramIndex) { + public AbstractMovePositionCommand(int diagramIndex, JiemamyViewFacade jiemamyFacade) { this.diagramIndex = diagramIndex; + this.jiemamyFacade = jiemamyFacade; } /** @@ -76,6 +81,14 @@ } /** + * TODO for daisuke + * @return the jiemamyFacade + */ + protected JiemamyViewFacade getJiemamyFacade() { + return jiemamyFacade; + } + + /** * ダイアグラムを全体的に移動させる。 * * @param negative 正方向に移動させる場合は{@code true}、負方向の場合は{@code false} @@ -96,27 +109,24 @@ } else { newBoundary = new JmRectangle(old.x + shift.x, old.y + shift.y, old.width, old.height); } - nodeProfile.setBoundary(newBoundary); + jiemamyFacade.changeModelProperty(nodeProfile, NodeProfileProperty.boundary, newBoundary); // ベンドポイントの移動 for (ConnectionAdapter connection : node.getSourceConnections()) { ConnectionProfile connectionProfile = presentation.getConnectionProfiles().get(connection); - List<JmPoint> oldBendpoints = new ArrayList<JmPoint>(connectionProfile.getBendpoints()); List<JmPoint> bendpoints = connectionProfile.getBendpoints(); - bendpoints.clear(); - for (JmPoint bendpoint : oldBendpoints) { - JmPoint newBendpoint; + for (JmPoint bendpoint : bendpoints) { + JmPoint newLocation; if (negative) { - newBendpoint = new JmPoint(bendpoint.x - shift.x, bendpoint.y - shift.y); + newLocation = new JmPoint(bendpoint.x - shift.x, bendpoint.y - shift.y); } else { - newBendpoint = new JmPoint(bendpoint.x + shift.x, bendpoint.y + shift.y); + newLocation = new JmPoint(bendpoint.x + shift.x, bendpoint.y + shift.y); } - bendpoints.add(newBendpoint); + jiemamyFacade.moveBendpoint(diagramIndex, connection, bendpoints.indexOf(bendpoint), newLocation); } } - // FIXME } } } Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -63,8 +63,6 @@ private final EditPartViewer viewer; - private final JiemamyViewFacade jiemamyFacade; - private SavePoint save; @@ -79,7 +77,7 @@ */ public ChangeNodeConstraintCommand(RootModel rootModel, int diagramIndex, NodeAdapter nodeAdapter, JmRectangle boundary, EditPartViewer viewer) { - super(diagramIndex); + super(diagramIndex, new JiemamyViewFacadeImpl(rootModel.getJiemamy())); this.rootModel = rootModel; this.diagramIndex = diagramIndex; this.nodeAdapter = nodeAdapter; @@ -93,8 +91,6 @@ int shiftX = boundary.x < 0 ? Math.abs(boundary.x) : 0; int shiftY = boundary.y < 0 ? Math.abs(boundary.y) : 0; setShift(new JmPoint(shiftX, shiftY)); - - jiemamyFacade = new JiemamyViewFacadeImpl(rootModel.getJiemamy()); } /** @@ -115,6 +111,7 @@ public void execute() { logger.debug(LogMarker.LIFECYCLE, "execute"); + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); save = jiemamyFacade.save(); // 本体の移動 jiemamyFacade.changeNodeBoundary(diagramIndex, nodeAdapter, boundary); @@ -128,9 +125,8 @@ @Override public void undo() { + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); jiemamyFacade.rollback(save); - shiftBendpoints(true); - shiftPosition(true); } private void shiftBendpoints(boolean positive) { @@ -146,15 +142,19 @@ // ベンドポイントも同時に移動させる(必要なもののみ) for (ConnectionAdapter connection : nodeAdapter.getSourceConnections()) { if (selectedModels.contains(connection.getSource()) && selectedModels.contains(connection.getTarget())) { + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); DiagramPresentationModel presentationModel = diagramPresentations.get(diagramIndex); List<JmPoint> bendpoints = presentationModel.getConnectionProfiles().get(connection).getBendpoints(); for (JmPoint bendpoint : bendpoints) { + int bendpointIndex = bendpoints.indexOf(bendpoint); + JmPoint newLocation; if (positive) { - JmPointUtil.shiftPositive(bendpoint, delta); + newLocation = JmPointUtil.shiftPositive(bendpoint, delta); } else { - JmPointUtil.shiftNegative(bendpoint, delta); + newLocation = JmPointUtil.shiftNegative(bendpoint, delta); } + jiemamyFacade.moveBendpoint(diagramIndex, connection, bendpointIndex, newLocation); } } } Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -42,8 +42,6 @@ /** source側からtarget側に向かって数えたベンドポイントのインデックス */ private int bendpointIndex; - private JiemamyViewFacade jiemamyFacade; - private SavePoint save; /** ダイアグラムエディタのインデックス(エディタ内のタブインデックス) */ @@ -61,7 +59,7 @@ */ public CreateBendpointCommand(RootModel rootModel, int diagramIndex, ConnectionAdapter connectionAdapter, Point location, int bendpointIndex) { - super(diagramIndex); + super(diagramIndex, new JiemamyViewFacadeImpl(rootModel.getJiemamy())); this.diagramIndex = diagramIndex; this.connectionAdapter = connectionAdapter; this.location = location; @@ -71,12 +69,11 @@ int shiftX = location.x < 0 ? Math.abs(location.x) : 0; int shiftY = location.y < 0 ? Math.abs(location.y) : 0; setShift(new JmPoint(shiftX, shiftY)); - - jiemamyFacade = new JiemamyViewFacadeImpl(rootModel.getJiemamy()); } @Override public void execute() { + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); save = jiemamyFacade.save(); jiemamyFacade.addBendpoint(diagramIndex, connectionAdapter, bendpointIndex, ConvertUtil.convert(location)); shiftPosition(false); @@ -84,8 +81,8 @@ @Override public void undo() { + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); jiemamyFacade.rollback(save); - shiftPosition(true); } } Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/MoveBendpointCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/MoveBendpointCommand.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/command/MoveBendpointCommand.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -43,8 +43,6 @@ /** source側からtarget側に向かって数えたベンドポイントのインデックス */ private int bendpointIndex; - private JiemamyViewFacade jiemamyFacade; - private SavePoint savePoint; private int diagramIndex; @@ -61,7 +59,7 @@ */ public MoveBendpointCommand(RootModel rootModel, int diagramIndex, ConnectionAdapter connectionAdapter, int bendpointIndex, Point newLocation) { - super(diagramIndex); + super(diagramIndex, new JiemamyViewFacadeImpl(rootModel.getJiemamy())); this.diagramIndex = diagramIndex; this.connectionAdapter = connectionAdapter; this.bendpointIndex = bendpointIndex; @@ -70,12 +68,11 @@ int shiftX = newLocation.x < 0 ? Math.abs(newLocation.x) : 0; int shiftY = newLocation.y < 0 ? Math.abs(newLocation.y) : 0; setShift(new JmPoint(shiftX, shiftY)); - - jiemamyFacade = new JiemamyViewFacadeImpl(rootModel.getJiemamy()); } @Override public void execute() { + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); savePoint = jiemamyFacade.save(); jiemamyFacade.moveBendpoint(diagramIndex, connectionAdapter, bendpointIndex, ConvertUtil.convert(newLocation)); shiftPosition(false); @@ -83,7 +80,7 @@ @Override public void undo() { - shiftPosition(true); + JiemamyViewFacade jiemamyFacade = getJiemamyFacade(); jiemamyFacade.rollback(savePoint); } } Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/foreignkey/ForeignKeyEditDialog.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -18,7 +18,6 @@ */ package org.jiemamy.eclipse.editor.dialog.foreignkey; -import java.util.ArrayList; import java.util.List; import org.apache.commons.lang.StringUtils; @@ -40,6 +39,7 @@ import org.slf4j.LoggerFactory; import org.jiemamy.Jiemamy; +import org.jiemamy.ReferenceResolver; import org.jiemamy.JiemamyProperty.AttributeProperty; import org.jiemamy.JiemamyProperty.DeferrabilityProperty; import org.jiemamy.JiemamyProperty.ForeignKeyProperty; @@ -48,13 +48,17 @@ import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.facade.JiemamyFacade; import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.attribute.ColumnRefImpl; import org.jiemamy.model.attribute.constraint.Deferrability; import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.attribute.constraint.KeyConstraint; import org.jiemamy.model.attribute.constraint.LocalKeyConstraint; import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; import org.jiemamy.model.attribute.constraint.ForeignKey.MatchType; import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.LogMarker; import org.jiemamy.utils.model.AttributeUtil; import org.jiemamy.utils.model.ForeignKeyUtil; @@ -101,6 +105,8 @@ private final JiemamyFacade jiemamyFacade; + private Composite composite; + /** * コンストラクタ。 @@ -124,8 +130,8 @@ sourceColumns = TableUtil.getColumns(sourceTableModel); referenceKeys = TableUtil.getAttributes(targetTableModel, LocalKeyConstraint.class, true); - keyColumnCombos = new ArrayList<Combo>(referenceKeys.size()); - referenceColumnLabels = new ArrayList<Label>(referenceKeys.size()); + keyColumnCombos = CollectionsUtil.newArrayList(referenceKeys.size()); + referenceColumnLabels = CollectionsUtil.newArrayList(referenceKeys.size()); logger.debug(LogMarker.LIFECYCLE, "construct"); } @@ -170,6 +176,12 @@ radDeferred.setEnabled(false); } + KeyConstraint referenceKeyConstraint = ForeignKeyUtil.getReferenceKeyConstraint(foreignKey); + cmbReferenceKey.setText(KeyConstraintUtil.toStringKeyColumns(referenceKeyConstraint)); + + assert composite != null; + createMappingControls(composite); + return super.open(); } @@ -191,7 +203,7 @@ logger.debug(LogMarker.LIFECYCLE, "createDialogArea"); getShell().setText(Messages.Dialog_Title); - final Composite composite = (Composite) super.createDialogArea(parent); + composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout(5, false)); Label label; @@ -214,19 +226,13 @@ for (LocalKeyConstraint referenceKey : referenceKeys) { cmbReferenceKey.add(KeyConstraintUtil.toStringKeyColumns(referenceKey)); } + cmbReferenceKey.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent evt) { - logger.info("reference key changed"); - grpMapping.dispose(); - - keyColumnCombos.clear(); - referenceColumnLabels.clear(); - createMappingControls(composite); - - getShell().pack(true); - composite.layout(false); + logger.debug(LogMarker.LIFECYCLE, "cmbReferenceKey selected"); + createMappingControls(grpMapping); } }); @@ -260,7 +266,7 @@ option.setLayoutData(gd); label = new Label(option, SWT.NULL); - label.setText("ON &DELETE"); // RESOURCE + label.setText("ON DELETE(&D)"); // RESOURCE cmbOnDelete = new Combo(option, SWT.READ_ONLY); cmbOnDelete.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); cmbOnDelete.add(""); @@ -269,7 +275,7 @@ } label = new Label(option, SWT.NULL); - label.setText("ON &UPDATE"); // RESOURCE + label.setText("ON UPDATE(&U)"); // RESOURCE cmbOnUpdate = new Combo(option, SWT.READ_ONLY); cmbOnUpdate.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); cmbOnUpdate.add(""); @@ -288,8 +294,6 @@ cmbMatchType.add(matchType.name()); } - createMappingControls(composite); - return composite; } @@ -344,39 +348,60 @@ initiallyCheckTime); } - // TODO -// if (sourceColumns.isEmpty() == false) { -// for (int i = 0; i < fkColumnCombos.size(); i++) { -// ForeignKeyMapping mapping = foreignKey.getMapping(i); -// int index = fkColumnCombos.get(i).getSelectionIndex(); -// if (index == -1) { -// continue; -// } -// ColumnModel constraintColumn = sourceColumns.get(index); -// mapping.setConstraintColumn(constraintColumn); -// } -// } + int selectionIndex = cmbReferenceKey.getSelectionIndex(); + LocalKeyConstraint referenceKeyConstraint = referenceKeys.get(selectionIndex); + // TODO facade経由で操作 + foreignKey.getReferenceColumns().clear(); + for (ColumnRef referenceColumnRef : referenceKeyConstraint.getKeyColumns()) { + // TODO facade経由で操作 + foreignKey.getReferenceColumns().add(new ColumnRefImpl(jiemamy, referenceColumnRef.getReferenceId())); + } + // TODO facade経由で操作 + foreignKey.getKeyColumns().clear(); + for (int i = 0; i < keyColumnCombos.size(); i++) { + int index = keyColumnCombos.get(i).getSelectionIndex(); + if (index == -1) { + continue; + } + ColumnModel keyColumn = sourceColumns.get(index); + // TODO facade経由で操作 + foreignKey.getKeyColumns().add(new ColumnRefImpl(jiemamy, keyColumn.getId())); + } + return true; } private void createMappingControls(final Composite composite) { + keyColumnCombos.clear(); + referenceColumnLabels.clear(); + Label label; GridData gd; - grpMapping = new Group(composite, SWT.NULL); - grpMapping.setText("マッピング"); // RESOURCE - grpMapping.setLayout(new GridLayout(3, false)); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 5; - grpMapping.setLayoutData(gd); - if (true) { // TODO 固定true + if (grpMapping == null || grpMapping.isDisposed()) { + grpMapping = new Group(composite, SWT.NULL); + grpMapping.setText("マッピング"); // RESOURCE + grpMapping.setLayout(new GridLayout(3, false)); + gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = 5; + grpMapping.setLayoutData(gd); + } + + int selectionIndex = cmbReferenceKey.getSelectionIndex(); + LocalKeyConstraint referenceKeyConstraint = referenceKeys.get(selectionIndex); + + if (referenceKeyConstraint.getKeyColumns().size() == 0) { label = new Label(grpMapping, SWT.NULL); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; label.setLayoutData(gd); label.setText("参照するカラムがありましぇん(´・ω・`)"); } else { + for (Control control : grpMapping.getChildren()) { + control.dispose(); + } + // ヘッダ label = new Label(grpMapping, SWT.BORDER); label.setText("参照元"); // RESOURCE @@ -391,38 +416,38 @@ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); label.setAlignment(SWT.CENTER); - cmbReferenceKey.addSelectionListener(new SelectionAdapter() { + ReferenceResolver resolver = jiemamy.getReferenceResolver(); + ForeignKey foreignKey = getTargetModel(); + for (ColumnRef referenceColumnRef : referenceKeyConstraint.getKeyColumns()) { + Combo cmbKeyColumn = new Combo(grpMapping, SWT.READ_ONLY); + cmbKeyColumn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + for (ColumnModel col : sourceColumns) { + cmbKeyColumn.add(col.getName()); + } - @Override - public void widgetSelected(SelectionEvent e) { - logger.debug(LogMarker.LIFECYCLE, "cmbReferenceKey selected"); - // TODO -// Control[] children = group.getChildren(); -// for (Control control : children) { -// control.dispose(); -// } -// for (ColumnRef columnRef : referenceKeys.get(cmbReferenceKey.getSelectionIndex()).getKeyColumns()) { -// ReferenceResolver resolver = jiemamy.getReferenceResolver(); -// ColumnModel columnModel = resolver.resolve(columnRef); -// Combo cmbKeyColumn = new Combo(group, SWT.READ_ONLY); -// cmbKeyColumn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// for (ColumnModel columnModel : sourceColumns) { -// cmbKeyColumn.add(columnModel.getName()); -// } -// cmbKeyColumn.setText(mapping.getConstraintColumnName()); -// cmbKeyColumn.setVisibleItemCount(20); -// fkColumnCombos.add(cmbKeyColumn); -// -// Label label = new Label(group, SWT.NULL); -// label.setText("=>"); -// -// Label lblReferenceColumn = new Label(group, SWT.BORDER); -// lblReferenceColumn.setText(mapping.getReferenceColumnName()); -// lblReferenceColumn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); -// pkColumnLabels.add(lblReferenceColumn); -// } + int index = foreignKey.getReferenceColumns().indexOf(referenceColumnRef); + if (index != -1) { + ColumnRef keyColumnRef = foreignKey.getKeyColumns().get(index); + ColumnModel keyColumnModel = resolver.resolve(keyColumnRef); + cmbKeyColumn.setText(keyColumnModel.getName()); + } else { + cmbKeyColumn.setText(cmbKeyColumn.getItem(0)); } - }); + cmbKeyColumn.setVisibleItemCount(20); + keyColumnCombos.add(cmbKeyColumn); + + label = new Label(grpMapping, SWT.NULL); + label.setText("=>"); + + ColumnModel referenceColumnModel = resolver.resolve(referenceColumnRef); + Label lblReferenceColumn = new Label(grpMapping, SWT.BORDER); + lblReferenceColumn.setText(referenceColumnModel.getName()); + lblReferenceColumn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + referenceColumnLabels.add(lblReferenceColumn); + } + + getShell().pack(true); + composite.layout(false); } } } Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -581,11 +581,9 @@ jiemamyFacade.changeModelProperty(domainModel, DomainProperty.name, newName); if (index < 0 || index > table.getItemCount()) { - // FIXME facadeで操作 - domains.add(domainModel); + jiemamyFacade.addDomain(domainModel); } else { - // FIXME facadeで操作 - domains.add(index, domainModel); + jiemamyFacade.addDomain(domainModel, index); } int addedIndex = domains.indexOf(domainModel); @@ -633,14 +631,14 @@ return null; } - // FIXME facadeで操作 - DomainModel domainToRemove = domains.remove(index); - tableViewer.remove(domainToRemove); + DomainModel domainModel = domains.get(index); + jiemamyFacade.removeDomain(domainModel); + tableViewer.remove(domainModel); table.setSelection(index); disableEditControls(); - return domainToRemove; + return domainModel; } private void updateModel() { Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java 2009-03-16 14:32:22 UTC (rev 2879) +++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogIndexTab.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -254,8 +254,8 @@ ColumnRef newColumnRef = factory.newReference(dialog.getResult()); jiemamyFacade.changeModelProperty(indexColumnModel, IndexColumnProperty.columnRef, newColumnRef); - // FIXME facadeで操作 - tableModel.getIndexes().get(indexIndex).getColumns().add(indexColumnModel); + IndexModel indexModel = tableModel.getIndexes().get(indexIndex); + jiemamyFacade.addIndexColumn(indexModel, indexColumnModel); int addedIndex = tableModel.getIndexes().get(indexIndex).getColumns().indexOf(indexColumnModel); table.setSelection(addedIndex); @@ -401,12 +401,11 @@ // FIXME facadeで操作 indexColumnModel.setColumn(factory.newReference(dialog.getResult())); + IndexModel indexModel = tableModel.getIndexes().get(indexIndex); if (index < 0 || index > table.getItemCount()) { - // FIXME facadeで操作 - tableModel.getIndexes().get(indexIndex).getColumns().add(indexColumnModel); + jiemamyFacade.addIndexColumn(indexModel, indexColumnModel); } else { - // FIXME facadeで操作 - tableModel.getIndexes().get(indexIndex).getColumns().add(index, indexColumnModel); + jiemamyFacade.addIndexColumn(indexModel, index, indexColumnModel); } int addedIndex = tableModel.getIndexes().get(indexIndex).getColumns().indexOf(indexColumnModel); @@ -588,12 +587,12 @@ Table table = getTableViewer().getTable(); JiemamyFactory factory = jiemamy.getFactory(); IndexModel indexModel = factory.newModel(IndexModel.class); - // FIXME facadeで操作 - indexModel.setName("idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1)); - // FIXME facadeで操作 - tableModel.getIndexes().add(indexModel); + String newName = "idx_" + tableModel.getName() + "_" + (tableModel.getIndexes().size() + 1); + jiemamyFacade.changeModelProperty(indexModel, IndexProperty.name, newName); + jiemamyFacade.addIndex(tableModel, indexModel); + int addedIndex = tableModel.getIndexes().indexOf(indexModel); table.setSelection(addedIndex); enableEditControls(addedIndex); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/facade/JiemamyFacade.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/facade/JiemamyFacade.java 2009-03-16 14:32:22 UTC (rev 2879) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/facade/JiemamyFacade.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -25,9 +25,12 @@ import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.constraint.ForeignKey; import org.jiemamy.model.attribute.constraint.KeyConstraint; +import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.index.IndexColumnModel; import org.jiemamy.model.index.IndexModel; /** @@ -65,6 +68,10 @@ */ void addAttribute(TableModel tableModel, int index, AttributeModel attributeModel); + void addDomain(DomainModel domainModel); + + void addDomain(DomainModel domainModel, int index); + /** * {@link RootModel}に{@link EntityModel}を追加する。 * @@ -93,6 +100,10 @@ */ void addIndex(TableModel tableModel, int index, IndexModel indexModel); + void addIndexColumn(IndexModel indexModel, IndexColumnModel indexColumnModel); + + void addIndexColumn(IndexModel indexModel, int index, IndexColumnModel indexColumnModel); + /** * {@link KeyConstraint}のキーカラム要素にカラムを追加する。 * @@ -126,6 +137,8 @@ */ void removeAttribute(TableModel tableModel, AttributeModel attributeModel); + void removeDomain(DomainModel domainModel); + /** * {@link RootModel}から{@link EntityModel}を削除する。 * @@ -144,6 +157,8 @@ */ void removeIndex(TableModel tableModel, IndexModel indexModel); + void removeIndexColumn(IndexModel indexModel, IndexColumnModel indexColumnModel); + /** * {@link KeyConstraint}のキーカラム要素からカラムを削除する。 * @@ -180,4 +195,6 @@ * @since 0.2 */ void swapListElement(JiemamyElement targetElement, List<?> list, int subjectIndex, int objectIndex); + + void updateKeyColumn(ForeignKey foreignKey, int index, ColumnModel columnModel); } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/ElementReference.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/ElementReference.java 2009-03-16 14:32:22 UTC (rev 2879) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/ElementReference.java 2009-03-16 16:53:01 UTC (rev 2880) @@ -35,6 +35,15 @@ public interface ElementReference<T extends JiemamyElement> { /** + * TODO for daisuke + * + * @param obj + * @return + * @since 0.2 + */ + boolean equals(Object obj); + + /** * 実体が属するインスタンス空間を取得する。 * * @return 実体が属するインスタンス空間 @@ -49,5 +58,4 @@ * @since 0.2 */ UUID getReferenceId(); - }