[Jiemamy-notify:2290] commit [3327] refactor

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 21日 (火) 09:03:31 JST


Revision: 3327
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3327
Author:   daisuke_m
Date:     2009-04-21 09:03:31 +0900 (Tue, 21 Apr 2009)

Log Message:
-----------
refactor

Modified Paths:
--------------
    hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java


-------------- next part --------------
Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java
===================================================================
--- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java	2009-04-20 15:27:48 UTC (rev 3326)
+++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java	2009-04-21 00:03:31 UTC (rev 3327)
@@ -18,7 +18,7 @@
  */
 package org.jiemamy.eclipse.editor;
 
-import java.util.Collection;
+import java.util.Map;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
@@ -45,6 +45,7 @@
 import org.jiemamy.eclipse.action.ImportAction;
 import org.jiemamy.eclipse.action.PropertyAction;
 import org.jiemamy.eclipse.action.SaveDiagramImageAction;
+import org.jiemamy.eclipse.extension.ExtensionResolver;
 import org.jiemamy.eclipse.ui.ExporterWizard;
 import org.jiemamy.eclipse.ui.ImporterWizard;
 import org.jiemamy.eclipse.utils.ExceptionHandler;
@@ -177,46 +178,24 @@
 	}
 	
 	private void buildExporterMenu(IMenuManager menu, GraphicalViewer viewer) {
-		Collection<IConfigurationElement> exporterElements =
-				JiemamyCorePlugin.getExporterResolver().getExtensionConfigurationElements().values();
-		if (exporterElements.size() > 0) {
+		ExtensionResolver<Exporter<ExportConfig>> exporterResolver = JiemamyCorePlugin.getExporterResolver();
+		Map<String, IConfigurationElement> configurationElements = exporterResolver.getExtensionConfigurationElements();
+		if (configurationElements.size() > 0) {
 			MenuManager exportMenu = new MenuManager("エクスポート(&E)"); // RESOURCE
-			for (IConfigurationElement exporterElement : exporterElements) {
-				try {
-					@SuppressWarnings("unchecked")
-					Exporter<ExportConfig> exporter =
-							(Exporter<ExportConfig>) exporterElement.createExecutableExtension("class");
-					@SuppressWarnings("unchecked")
-					ExporterWizard<Exporter<ExportConfig>, ExportConfig> wizard =
-							(ExporterWizard<Exporter<ExportConfig>, ExportConfig>) exporterElement
-								.createExecutableExtension("wizard");
-					exportMenu.add(new ExportAction(exporter, wizard, viewer, editorPart));
-				} catch (CoreException e) {
-					ExceptionHandler.handleException(e);
-				}
+			for (IConfigurationElement exporterElement : configurationElements.values()) {
+				registerExporterToMenu(viewer, exportMenu, exporterElement);
 			}
 			menu.add(exportMenu);
 		}
 	}
 	
 	private void buildImporterMenu(IMenuManager menu, GraphicalViewer viewer) {
-		Collection<IConfigurationElement> importerElements =
-				JiemamyCorePlugin.getImporterResolver().getExtensionConfigurationElements().values();
-		if (importerElements.size() > 0) {
+		ExtensionResolver<Importer<ImportConfig>> importerResolver = JiemamyCorePlugin.getImporterResolver();
+		Map<String, IConfigurationElement> configurationElements = importerResolver.getExtensionConfigurationElements();
+		if (configurationElements.size() > 0) {
 			MenuManager importMenu = new MenuManager("インポート(&I)"); // RESOURCE
-			for (IConfigurationElement importerElement : importerElements) {
-				try {
-					@SuppressWarnings("unchecked")
-					Importer<ImportConfig> importer =
-							(Importer<ImportConfig>) importerElement.createExecutableExtension("class");
-					@SuppressWarnings("unchecked")
-					ImporterWizard<Importer<ImportConfig>, ImportConfig> wizard =
-							(ImporterWizard<Importer<ImportConfig>, ImportConfig>) importerElement
-								.createExecutableExtension("wizard");
-					importMenu.add(new ImportAction(importer, wizard, viewer, editorPart));
-				} catch (CoreException e) {
-					ExceptionHandler.handleException(e);
-				}
+			for (IConfigurationElement importerElement : configurationElements.values()) {
+				registerImporterToMenu(viewer, importMenu, importerElement);
 			}
 			menu.add(importMenu);
 		}
@@ -229,4 +208,34 @@
 	private ActionRegistry getActionRegistry() {
 		return actionRegistry;
 	}
+	
+	private void registerExporterToMenu(GraphicalViewer viewer, MenuManager menu, IConfigurationElement element) {
+		try {
+			@SuppressWarnings("unchecked")
+			Exporter<ExportConfig> exporter = (Exporter<ExportConfig>) element.createExecutableExtension("class");
+			@SuppressWarnings("unchecked")
+			ExporterWizard<Exporter<ExportConfig>, ExportConfig> wizard =
+					(ExporterWizard<Exporter<ExportConfig>, ExportConfig>) element.createExecutableExtension("wizard");
+			menu.add(new ExportAction(exporter, wizard, viewer, editorPart));
+		} catch (ClassCastException e) {
+			ExceptionHandler.handleException(e);
+		} catch (CoreException e) {
+			ExceptionHandler.handleException(e);
+		}
+	}
+	
+	private void registerImporterToMenu(GraphicalViewer viewer, MenuManager menu, IConfigurationElement element) {
+		try {
+			@SuppressWarnings("unchecked")
+			Importer<ImportConfig> importer = (Importer<ImportConfig>) element.createExecutableExtension("class");
+			@SuppressWarnings("unchecked")
+			ImporterWizard<Importer<ImportConfig>, ImportConfig> wizard =
+					(ImporterWizard<Importer<ImportConfig>, ImportConfig>) element.createExecutableExtension("wizard");
+			menu.add(new ImportAction(importer, wizard, viewer, editorPart));
+		} catch (ClassCastException e) {
+			ExceptionHandler.handleException(e);
+		} catch (CoreException e) {
+			ExceptionHandler.handleException(e);
+		}
+	}
 }



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