X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fadapters%2FRemovers.java;h=4949793b46b9bbdae244427a8646e82fecae6364;hp=3d04996120278e63de6270438ba8f1d722b9362b;hb=ad0e5bf4b34705988e23c9ee3f8e4fcbb760c701;hpb=0f2d6b33db9eabe0c1b142f6d0197a5d1446c3b1 diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/Removers.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/Removers.java index 3d0499612..4949793b4 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/Removers.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/adapters/Removers.java @@ -11,12 +11,9 @@ *******************************************************************************/ package org.simantics.modeling.adapters; -import gnu.trove.set.hash.THashSet; - import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Set; import org.simantics.databoard.Bindings; @@ -28,7 +25,7 @@ import org.simantics.db.common.request.PossibleObjectWithType; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.VariableException; -import org.simantics.db.layer0.genericrelation.IndexQueries; +import org.simantics.db.layer0.QueryIndexUtils; import org.simantics.db.layer0.request.PossibleModel; import org.simantics.db.layer0.variable.RVI; import org.simantics.db.layer0.variable.Variable; @@ -37,11 +34,11 @@ import org.simantics.diagram.content.ConnectionUtil; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; -import org.simantics.operation.Layer0X; -import org.simantics.scl.runtime.function.Function; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.utils.ui.ErrorLogger; +import gnu.trove.set.hash.THashSet; + /** * @author Tuukka Lehtonen */ @@ -121,48 +118,41 @@ final class Removers { return; NamedResource namedRoot = new NamedResource(rootName, root); - @SuppressWarnings("rawtypes") - Function modules = graph.adapt(Layer0X.getInstance(graph).Dependencies, Function.class); - @SuppressWarnings("unchecked") - List> rows = (List>) modules.apply(graph, root, "Types:" + IndexQueries.quoteTerm(result.componentType.getName())); - if (rows.isEmpty()) + List components = QueryIndexUtils.searchByTypeShallow(graph, root, result.componentType.getResource()); + if (components.isEmpty()) return; ModelingResources MOD = ModelingResources.getInstance(graph); StructuralResource2 STR = StructuralResource2.getInstance(graph); - for (Map row : rows) { - Resource component = (Resource) row.get("Resource"); - if (graph.isInstanceOf(component, result.componentType.getResource())) { - String componentName = graph.getPossibleRelatedValue(component, L0.HasName, Bindings.STRING); - next_connection: - for (Resource connection : graph.getObjects(component, connectionRelation)) { - if (graph.isInstanceOf(connection, STR.Connection)) { - - if (diagramConnectionRelation != null) { - // When diagram connection relation is defined, validate that - // exactly the specified diagram connection relation is being - // used and not some other relation from another symbol. - for (Resource element : graph.getObjects(component, MOD.ComponentToElement)) { - for (Resource diagramConnector : graph.getObjects(element, diagramConnectionRelation)) { - Resource diagramConnection = ConnectionUtil.tryGetConnection(graph, diagramConnector); - if (diagramConnection == null) - continue; - Resource correspondingConnection = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnection); - Resource correspondingConnectionSpecial = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnectionSpecial); - if (connection.equals(correspondingConnection) || connection.equals(correspondingConnectionSpecial)) { - addUse(graph, component, componentName, namedRoot, rootURI, result); - continue next_connection; - } + for (Resource component : components) { + String componentName = graph.getPossibleRelatedValue(component, L0.HasName, Bindings.STRING); + next_connection: + for (Resource connection : graph.getObjects(component, connectionRelation)) { + if (graph.isInstanceOf(connection, STR.Connection)) { + + if (diagramConnectionRelation != null) { + // When diagram connection relation is defined, validate that + // exactly the specified diagram connection relation is being + // used and not some other relation from another symbol. + for (Resource element : graph.getObjects(component, MOD.ComponentToElement)) { + for (Resource diagramConnector : graph.getObjects(element, diagramConnectionRelation)) { + Resource diagramConnection = ConnectionUtil.tryGetConnection(graph, diagramConnector); + if (diagramConnection == null) + continue; + Resource correspondingConnection = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnection); + Resource correspondingConnectionSpecial = graph.getPossibleObject(diagramConnection, MOD.DiagramConnectionToConnectionSpecial); + if (connection.equals(correspondingConnection) || connection.equals(correspondingConnectionSpecial)) { + addUse(graph, component, componentName, namedRoot, rootURI, result); + continue next_connection; } } - } else { - addUse(graph, component, componentName, namedRoot, rootURI, result); } + } else { + addUse(graph, component, componentName, namedRoot, rootURI, result); } - } - } + } } }