match (syncRead (\x -> possibleSubstructureEditor element)) with
Nothing -> ()
Just (configuration,editor) -> openEditor editor configuration
-
\ No newline at end of file
+
+importJava "org.simantics.modeling.MigrateModel" where
+ "changeAllComponentTypes model oldComponentType newComponentType"
+ changeAllComponentTypes :: Resource -> Resource -> Resource -> <WriteGraph> ()
import org.simantics.db.common.NamedResource;
import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.Instances;
import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
new MigrationOperation(new NamedResource("", instance), new NamedResource("", newComponentType), new NamedResource("", newSymbol))
.perform(graph);
}
+
+ public static void changeAllComponentTypes(WriteGraph graph, Resource model, Resource oldComponentType, Resource newComponentType) throws DatabaseException {
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ NamedResource newComponentTypeN = new NamedResource("", newComponentType);
+ Resource newSymbol = graph.getSingleObject(newComponentType, MOD.ComponentTypeToSymbol);
+ NamedResource newSymbolN = new NamedResource("", newSymbol);
+
+ Collection<Resource> instances = graph.adapt(oldComponentType, Instances.class).find(graph, model);
+
+ for(Resource instance : instances) {
+ new MigrationOperation(
+ new NamedResource("", instance),
+ newComponentTypeN,
+ newSymbolN)
+ .perform(graph);
+ }
+ }
+
}