X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2FResourceEditorInputFactory2.java;fp=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fworkbench%2FResourceEditorInputFactory2.java;h=b22a8b9b440a6b012d092b692ee27d5fcaa757a6;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/workbench/ResourceEditorInputFactory2.java b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/ResourceEditorInputFactory2.java
new file mode 100644
index 000000000..b22a8b9b4
--- /dev/null
+++ b/bundles/org.simantics.ui/src/org/simantics/ui/workbench/ResourceEditorInputFactory2.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.ui.workbench;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+import org.simantics.utils.ui.ErrorLogger;
+import org.simantics.utils.ui.workbench.StringMemento;
+
+/**
+ * Factory for restoring a ResourceEditorInput2
. The stored
+ * representation of a ResourceEditorInput2
remembers a reference
+ * to the input resource, which is a string ID, a model URI and an RVI.
+ *
+ *
+ * The workbench will automatically create instances of this class as required. + * It is not intended to be instantiated or subclassed by the client. + *
+ */ +public class ResourceEditorInputFactory2 implements IElementFactory { + /** + * Factory id. The workbench plug-in registers a factory by this name + * with the "org.eclipse.ui.elementFactories" extension point. + */ + private static final String ID_FACTORY = "org.simantics.ui.workbench.resourceEditorInputFactory2"; //$NON-NLS-1$ + + /** + */ + public static final String TAG_RESOURCE_ID = ResourceEditorInputFactory.TAG_RESOURCE_ID; //$NON-NLS-1$ + + /** + */ + public static final String TAG_EDITOR_ID = ResourceEditorInputFactory.TAG_EDITOR_ID; //$NON-NLS-1$ + + /** + * + */ + public static final String TAG_MODEL_ID = "modelId"; + + /** + * + */ + public static final String TAG_RVI = "rvi"; + + /** Tag ID for node that contains external data */ + public static final String TAG_EXTERNAL_MEMENTO_ID = "external"; //$NON-NLS-1$ + + /** + * Creates a new factory. + */ + public ResourceEditorInputFactory2() { + } + + /* (non-Javadoc) + * Method declared on IElementFactory. + */ + @Override + public IAdaptable createElement(IMemento memento) { + // Get the resource id array. + IMemento[] children = memento.getChildren(TAG_RESOURCE_ID); + if (children.length != 1) + return null; + + List