X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Ftemplates%2FLoadDataValueTemplate.java;fp=bundles%2Forg.simantics.graph.compiler%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fcompiler%2Finternal%2Ftemplates%2FLoadDataValueTemplate.java;h=94afd0b95397c2d355b773329c51f273f0a4f209;hp=26ae85ed19add79d2b2b087801fc5ffab256cf2c;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/templates/LoadDataValueTemplate.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/templates/LoadDataValueTemplate.java index 26ae85ed1..94afd0b95 100644 --- a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/templates/LoadDataValueTemplate.java +++ b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/templates/LoadDataValueTemplate.java @@ -1,43 +1,43 @@ -package org.simantics.graph.compiler.internal.templates; - -import java.io.IOException; -import java.util.Collection; - -import org.simantics.databoard.Bindings; -import org.simantics.databoard.binding.mutable.Variant; -import org.simantics.databoard.serialization.Serializer; -import org.simantics.graph.compiler.ExternalFileLoader; -import org.simantics.graph.compiler.internal.store.LocationStore; -import org.simantics.graph.compiler.internal.store.PreValueStore; -import org.simantics.graph.query.IGraph; -import org.simantics.graph.store.GraphStore; -import org.simantics.ltk.Location; -import org.simantics.ltk.Problem; - -public enum LoadDataValueTemplate implements ITemplate { - INSTANCE; - - @Override - public void apply(IGraph graph, GraphStore store, - int[] parameters, ExternalFileLoader fileLoader, Collection problems) { - String fileName = store.getStore(PreValueStore.class).getStringValue(parameters[1]); - if(fileName == null) { - Location location = store.getStore(LocationStore.class) - .getLocation(parameters[1]); - problems.add(new Problem( - location, "Expected a string")); - } - try { - byte[] bytes = fileLoader.load(fileName); - Serializer variantSerializer = Bindings.getSerializerUnchecked(Bindings.VARIANT); - Variant value = (Variant)variantSerializer.deserialize(bytes); - store.values.setValue(parameters[0], value); - } catch (IOException e) { - Location location = store.getStore(LocationStore.class) - .getLocation(parameters[1]); - problems.add(new Problem( - location, e.getMessage())); - } - } - -} +package org.simantics.graph.compiler.internal.templates; + +import java.io.IOException; +import java.util.Collection; + +import org.simantics.databoard.Bindings; +import org.simantics.databoard.binding.mutable.Variant; +import org.simantics.databoard.serialization.Serializer; +import org.simantics.graph.compiler.ExternalFileLoader; +import org.simantics.graph.compiler.internal.store.LocationStore; +import org.simantics.graph.compiler.internal.store.PreValueStore; +import org.simantics.graph.query.IGraph; +import org.simantics.graph.store.GraphStore; +import org.simantics.ltk.Location; +import org.simantics.ltk.Problem; + +public enum LoadDataValueTemplate implements ITemplate { + INSTANCE; + + @Override + public void apply(IGraph graph, GraphStore store, + int[] parameters, ExternalFileLoader fileLoader, Collection problems) { + String fileName = store.getStore(PreValueStore.class).getStringValue(parameters[1]); + if(fileName == null) { + Location location = store.getStore(LocationStore.class) + .getLocation(parameters[1]); + problems.add(new Problem( + location, "Expected a string")); + } + try { + byte[] bytes = fileLoader.load(fileName); + Serializer variantSerializer = Bindings.getSerializerUnchecked(Bindings.VARIANT); + Variant value = (Variant)variantSerializer.deserialize(bytes); + store.values.setValue(parameters[0], value); + } catch (IOException e) { + Location location = store.getStore(LocationStore.class) + .getLocation(parameters[1]); + problems.add(new Problem( + location, e.getMessage())); + } + } + +}