• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

TMD-Maker(T字形ER図作成ツール)のEclipse Plugin版


コミットメタ情報

リビジョン56631fdc1d77ee9f7c662c56d1ce519c6ef677d6 (tree)
日時2015-09-26 08:27:03
作者nakag <nakag@user...>
コミッターnakag

ログメッセージ

#33783 対応

メモをdiagramに表示できるようにした。

変更サマリ

差分

--- a/tmdmaker.core/META-INF/MANIFEST.MF
+++ b/tmdmaker.core/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Export-Package: jp.sourceforge.tmdmaker.model,
99 jp.sourceforge.tmdmaker.model.dialect,
1010 jp.sourceforge.tmdmaker.model.generate,
1111 jp.sourceforge.tmdmaker.model.importer,
12+ jp.sourceforge.tmdmaker.model.other,
1213 jp.sourceforge.tmdmaker.model.persistence,
1314 jp.sourceforge.tmdmaker.model.rule,
1415 jp.sourceforge.tmdmaker.model.util
--- a/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/AbstractEntityModel.java
+++ b/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/AbstractEntityModel.java
@@ -467,14 +467,6 @@ public abstract class AbstractEntityModel extends ConnectableElement {
467467 this.keyModels = keyModels;
468468 }
469469
470- public void move(int x, int y) {
471- Constraint oldPosition = getConstraint();
472- Constraint newPosition = oldPosition.getCopy();
473- newPosition.x = x;
474- newPosition.y = y;
475- setConstraint(newPosition);
476- }
477-
478470 public int calcurateMaxIdentifierRefSize() {
479471 int rx = 0;
480472 final int RMARK_SIZE = 3;
--- a/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/IVisitor.java
+++ b/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/IVisitor.java
@@ -15,6 +15,8 @@
1515 */
1616 package jp.sourceforge.tmdmaker.model;
1717
18+import jp.sourceforge.tmdmaker.model.other.Memo;
19+
1820 /**
1921 * Visitorパターンの訪問者側
2022 *
@@ -48,4 +50,5 @@ public interface IVisitor {
4850 void visit(VirtualEntity entity);
4951 void visit(VirtualSuperset entity);
5052 void visit(VirtualSupersetType type);
53+ void visit(Memo model);
5154 }
\ No newline at end of file
--- a/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/ModelElement.java
+++ b/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/ModelElement.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
2525 * @author nakaG
2626 */
2727 @SuppressWarnings("serial")
28-public class ModelElement implements Serializable,IAcceptor {
28+public class ModelElement implements Serializable, IAcceptor {
2929 /** 名称プロパティ定数 */
3030 public static final String PROPERTY_NAME = "_property_name";
3131 /** 領域プロパティ定数 */
@@ -57,8 +57,7 @@ public class ModelElement implements Serializable,IAcceptor {
5757 * @param newValue
5858 * 変更後の値
5959 */
60- public void firePropertyChange(String propName, Object oldValue,
61- Object newValue) {
60+ public void firePropertyChange(String propName, Object oldValue, Object newValue) {
6261 listeners.firePropertyChange(propName, oldValue, newValue);
6362 }
6463
@@ -104,8 +103,16 @@ public class ModelElement implements Serializable,IAcceptor {
104103 this.constraint = constraint;
105104 firePropertyChange(PROPERTY_CONSTRAINT, oldValue, constraint);
106105 }
107-
106+
108107 public void accept(IVisitor visitor) {
109108 visitor.visit(this);
110109 }
110+
111+ public void move(int x, int y) {
112+ Constraint oldPosition = getConstraint();
113+ Constraint newPosition = oldPosition.getCopy();
114+ newPosition.x = x;
115+ newPosition.y = y;
116+ setConstraint(newPosition);
117+ }
111118 }
--- /dev/null
+++ b/tmdmaker.core/src/jp/sourceforge/tmdmaker/model/other/Memo.java
@@ -0,0 +1,61 @@
1+/*
2+ * Copyright 2009-2015 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.other;
17+
18+import jp.sourceforge.tmdmaker.model.ConnectableElement;
19+import jp.sourceforge.tmdmaker.model.IVisitor;
20+
21+/**
22+ * メモモデル
23+ *
24+ * @author nakag
25+ *
26+ */
27+@SuppressWarnings("serial")
28+public class Memo extends ConnectableElement {
29+ /** メモ変更のプロパティ */
30+ public static final String PROPERTY_MEMO = "p_memo";
31+
32+ /** メモ */
33+ private String memo;
34+
35+ /**
36+ * @return the memo
37+ */
38+ public String getMemo() {
39+ return memo;
40+ }
41+
42+ /**
43+ * @param memo
44+ * the memo to set
45+ */
46+ public void setMemo(String memo) {
47+ String oldValue = this.memo;
48+ this.memo = memo;
49+ firePropertyChange(PROPERTY_MEMO, oldValue, this.memo);
50+ }
51+
52+ /**
53+ * {@inheritDoc}
54+ *
55+ * @see jp.sourceforge.tmdmaker.model.ModelElement#accept(jp.sourceforge.tmdmaker.model.IVisitor)
56+ */
57+ @Override
58+ public void accept(IVisitor visitor) {
59+ visitor.visit(this);
60+ }
61+}
Binary files /dev/null and b/tmdmaker/icons/new_memo.gif differ
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/TMDEditor.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/TMDEditor.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2014 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
2+ * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.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.
@@ -19,44 +19,6 @@ import java.lang.reflect.InvocationTargetException;
1919 import java.util.EventObject;
2020 import java.util.List;
2121
22-import jp.sourceforge.tmdmaker.action.AutoSizeSettingAction;
23-import jp.sourceforge.tmdmaker.action.CommonAttributeSettingAction;
24-import jp.sourceforge.tmdmaker.action.CopyModelAction;
25-import jp.sourceforge.tmdmaker.action.DatabaseSelectAction;
26-import jp.sourceforge.tmdmaker.action.DiagramImageGenerateAction;
27-import jp.sourceforge.tmdmaker.action.FileImportAction;
28-import jp.sourceforge.tmdmaker.action.GenerateAction;
29-import jp.sourceforge.tmdmaker.action.ImplementInfoEditAction;
30-import jp.sourceforge.tmdmaker.action.MultivalueAndCreateAction;
31-import jp.sourceforge.tmdmaker.action.MultivalueAndSupersetHideAction;
32-import jp.sourceforge.tmdmaker.action.MultivalueAndSupersetShowAction;
33-import jp.sourceforge.tmdmaker.action.MultivalueOrCreateAction;
34-import jp.sourceforge.tmdmaker.action.PasteModelAction;
35-import jp.sourceforge.tmdmaker.action.SubsetCreateAction;
36-import jp.sourceforge.tmdmaker.action.SubsetTypeTurnAction;
37-import jp.sourceforge.tmdmaker.action.VirtualEntityCreateAction;
38-import jp.sourceforge.tmdmaker.action.VirtualSupersetCreateAction;
39-import jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart;
40-import jp.sourceforge.tmdmaker.editpart.DiagramEditPart;
41-import jp.sourceforge.tmdmaker.editpart.TMDEditPartFactory;
42-import jp.sourceforge.tmdmaker.extension.GeneratorFactory;
43-import jp.sourceforge.tmdmaker.extension.PluginExtensionPointFactory;
44-import jp.sourceforge.tmdmaker.extension.SerializerFactory;
45-import jp.sourceforge.tmdmaker.model.Diagram;
46-import jp.sourceforge.tmdmaker.model.Entity;
47-import jp.sourceforge.tmdmaker.model.Version;
48-import jp.sourceforge.tmdmaker.model.generate.Generator;
49-import jp.sourceforge.tmdmaker.model.importer.FileImporter;
50-import jp.sourceforge.tmdmaker.model.persistence.SerializationException;
51-import jp.sourceforge.tmdmaker.model.persistence.Serializer;
52-import jp.sourceforge.tmdmaker.property.TMDEditorPropertySourceProvider;
53-import jp.sourceforge.tmdmaker.ruler.TMDRulerProvider;
54-import jp.sourceforge.tmdmaker.ruler.model.RulerModel;
55-import jp.sourceforge.tmdmaker.tool.EntityCreationTool;
56-import jp.sourceforge.tmdmaker.tool.MovableSelectionTool;
57-import jp.sourceforge.tmdmaker.tool.TMDConnectionCreationTool;
58-import jp.sourceforge.tmdmaker.treeeditpart.TMDEditorOutlineTreePartFactory;
59-
6022 import org.eclipse.core.resources.IFile;
6123 import org.eclipse.core.resources.IMarker;
6224 import org.eclipse.core.resources.IResourceChangeEvent;
@@ -73,6 +35,8 @@ import org.eclipse.gef.ContextMenuProvider;
7335 import org.eclipse.gef.DefaultEditDomain;
7436 import org.eclipse.gef.EditPartViewer;
7537 import org.eclipse.gef.GraphicalViewer;
38+import org.eclipse.gef.KeyHandler;
39+import org.eclipse.gef.KeyStroke;
7640 import org.eclipse.gef.LayerConstants;
7741 import org.eclipse.gef.MouseWheelHandler;
7842 import org.eclipse.gef.MouseWheelZoomHandler;
@@ -92,6 +56,8 @@ import org.eclipse.gef.requests.SimpleFactory;
9256 import org.eclipse.gef.rulers.RulerProvider;
9357 import org.eclipse.gef.ui.actions.ActionRegistry;
9458 import org.eclipse.gef.ui.actions.AlignmentAction;
59+import org.eclipse.gef.ui.actions.DirectEditAction;
60+import org.eclipse.gef.ui.actions.GEFActionConstants;
9561 import org.eclipse.gef.ui.actions.SelectionAction;
9662 import org.eclipse.gef.ui.actions.ToggleGridAction;
9763 import org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction;
@@ -137,6 +103,45 @@ import org.osgi.framework.Bundle;
137103 import org.slf4j.Logger;
138104 import org.slf4j.LoggerFactory;
139105
106+import jp.sourceforge.tmdmaker.action.AutoSizeSettingAction;
107+import jp.sourceforge.tmdmaker.action.CommonAttributeSettingAction;
108+import jp.sourceforge.tmdmaker.action.CopyModelAction;
109+import jp.sourceforge.tmdmaker.action.DatabaseSelectAction;
110+import jp.sourceforge.tmdmaker.action.DiagramImageGenerateAction;
111+import jp.sourceforge.tmdmaker.action.FileImportAction;
112+import jp.sourceforge.tmdmaker.action.GenerateAction;
113+import jp.sourceforge.tmdmaker.action.ImplementInfoEditAction;
114+import jp.sourceforge.tmdmaker.action.MultivalueAndCreateAction;
115+import jp.sourceforge.tmdmaker.action.MultivalueAndSupersetHideAction;
116+import jp.sourceforge.tmdmaker.action.MultivalueAndSupersetShowAction;
117+import jp.sourceforge.tmdmaker.action.MultivalueOrCreateAction;
118+import jp.sourceforge.tmdmaker.action.PasteModelAction;
119+import jp.sourceforge.tmdmaker.action.SubsetCreateAction;
120+import jp.sourceforge.tmdmaker.action.SubsetTypeTurnAction;
121+import jp.sourceforge.tmdmaker.action.VirtualEntityCreateAction;
122+import jp.sourceforge.tmdmaker.action.VirtualSupersetCreateAction;
123+import jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart;
124+import jp.sourceforge.tmdmaker.editpart.DiagramEditPart;
125+import jp.sourceforge.tmdmaker.editpart.TMDEditPartFactory;
126+import jp.sourceforge.tmdmaker.extension.GeneratorFactory;
127+import jp.sourceforge.tmdmaker.extension.PluginExtensionPointFactory;
128+import jp.sourceforge.tmdmaker.extension.SerializerFactory;
129+import jp.sourceforge.tmdmaker.model.Diagram;
130+import jp.sourceforge.tmdmaker.model.Entity;
131+import jp.sourceforge.tmdmaker.model.Version;
132+import jp.sourceforge.tmdmaker.model.generate.Generator;
133+import jp.sourceforge.tmdmaker.model.importer.FileImporter;
134+import jp.sourceforge.tmdmaker.model.other.Memo;
135+import jp.sourceforge.tmdmaker.model.persistence.SerializationException;
136+import jp.sourceforge.tmdmaker.model.persistence.Serializer;
137+import jp.sourceforge.tmdmaker.property.TMDEditorPropertySourceProvider;
138+import jp.sourceforge.tmdmaker.ruler.TMDRulerProvider;
139+import jp.sourceforge.tmdmaker.ruler.model.RulerModel;
140+import jp.sourceforge.tmdmaker.tool.EntityCreationTool;
141+import jp.sourceforge.tmdmaker.tool.MovableSelectionTool;
142+import jp.sourceforge.tmdmaker.tool.TMDConnectionCreationTool;
143+import jp.sourceforge.tmdmaker.treeeditpart.TMDEditorOutlineTreePartFactory;
144+
140145 /**
141146 * TMDエディター
142147 *
@@ -386,12 +391,21 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso
386391 ConnectionCreationToolEntry connxCCreationEntry = new ConnectionCreationToolEntry(
387392 "リレーションシップ", "リレーションシップ", null, descriptor, descriptor);
388393 connxCCreationEntry.setToolClass(TMDConnectionCreationTool.class);
389- // new SimpleFactory(AbstractRelationship.class), descriptor,
390- // descriptor);
394+
391395 drawer.add(connxCCreationEntry);
392396
397+ PaletteDrawer otherDrawer = new PaletteDrawer("その他");
398+ ImageDescriptor memoDescriptor = TMDPlugin.getImageDescriptor("icons/new_memo.gif");
399+
400+ CreationToolEntry memoCreationEntry = new CreationToolEntry("メモ", "メモ",
401+ new SimpleFactory(Memo.class), memoDescriptor, memoDescriptor);
402+ // memoCreationEntry.setToolClass(CreationTool.class);
403+
404+ otherDrawer.add(memoCreationEntry);
405+
393406 root.add(toolGroup);
394407 root.add(drawer);
408+ root.add(otherDrawer);
395409
396410 return root;
397411 }
@@ -584,6 +598,10 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso
584598 registry.registerAction(action);
585599 selectionActions.add(action.getId());
586600
601+ action = new DirectEditAction(this);
602+ registry.registerAction(action);
603+ selectionActions.add(action.getId());
604+
587605 }
588606
589607 private void setupSelectionAction(ActionRegistry registry, List<String> selectionActions,
@@ -616,6 +634,15 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso
616634
617635 // viewerを取得するためcreateActionsメソッドではなくここでアクションを登録
618636 ActionRegistry registry = getActionRegistry();
637+ registerActions(viewer, rootEditPart, registry);
638+
639+ registerKeyHandleres(viewer, registry);
640+
641+ loadProperties();
642+ }
643+
644+ private void registerActions(GraphicalViewer viewer, ScalableFreeformRootEditPart rootEditPart,
645+ ActionRegistry registry) {
619646 DiagramImageGenerateAction action66 = new DiagramImageGenerateAction(viewer, this);
620647 registry.registerAction(action66);
621648
@@ -662,8 +689,13 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso
662689
663690 viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
664691 MouseWheelZoomHandler.SINGLETON);
692+ }
665693
666- loadProperties();
694+ private void registerKeyHandleres(GraphicalViewer viewer, ActionRegistry registry) {
695+ KeyHandler handler = new KeyHandler();
696+ viewer.setKeyHandler(handler);
697+ handler.put(KeyStroke.getPressed(SWT.F2, 0),
698+ registry.getAction(GEFActionConstants.DIRECT_EDIT));
667699 }
668700
669701 private void loadProperties() {
@@ -740,12 +772,12 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso
740772 for (Object o : editParts) {
741773 logger.debug(o.getClass().getName());
742774 if (o instanceof AbstractModelEditPart) {
743- ((AbstractModelEditPart<?>)o).updateAppearance();
775+ ((AbstractModelEditPart<?>) o).updateAppearance();
744776 } else if (o instanceof DiagramEditPart) {
745777 for (Object ob : ((DiagramEditPart) o).getChildren()) {
746778 if (ob instanceof AbstractModelEditPart) {
747- ((AbstractModelEditPart<?>)ob).updateAppearance();
748- }
779+ ((AbstractModelEditPart<?>) ob).updateAppearance();
780+ }
749781 }
750782 }
751783 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/action/AbstractEntitySelectionAction.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/action/AbstractEntitySelectionAction.java
@@ -18,6 +18,7 @@ package jp.sourceforge.tmdmaker.action;
1818 import jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart;
1919 import jp.sourceforge.tmdmaker.editpart.AbstractSubsetTypeEditPart;
2020 import jp.sourceforge.tmdmaker.editpart.LaputaEditPart;
21+import jp.sourceforge.tmdmaker.editpart.MemoEditPart;
2122 import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
2223
2324 import org.eclipse.gef.ui.actions.SelectionAction;
@@ -53,7 +54,8 @@ public abstract class AbstractEntitySelectionAction extends SelectionAction {
5354 Object selection = getSelectedObjects().get(0);
5455 return selection instanceof AbstractModelEditPart
5556 && !(selection instanceof AbstractSubsetTypeEditPart)
56- && !(selection instanceof LaputaEditPart);
57+ && !(selection instanceof LaputaEditPart)
58+ && !(selection instanceof MemoEditPart);
5759 } else {
5860 return false;
5961 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/action/AutoSizeSettingAction.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/action/AutoSizeSettingAction.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2011 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
2+ * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.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,16 +15,17 @@
1515 */
1616 package jp.sourceforge.tmdmaker.action;
1717
18-import jp.sourceforge.tmdmaker.editpart.LaputaEditPart;
19-import jp.sourceforge.tmdmaker.editpart.MultivalueAndAggregatorEditPart;
20-import jp.sourceforge.tmdmaker.editpart.SubsetTypeEditPart;
21-import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
22-import jp.sourceforge.tmdmaker.model.Constraint;
23-import jp.sourceforge.tmdmaker.ui.command.ModelConstraintChangeCommand;
18+import java.util.ArrayList;
19+import java.util.List;
2420
2521 import org.eclipse.gef.commands.CompoundCommand;
2622 import org.eclipse.ui.IWorkbenchPart;
2723
24+import jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart;
25+import jp.sourceforge.tmdmaker.model.ConnectableElement;
26+import jp.sourceforge.tmdmaker.model.Constraint;
27+import jp.sourceforge.tmdmaker.ui.command.ModelConstraintChangeCommand;
28+
2829 /**
2930 * モデルのサイズを自動調整に設定するAction
3031 *
@@ -55,7 +56,7 @@ public class AutoSizeSettingAction extends AbstractMultipleSelectionAction {
5556 @Override
5657 public void run() {
5758 CompoundCommand ccommand = new CompoundCommand();
58- for (AbstractEntityModel m : getSelectedModelList()) {
59+ for (ConnectableElement m : getSelectedElementList()) {
5960 Constraint constraint = m.getConstraint().getCopy();
6061 constraint.height = -1;
6162 constraint.width = -1;
@@ -68,13 +69,33 @@ public class AutoSizeSettingAction extends AbstractMultipleSelectionAction {
6869
6970 @Override
7071 protected boolean isTargetModel(Object selection) {
71- if (super.isTargetModel(selection)) {
72- return !(selection instanceof SubsetTypeEditPart)
73- && !(selection instanceof MultivalueAndAggregatorEditPart)
74- && !(selection instanceof LaputaEditPart);
72+ if (selection instanceof AbstractModelEditPart) {
73+ return ((AbstractModelEditPart<?>)selection).canAutoSize();
7574 } else {
7675 return false;
7776 }
7877 }
78+
79+ /**
80+ * {@inheritDoc}
81+ *
82+ * @see jp.sourceforge.tmdmaker.action.AbstractMultipleSelectionAction#calculateEnabled()
83+ */
84+ @Override
85+ protected boolean calculateEnabled() {
86+ return getSelectedElementList().size() >= 1;
87+ }
7988
89+ protected List<ConnectableElement> getSelectedElementList() {
90+ List<ConnectableElement> list = new ArrayList<ConnectableElement>();
91+ for (Object selection : getSelectedObjects()) {
92+ if (isTargetModel(selection)) {
93+ Object model = ((AbstractModelEditPart<?>) selection).getModel();
94+ if (model instanceof ConnectableElement) {
95+ list.add((ConnectableElement) model);
96+ }
97+ }
98+ }
99+ return list;
100+ }
80101 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/action/FileImportAction.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/action/FileImportAction.java
@@ -21,7 +21,7 @@ import jp.sourceforge.tmdmaker.TMDPlugin;
2121 import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
2222 import jp.sourceforge.tmdmaker.model.Diagram;
2323 import jp.sourceforge.tmdmaker.model.importer.FileImporter;
24-import jp.sourceforge.tmdmaker.ui.command.ModelAddCommand;
24+import jp.sourceforge.tmdmaker.ui.command.EntityModelAddCommand;
2525
2626 import org.eclipse.draw2d.Viewport;
2727 import org.eclipse.draw2d.geometry.Point;
@@ -60,8 +60,8 @@ public class FileImportAction extends Action {
6060 */
6161 @Override
6262 public void run() {
63- Viewport viewport = (Viewport) ((FreeformGraphicalRootEditPart) viewer
64- .getRootEditPart()).getFigure();
63+ Viewport viewport = (Viewport) ((FreeformGraphicalRootEditPart) viewer.getRootEditPart())
64+ .getFigure();
6565 Point p = viewport.getViewLocation();
6666 FileDialog dialog = new FileDialog(viewer.getControl().getShell());
6767
@@ -70,21 +70,19 @@ public class FileImportAction extends Action {
7070 try {
7171 List<AbstractEntityModel> l = importer.importEntities(filePath);
7272
73- viewer.getEditDomain().getCommandStack()
74- .execute(getCreateCommands(l, p));
73+ viewer.getEditDomain().getCommandStack().execute(getCreateCommands(l, p));
7574 } catch (Throwable t) {
7675 TMDPlugin.showErrorDialog(t);
7776 }
7877 }
7978 }
8079
81-
8280 private Command getCreateCommands(List<AbstractEntityModel> list, Point p) {
8381 CompoundCommand ccommand = new CompoundCommand();
8482 Diagram diagram = (Diagram) viewer.getContents().getModel();
8583 int i = 0;
8684 for (AbstractEntityModel model : list) {
87- ModelAddCommand c = new ModelAddCommand(diagram, p.x + i, p.y + i);
85+ EntityModelAddCommand c = new EntityModelAddCommand(diagram, p.x + i, p.y + i);
8886 i += 5;
8987 c.setModel(model);
9088 ccommand.add(c);
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractEntityModelEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractEntityModelEditPart.java
@@ -23,6 +23,7 @@ import java.util.Map;
2323 import jp.sourceforge.tmdmaker.TMDEditor;
2424 import jp.sourceforge.tmdmaker.dialog.ModelEditDialog;
2525 import jp.sourceforge.tmdmaker.dialog.model.EditAttribute;
26+import jp.sourceforge.tmdmaker.figure.EntityFigure;
2627 import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
2728 import jp.sourceforge.tmdmaker.model.Constraint;
2829 import jp.sourceforge.tmdmaker.model.Identifier;
@@ -50,15 +51,35 @@ import org.eclipse.ui.views.properties.IPropertySource;
5051
5152 /**
5253 * Entity系のeditpartの基底クラス
53- *
54+ *
5455 * @author tohosaku
5556 *
5657 */
57-public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> extends AbstractModelEditPart<T> implements IPropertyAvailable {
58+public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
59+ extends AbstractModelEditPart<T>implements IPropertyAvailable {
60+ /**
61+ *
62+ * {@inheritDoc}
63+ *
64+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
65+ */
66+ @Override
67+ protected IFigure createFigure() {
68+ EntityFigure figure = new EntityFigure();
69+ updateFigure(figure);
5870
71+ return figure;
72+ }
73+
74+ /**
75+ *
76+ * {@inheritDoc}
77+ *
78+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#updateFigure(org.eclipse.draw2d.IFigure)
79+ */
5980 @Override
6081 abstract protected void updateFigure(IFigure figure);
61-
82+
6283 /**
6384 *
6485 * {@inheritDoc}
@@ -68,48 +89,52 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
6889 @Override
6990 protected void onDoubleClicked() {
7091 ModelEditDialog<T> dialog = getDialog();
71- if (dialog.open() != Dialog.OK) return;
72- CompoundCommand ccommand = createEditCommand(dialog.getEditAttributeList(), dialog.getEditedValue());
92+ if (dialog.open() != Dialog.OK)
93+ return;
94+ CompoundCommand ccommand = createEditCommand(dialog.getEditAttributeList(),
95+ dialog.getEditedValue());
7396 executeEditCommand(ccommand);
7497 }
75-
98+
7699 /**
77100 * 編集用ダイアログを取得する。
101+ *
78102 * @return ダイアログボックス
79103 */
80104 protected abstract ModelEditDialog<T> getDialog();
81105
82106 /**
83107 * 編集用コマンドを生成する
108+ *
84109 * @param editAttributeList
85110 * @param editedValue
86111 * @return 編集用コマンド
87112 */
88- protected CompoundCommand createEditCommand(List<EditAttribute> editAttributeList, AbstractEntityModel editedValue)
89- {
113+ protected CompoundCommand createEditCommand(List<EditAttribute> editAttributeList,
114+ AbstractEntityModel editedValue) {
90115 CompoundCommand ccommand = new CompoundCommand();
91116 addAttributeEditCommands(ccommand, getModel(), editAttributeList);
92117 ModelEditCommand command = new ModelEditCommand(getModel(), editedValue);
93118 ccommand.add(command);
94119 return ccommand;
95120 }
96-
121+
97122 /**
98123 * 編集コマンドを実行する。
124+ *
99125 * @param command
100126 */
101- protected void executeEditCommand(Command command)
102- {
127+ protected void executeEditCommand(Command command) {
103128 getViewer().getEditDomain().getCommandStack().execute(command);
104129 }
105-
130+
106131 /**
107132 * 自分自身が実装対象でない場合に実行するコマンドを生成する。
133+ *
108134 * @param editedValue
109135 * @return
110136 */
111- protected Command getDeleteCommand(AbstractEntityModel editedValue)
112- {
137+ protected Command getDeleteCommand(AbstractEntityModel editedValue) {
113138 AbstractEntityModel table = getModel();
114139 if (table.isNotImplement() && !editedValue.isNotImplement()) {
115140 AbstractEntityModel original = ImplementRule.findOriginalImplementModel(table);
@@ -117,13 +142,13 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
117142 }
118143 return null;
119144 }
120-
145+
121146 /**
122147 * ダイアログ表示のためのShellを返す。
148+ *
123149 * @return ParentShell
124150 */
125- protected Shell getControllShell()
126- {
151+ protected Shell getControllShell() {
127152 return getViewer().getControl().getShell();
128153 }
129154
@@ -132,7 +157,8 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
132157 */
133158 protected List<String> extractRelationship(T table) {
134159 List<String> relationship = new ArrayList<String>();
135- for (Map.Entry<AbstractEntityModel, ReusedIdentifier> rk : table.getReusedIdentifieres().entrySet()) {
160+ for (Map.Entry<AbstractEntityModel, ReusedIdentifier> rk : table.getReusedIdentifieres()
161+ .entrySet()) {
136162 for (Identifier i : rk.getValue().getUniqueIdentifieres()) {
137163 relationship.add(i.getName());
138164 }
@@ -146,7 +172,8 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
146172 */
147173 protected List<String> extractRelationship(T table, IdentifierRef original) {
148174 List<String> relationship = new ArrayList<String>();
149- for (Map.Entry<AbstractEntityModel, ReusedIdentifier> rk : table.getReusedIdentifieres().entrySet()) {
175+ for (Map.Entry<AbstractEntityModel, ReusedIdentifier> rk : table.getReusedIdentifieres()
176+ .entrySet()) {
150177 for (IdentifierRef i : rk.getValue().getUniqueIdentifieres()) {
151178 if (i.isSame(original)) {
152179 // nothing
@@ -157,22 +184,20 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
157184 }
158185 return relationship;
159186 }
160-
187+
161188 @Override
162189 abstract protected void createEditPolicies();
163-
164- protected Color getForegroundColor()
165- {
190+
191+ protected Color getForegroundColor() {
166192 return createForegroundColor(getAppearance());
167193 }
168-
169- protected Color getBackgroundColor()
170- {
194+
195+ protected Color getBackgroundColor() {
171196 return createBackgroundColor(getAppearance());
172197 }
173198
174199 abstract protected ModelAppearance getAppearance();
175-
200+
176201 private Color createBackgroundColor(ModelAppearance appearance) {
177202 AppearanceSetting config = AppearanceSetting.getInstance();
178203 if (config.isColorEnabled()) {
@@ -190,10 +215,10 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
190215 return ColorConstants.black;
191216 }
192217 }
193-
218+
194219 /**
195220 * {@inheritDoc}
196- *
221+ *
197222 * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
198223 */
199224 @SuppressWarnings({ "rawtypes" })
@@ -201,7 +226,7 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
201226 protected List getModelChildren() {
202227 return getModel().getAttributes();
203228 }
204-
229+
205230 public IPropertySource getPropertySource(TMDEditor editor) {
206231 return new AbstractEntityModelPropertySource(editor, this.getModel());
207232 }
@@ -214,7 +239,6 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
214239 @Override
215240 protected void refreshVisuals() {
216241 logger.debug(getClass().toString() + "#refreshVisuals()");
217- super.refreshVisuals();
218242 Constraint constraint = getModel().getConstraint();
219243 Rectangle bounds = ConstraintConverter.toRectangle(constraint);
220244 ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
@@ -222,5 +246,15 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel>
222246 updateFigure(getFigure());
223247 refreshChildren();
224248 }
249+
250+ /**
251+ * {@inheritDoc}
252+ *
253+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#canAutoSize()
254+ */
255+ @Override
256+ public boolean canAutoSize() {
257+ return true;
258+ }
225259
226260 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractModelEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractModelEditPart.java
@@ -48,7 +48,8 @@ import org.eclipse.gef.requests.ReconnectRequest;
4848 * @author nakaG
4949 *
5050 */
51-public abstract class AbstractModelEditPart<T extends ConnectableElement> extends AbstractTMDEditPart<T> implements NodeEditPart {
51+public abstract class AbstractModelEditPart<T extends ConnectableElement>
52+ extends AbstractTMDEditPart<T>implements NodeEditPart {
5253
5354 /** このコントローラで利用するアンカー */
5455 private ConnectionAnchor anchor;
@@ -150,8 +151,8 @@ public abstract class AbstractModelEditPart<T extends ConnectableElement> extend
150151
151152 Rectangle bounds = sourceFigure.getBounds();
152153
153- Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y
154- + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
154+ Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4),
155+ bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
155156
156157 if (!centerRectangle.contains(location)) {
157158 Point point = new XYChopboxAnchorHelper(bounds).getIntersectionPoint(location);
@@ -222,8 +223,8 @@ public abstract class AbstractModelEditPart<T extends ConnectableElement> extend
222223
223224 Rectangle bounds = targetFigure.getBounds();
224225
225- Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y
226- + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
226+ Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4),
227+ bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
227228
228229 if (!centerRectangle.contains(location)) {
229230 Point point = new XYChopboxAnchorHelper(bounds).getIntersectionPoint(location);
@@ -457,16 +458,9 @@ public abstract class AbstractModelEditPart<T extends ConnectableElement> extend
457458 }
458459
459460 /**
460- *
461- * {@inheritDoc}
462- *
463- * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
461+ * モデルのサイズを自動調整可能か?
462+ *
463+ * @return 自動調整可能なモデルのコントローラはtrueを返す
464464 */
465- @Override
466- protected IFigure createFigure() {
467- EntityFigure figure = new EntityFigure();
468- updateFigure(figure);
469-
470- return figure;
471- }
465+ public abstract boolean canAutoSize();
472466 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractSubsetTypeEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractSubsetTypeEditPart.java
@@ -19,23 +19,24 @@ import java.beans.PropertyChangeEvent;
1919 import java.util.Collections;
2020 import java.util.List;
2121
22-import jp.sourceforge.tmdmaker.figure.SubsetTypeFigure;
23-import jp.sourceforge.tmdmaker.model.AbstractSubsetType;
24-import jp.sourceforge.tmdmaker.model.ConnectableElement;
25-
2622 import org.eclipse.draw2d.ConnectionAnchor;
2723 import org.eclipse.draw2d.Figure;
2824 import org.eclipse.draw2d.IFigure;
2925 import org.eclipse.gef.ConnectionEditPart;
3026 import org.eclipse.gef.Request;
3127
28+import jp.sourceforge.tmdmaker.figure.SubsetTypeFigure;
29+import jp.sourceforge.tmdmaker.model.AbstractSubsetType;
30+import jp.sourceforge.tmdmaker.model.ConnectableElement;
31+
3232 /**
3333 * スーパーセットとサブセットとの接点のEditPartの基底クラス.
3434 *
3535 * @author nakag
3636 *
3737 */
38-public abstract class AbstractSubsetTypeEditPart<T extends ConnectableElement> extends AbstractModelEditPart<T> {
38+public abstract class AbstractSubsetTypeEditPart<T extends ConnectableElement>
39+ extends AbstractModelEditPart<T> {
3940
4041 /**
4142 * コンストラクタ.
@@ -143,10 +144,20 @@ public abstract class AbstractSubsetTypeEditPart<T extends ConnectableElement> e
143144
144145 /**
145146 * {@inheritDoc}
146- *
147+ *
147148 * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
148149 */
149150 @Override
150151 protected void createEditPolicies() {
151152 }
153+
154+ /**
155+ * {@inheritDoc}
156+ *
157+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#canAutoSize()
158+ */
159+ @Override
160+ public boolean canAutoSize() {
161+ return false;
162+ }
152163 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractTMDEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/AbstractTMDEditPart.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2011 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
2+ * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.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.
@@ -74,23 +74,32 @@ public abstract class AbstractTMDEditPart<T extends ModelElement> extends Abstra
7474 */
7575 @Override
7676 public void performRequest(Request req) {
77- logger.debug(getClass().toString() + req.getType());
78- if (req.getType().equals(RequestConstants.REQ_OPEN)) {
77+ Object requestType = req.getType();
78+ logger.debug(getClass() + " " + requestType);
79+ if (requestType.equals(RequestConstants.REQ_OPEN)) {
7980 onDoubleClicked();
81+ } else if (requestType.equals(RequestConstants.REQ_DIRECT_EDIT)) {
82+ onDirectEdit();
8083 } else {
8184 super.performRequest(req);
8285 }
8386 }
84-
87+
8588 @SuppressWarnings("unchecked")
8689 @Override
87- public T getModel(){
88- return (T)super.getModel();
90+ public T getModel() {
91+ return (T) super.getModel();
8992 }
90-
93+
9194 /**
9295 * ダブルクリック時の処理をサブクラスで実装する
9396 */
9497 protected abstract void onDoubleClicked();
9598
99+ /**
100+ * ダイレクトエディット時の処理(必要なサブクラスのみ実装)
101+ */
102+ protected void onDirectEdit() {
103+
104+ }
96105 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/DiagramEditPart.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/DiagramEditPart.java
@@ -19,16 +19,6 @@ import java.beans.PropertyChangeEvent;
1919 import java.util.ArrayList;
2020 import java.util.List;
2121
22-import jp.sourceforge.tmdmaker.TMDEditor;
23-import jp.sourceforge.tmdmaker.model.Diagram;
24-import jp.sourceforge.tmdmaker.model.Entity;
25-import jp.sourceforge.tmdmaker.model.ModelElement;
26-import jp.sourceforge.tmdmaker.property.DiagramPropertySource;
27-import jp.sourceforge.tmdmaker.property.IPropertyAvailable;
28-import jp.sourceforge.tmdmaker.ui.command.ModelAddCommand;
29-import jp.sourceforge.tmdmaker.ui.command.ModelConstraintChangeCommand;
30-import jp.sourceforge.tmdmaker.util.ConstraintConverter;
31-
3222 import org.eclipse.draw2d.Figure;
3323 import org.eclipse.draw2d.FreeformLayer;
3424 import org.eclipse.draw2d.FreeformLayout;
@@ -42,6 +32,7 @@ import org.eclipse.gef.SnapToGeometry;
4232 import org.eclipse.gef.SnapToGrid;
4333 import org.eclipse.gef.SnapToHelper;
4434 import org.eclipse.gef.commands.Command;
35+import org.eclipse.gef.commands.CompoundCommand;
4536 import org.eclipse.gef.editpolicies.ResizableEditPolicy;
4637 import org.eclipse.gef.editpolicies.SnapFeedbackPolicy;
4738 import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
@@ -49,19 +40,32 @@ import org.eclipse.gef.requests.ChangeBoundsRequest;
4940 import org.eclipse.gef.requests.CreateRequest;
5041 import org.eclipse.ui.views.properties.IPropertySource;
5142
43+import jp.sourceforge.tmdmaker.TMDEditor;
44+import jp.sourceforge.tmdmaker.model.AbstractEntityModel;
45+import jp.sourceforge.tmdmaker.model.ConnectableElement;
46+import jp.sourceforge.tmdmaker.model.Diagram;
47+import jp.sourceforge.tmdmaker.model.ModelElement;
48+import jp.sourceforge.tmdmaker.model.other.Memo;
49+import jp.sourceforge.tmdmaker.property.DiagramPropertySource;
50+import jp.sourceforge.tmdmaker.property.IPropertyAvailable;
51+import jp.sourceforge.tmdmaker.ui.command.MemoAddCommand;
52+import jp.sourceforge.tmdmaker.ui.command.MemoChangeCommand;
53+import jp.sourceforge.tmdmaker.ui.command.EntityModelAddCommand;
54+import jp.sourceforge.tmdmaker.ui.command.ModelConstraintChangeCommand;
55+import jp.sourceforge.tmdmaker.util.ConstraintConverter;
56+
5257 /**
5358 * Diagramのコントローラ
5459 *
5560 * @author nakaG
5661 *
5762 */
58-public class DiagramEditPart extends AbstractTMDEditPart<Diagram> implements IPropertyAvailable {
59-
63+public class DiagramEditPart extends AbstractTMDEditPart<Diagram>implements IPropertyAvailable {
64+
6065 /**
6166 * コンストラクタ
6267 */
63- public DiagramEditPart(Diagram diagram)
64- {
68+ public DiagramEditPart(Diagram diagram) {
6569 super();
6670 setModel(diagram);
6771 }
@@ -173,8 +177,8 @@ public class DiagramEditPart extends AbstractTMDEditPart<Diagram> implements IPr
173177 }
174178
175179 @Override
176- protected Command createChangeConstraintCommand(ChangeBoundsRequest request,
177- EditPart child, Object constraint) {
180+ protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child,
181+ Object constraint) {
178182 logger.debug("resizedirection:" + request.getResizeDirection());
179183 logger.debug("NORTH_SOUTH/EAST_WEST:" + PositionConstants.NORTH_SOUTH + "/"
180184 + PositionConstants.EAST_WEST);
@@ -189,13 +193,30 @@ public class DiagramEditPart extends AbstractTMDEditPart<Diagram> implements IPr
189193 */
190194 @Override
191195 protected Command getCreateCommand(CreateRequest request) {
192- logger.debug(getClass() + "#getCreateCommand()");
196+ logger.debug(getClass() + "#getCreateCommand()"+ request.getNewObjectType());
193197 Rectangle constraint = (Rectangle) getConstraintFor(request);
194- constraint.width = -1;
195- constraint.height = -1;
196- Entity entity = (Entity) request.getNewObject();
197- entity.setConstraint(ConstraintConverter.toConstraint(constraint));
198- return new ModelAddCommand(getModel(), constraint.x, constraint.y);
198+ ConnectableElement model = (ConnectableElement) request.getNewObject();
199+ model.setConstraint(ConstraintConverter.toConstraintWithoutHeightWidth(constraint));
200+ logger.debug(model.getConstraint().toString());
201+ // EntityまたはLaputa
202+ if (model instanceof AbstractEntityModel) {
203+ return new EntityModelAddCommand(getModel(), constraint.x, constraint.y);
204+ }
205+ // Memo
206+ if (model instanceof Memo) {
207+ return createMemoCommand(constraint, model);
208+ }
209+ return null;
210+ }
211+
212+ private Command createMemoCommand(Rectangle constraint, ConnectableElement model) {
213+ Memo memo = (Memo) model;
214+ final String DEFAULT_MEMO_TEXT = "Memo";
215+
216+ CompoundCommand command = new CompoundCommand();
217+ command.add(new MemoAddCommand(getModel(), memo, constraint.x, constraint.y));
218+ command.add(new MemoChangeCommand(memo, DEFAULT_MEMO_TEXT));
219+ return command;
199220 }
200221 }
201222
--- /dev/null
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/MemoEditPart.java
@@ -0,0 +1,277 @@
1+/*
2+ * Copyright 2009-2015 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.editpart;
17+
18+import java.beans.PropertyChangeEvent;
19+
20+import org.eclipse.draw2d.IFigure;
21+import org.eclipse.draw2d.geometry.Rectangle;
22+import org.eclipse.draw2d.text.TextFlow;
23+import org.eclipse.gef.EditPolicy;
24+import org.eclipse.gef.GraphicalEditPart;
25+import org.eclipse.gef.commands.Command;
26+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
27+import org.eclipse.gef.editpolicies.DirectEditPolicy;
28+import org.eclipse.gef.requests.DirectEditRequest;
29+import org.eclipse.gef.requests.GroupRequest;
30+import org.eclipse.gef.tools.CellEditorLocator;
31+import org.eclipse.gef.tools.DirectEditManager;
32+import org.eclipse.jface.viewers.CellEditor;
33+import org.eclipse.jface.viewers.TextCellEditor;
34+import org.eclipse.swt.SWT;
35+import org.eclipse.swt.graphics.Point;
36+import org.eclipse.swt.widgets.Composite;
37+import org.eclipse.swt.widgets.Text;
38+
39+import jp.sourceforge.tmdmaker.figure.MemoFigure;
40+import jp.sourceforge.tmdmaker.model.Constraint;
41+import jp.sourceforge.tmdmaker.model.Diagram;
42+import jp.sourceforge.tmdmaker.model.other.Memo;
43+import jp.sourceforge.tmdmaker.ui.command.MemoChangeCommand;
44+import jp.sourceforge.tmdmaker.util.ConstraintConverter;
45+
46+/**
47+ * メモのコントローラ
48+ *
49+ * @author nakag
50+ *
51+ */
52+public class MemoEditPart extends AbstractModelEditPart<Memo> {
53+
54+ /**
55+ * コンストラクタ
56+ *
57+ * @param model
58+ * メモ
59+ */
60+ public MemoEditPart(Memo model) {
61+ super();
62+ setModel(model);
63+ }
64+
65+ /**
66+ * {@inheritDoc}
67+ *
68+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#refreshVisuals()
69+ */
70+ @Override
71+ protected void refreshVisuals() {
72+ logger.debug(getClass() + "#refreshVisuals()");
73+ Constraint constraint = getModel().getConstraint();
74+ Rectangle bounds = ConstraintConverter.toRectangle(constraint);
75+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
76+
77+ updateFigure(getFigure());
78+ }
79+
80+ /**
81+ *
82+ * {@inheritDoc}
83+ *
84+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
85+ */
86+ @Override
87+ protected IFigure createFigure() {
88+ logger.debug(getClass() + "#createFigure()");
89+ MemoFigure figure = new MemoFigure();
90+ return figure;
91+ }
92+
93+ /**
94+ *
95+ * {@inheritDoc}
96+ *
97+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#updateFigure(org.eclipse.draw2d.IFigure)
98+ */
99+ @Override
100+ protected void updateFigure(IFigure figure) {
101+ logger.debug(getClass() + "#updateFigure()");
102+ MemoFigure memoFigure = (MemoFigure) getFigure();
103+ Memo memo = getModel();
104+ memoFigure.setMemo(memo.getMemo());
105+ }
106+
107+ /**
108+ *
109+ * {@inheritDoc}
110+ *
111+ * @see jp.sourceforge.tmdmaker.editpart.AbstractTMDEditPart#onDoubleClicked()
112+ */
113+ @Override
114+ protected void onDoubleClicked() {
115+ logger.debug(getClass() + "#onDoubleClicked()");
116+ onDirectEdit();
117+ }
118+
119+ /**
120+ * {@inheritDoc}
121+ *
122+ * @see jp.sourceforge.tmdmaker.editpart.AbstractTMDEditPart#onDirectEdit()
123+ */
124+ @Override
125+ protected void onDirectEdit() {
126+ logger.debug(getClass() + "#onDirectEdit()");
127+ MemoFigure figure = (MemoFigure) getFigure();
128+ TextFlow label = figure.getMemoTextFlow();
129+ MemoDirectEditManager manager = new MemoDirectEditManager(this, label);
130+ manager.show();
131+ }
132+
133+ /**
134+ * {@inheritDoc}
135+ *
136+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#propertyChange(java.beans.PropertyChangeEvent)
137+ */
138+ @Override
139+ public void propertyChange(PropertyChangeEvent evt) {
140+ logger.debug(getClass() + "#propertyChange() " + evt.getPropertyName());
141+
142+ if (evt.getPropertyName().equals(Memo.PROPERTY_MEMO)) {
143+ refreshVisuals();
144+ } else {
145+ super.propertyChange(evt);
146+ }
147+ }
148+
149+ /**
150+ *
151+ * {@inheritDoc}
152+ *
153+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
154+ */
155+ @Override
156+ protected void createEditPolicies() {
157+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new MemoDirectEditPolicy());
158+ installEditPolicy(EditPolicy.COMPONENT_ROLE, new MemoDeleteEditPolicy());
159+ }
160+
161+ /**
162+ * {@inheritDoc}
163+ *
164+ * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#canAutoSize()
165+ */
166+ @Override
167+ public boolean canAutoSize() {
168+ return true;
169+ }
170+
171+ private static class MemoDirectEditPolicy extends DirectEditPolicy {
172+
173+ @Override
174+ protected Command getDirectEditCommand(DirectEditRequest request) {
175+ logger.debug(getClass() + "#getDirectEditCommand()");
176+ String newValue = (String) request.getCellEditor().getValue();
177+ Memo memo = (Memo) getHost().getModel();
178+ return new MemoChangeCommand(memo, newValue);
179+ }
180+
181+ @Override
182+ protected void showCurrentEditValue(DirectEditRequest request) {
183+ logger.debug(getClass() + "#showCurrentEditValue()");
184+ MemoFigure figure = (MemoFigure) getHostFigure();
185+ String value = (String) request.getCellEditor().getValue();
186+ figure.setMemo(value);
187+ }
188+ }
189+
190+ private static class MemoDirectEditManager extends DirectEditManager {
191+
192+ public MemoDirectEditManager(GraphicalEditPart source, TextFlow label) {
193+ super(source, TextCellEditor.class, new Locator(label), label);
194+ }
195+
196+ /**
197+ * {@inheritDoc}
198+ *
199+ * @see org.eclipse.gef.tools.DirectEditManager#createCellEditorOn(org.eclipse.swt.widgets.Composite)
200+ */
201+ @Override
202+ protected CellEditor createCellEditorOn(Composite composite) {
203+ return new TextCellEditor(composite, SWT.MULTI | SWT.WRAP);
204+ }
205+
206+ @Override
207+ protected void initCellEditor() {
208+ TextFlow label = (TextFlow) getDirectEditFeature();
209+ String initialLabelText = label.getText();
210+ getCellEditor().setValue(initialLabelText);
211+ }
212+ }
213+
214+ private static class Locator implements CellEditorLocator {
215+ private TextFlow label;
216+
217+ public Locator(TextFlow label) {
218+ this.label = label;
219+ }
220+
221+ @Override
222+ public void relocate(CellEditor celleditor) {
223+ Text text = (Text) celleditor.getControl();
224+ Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
225+ Rectangle rect = label.getBounds().getCopy();
226+ label.translateToAbsolute(rect);
227+ text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1);
228+ }
229+ }
230+
231+ private static class MemoDeleteEditPolicy extends ComponentEditPolicy {
232+
233+ /**
234+ * {@inheritDoc}
235+ *
236+ * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
237+ */
238+ @Override
239+ protected Command createDeleteCommand(GroupRequest deleteRequest) {
240+
241+ return new MemoDeleteCommand((Diagram) getHost().getParent().getModel(),
242+ (Memo) getHost().getModel());
243+ }
244+
245+ }
246+
247+ private static class MemoDeleteCommand extends Command {
248+ private Diagram diagram;
249+ private Memo memo;
250+
251+ public MemoDeleteCommand(Diagram diagram, Memo memo) {
252+ super();
253+ this.diagram = diagram;
254+ this.memo = memo;
255+ }
256+
257+ /**
258+ * {@inheritDoc}
259+ *
260+ * @see org.eclipse.gef.commands.Command#execute()
261+ */
262+ @Override
263+ public void execute() {
264+ diagram.removeChild(memo);
265+ }
266+
267+ /**
268+ * {@inheritDoc}
269+ *
270+ * @see org.eclipse.gef.commands.Command#undo()
271+ */
272+ @Override
273+ public void undo() {
274+ diagram.addChild(memo);
275+ }
276+ }
277+}
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/TMDEditPartVisitor.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/editpart/TMDEditPartVisitor.java
@@ -45,6 +45,7 @@ import jp.sourceforge.tmdmaker.model.SubsetType;
4545 import jp.sourceforge.tmdmaker.model.VirtualEntity;
4646 import jp.sourceforge.tmdmaker.model.VirtualSuperset;
4747 import jp.sourceforge.tmdmaker.model.VirtualSupersetType;
48+import jp.sourceforge.tmdmaker.model.other.Memo;
4849
4950 /**
5051 *
@@ -54,10 +55,10 @@ import jp.sourceforge.tmdmaker.model.VirtualSupersetType;
5455 * @author tohosaku
5556 *
5657 */
57-public class TMDEditPartVisitor implements IVisitor{
58-
58+public class TMDEditPartVisitor implements IVisitor {
59+
5960 private EditPart part = null;
60-
61+
6162 public EditPart getEditPart() {
6263 return part;
6364 }
@@ -191,4 +192,14 @@ public class TMDEditPartVisitor implements IVisitor{
191192 public void visit(Identifier identifier) {
192193 part = null;
193194 }
195+
196+ /**
197+ * {@inheritDoc}
198+ *
199+ * @see jp.sourceforge.tmdmaker.model.IVisitor#visit(jp.sourceforge.tmdmaker.model.other.Memo)
200+ */
201+ @Override
202+ public void visit(Memo model) {
203+ part = new MemoEditPart(model);
204+ }
194205 }
--- /dev/null
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/figure/MemoFigure.java
@@ -0,0 +1,63 @@
1+/*
2+ * Copyright 2009-2015 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.figure;
17+
18+import org.eclipse.draw2d.BorderLayout;
19+import org.eclipse.draw2d.Figure;
20+import org.eclipse.draw2d.LineBorder;
21+import org.eclipse.draw2d.text.FlowPage;
22+import org.eclipse.draw2d.text.ParagraphTextLayout;
23+import org.eclipse.draw2d.text.TextFlow;
24+
25+/**
26+ * メモFigure
27+ *
28+ * @author nakag
29+ *
30+ */
31+public class MemoFigure extends Figure {
32+ private TextFlow memo;
33+
34+ /**
35+ * コンストラクタ
36+ */
37+ public MemoFigure() {
38+ super();
39+ FlowPage page = new FlowPage();
40+
41+ setOpaque(true);
42+ setBorder(new LineBorder());
43+ setLayoutManager(new BorderLayout());
44+ memo = new TextFlow();
45+ ParagraphTextLayout l = new ParagraphTextLayout(memo, ParagraphTextLayout.WORD_WRAP_SOFT);
46+ memo.setLayoutManager(l);
47+ page.add(memo);
48+ add(page, BorderLayout.CENTER);
49+ }
50+
51+ public void setMemo(String memo) {
52+ this.memo.setText(memo);
53+ }
54+
55+ /**
56+ * DirectEdit時に利用
57+ *
58+ * @return TextFlow
59+ */
60+ public TextFlow getMemoTextFlow() {
61+ return memo;
62+ }
63+}
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/tool/EntityCreationTool.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/tool/EntityCreationTool.java
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2009-2010 TMD-Maker Project <http://tmdmaker.sourceforge.jp/>
2+ * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.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.
@@ -16,7 +16,7 @@
1616 package jp.sourceforge.tmdmaker.tool;
1717
1818 import jp.sourceforge.tmdmaker.dialog.EntityCreateDialog;
19-import jp.sourceforge.tmdmaker.ui.command.ModelAddCommand;
19+import jp.sourceforge.tmdmaker.ui.command.EntityModelAddCommand;
2020
2121 import org.eclipse.gef.commands.Command;
2222 import org.eclipse.gef.tools.CreationTool;
@@ -45,8 +45,8 @@ public class EntityCreationTool extends CreationTool {
4545 unlockTargetEditPart();
4646
4747 Command curCommand = getCurrentCommand();
48- if (curCommand instanceof ModelAddCommand) {
49- ModelAddCommand addCommand = (ModelAddCommand) curCommand;
48+ if (curCommand instanceof EntityModelAddCommand) {
49+ EntityModelAddCommand addCommand = (EntityModelAddCommand) curCommand;
5050
5151 EntityCreateDialog dialog = new EntityCreateDialog(
5252 getCurrentViewer().getControl().getShell());
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/treeeditpart/TMDOutlineTreeEditPartVisitor.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/treeeditpart/TMDOutlineTreeEditPartVisitor.java
@@ -44,6 +44,7 @@ import jp.sourceforge.tmdmaker.model.SubsetType;
4444 import jp.sourceforge.tmdmaker.model.VirtualEntity;
4545 import jp.sourceforge.tmdmaker.model.VirtualSuperset;
4646 import jp.sourceforge.tmdmaker.model.VirtualSupersetType;
47+import jp.sourceforge.tmdmaker.model.other.Memo;
4748
4849 /**
4950 *
@@ -190,4 +191,14 @@ public class TMDOutlineTreeEditPartVisitor implements IVisitor{
190191 public void visit(Identifier identifier) {
191192 part = new IdentifierTreeEditPart(identifier);
192193 }
194+
195+ /**
196+ * {@inheritDoc}
197+ *
198+ * @see jp.sourceforge.tmdmaker.model.IVisitor#visit(jp.sourceforge.tmdmaker.model.other.Memo)
199+ */
200+ @Override
201+ public void visit(Memo type) {
202+ part = null;
203+ }
193204 }
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/ui/command/ModelAddCommand.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/ui/command/EntityModelAddCommand.java
@@ -26,7 +26,7 @@ import org.eclipse.gef.commands.Command;
2626 * @author nakaG
2727 *
2828 */
29-public class ModelAddCommand extends Command {
29+public class EntityModelAddCommand extends Command {
3030 /** 親 */
3131 private Diagram diagram;
3232 /** 作成対象 */
@@ -44,7 +44,7 @@ public class ModelAddCommand extends Command {
4444 * @param y
4545 * Y座標
4646 */
47- public ModelAddCommand(Diagram diagram, int x, int y) {
47+ public EntityModelAddCommand(Diagram diagram, int x, int y) {
4848 this.diagram = diagram;
4949 this.x = x;
5050 this.y = y;
--- /dev/null
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/ui/command/MemoAddCommand.java
@@ -0,0 +1,80 @@
1+/*
2+ * Copyright 2009-2015 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.ui.command;
17+
18+import org.eclipse.gef.commands.Command;
19+
20+import jp.sourceforge.tmdmaker.model.Diagram;
21+import jp.sourceforge.tmdmaker.model.other.Memo;
22+
23+/**
24+ * メモ追加コマンド
25+ *
26+ * @author nakag
27+ *
28+ */
29+public class MemoAddCommand extends Command {
30+ /** 親 */
31+ private Diagram diagram;
32+ /** 作成対象 */
33+ private Memo model;
34+ private int x;
35+ private int y;
36+
37+ /**
38+ * コンストラクタ
39+ *
40+ * @param diagram
41+ * 親
42+ * @param model
43+ * メモ
44+ * @param x
45+ * X座標
46+ * @param y
47+ * Y座標
48+ */
49+ public MemoAddCommand(Diagram diagram, Memo model, int x, int y) {
50+ super();
51+ this.diagram = diagram;
52+ this.model = model;
53+ this.x = x;
54+ this.y = y;
55+ }
56+
57+ /**
58+ * {@inheritDoc}
59+ *
60+ * @see org.eclipse.gef.commands.Command#execute()
61+ */
62+ @Override
63+ public void execute() {
64+ if (model != null) {
65+ diagram.addChild(model);
66+ model.move(x, y);
67+ }
68+ }
69+
70+ /**
71+ * {@inheritDoc}
72+ *
73+ * @see org.eclipse.gef.commands.Command#undo()
74+ */
75+ @Override
76+ public void undo() {
77+ diagram.removeChild(model);
78+ }
79+
80+}
--- /dev/null
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/ui/command/MemoChangeCommand.java
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright 2009-2015 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.ui.command;
17+
18+import org.eclipse.gef.commands.Command;
19+
20+import jp.sourceforge.tmdmaker.model.other.Memo;
21+
22+/**
23+ * メモ変更コマンド
24+ *
25+ * @author nakag
26+ *
27+ */
28+public class MemoChangeCommand extends Command {
29+ private Memo memo;
30+ private String oldValue;
31+ private String newValue;
32+
33+ /**
34+ *
35+ */
36+ public MemoChangeCommand(Memo memo, String newValue) {
37+ this.memo = memo;
38+ this.oldValue = memo.getMemo();
39+ this.newValue = newValue;
40+ }
41+
42+ /**
43+ * {@inheritDoc}
44+ *
45+ * @see org.eclipse.gef.commands.Command#execute()
46+ */
47+ @Override
48+ public void execute() {
49+ memo.setMemo(newValue);
50+ }
51+
52+ /**
53+ * {@inheritDoc}
54+ *
55+ * @see org.eclipse.gef.commands.Command#undo()
56+ */
57+ @Override
58+ public void undo() {
59+ memo.setMemo(oldValue);
60+ }
61+
62+}
--- a/tmdmaker/src/jp/sourceforge/tmdmaker/util/ConstraintConverter.java
+++ b/tmdmaker/src/jp/sourceforge/tmdmaker/util/ConstraintConverter.java
@@ -38,4 +38,8 @@ public class ConstraintConverter {
3838 return new Constraint(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
3939 }
4040
41+ public static Constraint toConstraintWithoutHeightWidth(Rectangle rectangle) {
42+ return new Constraint(rectangle.x, rectangle.y, -1, -1);
43+ }
44+
4145 }