X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph.loader%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Floader%2FNodeRemover.java;h=7035de609adc2f5019c3dcb18eec4db3c6fc5cca;hb=refs%2Fchanges%2F38%2F238%2F2;hp=7bb4b2f36e3d3763520872c10cf1f104d32fa373;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/NodeRemover.java b/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/NodeRemover.java index 7bb4b2f36..7035de609 100644 --- a/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/NodeRemover.java +++ b/bundles/org.simantics.scenegraph.loader/src/org/simantics/scenegraph/loader/NodeRemover.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * 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.scenegraph.loader; - -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.utils.ListUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.adapter.Remover; -import org.simantics.db.layer0.adapter.impl.AbstractRemover; -import org.simantics.db.layer0.adapter.impl.EntityRemover; -import org.simantics.layer0.Layer0; -import org.simantics.scenegraph.ontology.ScenegraphResources; - -/** - * A {@link Remover} implementation for removing SG.Node instances. - * - *

- * In addition to removing the node instance itself, this remover first tries to - * remove the node from the children linked list of its possible parent - * node. - * - * @author Tuukka Lehtonen - */ -public class NodeRemover extends AbstractRemover { - - private static final boolean DEBUG = false; - - public NodeRemover(Resource node) throws DatabaseException { - super(node); - } - - @Override - public void remove(WriteGraph graph) throws DatabaseException { - if (DEBUG) - System.out.println(this + " removing scene graph node"); - - Layer0 L0 = Layer0.getInstance(graph); - ScenegraphResources SG = ScenegraphResources.getInstance(graph); - - // 1. Remove node from possible parent resource linked list. - for (Resource parentNode : graph.getObjects(resource, L0.PartOf)) { - for (Resource list : graph.getObjects(parentNode, SG.Node_children)) { - ListUtils.removeElement(graph, list, resource); - } - } - - // 2. Delete node itself - EntityRemover.remove(graph, resource); - } - - @Override - public String toString() { - return getClass().getSimpleName() + resource; - } - -} +/******************************************************************************* + * 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.scenegraph.loader; + +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.utils.ListUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.adapter.Remover; +import org.simantics.db.layer0.adapter.impl.AbstractRemover; +import org.simantics.db.layer0.adapter.impl.EntityRemover; +import org.simantics.layer0.Layer0; +import org.simantics.scenegraph.ontology.ScenegraphResources; + +/** + * A {@link Remover} implementation for removing SG.Node instances. + * + *

+ * In addition to removing the node instance itself, this remover first tries to + * remove the node from the children linked list of its possible parent + * node. + * + * @author Tuukka Lehtonen + */ +public class NodeRemover extends AbstractRemover { + + private static final boolean DEBUG = false; + + public NodeRemover(Resource node) throws DatabaseException { + super(node); + } + + @Override + public void remove(WriteGraph graph) throws DatabaseException { + if (DEBUG) + System.out.println(this + " removing scene graph node"); + + Layer0 L0 = Layer0.getInstance(graph); + ScenegraphResources SG = ScenegraphResources.getInstance(graph); + + // 1. Remove node from possible parent resource linked list. + for (Resource parentNode : graph.getObjects(resource, L0.PartOf)) { + for (Resource list : graph.getObjects(parentNode, SG.Node_children)) { + ListUtils.removeElement(graph, list, resource); + } + } + + // 2. Delete node itself + EntityRemover.remove(graph, resource); + } + + @Override + public String toString() { + return getClass().getSimpleName() + resource; + } + +}