TMD-Maker(T字形ER図作成ツール)のEclipse Plugin版
Revision | 56631fdc1d77ee9f7c662c56d1ce519c6ef677d6 (tree) |
---|---|
Zeit | 2015-09-26 08:27:03 |
Autor | nakag <nakag@user...> |
Commiter | nakag |
#33783 対応
メモをdiagramに表示できるようにした。
@@ -9,6 +9,7 @@ Export-Package: jp.sourceforge.tmdmaker.model, | ||
9 | 9 | jp.sourceforge.tmdmaker.model.dialect, |
10 | 10 | jp.sourceforge.tmdmaker.model.generate, |
11 | 11 | jp.sourceforge.tmdmaker.model.importer, |
12 | + jp.sourceforge.tmdmaker.model.other, | |
12 | 13 | jp.sourceforge.tmdmaker.model.persistence, |
13 | 14 | jp.sourceforge.tmdmaker.model.rule, |
14 | 15 | jp.sourceforge.tmdmaker.model.util |
@@ -467,14 +467,6 @@ public abstract class AbstractEntityModel extends ConnectableElement { | ||
467 | 467 | this.keyModels = keyModels; |
468 | 468 | } |
469 | 469 | |
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 | - | |
478 | 470 | public int calcurateMaxIdentifierRefSize() { |
479 | 471 | int rx = 0; |
480 | 472 | final int RMARK_SIZE = 3; |
@@ -15,6 +15,8 @@ | ||
15 | 15 | */ |
16 | 16 | package jp.sourceforge.tmdmaker.model; |
17 | 17 | |
18 | +import jp.sourceforge.tmdmaker.model.other.Memo; | |
19 | + | |
18 | 20 | /** |
19 | 21 | * Visitorパターンの訪問者側 |
20 | 22 | * |
@@ -48,4 +50,5 @@ public interface IVisitor { | ||
48 | 50 | void visit(VirtualEntity entity); |
49 | 51 | void visit(VirtualSuperset entity); |
50 | 52 | void visit(VirtualSupersetType type); |
53 | + void visit(Memo model); | |
51 | 54 | } |
\ No newline at end of file |
@@ -25,7 +25,7 @@ import java.io.Serializable; | ||
25 | 25 | * @author nakaG |
26 | 26 | */ |
27 | 27 | @SuppressWarnings("serial") |
28 | -public class ModelElement implements Serializable,IAcceptor { | |
28 | +public class ModelElement implements Serializable, IAcceptor { | |
29 | 29 | /** 名称プロパティ定数 */ |
30 | 30 | public static final String PROPERTY_NAME = "_property_name"; |
31 | 31 | /** 領域プロパティ定数 */ |
@@ -57,8 +57,7 @@ public class ModelElement implements Serializable,IAcceptor { | ||
57 | 57 | * @param newValue |
58 | 58 | * 変更後の値 |
59 | 59 | */ |
60 | - public void firePropertyChange(String propName, Object oldValue, | |
61 | - Object newValue) { | |
60 | + public void firePropertyChange(String propName, Object oldValue, Object newValue) { | |
62 | 61 | listeners.firePropertyChange(propName, oldValue, newValue); |
63 | 62 | } |
64 | 63 |
@@ -104,8 +103,16 @@ public class ModelElement implements Serializable,IAcceptor { | ||
104 | 103 | this.constraint = constraint; |
105 | 104 | firePropertyChange(PROPERTY_CONSTRAINT, oldValue, constraint); |
106 | 105 | } |
107 | - | |
106 | + | |
108 | 107 | public void accept(IVisitor visitor) { |
109 | 108 | visitor.visit(this); |
110 | 109 | } |
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 | + } | |
111 | 118 | } |
@@ -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 | +} |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - * Copyright 2009-2014 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
2 | + * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -19,44 +19,6 @@ import java.lang.reflect.InvocationTargetException; | ||
19 | 19 | import java.util.EventObject; |
20 | 20 | import java.util.List; |
21 | 21 | |
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 | - | |
60 | 22 | import org.eclipse.core.resources.IFile; |
61 | 23 | import org.eclipse.core.resources.IMarker; |
62 | 24 | import org.eclipse.core.resources.IResourceChangeEvent; |
@@ -73,6 +35,8 @@ import org.eclipse.gef.ContextMenuProvider; | ||
73 | 35 | import org.eclipse.gef.DefaultEditDomain; |
74 | 36 | import org.eclipse.gef.EditPartViewer; |
75 | 37 | import org.eclipse.gef.GraphicalViewer; |
38 | +import org.eclipse.gef.KeyHandler; | |
39 | +import org.eclipse.gef.KeyStroke; | |
76 | 40 | import org.eclipse.gef.LayerConstants; |
77 | 41 | import org.eclipse.gef.MouseWheelHandler; |
78 | 42 | import org.eclipse.gef.MouseWheelZoomHandler; |
@@ -92,6 +56,8 @@ import org.eclipse.gef.requests.SimpleFactory; | ||
92 | 56 | import org.eclipse.gef.rulers.RulerProvider; |
93 | 57 | import org.eclipse.gef.ui.actions.ActionRegistry; |
94 | 58 | import org.eclipse.gef.ui.actions.AlignmentAction; |
59 | +import org.eclipse.gef.ui.actions.DirectEditAction; | |
60 | +import org.eclipse.gef.ui.actions.GEFActionConstants; | |
95 | 61 | import org.eclipse.gef.ui.actions.SelectionAction; |
96 | 62 | import org.eclipse.gef.ui.actions.ToggleGridAction; |
97 | 63 | import org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction; |
@@ -137,6 +103,45 @@ import org.osgi.framework.Bundle; | ||
137 | 103 | import org.slf4j.Logger; |
138 | 104 | import org.slf4j.LoggerFactory; |
139 | 105 | |
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 | + | |
140 | 145 | /** |
141 | 146 | * TMDエディター |
142 | 147 | * |
@@ -386,12 +391,21 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso | ||
386 | 391 | ConnectionCreationToolEntry connxCCreationEntry = new ConnectionCreationToolEntry( |
387 | 392 | "リレーションシップ", "リレーションシップ", null, descriptor, descriptor); |
388 | 393 | connxCCreationEntry.setToolClass(TMDConnectionCreationTool.class); |
389 | - // new SimpleFactory(AbstractRelationship.class), descriptor, | |
390 | - // descriptor); | |
394 | + | |
391 | 395 | drawer.add(connxCCreationEntry); |
392 | 396 | |
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 | + | |
393 | 406 | root.add(toolGroup); |
394 | 407 | root.add(drawer); |
408 | + root.add(otherDrawer); | |
395 | 409 | |
396 | 410 | return root; |
397 | 411 | } |
@@ -584,6 +598,10 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso | ||
584 | 598 | registry.registerAction(action); |
585 | 599 | selectionActions.add(action.getId()); |
586 | 600 | |
601 | + action = new DirectEditAction(this); | |
602 | + registry.registerAction(action); | |
603 | + selectionActions.add(action.getId()); | |
604 | + | |
587 | 605 | } |
588 | 606 | |
589 | 607 | private void setupSelectionAction(ActionRegistry registry, List<String> selectionActions, |
@@ -616,6 +634,15 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso | ||
616 | 634 | |
617 | 635 | // viewerを取得するためcreateActionsメソッドではなくここでアクションを登録 |
618 | 636 | 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) { | |
619 | 646 | DiagramImageGenerateAction action66 = new DiagramImageGenerateAction(viewer, this); |
620 | 647 | registry.registerAction(action66); |
621 | 648 |
@@ -662,8 +689,13 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso | ||
662 | 689 | |
663 | 690 | viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), |
664 | 691 | MouseWheelZoomHandler.SINGLETON); |
692 | + } | |
665 | 693 | |
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)); | |
667 | 699 | } |
668 | 700 | |
669 | 701 | private void loadProperties() { |
@@ -740,12 +772,12 @@ public class TMDEditor extends GraphicalEditorWithFlyoutPalette implements IReso | ||
740 | 772 | for (Object o : editParts) { |
741 | 773 | logger.debug(o.getClass().getName()); |
742 | 774 | if (o instanceof AbstractModelEditPart) { |
743 | - ((AbstractModelEditPart<?>)o).updateAppearance(); | |
775 | + ((AbstractModelEditPart<?>) o).updateAppearance(); | |
744 | 776 | } else if (o instanceof DiagramEditPart) { |
745 | 777 | for (Object ob : ((DiagramEditPart) o).getChildren()) { |
746 | 778 | if (ob instanceof AbstractModelEditPart) { |
747 | - ((AbstractModelEditPart<?>)ob).updateAppearance(); | |
748 | - } | |
779 | + ((AbstractModelEditPart<?>) ob).updateAppearance(); | |
780 | + } | |
749 | 781 | } |
750 | 782 | } |
751 | 783 | } |
@@ -18,6 +18,7 @@ package jp.sourceforge.tmdmaker.action; | ||
18 | 18 | import jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart; |
19 | 19 | import jp.sourceforge.tmdmaker.editpart.AbstractSubsetTypeEditPart; |
20 | 20 | import jp.sourceforge.tmdmaker.editpart.LaputaEditPart; |
21 | +import jp.sourceforge.tmdmaker.editpart.MemoEditPart; | |
21 | 22 | import jp.sourceforge.tmdmaker.model.AbstractEntityModel; |
22 | 23 | |
23 | 24 | import org.eclipse.gef.ui.actions.SelectionAction; |
@@ -53,7 +54,8 @@ public abstract class AbstractEntitySelectionAction extends SelectionAction { | ||
53 | 54 | Object selection = getSelectedObjects().get(0); |
54 | 55 | return selection instanceof AbstractModelEditPart |
55 | 56 | && !(selection instanceof AbstractSubsetTypeEditPart) |
56 | - && !(selection instanceof LaputaEditPart); | |
57 | + && !(selection instanceof LaputaEditPart) | |
58 | + && !(selection instanceof MemoEditPart); | |
57 | 59 | } else { |
58 | 60 | return false; |
59 | 61 | } |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - * Copyright 2009-2011 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
2 | + * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -15,16 +15,17 @@ | ||
15 | 15 | */ |
16 | 16 | package jp.sourceforge.tmdmaker.action; |
17 | 17 | |
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; | |
24 | 20 | |
25 | 21 | import org.eclipse.gef.commands.CompoundCommand; |
26 | 22 | import org.eclipse.ui.IWorkbenchPart; |
27 | 23 | |
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 | + | |
28 | 29 | /** |
29 | 30 | * モデルのサイズを自動調整に設定するAction |
30 | 31 | * |
@@ -55,7 +56,7 @@ public class AutoSizeSettingAction extends AbstractMultipleSelectionAction { | ||
55 | 56 | @Override |
56 | 57 | public void run() { |
57 | 58 | CompoundCommand ccommand = new CompoundCommand(); |
58 | - for (AbstractEntityModel m : getSelectedModelList()) { | |
59 | + for (ConnectableElement m : getSelectedElementList()) { | |
59 | 60 | Constraint constraint = m.getConstraint().getCopy(); |
60 | 61 | constraint.height = -1; |
61 | 62 | constraint.width = -1; |
@@ -68,13 +69,33 @@ public class AutoSizeSettingAction extends AbstractMultipleSelectionAction { | ||
68 | 69 | |
69 | 70 | @Override |
70 | 71 | 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(); | |
75 | 74 | } else { |
76 | 75 | return false; |
77 | 76 | } |
78 | 77 | } |
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 | + } | |
79 | 88 | |
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 | + } | |
80 | 101 | } |
@@ -21,7 +21,7 @@ import jp.sourceforge.tmdmaker.TMDPlugin; | ||
21 | 21 | import jp.sourceforge.tmdmaker.model.AbstractEntityModel; |
22 | 22 | import jp.sourceforge.tmdmaker.model.Diagram; |
23 | 23 | import jp.sourceforge.tmdmaker.model.importer.FileImporter; |
24 | -import jp.sourceforge.tmdmaker.ui.command.ModelAddCommand; | |
24 | +import jp.sourceforge.tmdmaker.ui.command.EntityModelAddCommand; | |
25 | 25 | |
26 | 26 | import org.eclipse.draw2d.Viewport; |
27 | 27 | import org.eclipse.draw2d.geometry.Point; |
@@ -60,8 +60,8 @@ public class FileImportAction extends Action { | ||
60 | 60 | */ |
61 | 61 | @Override |
62 | 62 | public void run() { |
63 | - Viewport viewport = (Viewport) ((FreeformGraphicalRootEditPart) viewer | |
64 | - .getRootEditPart()).getFigure(); | |
63 | + Viewport viewport = (Viewport) ((FreeformGraphicalRootEditPart) viewer.getRootEditPart()) | |
64 | + .getFigure(); | |
65 | 65 | Point p = viewport.getViewLocation(); |
66 | 66 | FileDialog dialog = new FileDialog(viewer.getControl().getShell()); |
67 | 67 |
@@ -70,21 +70,19 @@ public class FileImportAction extends Action { | ||
70 | 70 | try { |
71 | 71 | List<AbstractEntityModel> l = importer.importEntities(filePath); |
72 | 72 | |
73 | - viewer.getEditDomain().getCommandStack() | |
74 | - .execute(getCreateCommands(l, p)); | |
73 | + viewer.getEditDomain().getCommandStack().execute(getCreateCommands(l, p)); | |
75 | 74 | } catch (Throwable t) { |
76 | 75 | TMDPlugin.showErrorDialog(t); |
77 | 76 | } |
78 | 77 | } |
79 | 78 | } |
80 | 79 | |
81 | - | |
82 | 80 | private Command getCreateCommands(List<AbstractEntityModel> list, Point p) { |
83 | 81 | CompoundCommand ccommand = new CompoundCommand(); |
84 | 82 | Diagram diagram = (Diagram) viewer.getContents().getModel(); |
85 | 83 | int i = 0; |
86 | 84 | 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); | |
88 | 86 | i += 5; |
89 | 87 | c.setModel(model); |
90 | 88 | ccommand.add(c); |
@@ -23,6 +23,7 @@ import java.util.Map; | ||
23 | 23 | import jp.sourceforge.tmdmaker.TMDEditor; |
24 | 24 | import jp.sourceforge.tmdmaker.dialog.ModelEditDialog; |
25 | 25 | import jp.sourceforge.tmdmaker.dialog.model.EditAttribute; |
26 | +import jp.sourceforge.tmdmaker.figure.EntityFigure; | |
26 | 27 | import jp.sourceforge.tmdmaker.model.AbstractEntityModel; |
27 | 28 | import jp.sourceforge.tmdmaker.model.Constraint; |
28 | 29 | import jp.sourceforge.tmdmaker.model.Identifier; |
@@ -50,15 +51,35 @@ import org.eclipse.ui.views.properties.IPropertySource; | ||
50 | 51 | |
51 | 52 | /** |
52 | 53 | * Entity系のeditpartの基底クラス |
53 | - * | |
54 | + * | |
54 | 55 | * @author tohosaku |
55 | 56 | * |
56 | 57 | */ |
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); | |
58 | 70 | |
71 | + return figure; | |
72 | + } | |
73 | + | |
74 | + /** | |
75 | + * | |
76 | + * {@inheritDoc} | |
77 | + * | |
78 | + * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#updateFigure(org.eclipse.draw2d.IFigure) | |
79 | + */ | |
59 | 80 | @Override |
60 | 81 | abstract protected void updateFigure(IFigure figure); |
61 | - | |
82 | + | |
62 | 83 | /** |
63 | 84 | * |
64 | 85 | * {@inheritDoc} |
@@ -68,48 +89,52 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
68 | 89 | @Override |
69 | 90 | protected void onDoubleClicked() { |
70 | 91 | 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()); | |
73 | 96 | executeEditCommand(ccommand); |
74 | 97 | } |
75 | - | |
98 | + | |
76 | 99 | /** |
77 | 100 | * 編集用ダイアログを取得する。 |
101 | + * | |
78 | 102 | * @return ダイアログボックス |
79 | 103 | */ |
80 | 104 | protected abstract ModelEditDialog<T> getDialog(); |
81 | 105 | |
82 | 106 | /** |
83 | 107 | * 編集用コマンドを生成する |
108 | + * | |
84 | 109 | * @param editAttributeList |
85 | 110 | * @param editedValue |
86 | 111 | * @return 編集用コマンド |
87 | 112 | */ |
88 | - protected CompoundCommand createEditCommand(List<EditAttribute> editAttributeList, AbstractEntityModel editedValue) | |
89 | - { | |
113 | + protected CompoundCommand createEditCommand(List<EditAttribute> editAttributeList, | |
114 | + AbstractEntityModel editedValue) { | |
90 | 115 | CompoundCommand ccommand = new CompoundCommand(); |
91 | 116 | addAttributeEditCommands(ccommand, getModel(), editAttributeList); |
92 | 117 | ModelEditCommand command = new ModelEditCommand(getModel(), editedValue); |
93 | 118 | ccommand.add(command); |
94 | 119 | return ccommand; |
95 | 120 | } |
96 | - | |
121 | + | |
97 | 122 | /** |
98 | 123 | * 編集コマンドを実行する。 |
124 | + * | |
99 | 125 | * @param command |
100 | 126 | */ |
101 | - protected void executeEditCommand(Command command) | |
102 | - { | |
127 | + protected void executeEditCommand(Command command) { | |
103 | 128 | getViewer().getEditDomain().getCommandStack().execute(command); |
104 | 129 | } |
105 | - | |
130 | + | |
106 | 131 | /** |
107 | 132 | * 自分自身が実装対象でない場合に実行するコマンドを生成する。 |
133 | + * | |
108 | 134 | * @param editedValue |
109 | 135 | * @return |
110 | 136 | */ |
111 | - protected Command getDeleteCommand(AbstractEntityModel editedValue) | |
112 | - { | |
137 | + protected Command getDeleteCommand(AbstractEntityModel editedValue) { | |
113 | 138 | AbstractEntityModel table = getModel(); |
114 | 139 | if (table.isNotImplement() && !editedValue.isNotImplement()) { |
115 | 140 | AbstractEntityModel original = ImplementRule.findOriginalImplementModel(table); |
@@ -117,13 +142,13 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
117 | 142 | } |
118 | 143 | return null; |
119 | 144 | } |
120 | - | |
145 | + | |
121 | 146 | /** |
122 | 147 | * ダイアログ表示のためのShellを返す。 |
148 | + * | |
123 | 149 | * @return ParentShell |
124 | 150 | */ |
125 | - protected Shell getControllShell() | |
126 | - { | |
151 | + protected Shell getControllShell() { | |
127 | 152 | return getViewer().getControl().getShell(); |
128 | 153 | } |
129 | 154 |
@@ -132,7 +157,8 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
132 | 157 | */ |
133 | 158 | protected List<String> extractRelationship(T table) { |
134 | 159 | 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()) { | |
136 | 162 | for (Identifier i : rk.getValue().getUniqueIdentifieres()) { |
137 | 163 | relationship.add(i.getName()); |
138 | 164 | } |
@@ -146,7 +172,8 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
146 | 172 | */ |
147 | 173 | protected List<String> extractRelationship(T table, IdentifierRef original) { |
148 | 174 | 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()) { | |
150 | 177 | for (IdentifierRef i : rk.getValue().getUniqueIdentifieres()) { |
151 | 178 | if (i.isSame(original)) { |
152 | 179 | // nothing |
@@ -157,22 +184,20 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
157 | 184 | } |
158 | 185 | return relationship; |
159 | 186 | } |
160 | - | |
187 | + | |
161 | 188 | @Override |
162 | 189 | abstract protected void createEditPolicies(); |
163 | - | |
164 | - protected Color getForegroundColor() | |
165 | - { | |
190 | + | |
191 | + protected Color getForegroundColor() { | |
166 | 192 | return createForegroundColor(getAppearance()); |
167 | 193 | } |
168 | - | |
169 | - protected Color getBackgroundColor() | |
170 | - { | |
194 | + | |
195 | + protected Color getBackgroundColor() { | |
171 | 196 | return createBackgroundColor(getAppearance()); |
172 | 197 | } |
173 | 198 | |
174 | 199 | abstract protected ModelAppearance getAppearance(); |
175 | - | |
200 | + | |
176 | 201 | private Color createBackgroundColor(ModelAppearance appearance) { |
177 | 202 | AppearanceSetting config = AppearanceSetting.getInstance(); |
178 | 203 | if (config.isColorEnabled()) { |
@@ -190,10 +215,10 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
190 | 215 | return ColorConstants.black; |
191 | 216 | } |
192 | 217 | } |
193 | - | |
218 | + | |
194 | 219 | /** |
195 | 220 | * {@inheritDoc} |
196 | - * | |
221 | + * | |
197 | 222 | * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren() |
198 | 223 | */ |
199 | 224 | @SuppressWarnings({ "rawtypes" }) |
@@ -201,7 +226,7 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
201 | 226 | protected List getModelChildren() { |
202 | 227 | return getModel().getAttributes(); |
203 | 228 | } |
204 | - | |
229 | + | |
205 | 230 | public IPropertySource getPropertySource(TMDEditor editor) { |
206 | 231 | return new AbstractEntityModelPropertySource(editor, this.getModel()); |
207 | 232 | } |
@@ -214,7 +239,6 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
214 | 239 | @Override |
215 | 240 | protected void refreshVisuals() { |
216 | 241 | logger.debug(getClass().toString() + "#refreshVisuals()"); |
217 | - super.refreshVisuals(); | |
218 | 242 | Constraint constraint = getModel().getConstraint(); |
219 | 243 | Rectangle bounds = ConstraintConverter.toRectangle(constraint); |
220 | 244 | ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds); |
@@ -222,5 +246,15 @@ public abstract class AbstractEntityModelEditPart<T extends AbstractEntityModel> | ||
222 | 246 | updateFigure(getFigure()); |
223 | 247 | refreshChildren(); |
224 | 248 | } |
249 | + | |
250 | + /** | |
251 | + * {@inheritDoc} | |
252 | + * | |
253 | + * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#canAutoSize() | |
254 | + */ | |
255 | + @Override | |
256 | + public boolean canAutoSize() { | |
257 | + return true; | |
258 | + } | |
225 | 259 | |
226 | 260 | } |
@@ -48,7 +48,8 @@ import org.eclipse.gef.requests.ReconnectRequest; | ||
48 | 48 | * @author nakaG |
49 | 49 | * |
50 | 50 | */ |
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 { | |
52 | 53 | |
53 | 54 | /** このコントローラで利用するアンカー */ |
54 | 55 | private ConnectionAnchor anchor; |
@@ -150,8 +151,8 @@ public abstract class AbstractModelEditPart<T extends ConnectableElement> extend | ||
150 | 151 | |
151 | 152 | Rectangle bounds = sourceFigure.getBounds(); |
152 | 153 | |
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); | |
155 | 156 | |
156 | 157 | if (!centerRectangle.contains(location)) { |
157 | 158 | Point point = new XYChopboxAnchorHelper(bounds).getIntersectionPoint(location); |
@@ -222,8 +223,8 @@ public abstract class AbstractModelEditPart<T extends ConnectableElement> extend | ||
222 | 223 | |
223 | 224 | Rectangle bounds = targetFigure.getBounds(); |
224 | 225 | |
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); | |
227 | 228 | |
228 | 229 | if (!centerRectangle.contains(location)) { |
229 | 230 | Point point = new XYChopboxAnchorHelper(bounds).getIntersectionPoint(location); |
@@ -457,16 +458,9 @@ public abstract class AbstractModelEditPart<T extends ConnectableElement> extend | ||
457 | 458 | } |
458 | 459 | |
459 | 460 | /** |
460 | - * | |
461 | - * {@inheritDoc} | |
462 | - * | |
463 | - * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure() | |
461 | + * モデルのサイズを自動調整可能か? | |
462 | + * | |
463 | + * @return 自動調整可能なモデルのコントローラはtrueを返す | |
464 | 464 | */ |
465 | - @Override | |
466 | - protected IFigure createFigure() { | |
467 | - EntityFigure figure = new EntityFigure(); | |
468 | - updateFigure(figure); | |
469 | - | |
470 | - return figure; | |
471 | - } | |
465 | + public abstract boolean canAutoSize(); | |
472 | 466 | } |
@@ -19,23 +19,24 @@ import java.beans.PropertyChangeEvent; | ||
19 | 19 | import java.util.Collections; |
20 | 20 | import java.util.List; |
21 | 21 | |
22 | -import jp.sourceforge.tmdmaker.figure.SubsetTypeFigure; | |
23 | -import jp.sourceforge.tmdmaker.model.AbstractSubsetType; | |
24 | -import jp.sourceforge.tmdmaker.model.ConnectableElement; | |
25 | - | |
26 | 22 | import org.eclipse.draw2d.ConnectionAnchor; |
27 | 23 | import org.eclipse.draw2d.Figure; |
28 | 24 | import org.eclipse.draw2d.IFigure; |
29 | 25 | import org.eclipse.gef.ConnectionEditPart; |
30 | 26 | import org.eclipse.gef.Request; |
31 | 27 | |
28 | +import jp.sourceforge.tmdmaker.figure.SubsetTypeFigure; | |
29 | +import jp.sourceforge.tmdmaker.model.AbstractSubsetType; | |
30 | +import jp.sourceforge.tmdmaker.model.ConnectableElement; | |
31 | + | |
32 | 32 | /** |
33 | 33 | * スーパーセットとサブセットとの接点のEditPartの基底クラス. |
34 | 34 | * |
35 | 35 | * @author nakag |
36 | 36 | * |
37 | 37 | */ |
38 | -public abstract class AbstractSubsetTypeEditPart<T extends ConnectableElement> extends AbstractModelEditPart<T> { | |
38 | +public abstract class AbstractSubsetTypeEditPart<T extends ConnectableElement> | |
39 | + extends AbstractModelEditPart<T> { | |
39 | 40 | |
40 | 41 | /** |
41 | 42 | * コンストラクタ. |
@@ -143,10 +144,20 @@ public abstract class AbstractSubsetTypeEditPart<T extends ConnectableElement> e | ||
143 | 144 | |
144 | 145 | /** |
145 | 146 | * {@inheritDoc} |
146 | - * | |
147 | + * | |
147 | 148 | * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies() |
148 | 149 | */ |
149 | 150 | @Override |
150 | 151 | protected void createEditPolicies() { |
151 | 152 | } |
153 | + | |
154 | + /** | |
155 | + * {@inheritDoc} | |
156 | + * | |
157 | + * @see jp.sourceforge.tmdmaker.editpart.AbstractModelEditPart#canAutoSize() | |
158 | + */ | |
159 | + @Override | |
160 | + public boolean canAutoSize() { | |
161 | + return false; | |
162 | + } | |
152 | 163 | } |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - * Copyright 2009-2011 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
2 | + * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * 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 | ||
74 | 74 | */ |
75 | 75 | @Override |
76 | 76 | 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)) { | |
79 | 80 | onDoubleClicked(); |
81 | + } else if (requestType.equals(RequestConstants.REQ_DIRECT_EDIT)) { | |
82 | + onDirectEdit(); | |
80 | 83 | } else { |
81 | 84 | super.performRequest(req); |
82 | 85 | } |
83 | 86 | } |
84 | - | |
87 | + | |
85 | 88 | @SuppressWarnings("unchecked") |
86 | 89 | @Override |
87 | - public T getModel(){ | |
88 | - return (T)super.getModel(); | |
90 | + public T getModel() { | |
91 | + return (T) super.getModel(); | |
89 | 92 | } |
90 | - | |
93 | + | |
91 | 94 | /** |
92 | 95 | * ダブルクリック時の処理をサブクラスで実装する |
93 | 96 | */ |
94 | 97 | protected abstract void onDoubleClicked(); |
95 | 98 | |
99 | + /** | |
100 | + * ダイレクトエディット時の処理(必要なサブクラスのみ実装) | |
101 | + */ | |
102 | + protected void onDirectEdit() { | |
103 | + | |
104 | + } | |
96 | 105 | } |
@@ -19,16 +19,6 @@ import java.beans.PropertyChangeEvent; | ||
19 | 19 | import java.util.ArrayList; |
20 | 20 | import java.util.List; |
21 | 21 | |
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 | - | |
32 | 22 | import org.eclipse.draw2d.Figure; |
33 | 23 | import org.eclipse.draw2d.FreeformLayer; |
34 | 24 | import org.eclipse.draw2d.FreeformLayout; |
@@ -42,6 +32,7 @@ import org.eclipse.gef.SnapToGeometry; | ||
42 | 32 | import org.eclipse.gef.SnapToGrid; |
43 | 33 | import org.eclipse.gef.SnapToHelper; |
44 | 34 | import org.eclipse.gef.commands.Command; |
35 | +import org.eclipse.gef.commands.CompoundCommand; | |
45 | 36 | import org.eclipse.gef.editpolicies.ResizableEditPolicy; |
46 | 37 | import org.eclipse.gef.editpolicies.SnapFeedbackPolicy; |
47 | 38 | import org.eclipse.gef.editpolicies.XYLayoutEditPolicy; |
@@ -49,19 +40,32 @@ import org.eclipse.gef.requests.ChangeBoundsRequest; | ||
49 | 40 | import org.eclipse.gef.requests.CreateRequest; |
50 | 41 | import org.eclipse.ui.views.properties.IPropertySource; |
51 | 42 | |
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 | + | |
52 | 57 | /** |
53 | 58 | * Diagramのコントローラ |
54 | 59 | * |
55 | 60 | * @author nakaG |
56 | 61 | * |
57 | 62 | */ |
58 | -public class DiagramEditPart extends AbstractTMDEditPart<Diagram> implements IPropertyAvailable { | |
59 | - | |
63 | +public class DiagramEditPart extends AbstractTMDEditPart<Diagram>implements IPropertyAvailable { | |
64 | + | |
60 | 65 | /** |
61 | 66 | * コンストラクタ |
62 | 67 | */ |
63 | - public DiagramEditPart(Diagram diagram) | |
64 | - { | |
68 | + public DiagramEditPart(Diagram diagram) { | |
65 | 69 | super(); |
66 | 70 | setModel(diagram); |
67 | 71 | } |
@@ -173,8 +177,8 @@ public class DiagramEditPart extends AbstractTMDEditPart<Diagram> implements IPr | ||
173 | 177 | } |
174 | 178 | |
175 | 179 | @Override |
176 | - protected Command createChangeConstraintCommand(ChangeBoundsRequest request, | |
177 | - EditPart child, Object constraint) { | |
180 | + protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, | |
181 | + Object constraint) { | |
178 | 182 | logger.debug("resizedirection:" + request.getResizeDirection()); |
179 | 183 | logger.debug("NORTH_SOUTH/EAST_WEST:" + PositionConstants.NORTH_SOUTH + "/" |
180 | 184 | + PositionConstants.EAST_WEST); |
@@ -189,13 +193,30 @@ public class DiagramEditPart extends AbstractTMDEditPart<Diagram> implements IPr | ||
189 | 193 | */ |
190 | 194 | @Override |
191 | 195 | protected Command getCreateCommand(CreateRequest request) { |
192 | - logger.debug(getClass() + "#getCreateCommand()"); | |
196 | + logger.debug(getClass() + "#getCreateCommand()"+ request.getNewObjectType()); | |
193 | 197 | 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; | |
199 | 220 | } |
200 | 221 | } |
201 | 222 |
@@ -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 | +} |
@@ -45,6 +45,7 @@ import jp.sourceforge.tmdmaker.model.SubsetType; | ||
45 | 45 | import jp.sourceforge.tmdmaker.model.VirtualEntity; |
46 | 46 | import jp.sourceforge.tmdmaker.model.VirtualSuperset; |
47 | 47 | import jp.sourceforge.tmdmaker.model.VirtualSupersetType; |
48 | +import jp.sourceforge.tmdmaker.model.other.Memo; | |
48 | 49 | |
49 | 50 | /** |
50 | 51 | * |
@@ -54,10 +55,10 @@ import jp.sourceforge.tmdmaker.model.VirtualSupersetType; | ||
54 | 55 | * @author tohosaku |
55 | 56 | * |
56 | 57 | */ |
57 | -public class TMDEditPartVisitor implements IVisitor{ | |
58 | - | |
58 | +public class TMDEditPartVisitor implements IVisitor { | |
59 | + | |
59 | 60 | private EditPart part = null; |
60 | - | |
61 | + | |
61 | 62 | public EditPart getEditPart() { |
62 | 63 | return part; |
63 | 64 | } |
@@ -191,4 +192,14 @@ public class TMDEditPartVisitor implements IVisitor{ | ||
191 | 192 | public void visit(Identifier identifier) { |
192 | 193 | part = null; |
193 | 194 | } |
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 | + } | |
194 | 205 | } |
@@ -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 | +} |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | - * Copyright 2009-2010 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
2 | + * Copyright 2009-2015 TMD-Maker Project <http://tmdmaker.sourceforge.jp/> | |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -16,7 +16,7 @@ | ||
16 | 16 | package jp.sourceforge.tmdmaker.tool; |
17 | 17 | |
18 | 18 | import jp.sourceforge.tmdmaker.dialog.EntityCreateDialog; |
19 | -import jp.sourceforge.tmdmaker.ui.command.ModelAddCommand; | |
19 | +import jp.sourceforge.tmdmaker.ui.command.EntityModelAddCommand; | |
20 | 20 | |
21 | 21 | import org.eclipse.gef.commands.Command; |
22 | 22 | import org.eclipse.gef.tools.CreationTool; |
@@ -45,8 +45,8 @@ public class EntityCreationTool extends CreationTool { | ||
45 | 45 | unlockTargetEditPart(); |
46 | 46 | |
47 | 47 | Command curCommand = getCurrentCommand(); |
48 | - if (curCommand instanceof ModelAddCommand) { | |
49 | - ModelAddCommand addCommand = (ModelAddCommand) curCommand; | |
48 | + if (curCommand instanceof EntityModelAddCommand) { | |
49 | + EntityModelAddCommand addCommand = (EntityModelAddCommand) curCommand; | |
50 | 50 | |
51 | 51 | EntityCreateDialog dialog = new EntityCreateDialog( |
52 | 52 | getCurrentViewer().getControl().getShell()); |
@@ -44,6 +44,7 @@ import jp.sourceforge.tmdmaker.model.SubsetType; | ||
44 | 44 | import jp.sourceforge.tmdmaker.model.VirtualEntity; |
45 | 45 | import jp.sourceforge.tmdmaker.model.VirtualSuperset; |
46 | 46 | import jp.sourceforge.tmdmaker.model.VirtualSupersetType; |
47 | +import jp.sourceforge.tmdmaker.model.other.Memo; | |
47 | 48 | |
48 | 49 | /** |
49 | 50 | * |
@@ -190,4 +191,14 @@ public class TMDOutlineTreeEditPartVisitor implements IVisitor{ | ||
190 | 191 | public void visit(Identifier identifier) { |
191 | 192 | part = new IdentifierTreeEditPart(identifier); |
192 | 193 | } |
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 | + } | |
193 | 204 | } |
@@ -26,7 +26,7 @@ import org.eclipse.gef.commands.Command; | ||
26 | 26 | * @author nakaG |
27 | 27 | * |
28 | 28 | */ |
29 | -public class ModelAddCommand extends Command { | |
29 | +public class EntityModelAddCommand extends Command { | |
30 | 30 | /** 親 */ |
31 | 31 | private Diagram diagram; |
32 | 32 | /** 作成対象 */ |
@@ -44,7 +44,7 @@ public class ModelAddCommand extends Command { | ||
44 | 44 | * @param y |
45 | 45 | * Y座標 |
46 | 46 | */ |
47 | - public ModelAddCommand(Diagram diagram, int x, int y) { | |
47 | + public EntityModelAddCommand(Diagram diagram, int x, int y) { | |
48 | 48 | this.diagram = diagram; |
49 | 49 | this.x = x; |
50 | 50 | this.y = y; |
@@ -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 | +} |
@@ -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 | +} |
@@ -38,4 +38,8 @@ public class ConstraintConverter { | ||
38 | 38 | return new Constraint(rectangle.x, rectangle.y, rectangle.width, rectangle.height); |
39 | 39 | } |
40 | 40 | |
41 | + public static Constraint toConstraintWithoutHeightWidth(Rectangle rectangle) { | |
42 | + return new Constraint(rectangle.x, rectangle.y, -1, -1); | |
43 | + } | |
44 | + | |
41 | 45 | } |