svnno****@sourc*****
svnno****@sourc*****
2009年 2月 14日 (土) 11:15:06 JST
Revision: 2668 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2668 Author: daisuke_m Date: 2009-02-14 11:15:06 +0900 (Sat, 14 Feb 2009) Log Message: ----------- Jiemamyインスタンスは複数のRootModelを持てないので、Jiemamyインスタンスの管理者を「プラグイン」から「エディタ」に変更。 (前のままだと、2つのエディタを開くと、同じRootModelを共有してしまう) Modified Paths: -------------- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java -------------- next part -------------- Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java 2009-02-14 01:45:07 UTC (rev 2667) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java 2009-02-14 02:15:06 UTC (rev 2668) @@ -31,9 +31,6 @@ import org.osgi.framework.BundleContext; import org.seasar.eclipse.common.util.ImageManager; -import org.jiemamy.Artemis; -import org.jiemamy.ArtemisView; -import org.jiemamy.Jiemamy; import org.jiemamy.composer.Exporter; import org.jiemamy.composer.Importer; import org.jiemamy.dialect.Dialect; @@ -72,8 +69,6 @@ /** 拡張ポイントに設定されたModelValidatorのリゾルバ */ private static ExtensionResolver<ModelValidator> validatorResolver; - private static Jiemamy jiemamy; - /** * Returns the shared instance @@ -122,10 +117,6 @@ return importerResolver; } - public static Jiemamy getJiemamy() { - return jiemamy; - } - /** * 設定を取得する。 * @@ -167,7 +158,6 @@ importerResolver = new ExtensionResolver<Importer>(PLUGIN_ID, "composers", "importer", "class"); exporterResolver = new ExtensionResolver<Exporter>(PLUGIN_ID, "composers", "exporter", "class"); validatorResolver = new ExtensionResolver<ModelValidator>(PLUGIN_ID, "validators", "dialect", "class"); - jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); } /** @@ -175,7 +165,6 @@ */ @Override public void stop(BundleContext context) throws Exception { - jiemamy = null; dialectResolver = null; importerResolver = null; exporterResolver = null; Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-14 01:45:07 UTC (rev 2667) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-14 02:15:06 UTC (rev 2668) @@ -78,9 +78,11 @@ import org.eclipse.ui.IEditorActionBarContributor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.WorkspaceModifyOperation; @@ -89,8 +91,12 @@ import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.Artemis; +import org.jiemamy.ArtemisView; +import org.jiemamy.Jiemamy; import org.jiemamy.eclipse.editor.editpart.DiagramEditPartFactory; import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; import org.jiemamy.eclipse.editor.editpart.OutlineTreeEditPartFactory; @@ -98,7 +104,6 @@ import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.JiemamySerializer; /** * ERダイアグラムエディタ。 @@ -106,6 +111,8 @@ */ public class DiagramEditor extends GraphicalEditorWithFlyoutPalette implements IResourceChangeListener, JiemamyEditor { + private static Logger logger = LoggerFactory.getLogger(DiagramEditor.class); + /** Palette component, holding the tools and shapes. */ private static PaletteRoot paletteModel; @@ -133,21 +140,21 @@ /** ルートEditPart(コントローラ) */ private ScalableRootEditPart rootEditPart = new ScalableRootEditPart(); - private JiemamySerializer serializer = JiemamyPlugin.getJiemamy().getSerializer(); - /** エディタのルートモデル */ private RootModel rootModel; private boolean savePreviouslyNeeded = false; + private Jiemamy jiemamy; + /** * インスタンスを生成する。 - * */ public DiagramEditor() { setEditDomain(new DefaultEditDomain(this)); ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + logger.debug("constructed"); } /** @@ -174,6 +181,7 @@ public void dispose() { ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); super.dispose(); + logger.debug("disposed"); } /** @@ -187,7 +195,7 @@ out = new ByteArrayOutputStream(); IFile file = ((IFileEditorInput) getEditorInput()).getFile(); - serializer.serialize(rootModel, out); + jiemamy.getSerializer().serialize(rootModel, out); in = new ByteArrayInputStream(out.toByteArray()); @@ -226,7 +234,7 @@ PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(in); - serializer.serialize(rootModel, out); + jiemamy.getSerializer().serialize(rootModel, out); out.close(); @@ -277,6 +285,18 @@ * {@inheritDoc} */ @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + super.init(site, input); + + jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + + logger.debug("initialized"); + } + + /** + * {@inheritDoc} + */ + @Override public boolean isSaveAsAllowed() { return true; } @@ -325,6 +345,7 @@ IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); ((JmContributor) contributor).selectCombo(rootModel); // Thanks to Naokiさん + logger.debug("setFocus"); } /** @@ -461,7 +482,7 @@ // 最上位モデルの設定 IFile file = ((IFileEditorInput) getEditorInput()).getFile(); try { - rootModel = serializer.deserialize(file.getContents()); + rootModel = jiemamy.getSerializer().deserialize(file.getContents()); // rootModel.setDisplayMode(DatabaseModel.MODE_PHYSICAL_ATTRTYPE); } catch (SerializationException e) { ExceptionHandler.handleException(e, "Data file is broken."); @@ -469,7 +490,7 @@ ExceptionHandler.handleException(e); } finally { if (rootModel == null) { - rootModel = JiemamyPlugin.getJiemamy().getFactory().getRootModel(); + rootModel = jiemamy.getFactory().getRootModel(); } if (rootModel.getAdapter(DiagramPresentations.class).size() == 0) { DiagramPresentationModel presentationModel = Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2009-02-14 01:45:07 UTC (rev 2667) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/MultiDiagramEditor.java 2009-02-14 02:15:06 UTC (rev 2668) @@ -44,12 +44,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.Artemis; +import org.jiemamy.ArtemisView; +import org.jiemamy.Jiemamy; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.JiemamySerializer; import org.jiemamy.utils.CollectionsUtil; /** @@ -60,13 +61,13 @@ private static Logger logger = LoggerFactory.getLogger(MultiDiagramEditor.class); - protected JiemamySerializer serializer = JiemamyPlugin.getJiemamy().getSerializer(); - private List<DiagramEditor2> editors = CollectionsUtil.newArrayList(); /** エディタのルートモデル */ private RootModel rootModel; + private Jiemamy jiemamy; + /** * インスタンスを生成する。 @@ -93,7 +94,7 @@ PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(in); - serializer.serialize(rootModel, out); + jiemamy.getSerializer().serialize(rootModel, out); out.close(); @@ -135,7 +136,7 @@ PipedInputStream in = new PipedInputStream(); PipedOutputStream out = new PipedOutputStream(in); - serializer.serialize(rootModel, out); + jiemamy.getSerializer().serialize(rootModel, out); out.close(); @@ -176,10 +177,12 @@ public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); + jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + // 最上位モデルの設定 IFile file = ((IFileEditorInput) input).getFile(); try { - rootModel = serializer.deserialize(file.getContents()); + rootModel = jiemamy.getSerializer().deserialize(file.getContents()); // rootModel.setDisplayMode(DatabaseModel.MODE_PHYSICAL_ATTRTYPE); } catch (SerializationException e) { ExceptionHandler.handleException(e, "Data file is broken."); @@ -187,7 +190,7 @@ ExceptionHandler.handleException(e); } finally { if (rootModel == null) { - rootModel = JiemamyPlugin.getJiemamy().getFactory().getRootModel(); + rootModel = jiemamy.getFactory().getRootModel(); } if (rootModel.getAdapter(DiagramPresentations.class).size() == 0) { DiagramPresentationModel presentationModel = Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2009-02-14 01:45:07 UTC (rev 2667) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2009-02-14 02:15:06 UTC (rev 2668) @@ -33,8 +33,9 @@ import org.eclipse.ui.dialogs.WizardNewFileCreationPage; import org.eclipse.ui.ide.IDE; +import org.jiemamy.Artemis; +import org.jiemamy.ArtemisView; import org.jiemamy.Jiemamy; -import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.model.RootModel; @@ -137,14 +138,13 @@ */ @Override protected InputStream getInitialContents() { - Jiemamy jiemamy = JiemamyPlugin.getJiemamy(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); RootModel rootModel = jiemamy.getFactory().getRootModel(); ByteArrayOutputStream out = null; try { out = new ByteArrayOutputStream(); jiemamy.getSerializer().serialize(rootModel, out); - return new ByteArrayInputStream(out.toByteArray()); } catch (Exception e) { ExceptionHandler.handleException(e);