]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.ui/src/org/simantics/ui/workbench/ResourceInputs.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / ResourceInputs.java
index 01d937eb2269f03882834118bceb4dbdfbaf41fa..039388cb31eb28ce442c6903e3a0a57ae2f30363 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * 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.ui.workbench;\r
-\r
-import java.lang.ref.Reference;\r
-import java.lang.ref.SoftReference;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.simantics.Simantics;\r
-import org.simantics.db.RequestProcessor;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.common.ResourceArray;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.RuntimeDatabaseException;\r
-import org.simantics.db.service.LifecycleSupport;\r
-import org.simantics.db.service.SerialisationSupport;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-final class ResourceInputs {\r
-\r
-    public static <T> Reference<T> makeReference(T t) {\r
-        return new SoftReference<T>(t);\r
-    }\r
-\r
-    public static Resource resolveResource(RequestProcessor processor, String resourceId) throws DatabaseException {\r
-        try {\r
-            SerialisationSupport ss = processor.getService(SerialisationSupport.class);\r
-            return ss.getResource(Long.parseLong(resourceId));\r
-        } catch (NumberFormatException e) {\r
-            throw new DatabaseException(e);\r
-        }\r
-    }\r
-\r
-    public static ResourceArray makeResourceArray(RequestProcessor processor, Collection<String> resourceIds) throws DatabaseException {\r
-        try {\r
-            SerialisationSupport ss = processor.getService(SerialisationSupport.class);\r
-            List<Resource> rs = new ArrayList<Resource>();\r
-            for (String id : resourceIds)\r
-                rs.add(ss.getResource(Long.parseLong(id)));\r
-            return new ResourceArray(rs);\r
-        } catch (NumberFormatException e) {\r
-            throw new DatabaseException(e);\r
-        }\r
-    }\r
-\r
-    public static String getRandomAccessId(Resource r) {\r
-        try {\r
-            SerialisationSupport support = getSession().getService(SerialisationSupport.class);\r
-            return String.valueOf( support.getRandomAccessId(r) );\r
-        } catch (DatabaseException e) {\r
-            throw new RuntimeDatabaseException(e);\r
-        }\r
-    }\r
-\r
-    public static List<String> getRandomAccessIds(ResourceArray ra) {\r
-        try {\r
-            List<String> randoms = new ArrayList<String>();\r
-            SerialisationSupport support = getSession().getService(SerialisationSupport.class);\r
-            for (Resource r : ra.resources)\r
-                randoms.add(String.valueOf(support.getRandomAccessId(r)));\r
-            return Collections.unmodifiableList(randoms);\r
-        } catch (DatabaseException e) {\r
-            throw new RuntimeDatabaseException(e);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * @return a graph instance if it exists and has not yet been disposed,\r
-     *         <code>null</code> otherwise\r
-     */\r
-    public static Session getSession() {\r
-        Session s = Simantics.getSession();\r
-        if (s.getService(LifecycleSupport.class).isClosed())\r
-            throw new IllegalStateException("database session is closed");\r
-        return s;\r
-    }\r
-\r
-    /**\r
-     * @return a graph instance if it exists and has not yet been disposed,\r
-     *         <code>null</code> otherwise\r
-     */\r
-    public static Session peekSession() {\r
-        Session s = Simantics.peekSession();\r
-        if (s == null)\r
-            return null;\r
-        if (s.getService(LifecycleSupport.class).isClosed())\r
-            throw new IllegalStateException("database session is closed");\r
-        return s;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 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.ui.workbench;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.simantics.Simantics;
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.common.ResourceArray;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.RuntimeDatabaseException;
+import org.simantics.db.service.LifecycleSupport;
+import org.simantics.db.service.SerialisationSupport;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+final class ResourceInputs {
+
+    public static <T> Reference<T> makeReference(T t) {
+        return new SoftReference<T>(t);
+    }
+
+    public static Resource resolveResource(RequestProcessor processor, String resourceId) throws DatabaseException {
+        try {
+            SerialisationSupport ss = processor.getService(SerialisationSupport.class);
+            return ss.getResource(Long.parseLong(resourceId));
+        } catch (NumberFormatException e) {
+            throw new DatabaseException(e);
+        }
+    }
+
+    public static ResourceArray makeResourceArray(RequestProcessor processor, Collection<String> resourceIds) throws DatabaseException {
+        try {
+            SerialisationSupport ss = processor.getService(SerialisationSupport.class);
+            List<Resource> rs = new ArrayList<Resource>();
+            for (String id : resourceIds)
+                rs.add(ss.getResource(Long.parseLong(id)));
+            return new ResourceArray(rs);
+        } catch (NumberFormatException e) {
+            throw new DatabaseException(e);
+        }
+    }
+
+    public static String getRandomAccessId(Resource r) {
+        try {
+            SerialisationSupport support = getSession().getService(SerialisationSupport.class);
+            return String.valueOf( support.getRandomAccessId(r) );
+        } catch (DatabaseException e) {
+            throw new RuntimeDatabaseException(e);
+        }
+    }
+
+    public static List<String> getRandomAccessIds(ResourceArray ra) {
+        try {
+            List<String> randoms = new ArrayList<String>();
+            SerialisationSupport support = getSession().getService(SerialisationSupport.class);
+            for (Resource r : ra.resources)
+                randoms.add(String.valueOf(support.getRandomAccessId(r)));
+            return Collections.unmodifiableList(randoms);
+        } catch (DatabaseException e) {
+            throw new RuntimeDatabaseException(e);
+        }
+    }
+
+    /**
+     * @return a graph instance if it exists and has not yet been disposed,
+     *         <code>null</code> otherwise
+     */
+    public static Session getSession() {
+        Session s = Simantics.getSession();
+        if (s.getService(LifecycleSupport.class).isClosed())
+            throw new IllegalStateException("database session is closed");
+        return s;
+    }
+
+    /**
+     * @return a graph instance if it exists and has not yet been disposed,
+     *         <code>null</code> otherwise
+     */
+    public static Session peekSession() {
+        Session s = Simantics.peekSession();
+        if (s == null)
+            return null;
+        if (s.getService(LifecycleSupport.class).isClosed())
+            throw new IllegalStateException("database session is closed");
+        return s;
+    }
+
+}