[Jiemamy-notify:1529] commit [2741] commandのインターフェイスを整理。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 26日 (木) 12:59:32 JST


Revision: 2741
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2741
Author:   daisuke_m
Date:     2009-02-26 12:59:32 +0900 (Thu, 26 Feb 2009)

Log Message:
-----------
commandのインターフェイスを整理。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java

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

Removed Paths:
-------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java


-------------- next part --------------
Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -1,105 +0,0 @@
-/*
- * 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 java.util.Stack;
-
-import org.jiemamy.editcommand.Command;
-import org.jiemamy.editcommand.CommandProcessor;
-import org.jiemamy.editcommand.CommandProcessorImpl;
-import org.jiemamy.editcommand.impl.AddEntityToRootCommand;
-import org.jiemamy.model.RootModel;
-import org.jiemamy.model.entity.EntityModel;
-
-/**
- * Jiemamyに対するファサードの実装クラス。
- * 
- * @author daisuke
- */
-public class JiemamyFacadeImpl {
-	
-	protected final Jiemamy jiemamy;
-	
-	protected Stack<Command> undoStack = new Stack<Command>();
-	
-	protected Stack<Command> redoStack = new Stack<Command>();
-	
-	protected final CommandProcessor processor;
-	
-
-	/**
-	 * インスタンスを生成する。
-	 * 
-	 * @param jiemamy
-	 */
-	public JiemamyFacadeImpl(Jiemamy jiemamy) {
-		this.jiemamy = jiemamy;
-		processor = new CommandProcessorImpl(jiemamy.getEventBroker());
-	}
-	
-	/**
-	 * TODO for daisuke
-	 * 
-	 * @param entity
-	 */
-	public void addEntity(EntityModel entity) {
-		AddEntityToRootCommand command = new AddEntityToRootCommand(getRootModel(), entity);
-		command.execute(processor, undoStack);
-	}
-	
-	/**
-	 * TODO for daisuke
-	 * 
-	 * @return the jiemamy
-	 */
-	public Jiemamy getJiemamy() {
-		return jiemamy;
-	}
-	
-	/**
-	 * TODO for daisuke
-	 * 
-	 * @return
-	 */
-	public RootModel getRootModel() {
-		return jiemamy.getFactory().getRootModel();
-	}
-	
-	/**
-	 * TODO for daisuke
-	 */
-	public void redo() {
-		if (redoStack.isEmpty()) {
-			return;
-		}
-		Command command = redoStack.pop();
-		command.execute(processor, undoStack);
-	}
-	
-	/**
-	 * TODO for daisuke
-	 */
-	public void undo() {
-		if (undoStack.isEmpty()) {
-			return;
-		}
-		Command command = undoStack.pop();
-		command.execute(processor, redoStack);
-	}
-}

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -19,6 +19,7 @@
 package org.jiemamy.editcommand.impl;
 
 import java.util.Collection;
+import java.util.Stack;
 
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
@@ -52,9 +53,12 @@
 		this.element = element;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return createDeleteFromRootCommand(root, element);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = createDeleteFromRootCommand(root, element);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,10 +18,7 @@
  */
 package org.jiemamy.editcommand.impl;
 
-import java.util.Stack;
-
 import org.jiemamy.editcommand.Command;
-import org.jiemamy.editcommand.CommandProcessor;
 
 /**
  * {@link Command}を実装するための抽象クラス。
@@ -30,9 +27,4 @@
  */
 public abstract class AbstractCommand implements Command {
 	
-	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
-		Command undo = execute(commandProcessor);
-		commandStack.push(undo);
-	}
-	
 }

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -19,6 +19,7 @@
 package org.jiemamy.editcommand.impl;
 
 import java.util.Collection;
+import java.util.Stack;
 
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
@@ -52,9 +53,12 @@
 		this.element = element;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return createAddToRootCommand(root, element);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = createAddToRootCommand(root, element);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand.impl;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
 import org.jiemamy.model.JiemamyElement;
@@ -45,12 +47,14 @@
 	public AddColumnCommand(TableModel table, ColumnModel column) {
 		this.table = table;
 		this.column = column;
-		
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new DeleteColumnCommand(table, column);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new DeleteColumnCommand(table, column);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -19,6 +19,7 @@
 package org.jiemamy.editcommand.impl;
 
 import java.util.List;
+import java.util.Stack;
 
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
@@ -71,9 +72,12 @@
 		this.index = index;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new DeleteColumnFromColumnRefListCommand(target, columnRefList, column, index);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new DeleteColumnFromColumnRefListCommand(target, columnRefList, column, index);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand.impl;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
 import org.jiemamy.model.JiemamyElement;
@@ -47,9 +49,12 @@
 		this.fk = fk;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new DeleteForeignKeyCommand(table, fk);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new DeleteForeignKeyCommand(table, fk);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand.impl;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
 import org.jiemamy.model.JiemamyElement;
@@ -47,9 +49,12 @@
 		this.primaryKey = primaryKey;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new DeletePrimaryKeyCommand(table, primaryKey);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new DeletePrimaryKeyCommand(table, primaryKey);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand.impl;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
 import org.jiemamy.model.JiemamyElement;
@@ -48,9 +50,12 @@
 		
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new AddColumnCommand(table, column);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new AddColumnCommand(table, column);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -19,6 +19,7 @@
 package org.jiemamy.editcommand.impl;
 
 import java.util.List;
+import java.util.Stack;
 
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
@@ -86,9 +87,12 @@
 		this.index = index;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new AddColumnToColumnRefListCommand(target, columnRefList, column, index);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new AddColumnToColumnRefListCommand(target, columnRefList, column, index);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand.impl;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
 import org.jiemamy.model.JiemamyElement;
@@ -47,9 +49,12 @@
 		
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new AddForeignKeyCommand(table, fk);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new AddForeignKeyCommand(table, fk);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand.impl;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.Command;
 import org.jiemamy.editcommand.CommandProcessor;
 import org.jiemamy.model.JiemamyElement;
@@ -47,9 +49,12 @@
 		this.primaryKey = primaryKey;
 	}
 	
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new AddPrimaryKeyCommand(table, primaryKey);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new AddPrimaryKeyCommand(table, primaryKey);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -20,6 +20,7 @@
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.util.Stack;
 
 import org.apache.commons.beanutils.BeanUtils;
 
@@ -57,13 +58,16 @@
 		this.newValue = newValue;
 	}
 	
-	public Command execute(CommandProcessor processor) {
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
 		try {
 			Object oldValue = BeanUtils.getProperty(target, propertyName);
-			processor.process(this);
+			commandProcessor.process(this);
 			Constructor<? extends ModifyModelPropertyCommand> constructor =
 					getClass().getConstructor(JiemamyElement.class, String.class, Object.class);
-			return constructor.newInstance(target, propertyName, oldValue);
+			Command undo = constructor.newInstance(target, propertyName, oldValue);
+			if (commandStack != null) {
+				commandStack.push(undo);
+			}
 		} catch (SecurityException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
@@ -83,8 +87,6 @@
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		// TODO 適当null返し
-		return null;
 	}
 	
 	/**

Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java (from rev 2740, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/JiemamyFacadeImpl.java)
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -0,0 +1,104 @@
+/*
+ * 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.facade;
+
+import java.util.Stack;
+
+import org.apache.commons.lang.Validate;
+
+import org.jiemamy.Jiemamy;
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.editcommand.CommandProcessor;
+import org.jiemamy.editcommand.CommandProcessorImpl;
+import org.jiemamy.editcommand.impl.AddEntityToRootCommand;
+import org.jiemamy.model.RootModel;
+import org.jiemamy.model.entity.EntityModel;
+
+/**
+ * Jiemamyに対するファサードの実装クラス。
+ * 
+ * @author daisuke
+ */
+public class JiemamyFacadeImpl {
+	
+	/** TODO for daisuke */
+	protected final Jiemamy jiemamy;
+	
+	protected Stack<Command> undoStack = new Stack<Command>();
+	
+	protected Stack<Command> redoStack = new Stack<Command>();
+	
+	private final CommandProcessor processor;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param jiemamy
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public JiemamyFacadeImpl(Jiemamy jiemamy) {
+		Validate.notNull(jiemamy);
+		this.jiemamy = jiemamy;
+		processor = new CommandProcessorImpl(jiemamy.getEventBroker());
+	}
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param entity
+	 */
+	public void addEntity(EntityModel entity) {
+		AddEntityToRootCommand command = new AddEntityToRootCommand(getRootModel(), entity);
+		command.execute(processor, undoStack);
+	}
+	
+	/**
+	 * TODO for daisuke
+	 */
+	@Deprecated
+	public void redo() {
+		if (redoStack.isEmpty()) {
+			return;
+		}
+		Command command = redoStack.pop();
+		command.execute(processor, undoStack);
+	}
+	
+	/**
+	 * TODO for daisuke
+	 */
+	@Deprecated
+	public void undo() {
+		if (undoStack.isEmpty()) {
+			return;
+		}
+		Command command = undoStack.pop();
+		command.execute(processor, redoStack);
+	}
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	protected RootModel getRootModel() {
+		return jiemamy.getFactory().getRootModel();
+	}
+}


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

Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -179,7 +179,7 @@
 		pkeyListener.commandList.clear();
 		tableListener.commandList.clear();
 		// columnをtableから削除する。
-		new DeleteColumnCommand(table, column1).execute(commandProcessor);
+		new DeleteColumnCommand(table, column1).execute(commandProcessor, commandStack);
 		
 		assertThat(columnListener1.commandList.size(), is(0)); // column自身は何も変更されていない。
 		assertThat(columnListener2.commandList.size(), is(0));

Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -23,9 +23,7 @@
 
 import java.util.Stack;
 
-import org.hamcrest.Matchers;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -134,12 +132,12 @@
 		//    -[ref]column1
 		//    -[ref]column2
 		
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), Matchers.is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(true));
 		
 		// 新たなStackを用意する。
 		commandStack = new Stack<Command>();
@@ -147,49 +145,48 @@
 		// columnをprimaryKeyから削除する。
 		new DeleteColumnFromColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1).execute(
 				commandProcessor, commandStack);
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), Matchers.is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(false));
 		
 		// columnをtableから削除する。
 		new DeleteColumnCommand(table, column1).execute(commandProcessor, commandStack);
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), Matchers.is(false));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), Matchers.is(false));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), Matchers.is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(false));
 		
 		// talbeをRootModelから削除する。
 		new DeleteEntityFromRootCommand(rootModel, table).execute(commandProcessor, commandStack);
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), Matchers.is(false));
-		Assert
-			.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), Matchers.is(false));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), Matchers.is(false));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), Matchers.is(false));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), Matchers.is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), is(false));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(false));
 		commandStackStack.push(commandStack); // 削除操作を行ったCommandStackをpushする。
 		
 		// 一連の削除操作を全て取り消す。
 		Stack<Command> deleteCommands = commandStackStack.pop();
 		while (deleteCommands.isEmpty() == false) {
 			Command command = deleteCommands.pop();
-			command.execute(commandProcessor);
+			command.execute(commandProcessor, null);
 		}
 		
 		assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey
 		assertThat(primaryKey.getKeyColumns().size(), is(2)); // [ref]column1, [ref]column2。
 		assertThat(primaryKey.getKeyColumns().get(0).getReferenceId(), is(column1.getId()));
 		assertThat(primaryKey.getKeyColumns().get(1).getReferenceId(), is(column2.getId()));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), Matchers.is(true));
-		Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), Matchers.is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, column1.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), is(true));
+		assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(true));
 	}
 }

Deleted: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -1,147 +0,0 @@
-/*
- * 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 java.util.Map;
-
-import org.jiemamy.editcommand.AddProfileToDiaglamCommand;
-import org.jiemamy.editcommand.Command;
-import org.jiemamy.editcommand.CommandProcessor;
-import org.jiemamy.editcommand.CommandProcessorImpl;
-import org.jiemamy.editcommand.DeleteProfileFromDiaglamCommand;
-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;
-
-/**
- * j-view用のコマンド実行ファサードクラス。
- * 
- * @author daisuke
- * @author shin1ogawa
- */
-public class JiemamyViewFacadeImpl extends JiemamyFacadeImpl {
-	
-	private final CommandProcessor commandProcessor;
-	
-
-	/**
-	 * インスタンスを生成する。
-	 * 
-	 * @param jiemamy
-	 */
-	public JiemamyViewFacadeImpl(Jiemamy jiemamy) {
-		super(jiemamy);
-		// j-viewを対象としたコマンドを実行できるCommandProcessorの実装クラスをインスタンス化する。
-		commandProcessor = new ViewCommandProcessor(jiemamy.getEventBroker());
-	}
-	
-	/**
-	 * TODO for shin1ogawa
-	 * 
-	 * @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス)
-	 * @param nodeAdapter ノードに対応する{@link NodeAdapter}
-	 * @param nodeProfile 追加する{@link NodeProfile}
-	 */
-	public void addNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter, final NodeProfile nodeProfile) {
-		final Command command = new AddProfileToDiaglamCommand(getRootModel(), diagramIndex, nodeAdapter, nodeProfile);
-		command.execute(commandProcessor, undoStack);
-		redoStack.push(command);
-	}
-	
-	/**
-	 * 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);
-		Map<NodeAdapter, NodeProfile> figureProfiles = diagramPresentationModel.getFigureProfiles();
-		if (figureProfiles.containsKey(nodeAdapter) == false) {
-			NodeProfile profile = jiemamy.getFactory().newModel(NodeProfile.class);
-			figureProfiles.put(nodeAdapter, profile);
-		}
-		NodeProfile nodeProfile = figureProfiles.get(nodeAdapter);
-		ModifyModelPropertyCommand redoCommand = new ModifyModelPropertyCommand(nodeProfile, "layout", constraint);
-		redoCommand.execute(commandProcessor, undoStack);
-		redoStack.push(redoCommand);
-	}
-	
-	/**
-	 * TODO for shin1ogawa
-	 * 
-	 * @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス)
-	 * @param nodeAdapter ノードに対応する{@link NodeAdapter}
-	 */
-	public void deleteNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter) {
-		final Command command = new DeleteProfileFromDiaglamCommand(getRootModel(), diagramIndex, nodeAdapter);
-		command.execute(commandProcessor, undoStack);
-		redoStack.push(command);
-	}
-	
-
-	/**
-	 * TODO for shin1ogawa
-	 * 
-	 * @author shin1ogawa
-	 */
-	public static class ViewCommandProcessor extends CommandProcessorImpl {
-		
-		/**
-		 * インスタンスを生成する。
-		 * 
-		 * @param eventBroker
-		 */
-		public ViewCommandProcessor(EventBroker eventBroker) {
-			super(eventBroker);
-		}
-		
-		/**
-		 * TODO for shin1ogawa
-		 * 
-		 * @param command
-		 */
-		public void process(AddProfileToDiaglamCommand command) {
-			DiagramPresentationModel diagramPresentationModel =
-					command.getRoot().getAdapter(DiagramPresentations.class).get(command.getDiagramIndex());
-			diagramPresentationModel.getFigureProfiles().put(command.getNodeAdapter(), command.getNodeProfile());
-			eventBroker.fireCommandProcessed(command);
-		}
-		
-		/**
-		 * TODO for shin1ogawa
-		 * 
-		 * @param command
-		 */
-		public void process(DeleteProfileFromDiaglamCommand command) {
-			DiagramPresentationModel diagramPresentationModel =
-					command.getRoot().getAdapter(DiagramPresentations.class).get(command.getDiagramIndex());
-			NodeProfile nodeProfile = diagramPresentationModel.getFigureProfiles().get(command.getNodeAdapter());
-			command.setNodeProfile(nodeProfile);
-			diagramPresentationModel.getFigureProfiles().remove(command.getNodeAdapter());
-			eventBroker.fireCommandProcessed(command);
-		}
-		
-	}
-}

Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.impl.AbstractCommand;
 import org.jiemamy.model.DiagramPresentations;
 import org.jiemamy.model.JiemamyElement;
@@ -58,12 +60,12 @@
 		this.nodeProfile = nodeProfile;
 	}
 	
-	/**
-	 * {@inheritDoc}
-	 */
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new DeleteProfileFromDiaglamCommand(root, getDiagramIndex(), nodeAdapter);
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new DeleteProfileFromDiaglamCommand(root, getDiagramIndex(), nodeAdapter);
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.editcommand;
 
+import java.util.Stack;
+
 import org.jiemamy.editcommand.impl.AbstractCommand;
 import org.jiemamy.model.DiagramPresentations;
 import org.jiemamy.model.JiemamyElement;
@@ -56,12 +58,12 @@
 		this.nodeAdapter = nodeAdapter;
 	}
 	
-	/**
-	 * {@inheritDoc}
-	 */
-	public Command execute(CommandProcessor processor) {
-		processor.process(this);
-		return new AddProfileToDiaglamCommand(root, getDiagramIndex(), nodeAdapter, getNodeProfile());
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) {
+		commandProcessor.process(this);
+		Command undo = new AddProfileToDiaglamCommand(root, getDiagramIndex(), nodeAdapter, getNodeProfile());
+		if (commandStack != null) {
+			commandStack.push(undo);
+		}
 	}
 	
 	/**

Copied: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java (from rev 2740, artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/JiemamyViewFacadeImpl.java)
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java	                        (rev 0)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -0,0 +1,150 @@
+/*
+ * 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.facade;
+
+import java.util.Map;
+
+import org.jiemamy.EventBroker;
+import org.jiemamy.Jiemamy;
+import org.jiemamy.editcommand.AddProfileToDiaglamCommand;
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.editcommand.CommandProcessor;
+import org.jiemamy.editcommand.CommandProcessorImpl;
+import org.jiemamy.editcommand.DeleteProfileFromDiaglamCommand;
+import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand;
+import org.jiemamy.facade.JiemamyFacadeImpl;
+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;
+
+/**
+ * j-view用のコマンド実行ファサードクラス。
+ * 
+ * @author daisuke
+ * @author shin1ogawa
+ */
+public class JiemamyViewFacadeImpl extends JiemamyFacadeImpl {
+	
+	private final CommandProcessor commandProcessor;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param jiemamy
+	 */
+	public JiemamyViewFacadeImpl(Jiemamy jiemamy) {
+		super(jiemamy);
+		// j-viewを対象としたコマンドを実行できるCommandProcessorの実装クラスをインスタンス化する。
+		commandProcessor = new ViewCommandProcessorImpl(jiemamy.getEventBroker());
+	}
+	
+	/**
+	 * TODO for shin1ogawa
+	 * 
+	 * @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス)
+	 * @param nodeAdapter ノードに対応する{@link NodeAdapter}
+	 * @param nodeProfile 追加する{@link NodeProfile}
+	 */
+	public void addNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter, final NodeProfile nodeProfile) {
+		final Command command = new AddProfileToDiaglamCommand(getRootModel(), diagramIndex, nodeAdapter, nodeProfile);
+		command.execute(commandProcessor, undoStack);
+		redoStack.push(command);
+	}
+	
+	/**
+	 * 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);
+		Map<NodeAdapter, NodeProfile> figureProfiles = diagramPresentationModel.getFigureProfiles();
+		if (figureProfiles.containsKey(nodeAdapter) == false) {
+			NodeProfile profile = jiemamy.getFactory().newModel(NodeProfile.class);
+			figureProfiles.put(nodeAdapter, profile);
+		}
+		NodeProfile nodeProfile = figureProfiles.get(nodeAdapter);
+		ModifyModelPropertyCommand redoCommand = new ModifyModelPropertyCommand(nodeProfile, "layout", constraint);
+		redoCommand.execute(commandProcessor, undoStack);
+		redoStack.push(redoCommand);
+	}
+	
+	/**
+	 * TODO for shin1ogawa
+	 * 
+	 * @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス)
+	 * @param nodeAdapter ノードに対応する{@link NodeAdapter}
+	 */
+	public void deleteNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter) {
+		final Command command = new DeleteProfileFromDiaglamCommand(getRootModel(), diagramIndex, nodeAdapter);
+		command.execute(commandProcessor, undoStack);
+		redoStack.push(command);
+	}
+	
+
+	/**
+	 * TODO for shin1ogawa
+	 * 
+	 * @author shin1ogawa
+	 */
+	public static class ViewCommandProcessorImpl extends CommandProcessorImpl {
+		
+		/**
+		 * インスタンスを生成する。
+		 * 
+		 * @param eventBroker
+		 */
+		public ViewCommandProcessorImpl(EventBroker eventBroker) {
+			super(eventBroker);
+		}
+		
+		/**
+		 * TODO for shin1ogawa
+		 * 
+		 * @param command
+		 */
+		public void process(AddProfileToDiaglamCommand command) {
+			DiagramPresentationModel diagramPresentationModel =
+					command.getRoot().getAdapter(DiagramPresentations.class).get(command.getDiagramIndex());
+			diagramPresentationModel.getFigureProfiles().put(command.getNodeAdapter(), command.getNodeProfile());
+			eventBroker.fireCommandProcessed(command);
+		}
+		
+		/**
+		 * TODO for shin1ogawa
+		 * 
+		 * @param command
+		 */
+		public void process(DeleteProfileFromDiaglamCommand command) {
+			DiagramPresentationModel diagramPresentationModel =
+					command.getRoot().getAdapter(DiagramPresentations.class).get(command.getDiagramIndex());
+			NodeProfile nodeProfile = diagramPresentationModel.getFigureProfiles().get(command.getNodeAdapter());
+			command.setNodeProfile(nodeProfile);
+			diagramPresentationModel.getFigureProfiles().remove(command.getNodeAdapter());
+			eventBroker.fireCommandProcessed(command);
+		}
+		
+	}
+}


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

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java	2009-02-25 23:17:03 UTC (rev 2740)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java	2009-02-26 03:59:32 UTC (rev 2741)
@@ -33,14 +33,6 @@
 	/**
 	 * コマンドを実行する。
 	 * 
-	 * @param processor コマンドプロセッサ
-	 * @return 逆操作を行うコマンド
-	 */
-	Command execute(CommandProcessor processor);
-	
-	/**
-	 * コマンドを実行する。
-	 * 
 	 * <p>逆操作を行うコマンドは、与えられたスタックに追加する。</p>
 	 * 
 	 * @param commandProcessor コマンドプロセッサ



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