]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/SCLModuleEditorAdapter.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / SCLModuleEditorAdapter.java
index 698fb4010bfc36da34adc2c0f8c2d5d71ad6bd7d..849c5be7c2ef9025de399a4b7c2dec96caeae71f 100644 (file)
@@ -1,68 +1,68 @@
-package org.simantics.modeling.ui.componentTypeEditor;\r
-\r
-import org.eclipse.core.runtime.IAdaptable;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.ui.IWorkbenchPage;\r
-import org.eclipse.ui.PartInitException;\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.ReadRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.scl.ui.editor2.StandardSCLModuleEditorInput;\r
-import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;\r
-import org.simantics.ui.workbench.editor.EditorAdapter;\r
-import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
-\r
-public class SCLModuleEditorAdapter extends AbstractResourceEditorAdapter\r
-        implements EditorAdapter {\r
-\r
-    public SCLModuleEditorAdapter() {\r
-        super("SCL Module Editor", null, 20);\r
-    }\r
-    \r
-    @Override\r
-    public boolean canHandle(ReadGraph g, Object input)\r
-            throws DatabaseException {\r
-        if(input instanceof IStructuredSelection)\r
-            input = ((IStructuredSelection)input).getFirstElement();\r
-        if(!(input instanceof Resource)) {\r
-            if(input instanceof IAdaptable) {\r
-                input = ((IAdaptable)input).getAdapter(Resource.class);\r
-                if(input == null)\r
-                    return false;\r
-            }\r
-            else\r
-                return false;\r
-        }\r
-        Resource resource = (Resource)input;\r
-        Layer0 L0 = Layer0.getInstance(g);\r
-        return g.isInstanceOf(resource, L0.SCLModule);\r
-    }\r
-    \r
-    protected void openEditor(Resource input) throws Exception {\r
-        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();\r
-        if(page == null)\r
-            return;\r
-        Simantics.getSession().asyncRequest(new ReadRequest() {\r
-            @Override\r
-            public void run(ReadGraph graph) throws DatabaseException {\r
-                String uri = graph.getURI(input);\r
-                PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\r
-                    @Override\r
-                    public void run() {\r
-                        try {\r
-                            WorkbenchUtils.openEditor("org.simantics.scl.ui.editor2",\r
-                                    new StandardSCLModuleEditorInput(uri));\r
-                        } catch (PartInitException e) {\r
-                            e.printStackTrace();\r
-                        }\r
-                    }\r
-                });\r
-            }\r
-        });\r
-    }\r
-\r
-}\r
+package org.simantics.modeling.ui.componentTypeEditor;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+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.ReadRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.scl.ui.editor2.StandardSCLModuleEditorInput;
+import org.simantics.ui.workbench.editor.AbstractResourceEditorAdapter;
+import org.simantics.ui.workbench.editor.EditorAdapter;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
+
+public class SCLModuleEditorAdapter extends AbstractResourceEditorAdapter
+        implements EditorAdapter {
+
+    public SCLModuleEditorAdapter() {
+        super("SCL Module Editor", null, 20);
+    }
+    
+    @Override
+    public boolean canHandle(ReadGraph g, Object input)
+            throws DatabaseException {
+        if(input instanceof IStructuredSelection)
+            input = ((IStructuredSelection)input).getFirstElement();
+        if(!(input instanceof Resource)) {
+            if(input instanceof IAdaptable) {
+                input = ((IAdaptable)input).getAdapter(Resource.class);
+                if(input == null)
+                    return false;
+            }
+            else
+                return false;
+        }
+        Resource resource = (Resource)input;
+        Layer0 L0 = Layer0.getInstance(g);
+        return g.isInstanceOf(resource, L0.SCLModule);
+    }
+    
+    protected void openEditor(Resource input) throws Exception {
+        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+        if(page == null)
+            return;
+        Simantics.getSession().asyncRequest(new ReadRequest() {
+            @Override
+            public void run(ReadGraph graph) throws DatabaseException {
+                String uri = graph.getURI(input);
+                PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            WorkbenchUtils.openEditor("org.simantics.scl.ui.editor2",
+                                    new StandardSCLModuleEditorInput(uri));
+                        } catch (PartInitException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+            }
+        });
+    }
+
+}