• R/O
  • HTTP
  • SSH
  • HTTPS

tmdmaker: Commit

TMD-Maker(T字形ER図作成ツール)のEclipse Plugin,RCP,Webサイト用


Commit MetaInfo

Revision8720e352114ae55a7a9ac5850d745c17069853ac (tree)
Time2018-09-06 22:56:33
Authornakag <nakag@user...>
Commiternakag

Log Message

Refactoring multivalue or build.

Change Summary

Incremental Difference

--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/AbstractEntityModel.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/AbstractEntityModel.java
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
2626
2727 import jp.sourceforge.tmdmaker.model.constraint.Constraint;
2828 import jp.sourceforge.tmdmaker.model.multivalue.MultivalueAnd;
29+import jp.sourceforge.tmdmaker.model.multivalue.MultivalueOr;
2930 import jp.sourceforge.tmdmaker.model.subset.Subsets;
3031
3132 /**
@@ -105,7 +106,7 @@ public abstract class AbstractEntityModel extends ConnectableElement {
105106 * @param source
106107 * 個体指定子取得元
107108 */
108- public void addReusedIdentifier(AbstractEntityModel source) {
109+ protected void addReusedIdentifier(AbstractEntityModel source) {
109110 addReusedIdentifier(source, source.createReusedIdentifier());
110111 }
111112
@@ -129,7 +130,7 @@ public abstract class AbstractEntityModel extends ConnectableElement {
129130 * 個体指定子取得元
130131 * @return 削除したReused個体指定子
131132 */
132- public ReusedIdentifier removeReusedIdentifier(AbstractEntityModel source) {
133+ protected ReusedIdentifier removeReusedIdentifier(AbstractEntityModel source) {
133134 ReusedIdentifier removed = this.reusedIdentifiers.remove(source);
134135 firePropertyChange(PROPERTY_REUSED, removed, null);
135136 return removed;
@@ -219,7 +220,7 @@ public abstract class AbstractEntityModel extends ConnectableElement {
219220 * @return SubsetType。存在しない場合はnullを返す。
220221 */
221222 public SubsetType findSubsetType() {
222- List<AbstractConnectionModel> results = findRelationship(getModelSourceConnections(),
223+ List<Entity2SubsetTypeRelationship> results = findRelationship(getModelSourceConnections(),
223224 Entity2SubsetTypeRelationship.class);
224225 if (results.size() != 0) {
225226 return ((Entity2SubsetTypeRelationship) results.get(0)).getSubsetType();
@@ -233,7 +234,7 @@ public abstract class AbstractEntityModel extends ConnectableElement {
233234 * @return VirtualSupersetType。存在しない場合はnullを返す。
234235 */
235236 public VirtualSupersetType findVirtualSupersetType() {
236- List<AbstractConnectionModel> results = findRelationshipFromSourceConnections(
237+ List<Entity2VirtualSupersetTypeRelationship> results = findRelationshipFromSourceConnections(
237238 Entity2VirtualSupersetTypeRelationship.class);
238239 if (results.size() != 0) {
239240 return (VirtualSupersetType) ((Entity2VirtualSupersetTypeRelationship) results.get(0))
@@ -257,12 +258,13 @@ public abstract class AbstractEntityModel extends ConnectableElement {
257258 * 取得したいリレーションシップのクラス
258259 * @return clazzで指定したクラスのリレーションシップのリスト
259260 */
260- protected List<AbstractConnectionModel> findRelationship(
261- List<AbstractConnectionModel> connections, Class<?> clazz) {
262- List<AbstractConnectionModel> results = new ArrayList<AbstractConnectionModel>();
261+ @SuppressWarnings("unchecked")
262+ protected <T extends AbstractConnectionModel> List<T> findRelationship(
263+ List<AbstractConnectionModel> connections, Class<T> clazz) {
264+ List<T> results = new ArrayList<T>();
263265 for (AbstractConnectionModel connection : connections) {
264266 if (clazz.equals(connection.getClass())) {
265- results.add(connection);
267+ results.add((T) connection);
266268 }
267269 }
268270 return results;
@@ -275,7 +277,8 @@ public abstract class AbstractEntityModel extends ConnectableElement {
275277 * 取得したいリレーションシップのクラス
276278 * @return clazzで指定したクラスのリレーションシップのリスト
277279 */
278- public List<AbstractConnectionModel> findRelationshipFromSourceConnections(Class<?> clazz) {
280+ public <T extends AbstractConnectionModel> List<T> findRelationshipFromSourceConnections(
281+ Class<T> clazz) {
279282 return findRelationship(getModelSourceConnections(), clazz);
280283 }
281284
@@ -286,7 +289,8 @@ public abstract class AbstractEntityModel extends ConnectableElement {
286289 * 取得したいリレーションシップのクラス
287290 * @return clazzで指定したクラスのリレーションシップのリスト
288291 */
289- public List<AbstractConnectionModel> findRelationshipFromTargetConnections(Class<?> clazz) {
292+ public <T extends AbstractConnectionModel> List<T> findRelationshipFromTargetConnections(
293+ Class<T> clazz) {
290294 return findRelationship(getModelTargetConnections(), clazz);
291295 }
292296
@@ -294,14 +298,14 @@ public abstract class AbstractEntityModel extends ConnectableElement {
294298 *
295299 * @param callConnection
296300 */
297- public void fireIdentifierChanged(AbstractConnectionModel callConnection) {
301+ protected void fireIdentifierChanged(AbstractConnectionModel callConnection) {
298302 firePropertyChange(AbstractEntityModel.PROPERTY_REUSED, null, null);
299303 if (getEntityType().equals(EntityType.RESOURCE)) {
300304 notifyIdentifierChangedToConnections(getModelSourceConnections(), callConnection);
301305 notifyIdentifierChangedToConnections(getModelTargetConnections(), callConnection);
302306 } else {
303307 notifyIdentifierChangedToConnections(getModelSourceConnections(), callConnection);
304- List<AbstractConnectionModel> targetcons = findRelationshipFromTargetConnections(
308+ List<Event2EventRelationship> targetcons = findRelationshipFromTargetConnections(
305309 Event2EventRelationship.class);
306310 notifyIdentifierChangedToConnections(targetcons, callConnection);
307311 }
@@ -315,8 +319,8 @@ public abstract class AbstractEntityModel extends ConnectableElement {
315319 * @param callConnection
316320 * 通知元コネクション。通知元がコネクションで無い場合はnullが設定される。
317321 */
318- private void notifyIdentifierChangedToConnections(List<AbstractConnectionModel> connections,
319- AbstractConnectionModel callConnection) {
322+ private <T extends AbstractConnectionModel> void notifyIdentifierChangedToConnections(
323+ List<T> connections, AbstractConnectionModel callConnection) {
320324 for (AbstractConnectionModel con : connections) {
321325 if (con instanceof IdentifierChangeListener && con != callConnection) {
322326 ((IdentifierChangeListener) con).identifierChanged();
@@ -595,7 +599,25 @@ public abstract class AbstractEntityModel extends ConnectableElement {
595599 return new Subsets(this);
596600 }
597601
602+ /**
603+ * 多値のANDの集約を返す.
604+ *
605+ * 多値のAND生成等の起点となるオブジェクト.
606+ *
607+ * @return
608+ */
598609 public MultivalueAnd multivalueAnd() {
599610 return new MultivalueAnd(this);
600611 }
612+
613+ /**
614+ * 多値のORの集約を返す.
615+ *
616+ * 多値のOR生成等の起点となるオブジェクト.
617+ *
618+ * @return
619+ */
620+ public MultivalueOr multivalueOr() {
621+ return new MultivalueOr(this);
622+ }
601623 }
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueOrEntity.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueOrEntity.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2016 TMD-Maker Project <http://tmdmaker.osdn.jp/>
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -17,6 +17,8 @@ package jp.sourceforge.tmdmaker.model;
1717
1818 import java.util.Map;
1919
20+import jp.sourceforge.tmdmaker.model.rule.ImplementRule;
21+
2022 /**
2123 * 多値のOR
2224 *
@@ -25,6 +27,49 @@ import java.util.Map;
2527 */
2628 @SuppressWarnings("serial")
2729 public class MultivalueOrEntity extends AbstractEntityModel {
30+
31+ /**
32+ * コンストラクタは公開しない.
33+ */
34+ protected MultivalueOrEntity() {
35+ }
36+
37+ /**
38+ * 多値のORのモデルを作成する。
39+ *
40+ * @param source
41+ * 派生元のモデル
42+ * @param typeName
43+ * 種別名
44+ * @return 多値のORのモデル
45+ */
46+ public static MultivalueOrEntity build(AbstractEntityModel source,
47+ String typeName) {
48+ MultivalueOrEntity target = new MultivalueOrEntity();
49+ target.setName(source.getName() + "." + typeName);
50+ target.setEntityType(source.getEntityType());
51+ target.addAttribute(createTypeCode(typeName));
52+ ImplementRule.setModelDefaultValue(target);
53+ return target;
54+ }
55+
56+ /**
57+ * 多値のORの種別コードを作成する。
58+ *
59+ * @param typeName
60+ * 種別名
61+ * @return 種別コードのアトリビュート
62+ */
63+ private static Attribute createTypeCode(String typeName) {
64+ Attribute attribute = new Attribute();
65+ attribute.setName(typeName + "コード");
66+ attribute.setImplementName(attribute.getName());
67+ attribute.setDataTypeDeclaration(
68+ new DataTypeDeclaration(StandardSQLDataType.SMALLINT, null, null));
69+
70+ return attribute;
71+ }
72+
2873 /**
2974 *
3075 * {@inheritDoc}
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueOrRelationship.java
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/MultivalueOrRelationship.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2017 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
1515 */
1616 package jp.sourceforge.tmdmaker.model;
1717
18-import jp.sourceforge.tmdmaker.model.rule.MultivalueRule;
19-
2018 /**
2119 * エンティティ系モデルと多値のORとのリレーションシップ
2220 *
@@ -39,12 +37,12 @@ public class MultivalueOrRelationship extends TransfarReuseKeysToTargetRelations
3937 public MultivalueOrRelationship(AbstractEntityModel source, String typeName) {
4038 setSource(source);
4139
42- MultivalueOrEntity target = MultivalueRule.createMultivalueOrEntity(getSource(), typeName);
40+ MultivalueOrEntity target = MultivalueOrEntity.build(getSource(), typeName);
4341
4442 setTargetCardinality(Cardinality.MANY);
4543
46- setTarget(target);
4744 this.table = target;
45+ setTarget(this.table);
4846 }
4947
5048 /**
@@ -55,7 +53,9 @@ public class MultivalueOrRelationship extends TransfarReuseKeysToTargetRelations
5553 @Override
5654 public void connect() {
5755 Diagram diagram = getSource().getDiagram();
58- diagram.addChild(getTarget());
56+ if (diagram != null) {
57+ diagram.addChild(getTarget());
58+ }
5959 super.connect();
6060 }
6161
@@ -67,7 +67,10 @@ public class MultivalueOrRelationship extends TransfarReuseKeysToTargetRelations
6767 @Override
6868 public void disconnect() {
6969 super.disconnect();
70- getSource().getDiagram().removeChild(table);
70+ Diagram diagram = getSource().getDiagram();
71+ if (diagram != null) {
72+ diagram.removeChild(getTarget());
73+ }
7174 }
7275
7376 /**
@@ -80,4 +83,13 @@ public class MultivalueOrRelationship extends TransfarReuseKeysToTargetRelations
8083 return getTarget().isDeletable();
8184 }
8285
86+ /**
87+ * 多値のORを返す.
88+ *
89+ * @return
90+ */
91+ public MultivalueOrEntity getMultivalueOrEntity() {
92+ return (MultivalueOrEntity) getTarget();
93+ }
94+
8395 }
--- /dev/null
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/multivalue/MultivalueOr.java
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package jp.sourceforge.tmdmaker.model.multivalue;
17+
18+import java.util.ArrayList;
19+import java.util.List;
20+
21+import jp.sourceforge.tmdmaker.model.AbstractConnectionModel;
22+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
23+import jp.sourceforge.tmdmaker.model.MultivalueOrEntity;
24+import jp.sourceforge.tmdmaker.model.MultivalueOrRelationship;
25+
26+/**
27+ * 多値のORの集約クラス
28+ *
29+ * @author nakag
30+ *
31+ */
32+public class MultivalueOr {
33+ private AbstractEntityModel source;
34+
35+ public MultivalueOr(AbstractEntityModel source) {
36+ this.source = source;
37+ }
38+
39+ public MultivalueOrBuilder builder() {
40+ return new MultivalueOrBuilder(this.source);
41+ }
42+
43+ public List<MultivalueOrEntity> all() {
44+ List<MultivalueOrRelationship> relationships = this.source
45+ .findRelationshipFromTargetConnections(MultivalueOrRelationship.class);
46+ List<MultivalueOrEntity> results = new ArrayList<MultivalueOrEntity>();
47+ for (AbstractConnectionModel r : relationships) {
48+ results.add((MultivalueOrEntity) r.getTarget());
49+ }
50+ return results;
51+ }
52+
53+ public MultivalueOrQuery query() {
54+ return new MultivalueOrQuery(this.source);
55+ }
56+
57+}
--- /dev/null
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/multivalue/MultivalueOrBuilder.java
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package jp.sourceforge.tmdmaker.model.multivalue;
17+
18+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
19+import jp.sourceforge.tmdmaker.model.MultivalueOrEntity;
20+import jp.sourceforge.tmdmaker.model.MultivalueOrRelationship;
21+
22+/**
23+ * 多値のORを生成するクラス.
24+ *
25+ * @author nakag
26+ *
27+ */
28+public class MultivalueOrBuilder {
29+ private AbstractEntityModel source;
30+ private String typeName;
31+ private MultivalueOrRelationship relationship;
32+
33+ public MultivalueOrBuilder(AbstractEntityModel source) {
34+ this.source = source;
35+ }
36+
37+ public MultivalueOrBuilder typeName(String typeName) {
38+ this.typeName = typeName;
39+ return this;
40+ }
41+
42+ public void build() {
43+ if (this.relationship == null) {
44+ this.relationship = new MultivalueOrRelationship(this.source, this.typeName);
45+ }
46+ this.relationship.connect();
47+ }
48+
49+ public void rollback() {
50+ this.relationship.disconnect();
51+ }
52+
53+ public MultivalueOrEntity getMultivalueOrEntity() {
54+ return this.relationship.getMultivalueOrEntity();
55+ }
56+}
--- /dev/null
+++ b/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/multivalue/MultivalueOrQuery.java
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package jp.sourceforge.tmdmaker.model.multivalue;
17+
18+import java.util.ArrayList;
19+import java.util.List;
20+
21+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
22+import jp.sourceforge.tmdmaker.model.ModelQuery;
23+import jp.sourceforge.tmdmaker.model.MultivalueOrEntity;
24+import jp.sourceforge.tmdmaker.model.MultivalueOrRelationship;
25+import jp.sourceforge.tmdmaker.model.parts.ModelName;
26+
27+/**
28+ * 多値のORを検索するクラス.
29+ *
30+ * @author nakag
31+ *
32+ */
33+public class MultivalueOrQuery implements ModelQuery<MultivalueOrEntity> {
34+ private AbstractEntityModel source;
35+
36+ public MultivalueOrQuery(AbstractEntityModel source) {
37+ this.source = source;
38+ }
39+
40+ @Override
41+ public List<MultivalueOrEntity> findByName(ModelName name) {
42+ List<MultivalueOrEntity> results = new ArrayList<MultivalueOrEntity>();
43+ for (MultivalueOrRelationship r : this.source
44+ .findRelationshipFromSourceConnections(MultivalueOrRelationship.class)) {
45+ MultivalueOrEntity target = r.getMultivalueOrEntity();
46+ if (name.getValue().equals(target.getName())) {
47+ results.add(target);
48+ }
49+ }
50+ return results;
51+ }
52+
53+}
--- a/bundles/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/rule/MultivalueRule.java
+++ /dev/null
@@ -1,69 +0,0 @@
1-/*
2- * Copyright 2009-2017 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-package jp.sourceforge.tmdmaker.model.rule;
17-
18-import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
19-import jp.sourceforge.tmdmaker.model.Attribute;
20-import jp.sourceforge.tmdmaker.model.DataTypeDeclaration;
21-import jp.sourceforge.tmdmaker.model.MultivalueOrEntity;
22-import jp.sourceforge.tmdmaker.model.StandardSQLDataType;
23-
24-/**
25- * 多値に関するルールをまとめたクラス
26- *
27- * @author nakaG
28- *
29- */
30-public class MultivalueRule {
31- /**
32- * 多値のORのモデルを作成する。
33- *
34- * @param source
35- * 派生元のモデル
36- * @param typeName
37- * 種別名
38- * @return 多値のORのモデル
39- */
40- public static MultivalueOrEntity createMultivalueOrEntity(AbstractEntityModel source,
41- String typeName) {
42- MultivalueOrEntity target = new MultivalueOrEntity();
43- target.setName(source.getName() + "." + typeName);
44- target.setEntityType(source.getEntityType());
45- target.addAttribute(createTypeCode(typeName));
46- ImplementRule.setModelDefaultValue(target);
47- return target;
48- }
49-
50- /**
51- * 多値のORの種別コードを作成する。
52- *
53- * @param typeName
54- * 種別名
55- * @return 種別コードのアトリビュート
56- */
57- private static Attribute createTypeCode(String typeName) {
58- Attribute attribute = new Attribute();
59- attribute.setName(typeName + "コード");
60- attribute.setImplementName(attribute.getName());
61- attribute.setDataTypeDeclaration(
62- new DataTypeDeclaration(StandardSQLDataType.SMALLINT, null, null));
63-
64- return attribute;
65- }
66-
67-
68-
69-}
--- a/bundles/tmdmaker/src/jp/sourceforge/tmdmaker/ui/actions/MultivalueOrCreateAction.java
+++ b/bundles/tmdmaker/src/jp/sourceforge/tmdmaker/ui/actions/MultivalueOrCreateAction.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2017 TMD-Maker Project <http://tmdmaker.osdn.jp/>
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -15,15 +15,12 @@
1515 */
1616 package jp.sourceforge.tmdmaker.ui.actions;
1717
18-import org.eclipse.gef.commands.CompoundCommand;
1918 import org.eclipse.jface.dialogs.Dialog;
2019 import org.eclipse.ui.IWorkbenchPart;
2120
2221 import jp.sourceforge.tmdmaker.Messages;
23-import jp.sourceforge.tmdmaker.model.MultivalueOrRelationship;
2422 import jp.sourceforge.tmdmaker.ui.dialogs.MultivalueOrEntityCreateDialog;
25-import jp.sourceforge.tmdmaker.ui.editor.gef3.commands.ConstraintAdjusterCommand;
26-import jp.sourceforge.tmdmaker.ui.editor.gef3.commands.RelationshipConnectionCommand;
23+import jp.sourceforge.tmdmaker.ui.editor.gef3.commands.MultivalueOrCreateCommand;
2724 import jp.sourceforge.tmdmaker.ui.editor.gef3.editparts.node.AbstractModelEditPart;
2825
2926 /**
@@ -58,11 +55,7 @@ public class MultivalueOrCreateAction extends AbstractEntitySelectionAction {
5855 MultivalueOrEntityCreateDialog dialog = new MultivalueOrEntityCreateDialog(
5956 getPart().getViewer().getControl().getShell());
6057 if (dialog.open() == Dialog.OK) {
61- CompoundCommand ccommand = new CompoundCommand();
62- MultivalueOrRelationship relationship = new MultivalueOrRelationship(getModel(), dialog.getInputTypeName());
63- ccommand.add(new RelationshipConnectionCommand(relationship));
64- ccommand.add(new ConstraintAdjusterCommand(relationship,150, 00));
65- execute(ccommand);
58+ execute(new MultivalueOrCreateCommand(getModel(), dialog.getInputTypeName()));
6659 }
6760 }
6861
--- /dev/null
+++ b/bundles/tmdmaker/src/jp/sourceforge/tmdmaker/ui/editor/draw2d/adjuster/ModelConstraintAdjuster.java
@@ -0,0 +1,48 @@
1+/*
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package jp.sourceforge.tmdmaker.ui.editor.draw2d.adjuster;
17+
18+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
19+import jp.sourceforge.tmdmaker.ui.editor.draw2d.ConstraintAdjuster;
20+import jp.sourceforge.tmdmaker.ui.editor.draw2d.ConstraintConverter;
21+
22+/**
23+ *
24+ * モデル作成時の位置調整.
25+ *
26+ * @author nakag
27+ *
28+ */
29+public class ModelConstraintAdjuster implements ConstraintAdjuster {
30+ private AbstractEntityModel base;
31+ private AbstractEntityModel model;
32+ private int x;
33+ private int y;
34+
35+ public ModelConstraintAdjuster(AbstractEntityModel model, AbstractEntityModel base, int x,
36+ int y) {
37+ this.model = model;
38+ this.base = base;
39+ this.x = x;
40+ this.y = y;
41+ }
42+
43+ @Override
44+ public void adjust() {
45+ ConstraintConverter.setTranslatedConstraint(this.model, this.base, this.x, this.y);
46+ }
47+
48+}
--- a/bundles/tmdmaker/src/jp/sourceforge/tmdmaker/ui/editor/gef3/commands/ConstraintAdjusterCommand.java
+++ b/bundles/tmdmaker/src/jp/sourceforge/tmdmaker/ui/editor/gef3/commands/ConstraintAdjusterCommand.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2017 TMD-Maker Project <http://tmdmaker.osdn.jp/>
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -43,14 +43,6 @@ public class ConstraintAdjusterCommand extends Command {
4343 this.y = y;
4444 }
4545
46- public ConstraintAdjusterCommand(AbstractEntityModel source, ConnectableElement target, int x,
47- int y) {
48- this.source = source;
49- this.target = target;
50- this.x = x;
51- this.y = y;
52- }
53-
5446 /**
5547 *
5648 * {@inheritDoc}
--- /dev/null
+++ b/bundles/tmdmaker/src/jp/sourceforge/tmdmaker/ui/editor/gef3/commands/MultivalueOrCreateCommand.java
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright 2009-2018 TMD-Maker Project <https://tmdmaker.osdn.jp/>
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+package jp.sourceforge.tmdmaker.ui.editor.gef3.commands;
17+
18+import org.eclipse.gef.commands.Command;
19+
20+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
21+import jp.sourceforge.tmdmaker.model.multivalue.MultivalueOrBuilder;
22+import jp.sourceforge.tmdmaker.ui.editor.draw2d.adjuster.ModelConstraintAdjuster;
23+
24+/**
25+ * 多値のORを作成するCommand.
26+ *
27+ * @author nakag
28+ *
29+ */
30+public class MultivalueOrCreateCommand extends Command {
31+ private AbstractEntityModel model;
32+ private MultivalueOrBuilder builder;
33+
34+ public MultivalueOrCreateCommand(AbstractEntityModel model, String typeName) {
35+ this.model = model;
36+ this.builder = this.model.multivalueOr().builder().typeName(typeName);
37+ }
38+
39+ @Override
40+ public void execute() {
41+ this.builder.build();
42+ new ModelConstraintAdjuster(this.builder.getMultivalueOrEntity(), this.model, 150, 0)
43+ .adjust();
44+ ;
45+ }
46+
47+ @Override
48+ public void undo() {
49+ this.builder.rollback();
50+ }
51+
52+ @Override
53+ public void redo() {
54+ this.builder.build();
55+ }
56+
57+}
--- a/tests/tmdmaker.test/src/jp/sourceforge/tmdmaker/editpart/TMDEditPartFactoryTest.java
+++ b/tests/tmdmaker.test/src/jp/sourceforge/tmdmaker/editpart/TMDEditPartFactoryTest.java
@@ -39,7 +39,6 @@ import jp.sourceforge.tmdmaker.model.Identifier;
3939 import jp.sourceforge.tmdmaker.model.Laputa;
4040 import jp.sourceforge.tmdmaker.model.MappingList;
4141 import jp.sourceforge.tmdmaker.model.ModelElement;
42-import jp.sourceforge.tmdmaker.model.MultivalueOrEntity;
4342 import jp.sourceforge.tmdmaker.model.RecursiveRelationship;
4443 import jp.sourceforge.tmdmaker.model.RecursiveTable;
4544 import jp.sourceforge.tmdmaker.model.RelatedRelationship;
@@ -166,7 +165,8 @@ public class TMDEditPartFactoryTest {
166165 editPart = factory.createEditPart(null, o);
167166 assertThat(editPart, instanceOf(MultivalueAndSupersetEditPart.class));
168167
169- o = new MultivalueOrEntity();
168+ ev1.multivalueOr().builder().typeName("テスト種別").build();
169+ o = ev1.multivalueOr().query().findByName(new ModelName("テスト種別")).get(0);
170170 editPart = factory.createEditPart(null, o);
171171 assertThat(editPart, instanceOf(MultivalueOrEditPart.class));
172172
Show on old repository browser