]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ValidateMappingHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / ValidateMappingHandler.java
index 2bc74652d58c0e121c75f826374cb88605cd9eaf..8ed33bf59570423948f443067ff487150e8e2897 100644 (file)
@@ -1,82 +1,82 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.actions;\r
-\r
-import java.util.ArrayDeque;\r
-import java.util.Deque;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.runtime.IAdaptable;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.Simantics;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.common.request.ReadRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.modeling.validation.ValidateMapping;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
-import org.simantics.structural.ui.modelBrowser.nodes.CompositeNode;\r
-\r
-public class ValidateMappingHandler extends AbstractHandler {\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();\r
-\r
-        if (!selection.isEmpty() && selection instanceof StructuredSelection) {\r
-            final Set<Resource> compositesToTest = new HashSet<Resource>(); \r
-\r
-            final List<?> elements = ((StructuredSelection) selection).toList();\r
-            for (Object element : elements) {\r
-                if (element instanceof IAdaptable) {\r
-                    Resource node = (Resource) ((IAdaptable) element).getAdapter(Resource.class);\r
-                    if (node != null) {\r
-                        compositesToTest.add(node);\r
-                    }\r
-                }\r
-            }\r
-\r
-            Simantics.getSession().asyncRequest(new ReadRequest() {\r
-                @Override\r
-                public void run(ReadGraph graph) throws DatabaseException {\r
-                    Layer0 L0 = Layer0.getInstance(graph); \r
-                    StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
-\r
-                    // Try to test all child composites also.\r
-                    Deque<Resource> toBeChecked = new ArrayDeque<Resource>(compositesToTest);\r
-                    while (!toBeChecked.isEmpty()) {\r
-                        Resource check = toBeChecked.poll();\r
-\r
-                        for (Resource child : graph.syncRequest(new ObjectsWithType(check, L0.ConsistsOf, STR.Composite))) {\r
-                            if (compositesToTest.add(child))\r
-                                toBeChecked.offer(child);\r
-                        }\r
-                    }\r
-\r
-                    for (Resource composite : compositesToTest)\r
-                        graph.syncRequest(new ValidateMapping(composite));\r
-                }\r
-            });\r
-        }\r
-        return null;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * 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.modeling.ui.actions;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.PlatformUI;
+import org.simantics.Simantics;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ObjectsWithType;
+import org.simantics.db.common.request.ReadRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.modeling.validation.ValidateMapping;
+import org.simantics.structural.stubs.StructuralResource2;
+import org.simantics.structural.ui.modelBrowser.nodes.CompositeNode;
+
+public class ValidateMappingHandler extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
+
+        if (!selection.isEmpty() && selection instanceof StructuredSelection) {
+            final Set<Resource> compositesToTest = new HashSet<Resource>(); 
+
+            final List<?> elements = ((StructuredSelection) selection).toList();
+            for (Object element : elements) {
+                if (element instanceof IAdaptable) {
+                    Resource node = (Resource) ((IAdaptable) element).getAdapter(Resource.class);
+                    if (node != null) {
+                        compositesToTest.add(node);
+                    }
+                }
+            }
+
+            Simantics.getSession().asyncRequest(new ReadRequest() {
+                @Override
+                public void run(ReadGraph graph) throws DatabaseException {
+                    Layer0 L0 = Layer0.getInstance(graph); 
+                    StructuralResource2 STR = StructuralResource2.getInstance(graph);
+
+                    // Try to test all child composites also.
+                    Deque<Resource> toBeChecked = new ArrayDeque<Resource>(compositesToTest);
+                    while (!toBeChecked.isEmpty()) {
+                        Resource check = toBeChecked.poll();
+
+                        for (Resource child : graph.syncRequest(new ObjectsWithType(check, L0.ConsistsOf, STR.Composite))) {
+                            if (compositesToTest.add(child))
+                                toBeChecked.offer(child);
+                        }
+                    }
+
+                    for (Resource composite : compositesToTest)
+                        graph.syncRequest(new ValidateMapping(composite));
+                }
+            });
+        }
+        return null;
+    }
+
+}