]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/GraphEnumerationModifierBase.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / GraphEnumerationModifierBase.java
index 4f8167d4a6579a4811a6cf6d08a744be288a6f47..28558d5f82b5ba87820678c3be9ef525de2066cf 100644 (file)
@@ -1,86 +1,86 @@
-/*******************************************************************************\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.browsing.ui.graph.impl;\r
-\r
-import org.simantics.browsing.ui.common.modifiers.AbstractEnumerationModifier;\r
-import org.simantics.browsing.ui.common.modifiers.EnumeratedValue;\r
-import org.simantics.browsing.ui.common.modifiers.Enumeration;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.utils.ObjectUtils;\r
-\r
-/**\r
- * A graph resource based EnumerationModifier utility implementation.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public abstract class GraphEnumerationModifierBase<T> extends AbstractEnumerationModifier<T> {\r
-\r
-    protected final Session  session;\r
-\r
-    public GraphEnumerationModifierBase(Session session, Enumeration<T> enumeration, T value) {\r
-        this(session, enumeration, enumeration.find(value));\r
-    }\r
-\r
-    public GraphEnumerationModifierBase(Session session, Enumeration<T> enumeration, EnumeratedValue<T> value) {\r
-        super(enumeration, value);\r
-        if (session == null)\r
-            throw new NullPointerException("null session");\r
-        this.session = session;\r
-    }\r
-\r
-    @Override\r
-    protected void modifyWithObject(final T oldEnumObject, final T enumObject) {\r
-        if (ObjectUtils.objectEquals(oldEnumObject, enumObject))\r
-            return;\r
-\r
-        try {\r
-            session.getSession().syncRequest(new WriteRequest() {\r
-                @Override\r
-                public void perform(WriteGraph graph) throws DatabaseException {\r
-//                    System.out.println("old enum object: " + oldEnumObject);\r
-//                    System.out.println("enum object: " + enumObject);\r
-                    modifyWithObject(graph, oldEnumObject, enumObject);\r
-                }\r
-            });\r
-        } catch (DatabaseException e) {\r
-            handleException(e);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Implement this modifier to perform database modifications.\r
-     * \r
-     * @param graph\r
-     * @param oldEnumObject\r
-     * @param enumObject\r
-     */\r
-    protected abstract void modifyWithObject(WriteGraph graph, T oldEnumObject, T enumObject) throws DatabaseException;\r
-\r
-    /**\r
-     * Client overridable handler for possible exceptions that may occur while\r
-     * performing the database modifications.\r
-     * \r
-     * <p>\r
-     * This default implementation merely forwards the exception as a runtime\r
-     * exception.\r
-     * \r
-     * @param e\r
-     */\r
-    protected void handleException(DatabaseException e) {\r
-        throw new RuntimeException(e);\r
-    }\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.browsing.ui.graph.impl;
+
+import org.simantics.browsing.ui.common.modifiers.AbstractEnumerationModifier;
+import org.simantics.browsing.ui.common.modifiers.EnumeratedValue;
+import org.simantics.browsing.ui.common.modifiers.Enumeration;
+import org.simantics.db.Session;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.utils.ObjectUtils;
+
+/**
+ * A graph resource based EnumerationModifier utility implementation.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public abstract class GraphEnumerationModifierBase<T> extends AbstractEnumerationModifier<T> {
+
+    protected final Session  session;
+
+    public GraphEnumerationModifierBase(Session session, Enumeration<T> enumeration, T value) {
+        this(session, enumeration, enumeration.find(value));
+    }
+
+    public GraphEnumerationModifierBase(Session session, Enumeration<T> enumeration, EnumeratedValue<T> value) {
+        super(enumeration, value);
+        if (session == null)
+            throw new NullPointerException("null session");
+        this.session = session;
+    }
+
+    @Override
+    protected void modifyWithObject(final T oldEnumObject, final T enumObject) {
+        if (ObjectUtils.objectEquals(oldEnumObject, enumObject))
+            return;
+
+        try {
+            session.getSession().syncRequest(new WriteRequest() {
+                @Override
+                public void perform(WriteGraph graph) throws DatabaseException {
+//                    System.out.println("old enum object: " + oldEnumObject);
+//                    System.out.println("enum object: " + enumObject);
+                    modifyWithObject(graph, oldEnumObject, enumObject);
+                }
+            });
+        } catch (DatabaseException e) {
+            handleException(e);
+        }
+    }
+
+    /**
+     * Implement this modifier to perform database modifications.
+     * 
+     * @param graph
+     * @param oldEnumObject
+     * @param enumObject
+     */
+    protected abstract void modifyWithObject(WriteGraph graph, T oldEnumObject, T enumObject) throws DatabaseException;
+
+    /**
+     * Client overridable handler for possible exceptions that may occur while
+     * performing the database modifications.
+     * 
+     * <p>
+     * This default implementation merely forwards the exception as a runtime
+     * exception.
+     * 
+     * @param e
+     */
+    protected void handleException(DatabaseException e) {
+        throw new RuntimeException(e);
+    }
+
+
+}