]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/FlagRemover.java
Merge "Make it possible to debug SCL compiler in production builds"
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / adapters / FlagRemover.java
index 34af8d2fef3b1d3d32c9e073bba2ce0033c3d94e..62b70c9aed6a16bdce9691c78aa45df20c83750f 100644 (file)
@@ -1,65 +1,66 @@
-/*******************************************************************************\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.modeling.adapters;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.diagram.flag.FlagUtil;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.modeling.adapters.Removers.ValidationResult;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class FlagRemover extends ElementRemover {\r
-\r
-    public FlagRemover(Resource flag) {\r
-        super(flag);\r
-    }\r
-\r
-    @Override\r
-    public String canRemove(ReadGraph graph, Map<Object, Object> aux) throws DatabaseException {\r
-        boolean lifted = FlagUtil.isLifted(graph, resource);\r
-        if (lifted) {\r
-            ValidationResult result = Removers.validateFlagRemoval(graph, resource);\r
-            if (result.inUse()) {\r
-                return Removers.formatError(graph, result);\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public void remove(WriteGraph graph) throws DatabaseException {\r
-        FlagUtil.disconnectFlag(graph, resource);\r
-\r
-        DiagramResource DIA = DiagramResource.getInstance(graph);\r
-        Collection<Resource> connectionRelations = Collections.emptySet();\r
-        if (FlagUtil.isLifted(graph, resource))\r
-            connectionRelations = graph.getObjects(resource, DIA.IsLiftedAs);\r
-\r
-        removeElement(graph);\r
-\r
-        if (!connectionRelations.isEmpty()) {\r
-            for (Resource connectionRelation : connectionRelations) {\r
-                new ConnectionRelationRemover(connectionRelation).remove(graph);\r
-            }\r
-        }\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.modeling.adapters;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.diagram.flag.FlagUtil;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.modeling.utils.RemoverUtils;
+import org.simantics.modeling.utils.RemoverUtils.ValidationResult;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class FlagRemover extends ElementRemover {
+
+    public FlagRemover(Resource flag) {
+        super(flag);
+    }
+
+    @Override
+    public String canRemove(ReadGraph graph, Map<Object, Object> aux) throws DatabaseException {
+        boolean lifted = FlagUtil.isLifted(graph, resource);
+        if (lifted) {
+            ValidationResult result = RemoverUtils.validateFlagRemoval(graph, resource);
+            if (result.inUse()) {
+                return RemoverUtils.formatError(graph, result);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void remove(WriteGraph graph) throws DatabaseException {
+        FlagUtil.disconnectFlag(graph, resource);
+
+        DiagramResource DIA = DiagramResource.getInstance(graph);
+        Collection<Resource> connectionRelations = Collections.emptySet();
+        if (FlagUtil.isLifted(graph, resource))
+            connectionRelations = graph.getObjects(resource, DIA.IsLiftedAs);
+
+        removeElement(graph);
+
+        if (!connectionRelations.isEmpty()) {
+            for (Resource connectionRelation : connectionRelations) {
+                new ConnectionRelationRemover(connectionRelation).remove(graph);
+            }
+        }
+    }
+
+}