]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.charts/src/org/simantics/charts/ui/NewChartGroup.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / ui / NewChartGroup.java
index 8072df28d820d55b55da1bd9d001246a79b2ec28..f2dfbcd5b529abf7e4343d1cdb5bcb380f7bf94e 100644 (file)
@@ -1,71 +1,71 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2013 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
- *     Semantum Oy - issue #4262\r
- *******************************************************************************/\r
-package org.simantics.charts.ui;\r
-\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.simantics.Simantics;\r
-import org.simantics.charts.Activator;\r
-import org.simantics.charts.ontology.ChartResource;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteResultRequest;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.layer0.Layer0;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class NewChartGroup implements ActionFactory {\r
-\r
-    @Override\r
-    public Runnable create(Object target) {\r
-        if(!(target instanceof Resource))\r
-            return null;\r
-        final Resource parent = (Resource)target;\r
-\r
-        return new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                try {\r
-                    createChartGroup(parent);\r
-                } catch (DatabaseException e) {\r
-                    Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create chart group.", e));\r
-                }\r
-            }\r
-        };\r
-    }\r
-\r
-    public static Resource createChartGroup (final Resource target) throws DatabaseException {\r
-\r
-        return Simantics.getSession().syncRequest(new WriteResultRequest<Resource>() {\r
-            @Override\r
-            public Resource perform(WriteGraph g) throws DatabaseException {\r
-                g.markUndoPoint();\r
-                Layer0 l0 = Layer0.getInstance(g);\r
-                ChartResource wr = ChartResource.getInstance(g);\r
-                String freshName = NameUtils.findFreshName(g, "Chart Group", target);\r
-                Resource chart = g.newResource();\r
-                g.claim(chart, l0.InstanceOf, null, wr.ChartGroup);\r
-                g.claimLiteral(chart, l0.HasName, freshName, Bindings.STRING);\r
-                g.claim(chart, l0.PartOf, target);\r
-                return chart;\r
-            }\r
-        });\r
-\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2013 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
+ *     Semantum Oy - issue #4262
+ *******************************************************************************/
+package org.simantics.charts.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.simantics.Simantics;
+import org.simantics.charts.Activator;
+import org.simantics.charts.ontology.ChartResource;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteResultRequest;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.layer0.Layer0;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class NewChartGroup implements ActionFactory {
+
+    @Override
+    public Runnable create(Object target) {
+        if(!(target instanceof Resource))
+            return null;
+        final Resource parent = (Resource)target;
+
+        return new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    createChartGroup(parent);
+                } catch (DatabaseException e) {
+                    Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create chart group.", e));
+                }
+            }
+        };
+    }
+
+    public static Resource createChartGroup (final Resource target) throws DatabaseException {
+
+        return Simantics.getSession().syncRequest(new WriteResultRequest<Resource>() {
+            @Override
+            public Resource perform(WriteGraph g) throws DatabaseException {
+                g.markUndoPoint();
+                Layer0 l0 = Layer0.getInstance(g);
+                ChartResource wr = ChartResource.getInstance(g);
+                String freshName = NameUtils.findFreshName(g, "Chart Group", target);
+                Resource chart = g.newResource();
+                g.claim(chart, l0.InstanceOf, null, wr.ChartGroup);
+                g.claimLiteral(chart, l0.HasName, freshName, Bindings.STRING);
+                g.claim(chart, l0.PartOf, target);
+                return chart;
+            }
+        });
+
+    }
+
+}