[Jiemamy-notify] commit [2007] モデルエディタによるモデルインスタンスの生成を、Jiemamy仕様に基づく方法に変更。

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2008年 10月 7日 (火) 02:15:53 JST


Revision: 2007
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2007
Author:   daisuke_m
Date:     2008-10-07 02:15:53 +0900 (Tue, 07 Oct 2008)

Log Message:
-----------
モデルエディタによるモデルインスタンスの生成を、Jiemamy仕様に基づく方法に変更。

Modified Paths:
--------------
    vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java


-------------- next part --------------
Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java	2008-10-06 17:02:54 UTC (rev 2006)
+++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorPaletteFactory.java	2008-10-06 17:15:53 UTC (rev 2007)
@@ -28,11 +28,14 @@
 import org.eclipse.gef.palette.PaletteSeparator;
 import org.eclipse.gef.palette.PanningSelectionToolEntry;
 import org.eclipse.gef.palette.ToolEntry;
-import org.eclipse.gef.requests.SimpleFactory;
+import org.eclipse.gef.requests.CreationFactory;
 import org.eclipse.jface.resource.ImageRegistry;
 
 import org.jiemamy.eclipse.Images;
 import org.jiemamy.eclipse.JiemamyPlugin;
+import org.jiemamy.eclipse.utils.EditorUtil;
+import org.jiemamy.spec.model.JiemamyModel;
+import org.jiemamy.spec.model.RootModel;
 import org.jiemamy.spec.model.connection.ForeignKeyModel;
 import org.jiemamy.spec.model.node.StickyModel;
 import org.jiemamy.spec.model.node.TableModel;
@@ -129,19 +132,17 @@
 		PaletteDrawer drawer = new PaletteDrawer("palette.entity"); // RESOURCE
 		
 		CombinedTemplateCreationEntry tableCreationEntry =
-				new CombinedTemplateCreationEntry(
-						"palette.entity.table", // RESOURCE
+				new CombinedTemplateCreationEntry("palette.entity.table", // RESOURCE
 						"palette.entity.table.desc", // RESOURCE
-						new SimpleFactory(TableModel.class), imageRegistry.getDescriptor(Images.BUTTON_TABLE),
-						imageRegistry.getDescriptor(Images.BUTTON_TABLE));
+						new JiemamyModelCreationFactory(TableModel.class), imageRegistry
+							.getDescriptor(Images.BUTTON_TABLE), imageRegistry.getDescriptor(Images.BUTTON_TABLE));
 		drawer.add(tableCreationEntry);
 		
 		CombinedTemplateCreationEntry viewCreationEntry =
-				new CombinedTemplateCreationEntry(
-						"palette.entity.view", // RESOURCE
+				new CombinedTemplateCreationEntry("palette.entity.view", // RESOURCE
 						"palette.entity.view.desc", // RESOURCE
-						new SimpleFactory(ViewModel.class), imageRegistry.getDescriptor(Images.BUTTON_VIEW),
-						imageRegistry.getDescriptor(Images.BUTTON_VIEW));
+						new JiemamyModelCreationFactory(ViewModel.class), imageRegistry
+							.getDescriptor(Images.BUTTON_VIEW), imageRegistry.getDescriptor(Images.BUTTON_VIEW));
 		drawer.add(viewCreationEntry);
 		
 		return drawer;
@@ -151,11 +152,10 @@
 		PaletteDrawer drawer = new PaletteDrawer("palette.other"); // RESOURCE
 		
 		CombinedTemplateCreationEntry stickyCreationEntry =
-				new CombinedTemplateCreationEntry(
-						"palette.other.sticky", // RESOURCE
+				new CombinedTemplateCreationEntry("palette.other.sticky", // RESOURCE
 						"palette.other.sticky.desc", // RESOURCE
-						new SimpleFactory(StickyModel.class), imageRegistry.getDescriptor(Images.BUTTON_VIEW),
-						imageRegistry.getDescriptor(Images.BUTTON_VIEW));
+						new JiemamyModelCreationFactory(StickyModel.class), imageRegistry
+							.getDescriptor(Images.BUTTON_VIEW), imageRegistry.getDescriptor(Images.BUTTON_VIEW));
 		drawer.add(stickyCreationEntry);
 		
 		return drawer;
@@ -165,11 +165,10 @@
 		PaletteDrawer drawer = new PaletteDrawer("palette.relation"); // RESOURCE
 		
 		ConnectionCreationToolEntry foreignKeyCreationEntry =
-				new ConnectionCreationToolEntry(
-						"palette.relation.foreignKey", // RESOURCE
+				new ConnectionCreationToolEntry("palette.relation.foreignKey", // RESOURCE
 						"palette.relation.foreignKey.desc", // RESOURCE
-						new SimpleFactory(ForeignKeyModel.class), imageRegistry.getDescriptor(Images.BUTTON_FK),
-						imageRegistry.getDescriptor(Images.BUTTON_FK));
+						new JiemamyModelCreationFactory(ForeignKeyModel.class), imageRegistry
+							.getDescriptor(Images.BUTTON_FK), imageRegistry.getDescriptor(Images.BUTTON_FK));
 		drawer.add(foreignKeyCreationEntry);
 		
 		return drawer;
@@ -180,4 +179,40 @@
 	 */
 	private DiagramEditorPaletteFactory() {
 	}
+	
+
+	/**
+	 * TODO for daisuke
+	 * @author daisuke
+	 */
+	private static class JiemamyModelCreationFactory implements CreationFactory {
+		
+		private Class<? extends JiemamyModel> type;
+		
+
+		/**
+		 * コンストラクタ。
+		 * @param type 
+		 * @category instance creation
+		 */
+		public JiemamyModelCreationFactory(Class<? extends JiemamyModel> type) {
+			this.type = type;
+		}
+		
+		/**
+		 * {@inheritDoc}
+		 */
+		public Object getNewObject() {
+			RootModel rootModel = ((MultiDiagramEditor) EditorUtil.getActiveEditor()).getRootModel();
+			return rootModel.createJiemamyModel(type);
+		}
+		
+		/**
+		 * {@inheritDoc}
+		 */
+		public Object getObjectType() {
+			return type;
+		}
+		
+	}
 }


Jiemamy-notify メーリングリストの案内
Zurück zum Archiv-Index