[Jiemamy-notify:1482] commit [2707] Facadeの実装を追加し、vestaから使ってみた。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 22日 (日) 15:56:25 JST


Revision: 2707
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2707
Author:   daisuke_m
Date:     2009-02-22 15:56:24 +0900 (Sun, 22 Feb 2009)

Log Message:
-----------
Facadeの実装を追加し、vestaから使ってみた。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java

Added Paths:
-----------
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java	2009-02-22 06:15:41 UTC (rev 2706)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java	2009-02-22 06:56:24 UTC (rev 2707)
@@ -33,13 +33,13 @@
  */
 public class JiemamyFacadeImpl {
 	
-	private final Jiemamy jiemamy;
+	protected final Jiemamy jiemamy;
 	
-	private Stack<Command> undoStack = new Stack<Command>();
+	protected Stack<Command> undoStack = new Stack<Command>();
 	
-	private Stack<Command> redoStack = new Stack<Command>();
+	protected Stack<Command> redoStack = new Stack<Command>();
 	
-	private final CommandProcessor processor;
+	protected final CommandProcessor processor;
 	
 
 	/**
@@ -74,6 +74,14 @@
 		return jiemamy.getFactory().getRootModel();
 	}
 	
+	public void redo() {
+		if (redoStack.isEmpty() == false) {
+			return;
+		}
+		Command command = redoStack.pop();
+		command.execute(processor, undoStack);
+	}
+	
 	public void undo() {
 		if (undoStack.isEmpty() == false) {
 			return;

Added: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java	                        (rev 0)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java	2009-02-22 06:56:24 UTC (rev 2707)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/22
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy;
+
+import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand;
+import org.jiemamy.model.DiagramPresentationModel;
+import org.jiemamy.model.DiagramPresentations;
+import org.jiemamy.model.NodeProfile;
+import org.jiemamy.model.geometory.JmRectangle;
+import org.jiemamy.model.node.NodeAdapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class JiemamyViewFacadeImpl extends JiemamyFacadeImpl {
+	
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param jiemamy
+	 */
+	public JiemamyViewFacadeImpl(Jiemamy jiemamy) {
+		super(jiemamy);
+	}
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param diagramIndex
+	 * @param nodeAdapter
+	 * @param constraint
+	 */
+	public void changeNodeConstraint(int diagramIndex, NodeAdapter nodeAdapter, JmRectangle constraint) {
+		DiagramPresentations diagramPresentations = getRootModel().getAdapter(DiagramPresentations.class);
+		DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(diagramIndex);
+		
+		NodeProfile nodeProfile = diagramPresentationModel.getFigureProfiles().get(nodeAdapter);
+		try {
+			new ModifyModelPropertyCommand(nodeProfile, "layout", constraint).execute(processor);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java	2009-02-22 06:15:41 UTC (rev 2706)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java	2009-02-22 06:56:24 UTC (rev 2707)
@@ -27,15 +27,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.jiemamy.EventBroker;
+import org.jiemamy.JiemamyViewFacadeImpl;
 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.ModifyModelPropertyCommand;
-import org.jiemamy.model.DiagramPresentationModel;
 import org.jiemamy.model.DiagramPresentations;
-import org.jiemamy.model.NodeProfile;
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.connection.ConnectionAdapter;
 import org.jiemamy.model.geometory.JmPoint;
@@ -62,6 +57,8 @@
 	
 	private EditPartViewer viewer;
 	
+	private JiemamyViewFacadeImpl jiemamyFacade;
+	
 
 	/**
 	 * インスタンスを生成する。
@@ -85,6 +82,7 @@
 		int shiftY = rectangle.y < 0 ? Math.abs(rectangle.y) : 0;
 		setShift(new JmPoint(shiftX, shiftY));
 		
+		jiemamyFacade = new JiemamyViewFacadeImpl(rootModel.getJiemamy());
 	}
 	
 	/**
@@ -105,21 +103,22 @@
 	@Override
 	public void execute() {
 		logger.debug("execute");
-		EventBroker eventBroker = rootModel.getJiemamy().getEventBroker();
-		CommandProcessor commandProcessor = new CommandProcessorImpl(eventBroker);
+//		EventBroker eventBroker = rootModel.getJiemamy().getEventBroker();
+//		CommandProcessor commandProcessor = new CommandProcessorImpl(eventBroker);
 		
-		DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class);
-		DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(Migration.DIAGRAM_INDEX);
+//		DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class);
+//		DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(Migration.DIAGRAM_INDEX);
 		
 		// 本体の移動
+		jiemamyFacade.changeNodeConstraint(Migration.DIAGRAM_INDEX, nodeAdapter, constraint);
 //		diagramPresentationModel.getFigureProfiles().get(nodeAdapter).setLayout(constraint);
-		NodeProfile nodeProfile = diagramPresentationModel.getFigureProfiles().get(nodeAdapter);
-		try {
-			new ModifyModelPropertyCommand(nodeProfile, "layout", constraint).execute(commandProcessor);
-		} catch (Exception e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+//		NodeProfile nodeProfile = diagramPresentationModel.getFigureProfiles().get(nodeAdapter);
+//		try {
+//			new ModifyModelPropertyCommand(nodeProfile, "layout", constraint).execute(commandProcessor);
+//		} catch (Exception e) {
+//			// TODO Auto-generated catch block
+//			e.printStackTrace();
+//		}
 		
 		// ベンドポイントの移動
 		shiftBendpoints(false);
@@ -128,17 +127,6 @@
 		shiftPosition(false);
 	}
 	
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void undo() {
-		rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX).getFigureProfiles().get(
-				nodeAdapter).setLayout(oldConstraint);
-		shiftBendpoints(true);
-		shiftPosition(true);
-	}
-	
 	private void shiftBendpoints(boolean positive) {
 		JmPoint delta = JmPointUtil.delta(oldConstraint, constraint);
 		
@@ -166,4 +154,16 @@
 			}
 		}
 	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void undo() {
+		jiemamyFacade.undo();
+//		rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX).getFigureProfiles().get(
+//				nodeAdapter).setLayout(oldConstraint);
+		shiftBendpoints(true);
+		shiftPosition(true);
+	}
 }

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-22 06:15:41 UTC (rev 2706)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java	2009-02-22 06:56:24 UTC (rev 2707)
@@ -19,18 +19,14 @@
 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;
 
+import org.jiemamy.JiemamyFacadeImpl;
 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;
@@ -50,6 +46,8 @@
 	
 	private Rectangle rectangle;
 	
+	private JiemamyFacadeImpl jiemamyFacade;
+	
 
 	/**
 	 * インスタンスを生成する。
@@ -61,6 +59,7 @@
 		this.rootModel = rootModel;
 		this.model = model;
 		this.rectangle = rectangle;
+		jiemamyFacade = new JiemamyFacadeImpl(model.getJiemamy());
 	}
 	
 	/**
@@ -71,14 +70,10 @@
 		NodeAdapter nodeAdapter;
 		DiagramPresentationModel diagramPresentationModel =
 				rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX);
-		AbstractAddToRootCommand<?> addToRootCommand = null;
-		if (model instanceof EntityModel) {
-			// Commandで操作する。
-			addToRootCommand = new AddEntityToRootCommand(rootModel, (EntityModel) model);
-//			rootModel.getEntities().add((EntityModel) model);
-			nodeAdapter = model.getAdapter(NodeAdapter.class);
-		} else {
+		if (model instanceof NodeAdapter) {
 			nodeAdapter = (NodeAdapter) model;
+		} else {
+			nodeAdapter = model.getAdapter(NodeAdapter.class);
 		}
 		Map<NodeAdapter, NodeProfile> figureProfiles = diagramPresentationModel.getFigureProfiles();
 		if (figureProfiles.containsKey(nodeAdapter) == false) {
@@ -89,14 +84,8 @@
 		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();
-			}
+			EntityModel entityModel = (EntityModel) model;
+			jiemamyFacade.addEntity(entityModel);
 		}
 	}
 	
@@ -105,11 +94,6 @@
 	 */
 	@Override
 	public void undo() {
-		DiagramPresentationModel diagramPresentationModel =
-				rootModel.getAdapter(DiagramPresentations.class).get(Migration.DIAGRAM_INDEX);
-		if (model instanceof EntityModel) {
-			rootModel.getEntities().remove(model);
-		}
-		diagramPresentationModel.getFigureProfiles().get(model).setLayout(ConvertUtil.convert(rectangle));
+		jiemamyFacade.undo();
 	}
 }



Jiemamy-notify メーリングリストの案内
Back to archive index