]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.views/src/org/simantics/views/All.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.views / src / org / simantics / views / All.java
index 6d26bb7f83540f680250f9c571666ec41c888e0d..3e8338946703c379845fad32e88c63331840030b 100644 (file)
-package org.simantics.views;\r
-\r
-import java.io.IOException;\r
-import java.net.MalformedURLException;\r
-import java.net.URL;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.List;\r
-\r
-import org.eclipse.core.runtime.FileLocator;\r
-import org.eclipse.core.runtime.Path;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.osgi.framework.Bundle;\r
-import org.simantics.databoard.util.StreamUtil;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.utils.ListUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;\r
-import org.simantics.scl.reflection.annotations.SCLValue;\r
-import org.simantics.views.ViewUtils.ColumnBean;\r
-import org.simantics.views.ontology.ViewsResources;\r
-\r
-public class All {\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object resourceURI(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       \r
-       ViewsResources VIEW = ViewsResources.getInstance(graph);\r
-       Resource resource = graph.getSingleObject(converter, VIEW.ResourceURI_HasResource);\r
-       return graph.getURI(resource);\r
-        \r
-    }\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object parameterValue(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       \r
-       Variable runtime = ScenegraphLoaderUtils.getRuntimeVariable(graph, context);\r
-       Variable base = ScenegraphLoaderUtils.getBaseVariable(graph, context);\r
-       //System.err.println("parameterValue " + context.getURI(graph) + " " + base.getURI(graph) + " " + runtime.getURI(graph));\r
-       String rvi = context.getURI(graph).substring(base.getURI(graph).length());\r
-       //System.err.println("rvi " + rvi);\r
-       Variable parameter = runtime.browse(graph, rvi);\r
-       return parameter.getValue(graph);\r
-        \r
-    }\r
-    \r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> Resource")\r
-    public static Resource singleResourceSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {\r
-       return ScenegraphLoaderUtils.getPossibleResourceSelection(graph, context);\r
-    }\r
-    \r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> [String]")\r
-    public static List<String> tabChildNames(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       \r
-       Collection<Variable> children = context.getParent(graph).getChildren(graph);\r
-       \r
-       List<String> result = new ArrayList<String>();\r
-\r
-               for(Variable child : children) {\r
-                       String label = child.getPropertyValue(graph, Variables.LABEL); \r
-                       result.add(label);\r
-               }\r
-               \r
-               return result;          \r
-        \r
-    }\r
-    \r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object bundleImage(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       \r
-       ViewsResources VIEW = ViewsResources.getInstance(graph);\r
-       String reference = graph.getRelatedValue(converter, VIEW.BundleImage_HasReference);\r
-       \r
-       String[] parts = reference.split(":");\r
-       if(parts.length != 2) return null;\r
-       \r
-        Bundle bundle = Platform.getBundle(parts[0]);\r
-        \r
-        if (bundle == null) {\r
-            throw new IllegalArgumentException("null bundle");\r
-        }\r
-\r
-        // look for the image (this will check both the plugin and fragment folders\r
-        URL fullPathString = FileLocator.find(bundle, new Path(parts[1]), null);\r
-        if (fullPathString == null) {\r
-            try {\r
-                fullPathString = new URL(parts[1]);\r
-            } catch (MalformedURLException e) {\r
-                return null;\r
-            }\r
-        }\r
-        \r
-        try {\r
-                       return StreamUtil.readFully(fullPathString.openStream());\r
-               } catch (IOException e) {\r
-                       e.printStackTrace();\r
-                       return null;\r
-               }\r
-        \r
-    }\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object gridData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-        return ViewUtils.getGridData(graph, converter);\r
-    }\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object gridLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-        return ViewUtils.getLayout(graph, converter);\r
-    }\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object rowData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-        return ViewUtils.getRowData(graph, converter);\r
-    }\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object rowLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-        return ViewUtils.getRowLayout(graph, converter);\r
-    }\r
-\r
-    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")\r
-    public static Object style(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {\r
-       return ViewUtils.getStyle(graph, converter);\r
-    }\r
-    \r
-    @SCLValue(type = "ReadGraph -> Resource -> a -> b")\r
-    public static Object columnList(ReadGraph graph, Resource resource, Object context) throws DatabaseException {\r
-       ArrayList<ColumnBean> result = new ArrayList<ColumnBean>();\r
-       for(Resource item : ListUtils.toList(graph, resource)) {\r
-               result.add(ViewUtils.getColumn(graph, item));\r
-       }\r
-       return result;\r
-    }\r
-    \r
-    \r
+package org.simantics.views;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+import org.simantics.databoard.util.StreamUtil;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.utils.ListUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.variable.Variable;
+import org.simantics.db.layer0.variable.Variables;
+import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;
+import org.simantics.scl.reflection.annotations.SCLValue;
+import org.simantics.views.ViewUtils.ColumnBean;
+import org.simantics.views.ontology.ViewsResources;
+
+public class All {
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object resourceURI(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+       
+       ViewsResources VIEW = ViewsResources.getInstance(graph);
+       Resource resource = graph.getSingleObject(converter, VIEW.ResourceURI_HasResource);
+       return graph.getURI(resource);
+        
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object parameterValue(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+       
+       Variable runtime = ScenegraphLoaderUtils.getRuntimeVariable(graph, context);
+       Variable base = ScenegraphLoaderUtils.getBaseVariable(graph, context);
+       //System.err.println("parameterValue " + context.getURI(graph) + " " + base.getURI(graph) + " " + runtime.getURI(graph));
+       String rvi = context.getURI(graph).substring(base.getURI(graph).length());
+       //System.err.println("rvi " + rvi);
+       Variable parameter = runtime.browse(graph, rvi);
+       return parameter.getValue(graph);
+        
+    }
+    
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> Resource")
+    public static Resource singleResourceSelection(ReadGraph graph, Resource resource, Variable context) throws DatabaseException {
+       return ScenegraphLoaderUtils.getPossibleResourceSelection(graph, context);
+    }
+    
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> [String]")
+    public static List<String> tabChildNames(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+       
+       Collection<Variable> children = context.getParent(graph).getChildren(graph);
+       
+       List<String> result = new ArrayList<String>();
+
+               for(Variable child : children) {
+                       String label = child.getPropertyValue(graph, Variables.LABEL); 
+                       result.add(label);
+               }
+               
+               return result;          
+        
+    }
+    
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object bundleImage(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+       
+       ViewsResources VIEW = ViewsResources.getInstance(graph);
+       String reference = graph.getRelatedValue(converter, VIEW.BundleImage_HasReference);
+       
+       String[] parts = reference.split(":");
+       if(parts.length != 2) return null;
+       
+        Bundle bundle = Platform.getBundle(parts[0]);
+        
+        if (bundle == null) {
+            throw new IllegalArgumentException("null bundle");
+        }
+
+        // look for the image (this will check both the plugin and fragment folders
+        URL fullPathString = FileLocator.find(bundle, new Path(parts[1]), null);
+        if (fullPathString == null) {
+            try {
+                fullPathString = new URL(parts[1]);
+            } catch (MalformedURLException e) {
+                return null;
+            }
+        }
+        
+        try {
+                       return StreamUtil.readFully(fullPathString.openStream());
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       return null;
+               }
+        
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object gridData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+        return ViewUtils.getGridData(graph, converter);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object gridLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+        return ViewUtils.getLayout(graph, converter);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object rowData(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+        return ViewUtils.getRowData(graph, converter);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object rowLayout(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+        return ViewUtils.getRowLayout(graph, converter);
+    }
+
+    @SCLValue(type = "ReadGraph -> Resource -> Variable -> a")
+    public static Object style(ReadGraph graph, Resource converter, Variable context) throws DatabaseException {
+       return ViewUtils.getStyle(graph, converter);
+    }
+    
+    @SCLValue(type = "ReadGraph -> Resource -> a -> b")
+    public static Object columnList(ReadGraph graph, Resource resource, Object context) throws DatabaseException {
+       ArrayList<ColumnBean> result = new ArrayList<ColumnBean>();
+       for(Resource item : ListUtils.toList(graph, resource)) {
+               result.add(ViewUtils.getColumn(graph, item));
+       }
+       return result;
+    }
+    
+    
 }
\ No newline at end of file