svnno****@sourc*****
svnno****@sourc*****
2009年 2月 22日 (日) 02:32:54 JST
Revision: 2703 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2703 Author: shin1 Date: 2009-02-22 02:32:54 +0900 (Sun, 22 Feb 2009) Log Message: ----------- パレットからEntityを追加したタイミングで再描画されるように、editcommand.Command経由でEntityの追加を行う。 Modified Paths: -------------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java -------------- next part -------------- Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2009-02-21 16:15:06 UTC (rev 2702) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2009-02-21 17:32:54 UTC (rev 2703) @@ -19,6 +19,7 @@ package org.jiemamy.eclipse.editor.command; import java.util.Map; +import java.util.Stack; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.commands.Command; @@ -26,6 +27,10 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.Migration; import org.jiemamy.eclipse.utils.ConvertUtil; +import org.jiemamy.editcommand.CommandProcessor; +import org.jiemamy.editcommand.CommandProcessorImpl; +import org.jiemamy.editcommand.impl.AbstractAddToRootCommand; +import org.jiemamy.editcommand.impl.AddEntityToRootCommand; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.JiemamyElement; @@ -66,8 +71,11 @@ NodeAdapter nodeAdapter; DiagramPresentationModel diagramPresentationModel = rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX); + AbstractAddToRootCommand<?> addToRootCommand = null; if (model instanceof EntityModel) { - rootModel.getEntities().add((EntityModel) model); + // Commandで操作する。 + addToRootCommand = new AddEntityToRootCommand(rootModel, (EntityModel) model); +// rootModel.getEntities().add((EntityModel) model); nodeAdapter = model.getAdapter(NodeAdapter.class); } else { nodeAdapter = (NodeAdapter) model; @@ -79,6 +87,17 @@ figureProfiles.put(nodeAdapter, profile); } diagramPresentationModel.getFigureProfiles().get(nodeAdapter).setLayout(ConvertUtil.convert(rectangle)); + // Command経由でモデルを追加するサンプル。 + if (model instanceof EntityModel) { + // TODO CommandStackとCommnadProcessorはどこかから取得した方が良い。 + Stack<org.jiemamy.editcommand.Command> commandStack = new Stack<org.jiemamy.editcommand.Command>(); + CommandProcessor commandProcessor = new CommandProcessorImpl(rootModel.getJiemamy().getEventBroker()); + try { + addToRootCommand.execute(commandProcessor, commandStack); + } catch (Exception e) { + e.printStackTrace(); + } + } } /**