]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.views.swt/src/org/simantics/views/swt/WizardFactory.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.views.swt / src / org / simantics / views / swt / WizardFactory.java
diff --git a/bundles/org.simantics.views.swt/src/org/simantics/views/swt/WizardFactory.java b/bundles/org.simantics.views.swt/src/org/simantics/views/swt/WizardFactory.java
new file mode 100644 (file)
index 0000000..72ecf1c
--- /dev/null
@@ -0,0 +1,56 @@
+package org.simantics.views.swt;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IConfigurationElement;\r
+import org.eclipse.core.runtime.IExecutableExtension;\r
+import org.eclipse.core.runtime.IExecutableExtensionFactory;\r
+import org.eclipse.core.runtime.IStatus;\r
+import org.eclipse.core.runtime.Status;\r
+\r
+/**\r
+ * \r
+ * @author Antti Villberg\r
+ */\r
+public class WizardFactory implements IExecutableExtensionFactory, IExecutableExtension {\r
+    \r
+    private IConfigurationElement config;\r
+\r
+    private String id;\r
+\r
+    private String propertyName;\r
+\r
+    public WizardFactory() {\r
+        // do nothing\r
+    }\r
+\r
+    private Object configure(Object obj) throws CoreException {\r
+        if (obj instanceof IExecutableExtension) {\r
+            ((IExecutableExtension) obj).setInitializationData(config, propertyName, null);\r
+        }\r
+        return obj;\r
+    }\r
+\r
+    @Override\r
+    public Object create() throws CoreException {\r
+       \r
+       return configure(new ModelledWizard(id));\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void setInitializationData(IConfigurationElement config, String propertyName, Object data)\r
+    throws CoreException {\r
+        //System.out.println("setInitializationData: " + config + ", " + propertyName + ", " + data);\r
+\r
+        if (data instanceof String) {\r
+            id = (String) data;\r
+        } else {\r
+            throw new CoreException(new Status(IStatus.ERROR,\r
+                    Activator.PLUGIN_ID, 0,\r
+                    "Data argument must be a String for " + getClass(), null)); //$NON-NLS-1$\r
+        }\r
+        this.config = config;\r
+        this.propertyName = propertyName;\r
+    }\r
+\r
+}\r