]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fixed code breakage caused by platform issue #7728 changes 42/1442/2
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 9 Feb 2018 09:27:08 +0000 (11:27 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 9 Feb 2018 11:53:05 +0000 (13:53 +0200)
refs #7759

Change-Id: I2a0be56450ac278e2102dc9880e71acba762f34a

bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/functions/WizardFunctionsExportPage.java
bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/models/WizardModelsExportPage.java
bundles/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/wizards/modules/WizardModulesExportPage.java

index 785df451b238b71400763accd0e3e14d062179d8..372fe62162e7f58e2126d908bcd3a31f48515d21 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.sysdyn.ui.wizards.functions;\r
 \r
 import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
 \r
+import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Path;\r
+import org.eclipse.core.runtime.Status;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.PixelConverter;\r
 import org.eclipse.jface.viewers.ISelection;\r
@@ -29,22 +29,23 @@ import org.eclipse.swt.widgets.Tree;
 import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
 import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
 import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.Files;\r
-import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.primitiverequest.PossibleRelatedValue;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.TransferableGraphRequest2;\r
+import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest;\r
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.graph.db.TGStatusMonitor;\r
+import org.simantics.graph.db.TransferableGraphSource;\r
+import org.simantics.graph.db.TransferableGraphs;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
-import org.simantics.utils.datastructures.Pair;\r
 \r
 public class WizardFunctionsExportPage extends WizardPage {\r
        \r
@@ -171,52 +172,36 @@ public class WizardFunctionsExportPage extends WizardPage {
                Label title = new Label(workArea, SWT.NONE);\r
                title.setText("Select Function Library to export:");\r
 \r
-               try {\r
-                       Resource input = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+               Resource input = SimanticsUI.getProject().get();\r
 \r
-                               @Override\r
-                               public Resource perform(ReadGraph graph)\r
-                                               throws DatabaseException {\r
-                                       Resource model = SimanticsUI.getProject().get();\r
-                                       return model;\r
-                               }\r
+               functionLibraryExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+                               "displaySelectors", "displayFilter").values(false, false), null, workArea, SWT.BORDER | SWT.SINGLE);\r
 \r
-                       });\r
+               functionLibraryExplorer\r
+               .setBrowseContexts(SysdynResource.URIs.FunctionTree);\r
 \r
-                       functionLibraryExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
-                                       "displaySelectors", "displayFilter").values(false, false), null, workArea, SWT.BORDER | SWT.SINGLE);\r
+               functionLibraryExplorer.finish();\r
 \r
-                       functionLibraryExplorer\r
-                       .setBrowseContexts(SysdynResource.URIs.FunctionTree);\r
+               functionLibraryExplorer.setInput(null, input);\r
 \r
-                       functionLibraryExplorer.finish();\r
-\r
-                       functionLibraryExplorer.setInput(null, input);\r
-\r
-                       GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
-                                       functionLibraryExplorer);\r
-                       \r
-                       ((Tree)functionLibraryExplorer.getExplorer().getControl()).addSelectionListener(new SelectionListener() {\r
-                               \r
-                               @Override\r
-                               public void widgetSelected(SelectionEvent e) {\r
-                                       setMessage(null);\r
-                                       selectionMade = true;\r
-                                       validatePage();\r
-                               }\r
-                               @Override\r
-                               public void widgetDefaultSelected(SelectionEvent e) {\r
-                                       setMessage(null);\r
-                                       selectionMade = true;\r
-                                       validatePage();\r
-                               }\r
-                       });\r
-\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
+               GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+                               functionLibraryExplorer);\r
 \r
+               ((Tree)functionLibraryExplorer.getExplorer().getControl()).addSelectionListener(new SelectionListener() {\r
 \r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e) {\r
+                               setMessage(null);\r
+                               selectionMade = true;\r
+                               validatePage();\r
+                       }\r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e) {\r
+                               setMessage(null);\r
+                               selectionMade = true;\r
+                               validatePage();\r
+                       }\r
+               });\r
        }\r
     \r
        //Set filePathField active\r
@@ -295,30 +280,22 @@ public class WizardFunctionsExportPage extends WizardPage {
                                }\r
                                \r
                        });\r
-               } catch (DatabaseException e1) {\r
-                       e1.printStackTrace();\r
+               } catch (DatabaseException ex) {\r
+                       Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
+                                       "Failed to read name of function library " + functionLibrary + ", see exception for details.", ex));\r
                }\r
                if(name == null) return false;\r
-       \r
+\r
                SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
-                       \r
                        @Override\r
                        public void run(ReadGraph graph) throws DatabaseException {\r
-                               Layer0 l0 = Layer0.getInstance(graph);\r
-                               String name = graph.syncRequest(new PossibleRelatedValue<String>(functionLibrary, l0.HasName, Bindings.STRING ));\r
-                               ArrayList<Pair<Resource, String>> roots = new ArrayList<Pair<Resource, String>>();\r
-                               roots.add(Pair.make(functionLibrary, name));\r
-                               TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest2(roots, functionLibrary));\r
-\r
-                               try {\r
-                                       Files.createFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class), tg);\r
-                               } catch (RuntimeBindingConstructionException e) {\r
-                                       e.printStackTrace();\r
-                               } catch (IOException e) {\r
-                                       e.printStackTrace();\r
+                               TransferableGraphConfiguration2 conf = new TransferableGraphConfiguration2(graph, functionLibrary);\r
+                               try (TransferableGraphSource tgs = graph.syncRequest( new ModelTransferableGraphSourceRequest(conf) )) {\r
+                                       TransferableGraphs.writeTransferableGraph(graph, tgs, new File(selected), TGStatusMonitor.NULL_MONITOR);\r
+                               } catch (Exception e) {\r
+                                       Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
+                                                       "Failed to export function library, see exception for details.", e));\r
                                }\r
-\r
-                               \r
                        }\r
                });\r
         \r
@@ -355,7 +332,8 @@ public class WizardFunctionsExportPage extends WizardPage {
                                        return;\r
                                }\r
                        } catch (DatabaseException e) {\r
-                               e.printStackTrace();\r
+                               Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
+                                               "Failed to validate wizard page contents, see exception for details.", e));\r
                        }\r
                }\r
                \r
index ae1f0e8ed81ff671c511e06052d4a2c3dac3c2f5..f53eb7ec8138528d5f57f35e8933c3ccfd5d851f 100644 (file)
@@ -1,10 +1,10 @@
 package org.simantics.sysdyn.ui.wizards.models;\r
 \r
 import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
 \r
+import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Path;\r
+import org.eclipse.core.runtime.Status;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.PixelConverter;\r
 import org.eclipse.jface.viewers.ISelection;\r
@@ -28,22 +28,19 @@ import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.Tree;\r
 import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
 import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.Files;\r
-import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.common.primitiverequest.PossibleRelatedValue;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.TransferableGraphRequest2;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.graph.representation.TransferableGraph1;\r
-import org.simantics.layer0.Layer0;\r
+import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest;\r
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2;\r
+import org.simantics.graph.db.TGStatusMonitor;\r
+import org.simantics.graph.db.TransferableGraphSource;\r
+import org.simantics.graph.db.TransferableGraphs;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
-import org.simantics.utils.datastructures.Pair;\r
 \r
 public class WizardModelsExportPage extends WizardPage {\r
        \r
@@ -167,59 +164,43 @@ public class WizardModelsExportPage extends WizardPage {
                });\r
                \r
        }\r
-       \r
+\r
        private void createTree(Composite workArea){\r
-               \r
+\r
                //set label for tree\r
                Label title = new Label(workArea, SWT.NONE);\r
                title.setText("Select Model to export:");\r
 \r
-               try {\r
-                       Resource input = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+               Resource input = SimanticsUI.getProject().get();\r
 \r
-                               @Override\r
-                               public Resource perform(ReadGraph graph)\r
-                                               throws DatabaseException {\r
-                                       Resource model = SimanticsUI.getProject().get();\r
-                                       return model;\r
-                               }\r
+               modelExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+                               "displaySelectors", "displayFilter").values(false, false), null, workArea, SWT.BORDER | SWT.SINGLE);\r
 \r
-                       });\r
+               modelExplorer\r
+               .setBrowseContexts(SysdynResource.URIs.ImportModuleTree);\r
 \r
-                       modelExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
-                                       "displaySelectors", "displayFilter").values(false, false), null, workArea, SWT.BORDER | SWT.SINGLE);\r
+               modelExplorer.finish();\r
 \r
-                       modelExplorer\r
-                       .setBrowseContexts(SysdynResource.URIs.ImportModuleTree);\r
+               modelExplorer.setInput(null, input);\r
 \r
-                       modelExplorer.finish();\r
+               GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+                               modelExplorer);\r
 \r
-                       modelExplorer.setInput(null, input);\r
-\r
-                       GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
-                                       modelExplorer);\r
-                       \r
-                       ((Tree)modelExplorer.getExplorer().getControl()).addSelectionListener(new SelectionListener() {\r
-                               \r
-                               @Override\r
-                               public void widgetSelected(SelectionEvent e) {\r
-                                       selectionMade = true;\r
-                                       validatePage();\r
-                               }\r
-                               @Override\r
-                               public void widgetDefaultSelected(SelectionEvent e) {\r
-                                       selectionMade = true;\r
-                                       validatePage();\r
-                               }\r
-                       });\r
-                       \r
-\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
+               ((Tree)modelExplorer.getExplorer().getControl()).addSelectionListener(new SelectionListener() {\r
 \r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e) {\r
+                               selectionMade = true;\r
+                               validatePage();\r
+                       }\r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e) {\r
+                               selectionMade = true;\r
+                               validatePage();\r
+                       }\r
+               });\r
        }\r
-       \r
+\r
        //Set filePathField active\r
        public void setVisible(boolean visible) {\r
                super.setVisible(visible);\r
@@ -241,7 +222,7 @@ public class WizardModelsExportPage extends WizardPage {
                \r
                File path = new File(dirName);\r
                if (path.exists()) {\r
-                       dialog.setFilterPath(new Path(dirName).toOSString());   \r
+                       dialog.setFilterPath(new Path(dirName).toOSString());\r
                }\r
                \r
                String selectedFile = dialog.open();\r
@@ -276,7 +257,7 @@ public class WizardModelsExportPage extends WizardPage {
                final String selected = previouslyBrowsedFile;\r
                if(selected == null) return false;\r
                \r
-               selectedModel= getExplorerResource(modelExplorer, Resource.class);\r
+               selectedModel = getExplorerResource(modelExplorer, Resource.class);\r
                if(selectedModel == null)\r
                        return false;\r
         \r
@@ -287,20 +268,13 @@ public class WizardModelsExportPage extends WizardPage {
                        \r
                        @Override\r
                        public void run(ReadGraph graph) throws DatabaseException {\r
-                               Layer0 l0 = Layer0.getInstance(graph);\r
-                               String name = graph.syncRequest(new PossibleRelatedValue<String>(selectedModel, l0.HasName, Bindings.STRING ));\r
-                               ArrayList<Pair<Resource, String>> roots = new ArrayList<Pair<Resource, String>>();\r
-                               roots.add(Pair.make(selectedModel, name));\r
-                               TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest2(roots, selectedModel));\r
-\r
-                               try {\r
-                                       Files.createFile(new File(selected), Bindings.getBindingUnchecked(TransferableGraph1.class), tg);\r
-                               } catch (RuntimeBindingConstructionException e) {\r
-                                       e.printStackTrace();\r
-                               } catch (IOException e) {\r
-                                       e.printStackTrace();\r
+                               TransferableGraphConfiguration2 conf = new TransferableGraphConfiguration2(graph, selectedModel);\r
+                               try (TransferableGraphSource tgs = graph.syncRequest( new ModelTransferableGraphSourceRequest(conf) )) {\r
+                                       TransferableGraphs.writeTransferableGraph(graph, tgs, new File(selected), TGStatusMonitor.NULL_MONITOR);\r
+                               } catch (Exception e) {\r
+                                       Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
+                                                       "Failed to export model, see exception for details.", e));\r
                                }\r
-                               \r
                        }\r
                });\r
 \r
index 3625dd9d770aadcff597cd59a1266f3c45b0bff5..e57a8210fdaedd0faf6cdae91adeb3b5c4ef6edf 100644 (file)
@@ -1,11 +1,12 @@
 package org.simantics.sysdyn.ui.wizards.modules;\r
 \r
 import java.io.File;\r
-import java.io.IOException;\r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
 \r
+import org.eclipse.core.runtime.IStatus;\r
 import org.eclipse.core.runtime.Path;\r
+import org.eclipse.core.runtime.Status;\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.PixelConverter;\r
 import org.eclipse.jface.viewers.ISelection;\r
@@ -30,24 +31,25 @@ import org.eclipse.swt.widgets.Tree;
 import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
 import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
 import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.Files;\r
-import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.primitiverequest.PossibleRelatedValue;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.TransferableGraphRequest2;\r
+import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest;\r
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.graph.representation.TransferableGraph1;\r
+import org.simantics.graph.db.TGStatusMonitor;\r
+import org.simantics.graph.db.TransferableGraphSource;\r
+import org.simantics.graph.db.TransferableGraphs;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 import org.simantics.utils.datastructures.Pair;\r
@@ -176,53 +178,38 @@ public class WizardModulesExportPage extends WizardPage {
                Label title = new Label(workArea, SWT.NONE);\r
                title.setText("Select Module to export:");\r
 \r
-               try {\r
-                       Resource input = SimanticsUI.getSession().syncRequest(new Read<Resource>() {\r
+               Resource input = SimanticsUI.getProject().get();\r
 \r
-                               @Override\r
-                               public Resource perform(ReadGraph graph)\r
-                                               throws DatabaseException {\r
-                                       Resource model = SimanticsUI.getProject().get();\r
-                                       return model;\r
-                               }\r
+               modelExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+                               "displaySelectors", "displayFilter").values(false, false), null, workArea, SWT.BORDER | SWT.SINGLE);\r
 \r
-                       });\r
+               modelExplorer\r
+               .setBrowseContexts(SysdynResource.URIs.ExportModuleTree);\r
 \r
-                       modelExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
-                                       "displaySelectors", "displayFilter").values(false, false), null, workArea, SWT.BORDER | SWT.SINGLE);\r
+               modelExplorer.finish();\r
 \r
-                       modelExplorer\r
-                       .setBrowseContexts(SysdynResource.URIs.ExportModuleTree);\r
+               modelExplorer.setInput(null, input);\r
 \r
-                       modelExplorer.finish();\r
-                       \r
-                       modelExplorer.setInput(null, input);\r
+               GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+                               modelExplorer);\r
 \r
-                       GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
-                                       modelExplorer);\r
-                       \r
-                       ((Tree)modelExplorer.getExplorer().getControl()).addSelectionListener(new SelectionListener() {\r
-                               \r
-                               @Override\r
-                               public void widgetSelected(SelectionEvent e) {\r
-                                       setMessage(null);\r
-                                       selectionMade = true;\r
-                                       validatePage();\r
-                               }\r
-                               @Override\r
-                               public void widgetDefaultSelected(SelectionEvent e) {\r
-                                       setMessage(null);\r
-                                       selectionMade = true;\r
-                                       validatePage();\r
-                               }\r
-                       });\r
-\r
-               } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
-               }\r
+               ((Tree)modelExplorer.getExplorer().getControl()).addSelectionListener(new SelectionListener() {\r
 \r
+                       @Override\r
+                       public void widgetSelected(SelectionEvent e) {\r
+                               setMessage(null);\r
+                               selectionMade = true;\r
+                               validatePage();\r
+                       }\r
+                       @Override\r
+                       public void widgetDefaultSelected(SelectionEvent e) {\r
+                               setMessage(null);\r
+                               selectionMade = true;\r
+                               validatePage();\r
+                       }\r
+               });\r
        }\r
-    \r
+\r
        //Set filePathField active\r
        public void setVisible(boolean visible) {\r
                super.setVisible(visible);\r
@@ -307,7 +294,7 @@ public class WizardModulesExportPage extends WizardPage {
                                        ArrayList<String> dependencies = null;\r
                                        for(Resource r : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Module))) {\r
                                                if(dependencies == null)\r
-                                                       dependencies = new ArrayList<String>();\r
+                                                       dependencies = new ArrayList<>();\r
                                                String name = NameUtils.getSafeName(graph, r);\r
                                                String instanceOf = NameUtils.getSafeName(graph, graph.getSingleObject(r, l0.InstanceOf));\r
                                                dependencies.add(name + " : " + instanceOf);\r
@@ -331,15 +318,10 @@ public class WizardModulesExportPage extends WizardPage {
                        \r
                        @Override\r
                        public void run(ReadGraph graph) throws DatabaseException {\r
-                               Layer0 l0 = Layer0.getInstance(graph);\r
-                               \r
                                final Resource component = selectedModule;\r
                                //final Resource component = graph.getPossibleObject(modulesymbol, mr.SymbolToComponentType);\r
                                if (component == null || !graph.hasStatement(component, Layer0.getInstance(graph).PartOf))\r
                                        return;\r
-                               String name = graph.syncRequest(new PossibleRelatedValue<String>(component, l0.HasName, Bindings.STRING ));\r
-                               final ArrayList<Pair<Resource, String>> roots = new ArrayList<Pair<Resource, String>>();\r
-                               roots.add(Pair.make(component, name));\r
 \r
                                graph.asyncRequest(new WriteRequest() {\r
 \r
@@ -361,7 +343,7 @@ public class WizardModulesExportPage extends WizardPage {
                                                        graph.claim(configuration, l0.PartOf, l0.ConsistsOf, component);\r
                                                        graph.claim(modulesymbol, l0.PartOf, l0.ConsistsOf, component);\r
 \r
-                                                       export(graph, selected, roots, component);\r
+                                                       export(graph, selected, component);\r
 \r
                                                        graph.deny(configuration, l0.PartOf);\r
                                                        graph.deny(modulesymbol, l0.PartOf);\r
@@ -369,9 +351,11 @@ public class WizardModulesExportPage extends WizardPage {
                                                        graph.claim(modulesymbol, l0.PartOf, l0.ConsistsOf, previousPartof);\r
                                                } else {\r
                                                        // Normal export\r
-                                                       export(graph, selected, roots, component);\r
+                                                       export(graph, selected, component);\r
                                                }\r
                                        }\r
+                               }, e -> {\r
+                                       Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to export module, see exception for details.", e));\r
                                });\r
 \r
                        }\r
@@ -380,43 +364,45 @@ public class WizardModulesExportPage extends WizardPage {
                return true;\r
        }\r
        \r
-       private void export(WriteGraph graph, String path, ArrayList<Pair<Resource, String>> roots, Resource component) {\r
-               \r
+       private void export(WriteGraph graph, String path, Resource component) throws DatabaseException {\r
                // FIXME: Enumeration replacement handling like this is not suitable.\r
-               try {\r
-                       Layer0 l0 = Layer0.getInstance(graph);\r
-                       SysdynResource sr = SysdynResource.getInstance(graph);\r
-                       StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
 \r
-                       Resource configuration = graph.getPossibleObject(component, sr2.IsDefinedBy);\r
-                       ArrayList<Pair<Resource, Resource>> replacements = new ArrayList<Pair<Resource, Resource>>();\r
+               Layer0 l0 = Layer0.getInstance(graph);\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
 \r
-                       for(Resource enumeration : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {\r
-                               if(graph.hasStatement(enumeration, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
-                                       for(Resource replacement : graph.getObjects(enumeration, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
-                                               replacements.add(new Pair<Resource, Resource>(enumeration, replacement));\r
-                                       }\r
+               Resource configuration = graph.getPossibleObject(component, sr2.IsDefinedBy);\r
+               ArrayList<Pair<Resource, Resource>> replacements = new ArrayList<>();\r
+\r
+               for(Resource enumeration : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {\r
+                       if(graph.hasStatement(enumeration, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
+                               for(Resource replacement : graph.getObjects(enumeration, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
+                                       replacements.add(Pair.make(enumeration, replacement));\r
                                }\r
                        }\r
-                       \r
-                       for(Pair<Resource,Resource> replacement : replacements)\r
-                               graph.deny(replacement.first, sr.Redeclaration_replacedEnumeration_Inverse, replacement.second);\r
-                       \r
-                       TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest2(roots, component));\r
-                       Files.createFile(new File(path), Bindings.getBindingUnchecked(TransferableGraph1.class), tg);\r
-                       \r
-                       for(Pair<Resource,Resource> replacement : replacements)\r
-                               graph.claim(replacement.first, sr.Redeclaration_replacedEnumeration_Inverse, replacement.second);\r
+               }\r
 \r
-               } catch (RuntimeBindingConstructionException e) {\r
-                       e.printStackTrace();\r
-               } catch (IOException e) {\r
-                       e.printStackTrace();\r
+               for(Pair<Resource,Resource> replacement : replacements)\r
+                       graph.deny(replacement.first, sr.Redeclaration_replacedEnumeration_Inverse, replacement.second);\r
+\r
+               try {\r
+                       TransferableGraphConfiguration2 conf = new TransferableGraphConfiguration2(graph, component);\r
+                       try (TransferableGraphSource tgs = graph.syncRequest( new ModelTransferableGraphSourceRequest(conf) )) {\r
+                               TransferableGraphs.writeTransferableGraph(graph, tgs, new File(path), TGStatusMonitor.NULL_MONITOR);\r
+                       } catch (Exception e) {\r
+                               Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
+                                               "Failed to export module, see exception for details.", e));\r
+                       }\r
                } catch (DatabaseException e) {\r
-                       e.printStackTrace();\r
+                       throw e;\r
+               } catch (Exception e) {\r
+                       throw new DatabaseException(e);\r
+               } finally {\r
+                       for(Pair<Resource,Resource> replacement : replacements)\r
+                               graph.claim(replacement.first, sr.Redeclaration_replacedEnumeration_Inverse, replacement.second);\r
                }\r
        }\r
-       \r
+\r
        class ContainsDependenciesException extends DatabaseException {\r
                private static final long serialVersionUID = -1533706136673146020L;\r
                \r
@@ -462,7 +448,8 @@ public class WizardModulesExportPage extends WizardPage {
                                        return;\r
                                }\r
                        } catch (DatabaseException e) {\r
-                               e.printStackTrace();\r
+                               Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,\r
+                                               "Failed to validate wizard page contents, see exception for details.", e));\r
                        }\r
                }\r
                \r