From e50b527c15e0ed6d232488868bec70bd07b635f4 Mon Sep 17 00:00:00 2001 From: kalajainen Date: Tue, 7 Dec 2010 12:31:57 +0000 Subject: [PATCH] Switch to Databoard 0.6.0 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18967 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/elements2/ComponentNameSynchronizer.java | 4 ++-- .../DependencyConnectionFactory.java | 4 ++-- .../sysdyn/ui/handlers/ExportModelHandler.java | 11 ++--------- .../sysdyn/ui/handlers/ImportModelHandler.java | 2 -- .../sysdyn/ui/handlers/ShowModuleHandler.java | 8 ++++---- .../sysdyn/ui/project/DefaultVariable.java | 17 +++++++++-------- .../project/HistoryRealizationVirtualGraph.java | 6 +++--- .../sysdyn/ui/project/SysdynProject.java | 4 ++-- .../sysdyn/ui/properties/EnumerationTab.java | 4 ++-- .../ui/properties/widgets/ReferenceRow.java | 4 ++-- .../factories/DoublePropertyModifier.java | 4 ++-- .../factories/VariableNamePropertyModifier.java | 4 ++-- .../ui/property/OperationModelLabels.java | 4 ++-- .../ui/property/OperationVariableLabels.java | 4 ++-- 14 files changed, 36 insertions(+), 44 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ComponentNameSynchronizer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ComponentNameSynchronizer.java index dada9f99..7e08e26d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ComponentNameSynchronizer.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ComponentNameSynchronizer.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.elements2; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.exception.DatabaseException; @@ -50,7 +50,7 @@ public class ComponentNameSynchronizer extends ResourceSynchronizer { try { l0 = Layer0.getInstance(session); ModelingResources mr = session.getService(ModelingResources.class); - return queue.offer(new RelatedPropertyModification(object, mr.ElementToComponent, l0.HasName, l0.String, newValue, StringBindingDefault.INSTANCE), null); + return queue.offer(new RelatedPropertyModification(object, mr.ElementToComponent, l0.HasName, l0.String, newValue, Bindings.STRING), null); } catch (DatabaseException e) { e.printStackTrace(); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java index 2f7a6713..71eb30f6 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/connections/DependencyConnectionFactory.java @@ -15,7 +15,7 @@ import java.util.HashMap; import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.atomic.AtomicInteger; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.AsyncReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; @@ -115,7 +115,7 @@ public class DependencyConnectionFactory extends ElementFactoryAdapter { return; } - graph.forPossibleRelatedValue(property, l0.HasName, StringBindingDefault.INSTANCE, new AsyncProcedure() { + graph.forPossibleRelatedValue(property, l0.HasName, Bindings.STRING, new AsyncProcedure() { @Override public void exception(AsyncReadGraph graph, Throwable throwable) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModelHandler.java index 9dbd3d1c..51ec9466 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModelHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportModelHandler.java @@ -26,10 +26,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.handlers.HandlerUtil; import org.simantics.databoard.Bindings; import org.simantics.databoard.Files; -import org.simantics.databoard.binding.error.BindingException; import org.simantics.databoard.binding.error.RuntimeBindingConstructionException; -import org.simantics.databoard.binding.java.StringBindingDefault; -import org.simantics.databoard.serialization.SerializationException; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.primitiverequest.PossibleRelatedValue; @@ -62,7 +59,7 @@ public class ExportModelHandler extends AbstractHandler { if (!graph.hasStatement(model, Layer0.getInstance(graph).PartOf)) return null; Layer0 l0 = Layer0.getInstance(graph); - String name = graph.syncRequest(new PossibleRelatedValue(model, l0.HasName, StringBindingDefault.INSTANCE )); + String name = graph.syncRequest(new PossibleRelatedValue(model, l0.HasName, Bindings.STRING )); return name; } @@ -89,7 +86,7 @@ public class ExportModelHandler extends AbstractHandler { @Override public void run(ReadGraph graph) throws DatabaseException { Layer0 l0 = Layer0.getInstance(graph); - String name = graph.syncRequest(new PossibleRelatedValue(model, l0.HasName, StringBindingDefault.INSTANCE )); + String name = graph.syncRequest(new PossibleRelatedValue(model, l0.HasName, Bindings.STRING )); ArrayList> roots = new ArrayList>(); roots.add(Pair.make(model, name)); TransferableGraph1 tg = graph.syncRequest(new TransferableGraphRequest(roots, model)); @@ -100,10 +97,6 @@ public class ExportModelHandler extends AbstractHandler { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); - } catch (SerializationException e) { - e.printStackTrace(); - } catch (BindingException e) { - e.printStackTrace(); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModelHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModelHandler.java index 4ef70cf2..12aff672 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModelHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportModelHandler.java @@ -56,8 +56,6 @@ public class ImportModelHandler extends AbstractHandler { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); - } catch (SerializationException e) { - e.printStackTrace(); } if(tg == null) return null; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java index 4ecf3b8f..4da75f82 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ShowModuleHandler.java @@ -18,7 +18,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ReadRequest; @@ -65,8 +65,8 @@ public class ShowModuleHandler extends AbstractHandler { DiagramResource dr = DiagramResource.getInstance(graph); Resource runtime = viewer.getRuntime(); - String uri = graph.getPossibleRelatedValue(runtime, dr.HasVariable, StringBindingDefault.INSTANCE); - String currentRVI = graph.getPossibleRelatedValue(runtime, dr.HasRVI, StringBindingDefault.INSTANCE); + String uri = graph.getPossibleRelatedValue(runtime, dr.HasVariable, Bindings.STRING); + String currentRVI = graph.getPossibleRelatedValue(runtime, dr.HasRVI, Bindings.STRING); Variable variable = Variables.getVariable(graph, uri); Resource model = Variables.getModel(graph, variable); final String modelURI = graph.getURI(model); @@ -85,7 +85,7 @@ public class ShowModuleHandler extends AbstractHandler { if(diagram == null) return; - String finalRvi = currentRVI + "/" + graph.getPossibleRelatedValue(component, l0.HasName, StringBindingDefault.INSTANCE); + String finalRvi = currentRVI + "/" + graph.getPossibleRelatedValue(component, l0.HasName, Bindings.STRING); // This is ugly but it has to be done like this because WorkModel example has too PartOfs Resource rootLibrary = graph.getPossibleObject(model, l0.PartOf); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/DefaultVariable.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/DefaultVariable.java index 54608589..ad5bd59b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/DefaultVariable.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/DefaultVariable.java @@ -14,10 +14,11 @@ package org.simantics.sysdyn.ui.project; import java.util.List; import org.simantics.databoard.binding.Binding; -import org.simantics.databoard.binding.java.DoubleBindingDefault; -import org.simantics.databoard.binding.java.StringBindingDefault; -import org.simantics.databoard.binding.mutable.MutableDouble; -import org.simantics.databoard.type.DataType; +import org.simantics.databoard.Bindings; +import org.simantics.databoard.Bindings; +import org.simantics.databoard.Datatypes; +import org.simantics.databoard.primitives.MutableDouble; +import org.simantics.databoard.type.Datatype; import org.simantics.databoard.type.DoubleType; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -56,7 +57,7 @@ public class DefaultVariable extends ResourceVariable { @Override public T getValue(ReadGraph graph, Binding binding) throws DatabaseException { - if(!DoubleBindingDefault.INSTANCE.equals(binding)) return null; + if(!Bindings.DOUBLE.equals(binding)) return null; return getValue(graph); } @@ -64,7 +65,7 @@ public class DefaultVariable extends ResourceVariable { public void setValue(WriteGraph graph, Object object, Binding binding) throws DatabaseException { Layer0 l0 = Layer0.getInstance(graph); SysdynResource sr = SysdynResource.getInstance(graph); -// if(!DoubleBindingDefault.INSTANCE.equals(binding)) return; +// if(!Bindings.DOUBLE.equals(binding)) return; // if(!MutableDoubleBinding.INSTANCE.equals(binding)) return; Resource represents = graph.getPossibleObject(resource, l0.Represents); if(represents == null) return; @@ -76,14 +77,14 @@ public class DefaultVariable extends ResourceVariable { if(expression == null) return; if(!graph.isInstanceOf(expression, sr.ParameterExpression)) return; Double value = new Double(((MutableDouble)object).doubleValue()); - graph.claimLiteral(expression, sr.HasEquation, value.toString(), StringBindingDefault.INSTANCE); + graph.claimLiteral(expression, sr.HasEquation, value.toString(), Bindings.STRING); } @SuppressWarnings("unchecked") @Override public T getInterface(ReadGraph graph, Class clazz) throws DatabaseException { - if(DataType.class.equals(clazz)) return (T)DoubleType.INSTANCE; + if(Datatype.class.equals(clazz)) return (T)Datatypes.DOUBLE; return super.getInterface(graph, clazz); } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java index 6c557969..7fcc060c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java @@ -14,7 +14,7 @@ package org.simantics.sysdyn.ui.project; import java.util.Collection; import java.util.HashSet; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Session; @@ -69,7 +69,7 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { public void add(ReadGraph graph, final Resource run) throws DatabaseException { final Layer0 l0 = Layer0.getInstance(graph); - final String experimentName = graph.getPossibleRelatedValue(run, l0.HasName, StringBindingDefault.INSTANCE); + final String experimentName = graph.getPossibleRelatedValue(run, l0.HasName, Bindings.STRING); RuntimeValuations vs = graph.getService(RuntimeValuations.class); if(vs.supports(experimentName)) { @@ -81,7 +81,7 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { HashSet> result = new HashSet>(); Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration); for(Resource part : graph.getObjects(configuration, l0.ConsistsOf)) { - String partName = graph.getPossibleRelatedValue(part, l0.HasName, StringBindingDefault.INSTANCE); + String partName = graph.getPossibleRelatedValue(part, l0.HasName, Bindings.STRING); result.add(new Pair(partName, part)); } return result; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java index 41f43da3..191d715b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java @@ -21,7 +21,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PartInitException; import org.osgi.service.prefs.BackingStoreException; import org.simantics.databoard.accessor.Accessor; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -129,7 +129,7 @@ public class SysdynProject extends AbstractProjectFeature { Resource diagram = OrderedSetUtils.create(g, sr.ConfigurationDiagram); GraphLayer l = new GraphLayerUtil(g).createLayer(DiagramConstants.DEFAULT_LAYER_NAME, true); g.claim(diagram, mu.dr.HasLayer, l.getLayer()); - g.claimLiteral(diagram, l0.HasName, "Diagrammi", StringBindingDefault.INSTANCE); + g.claimLiteral(diagram, l0.HasName, "Diagrammi", Bindings.STRING); Resource conf = GraphUtils.create2(g, sr.Configuration, diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java index ffabdef0..0e43aba7 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java @@ -28,7 +28,7 @@ import org.simantics.browsing.ui.swt.widgets.TrackedText; import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -79,7 +79,7 @@ public class EnumerationTab extends PropertyTabContributorImpl { List> result = new ArrayList>(); for(Resource r : resourceList) { result.add(new Pair( - (String)graph.getRelatedValue(r, Layer0.getInstance(graph).HasName, StringBindingDefault.INSTANCE) + (String)graph.getRelatedValue(r, Layer0.getInstance(graph).HasName, Bindings.STRING) , r)); } return result; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ReferenceRow.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ReferenceRow.java index 70d37cc5..d3ad2718 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ReferenceRow.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ReferenceRow.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.properties.widgets; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; @@ -78,7 +78,7 @@ public class ReferenceRow { valueResource = graph.getPossibleObject(dependency, sr.HasHead); if(!graph.isInstanceOf(valueResource, sr.Variable)) return ""; - return (String)graph.getRelatedValue(valueResource, l0.HasName, StringBindingDefault.INSTANCE); + return (String)graph.getRelatedValue(valueResource, l0.HasName, Bindings.STRING); } }); } catch (DatabaseException e) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyModifier.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyModifier.java index 34459fef..58dc654e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyModifier.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyModifier.java @@ -12,7 +12,7 @@ package org.simantics.sysdyn.ui.properties.widgets.factories; import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl; -import org.simantics.databoard.binding.java.DoubleBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; @@ -32,7 +32,7 @@ public class DoublePropertyModifier extends TextModifyListenerImpl { if(graph.hasStatement(input, graph.getResource(propertyURI))) graph.deny(input, graph.getResource(propertyURI)); } else { - graph.claimLiteral(input, graph.getResource(propertyURI), Double.parseDouble(text), DoubleBindingDefault.INSTANCE); + graph.claimLiteral(input, graph.getResource(propertyURI), Double.parseDouble(text), Bindings.DOUBLE); } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/VariableNamePropertyModifier.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/VariableNamePropertyModifier.java index 4025beb8..c6320dfd 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/VariableNamePropertyModifier.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/VariableNamePropertyModifier.java @@ -12,7 +12,7 @@ package org.simantics.sysdyn.ui.properties.widgets.factories; import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; @@ -39,6 +39,6 @@ public class VariableNamePropertyModifier extends TextModifyListenerImpl getLabel(ReadGraph graph, OperationModelNode model) throws DatabaseException { - String label = model.data.getPropertyValue(graph, "Name", StringBindingDefault.INSTANCE); + String label = model.data.getPropertyValue(graph, "Name", Bindings.STRING); return new ArrayMap(new String[] { ColumnKeys.SINGLE } , new String[] { label }); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java index 7a2210dc..bdcd46d9 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/property/OperationVariableLabels.java @@ -15,7 +15,7 @@ import java.util.Map; import org.simantics.browsing.ui.common.ColumnKeys; import org.simantics.browsing.ui.graph.contributor.labeler.ColumnLabelerContributor; -import org.simantics.databoard.binding.java.StringBindingDefault; +import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; @@ -26,7 +26,7 @@ public class OperationVariableLabels extends ColumnLabelerContributor @Override public Map getLabel(ReadGraph graph, Variable variable) throws DatabaseException { - String label = variable.getPropertyValue(graph, "Name", StringBindingDefault.INSTANCE); + String label = variable.getPropertyValue(graph, "Name", Bindings.STRING); return new ArrayMap(new String[] { ColumnKeys.SINGLE } , new String[] { label }); -- 2.47.1