]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewTypicalDiagramInstance.java
Sync git svn branch with SVN repository r33249.
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / typicals / NewTypicalDiagramInstance.java
index 2bb0f9dfc706cbdd97261c89e2b6ca70f9ba2af8..25fd46e69dd4fb914a18c78b989dcb34feacac10 100644 (file)
@@ -47,47 +47,44 @@ public class NewTypicalDiagramInstance implements ActionFactory {
 \r
     @Override\r
     public Runnable create(Object target_) {\r
-        final Resource target = (Resource) target_;\r
-        return new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                Job job = new DatabaseJob("Instantiate Typical") {\r
-                    @Override\r
-                    protected IStatus run(IProgressMonitor monitor) {\r
-                        monitor.beginTask("Instantiate Typical...", IProgressMonitor.UNKNOWN);\r
+        Resource target = (Resource) target_;\r
+        return () -> {\r
+            Job job = new DatabaseJob("Instantiate Typical") {\r
+                @Override\r
+                protected IStatus run(IProgressMonitor monitor) {\r
+                    monitor.beginTask("Instantiate Typical...", IProgressMonitor.UNKNOWN);\r
 \r
-                        final Session session = Simantics.getSession();\r
-                        session.markUndoPoint();\r
-                        try {\r
-                            final AtomicReference<Resource> model = new AtomicReference<Resource>();\r
-                            Function2<Resource, Resource, Resource> instantiator = session.syncRequest(new UniqueRead<Function2<Resource, Resource, Resource>>() {\r
-                                @Override\r
-                                public Function2<Resource, Resource, Resource> perform(ReadGraph graph) throws DatabaseException {\r
-                                    model.set( graph.sync(new PossibleModel(target)) );\r
-                                    if (model.get() == null)\r
-                                        throw new CancelTransactionException("Cannot find a model from the input selection. Typical diagram instantiation not possible.");\r
+                    Session session = Simantics.getSession();\r
+                    session.markUndoPoint();\r
+                    try {\r
+                        AtomicReference<Resource> model = new AtomicReference<Resource>();\r
+                        Function2<Resource, Resource, Resource> instantiator = session.syncRequest(new UniqueRead<Function2<Resource, Resource, Resource>>() {\r
+                            @Override\r
+                            public Function2<Resource, Resource, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+                                model.set( graph.sync(new PossibleModel(target)) );\r
+                                if (model.get() == null)\r
+                                    throw new CancelTransactionException("Cannot find a model from the input selection. Typical diagram instantiation not possible.");\r
 \r
-                                    ModelingResources MOD = ModelingResources.getInstance(graph);\r
-                                    Function2<Resource, Resource, Resource> instantiator = graph.getRelatedValue2(model.get(), MOD.StructuralModel_typicalInstantiationFunction);\r
-                                    return instantiator;\r
-                                }\r
-                            });\r
+                                ModelingResources MOD = ModelingResources.getInstance(graph);\r
+                                Function2<Resource, Resource, Resource> instantiator = graph.getRelatedValue2(model.get(), MOD.StructuralModel_typicalInstantiationFunction);\r
+                                return instantiator;\r
+                            }\r
+                        });\r
 \r
-                            instantiator.apply(model.get(), target);\r
+                        instantiator.apply(model.get(), target);\r
 \r
-                            return Status.OK_STATUS;\r
-                        } catch (CancelTransactionException e) {\r
-                            return new Status(IStatus.INFO , Activator.PLUGIN_ID, e.getMessage());\r
-                        } catch (DatabaseException e) {\r
-                            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);\r
-                        } finally {\r
-                            monitor.done();\r
-                        }\r
+                        return Status.OK_STATUS;\r
+                    } catch (CancelTransactionException e) {\r
+                        return new Status(IStatus.INFO , Activator.PLUGIN_ID, e.getMessage());\r
+                    } catch (DatabaseException e) {\r
+                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);\r
+                    } finally {\r
+                        monitor.done();\r
                     }\r
-                };\r
-                //job.setUser(true);\r
-                job.schedule();\r
-            }\r
+                }\r
+            };\r
+            //job.setUser(true);\r
+            job.schedule();\r
         };\r
     }\r
 \r