From: Antti Villberg Date: Fri, 26 Oct 2018 11:54:42 +0000 (+0300) Subject: Refactoring of simulator toolkit X-Git-Tag: v1.43.0~136^2~311^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=bb4e04be3cb29a5d08e412cd4eaa90ad0158b954;p=simantics%2Fplatform.git Refactoring of simulator toolkit gitlab #162 Change-Id: Id68f68667a1ad5840eccbd53a4b8ec81483c0cdb --- diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateNodeManager.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateNodeManager.java index 0b48e2722..97bc4b1c7 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateNodeManager.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateNodeManager.java @@ -1,9 +1,7 @@ package org.simantics.document.server.state; import java.io.IOException; -import java.util.Collections; import java.util.Map; -import java.util.Set; import org.simantics.databoard.Bindings; import org.simantics.databoard.binding.Binding; @@ -11,38 +9,19 @@ import org.simantics.databoard.binding.error.BindingConstructionException; import org.simantics.databoard.binding.mutable.Variant; import org.simantics.databoard.serialization.RuntimeSerializerConstructionException; import org.simantics.databoard.serialization.SerializerConstructionException; -import org.simantics.db.layer0.variable.NodeSupport; -import org.simantics.simulator.toolkit.StandardNodeManager; import org.simantics.simulator.toolkit.StandardRealm; +import org.simantics.simulator.toolkit.db.StandardVariableNodeManager; import org.simantics.simulator.variable.exceptions.NodeManagerException; import org.slf4j.LoggerFactory; -public class StateNodeManager extends StandardNodeManager { +public class StateNodeManager extends StandardVariableNodeManager { private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StateNodeManager.class); - private NodeSupport support; - public StateNodeManager(StandardRealm realm, StateNode root) { super(realm, root); } - public void registerSupport(NodeSupport support) { - this.support = support; - } - - @Override - public Set getClassifications(StateNode node) throws NodeManagerException { - return Collections.emptySet(); - } - - @Override - public void refreshVariable(StateNode node) { - super.refreshVariable(node); - support.valueCache.clearExpired(); - support.structureCache.clearExpired(); - } - public void setState(String key, Object value) { try { getRealm().syncExec(() -> { diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateSessionManager.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateSessionManager.java index 267217c20..321141abc 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateSessionManager.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/state/StateSessionManager.java @@ -2,12 +2,10 @@ package org.simantics.document.server.state; import org.simantics.db.ReadGraph; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.NodeSupport; -import org.simantics.simulator.toolkit.StandardNodeManager; import org.simantics.simulator.toolkit.StandardRealm; -import org.simantics.simulator.toolkit.db.StandardSessionManager; +import org.simantics.simulator.toolkit.db.StandardVariableSessionManager; -public class StateSessionManager extends StandardSessionManager { +public class StateSessionManager extends StandardVariableSessionManager { private static StateSessionManager INSTANCE; @@ -28,10 +26,4 @@ public class StateSessionManager extends StandardSessionManager manager, - NodeSupport support) { - ((StateNodeManager)manager).registerSupport(support); - } - } diff --git a/bundles/org.simantics.jdbc/src/org/simantics/jdbc/variable/JDBCSessionManager.java b/bundles/org.simantics.jdbc/src/org/simantics/jdbc/variable/JDBCSessionManager.java index f6a6077e4..17ffcf143 100644 --- a/bundles/org.simantics.jdbc/src/org/simantics/jdbc/variable/JDBCSessionManager.java +++ b/bundles/org.simantics.jdbc/src/org/simantics/jdbc/variable/JDBCSessionManager.java @@ -21,7 +21,7 @@ import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.NodeSupport; import org.simantics.jdbc.SimanticsJDBC; import org.simantics.simulator.toolkit.StandardRealm; -import org.simantics.simulator.toolkit.db.StandardSessionManager; +import org.simantics.simulator.toolkit.db.StandardVariableSessionManager; import org.simantics.simulator.variable.exceptions.NodeManagerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,7 +30,7 @@ import com.impossibl.postgres.api.jdbc.PGConnection; import com.impossibl.postgres.api.jdbc.PGNotificationListener; import com.impossibl.postgres.jdbc.PGDataSource; -public class JDBCSessionManager extends StandardSessionManager { +public class JDBCSessionManager extends StandardVariableSessionManager { private static final Logger LOGGER = LoggerFactory.getLogger(JDBCSessionManager.class); private static JDBCSessionManager INSTANCE = new JDBCSessionManager(); diff --git a/bundles/org.simantics.simulator.toolkit.db/META-INF/MANIFEST.MF b/bundles/org.simantics.simulator.toolkit.db/META-INF/MANIFEST.MF index ea7f97e6d..982c354d0 100644 --- a/bundles/org.simantics.simulator.toolkit.db/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.simulator.toolkit.db/META-INF/MANIFEST.MF @@ -5,6 +5,7 @@ Bundle-SymbolicName: org.simantics.simulator.toolkit.db Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.simantics.simulator.toolkit;bundle-version="1.0.0";visibility:=reexport, - org.simantics.db.layer0;bundle-version="1.1.0" + org.simantics.db.layer0;bundle-version="1.1.0", + org.slf4j.api;bundle-version="1.7.25" Export-Package: org.simantics.simulator.toolkit.db Bundle-Vendor: Semantum Oy diff --git a/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardSessionManager.java b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardSessionManager.java index 47b678282..2ad2546a6 100644 --- a/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardSessionManager.java +++ b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardSessionManager.java @@ -1,130 +1,7 @@ package org.simantics.simulator.toolkit.db; -import java.util.Collection; -import java.util.concurrent.ConcurrentHashMap; - -import org.simantics.db.ReadGraph; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.ParametrizedPrimitiveRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.NodeSupport; -import org.simantics.db.procedure.Listener; -import org.simantics.simulator.toolkit.StandardNodeManager; import org.simantics.simulator.toolkit.StandardNodeManagerSupport; -import org.simantics.simulator.toolkit.StandardRealm; - -public abstract class StandardSessionManager> { - - private ConcurrentHashMap>> realmListeners = new ConcurrentHashMap<>(); - private ConcurrentHashMap> REALMS = new ConcurrentHashMap<>(); - private ConcurrentHashMap> SUPPORTS = new ConcurrentHashMap<>(); - - // Accessing Realms should be done over ParametrizedPrimitveRead for the - // case if a realm is destroyed and new one is created with the same id than - // the previously deleted one for the listeners to get discarded and new - // registered - private class RealmRequest extends ParametrizedPrimitiveRead> { - - public RealmRequest(String parameter) { - super(parameter); - } - - @Override - public void register(ReadGraph graph, Listener> procedure) { - StandardRealm realm = REALMS.get(parameter); - if (realm == null) { - try { - realm = createRealmInner(graph, parameter); - } catch (DatabaseException e) { - e.printStackTrace(); - } - } - - if(procedure.isDisposed()) { - procedure.execute(realm); - return; - } - - Listener> existing = getOrDisposeListener(parameter); - assert(existing == null); - realmListeners.put(parameter, procedure); - procedure.execute(realm); - } - - private StandardRealm createRealmInner(ReadGraph graph, String id) throws DatabaseException { - Engine engine = createEngine(graph, id); - StandardRealm realm = createRealm(engine, id); - modifyRealms(id, realm); - return realm; - } - } - - protected StandardSessionManager() { - } - - private Listener> getOrDisposeListener(String key) { - Listener> listener = realmListeners.get(key); - if(listener != null) { - if(listener.isDisposed()) { - realmListeners.remove(key); - } else { - return listener; - } - } - return null; - } - - private void modifyRealms(String key, StandardRealm realm) { - if(realm != null) { - REALMS.put(key, realm); - } else { - StandardRealm removedRealm = REALMS.remove(key); - if (removedRealm != null) - removedRealm.close(); - } - Listener> listener = getOrDisposeListener(key); - if(listener != null) { - listener.execute(realm); - } - } - - public void registerNodeSupport(StandardNodeManager realm, NodeSupport support) { - - } - - public NodeSupport getOrCreateNodeSupport(ReadGraph graph, String id) throws DatabaseException { - synchronized(SUPPORTS) { - NodeSupport result = SUPPORTS.get(id); - if(result == null) { - StandardRealm realm = getOrCreateRealm(graph, id); - result = new NodeSupport(realm.getNodeManager()); - registerNodeSupport(realm.getNodeManager(), result); - SUPPORTS.put(id, result); - } - return result; - } - } - - public StandardRealm getOrCreateRealm(ReadGraph graph, String id) throws DatabaseException { - synchronized(REALMS) { - return graph.syncRequest(new RealmRequest(id)); - } - } - - protected abstract Engine createEngine(ReadGraph graph, String id) throws DatabaseException; - protected abstract StandardRealm createRealm(Engine engine, String id); - public void removeRealm(WriteGraph graph, String id) throws DatabaseException { - modifyRealms(id, null); - // remove listeners from this realm - realmListeners.remove(id); - // if node support has been created remove it as well - NodeSupport support = SUPPORTS.remove(id); - if (support != null) - support.dispose(); - } +public abstract class StandardSessionManager> extends StandardVariableSessionManager { - public Collection getRealms() { - return REALMS.keySet(); - } } diff --git a/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableManagerVariableBuilder.java b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableManagerVariableBuilder.java new file mode 100644 index 000000000..7699a24fe --- /dev/null +++ b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableManagerVariableBuilder.java @@ -0,0 +1,29 @@ +package org.simantics.simulator.toolkit.db; + +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.NodeManagerVariableBuilder; +import org.simantics.db.layer0.variable.NodeSupport; +import org.simantics.simulator.toolkit.StandardNodeManager; + +public abstract class StandardVariableManagerVariableBuilder extends NodeManagerVariableBuilder { + + @Override + protected Object getRoot(ReadGraph graph, NodeSupport support, String sessionName) { + StandardNodeManager manager = (StandardNodeManager)support.manager; + return manager.getRoot(); + } + + /* + * For compatibility reasons. Existing implementations implement getNodeSupport directly and in that case this is not needed. + * New implementations should not implement getNodeSupport but rather implement this. + */ + protected StandardVariableSessionManager getSessionManager() { + throw new UnsupportedOperationException(); + } + + protected NodeSupport getNodeSupport(ReadGraph graph, String sessionName) throws DatabaseException { + return getSessionManager().getOrCreateNodeSupport(graph, sessionName); + } + +} diff --git a/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableNodeManager.java b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableNodeManager.java new file mode 100644 index 000000000..883f8099f --- /dev/null +++ b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableNodeManager.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2013 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 + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.simulator.toolkit.db; + +import org.simantics.db.layer0.variable.NodeSupport; +import org.simantics.simulator.toolkit.StandardNodeManager; +import org.simantics.simulator.toolkit.StandardNodeManagerSupport; +import org.simantics.simulator.toolkit.StandardRealm; + +/** + * Adds support for Layer0 Variable interface in StandardNodeManager + * + * @author Antti Villberg + */ +public class StandardVariableNodeManager> extends StandardNodeManager { + + protected NodeSupport support; + + public StandardVariableNodeManager(StandardRealm realm, Node root) { + super(realm, root); + this.support = new NodeSupport<>(this); + } + +/* public void registerNodeSupport(NodeSupport support) { + this.support = support; + } + + + public void registerSupport(NodeSupport support) { + this.support = support; + }*/ + + @Override + public void refreshVariable(Node node) { + super.refreshVariable(node); + support.valueCache.clearExpired(); + support.structureCache.clearExpired(); + } + +} \ No newline at end of file diff --git a/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableRealm.java b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableRealm.java new file mode 100644 index 000000000..6ed50d429 --- /dev/null +++ b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableRealm.java @@ -0,0 +1,18 @@ +package org.simantics.simulator.toolkit.db; + +import org.simantics.simulator.toolkit.StandardNodeManager; +import org.simantics.simulator.toolkit.StandardNodeManagerSupport; +import org.simantics.simulator.toolkit.StandardRealm; + +public abstract class StandardVariableRealm> extends StandardRealm { + + protected StandardVariableRealm(Engine engine, String id) { + super(engine, id); + } + + @Override + protected StandardNodeManager createManager(Node root) { + return new StandardVariableNodeManager(this, root); + } + +} \ No newline at end of file diff --git a/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableSessionManager.java b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableSessionManager.java new file mode 100644 index 000000000..5e824f45f --- /dev/null +++ b/bundles/org.simantics.simulator.toolkit.db/src/org/simantics/simulator/toolkit/db/StandardVariableSessionManager.java @@ -0,0 +1,129 @@ +package org.simantics.simulator.toolkit.db; + +import java.util.Collection; +import java.util.concurrent.ConcurrentHashMap; + +import org.simantics.db.ReadGraph; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.ParametrizedPrimitiveRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.NodeSupport; +import org.simantics.db.procedure.Listener; +import org.simantics.simulator.toolkit.StandardNodeManagerSupport; +import org.simantics.simulator.toolkit.StandardRealm; +import org.simantics.simulator.variable.NodeManager; + +public abstract class StandardVariableSessionManager> { + + private ConcurrentHashMap>> realmListeners = new ConcurrentHashMap<>(); + private ConcurrentHashMap> REALMS = new ConcurrentHashMap<>(); + private ConcurrentHashMap> SUPPORTS = new ConcurrentHashMap<>(); + + // Accessing Realms should be done over ParametrizedPrimitveRead for the + // case if a realm is destroyed and new one is created with the same id than + // the previously deleted one for the listeners to get discarded and new + // registered + private class RealmRequest extends ParametrizedPrimitiveRead> { + + public RealmRequest(String parameter) { + super(parameter); + } + + @Override + public void register(ReadGraph graph, Listener> procedure) { + StandardRealm realm = REALMS.get(parameter); + if (realm == null) { + try { + realm = createRealmInner(graph, parameter); + } catch (DatabaseException e) { + e.printStackTrace(); + } + } + + if(procedure.isDisposed()) { + procedure.execute(realm); + return; + } + + Listener> existing = getOrDisposeListener(parameter); + assert(existing == null); + realmListeners.put(parameter, procedure); + procedure.execute(realm); + } + + private StandardRealm createRealmInner(ReadGraph graph, String id) throws DatabaseException { + Engine engine = createEngine(graph, id); + StandardRealm realm = createRealm(engine, id); + modifyRealms(id, realm); + return realm; + } + } + + protected StandardVariableSessionManager() { + } + + private Listener> getOrDisposeListener(String key) { + Listener> listener = realmListeners.get(key); + if(listener != null) { + if(listener.isDisposed()) { + realmListeners.remove(key); + } else { + return listener; + } + } + return null; + } + + private void modifyRealms(String key, StandardRealm realm) { + if(realm != null) { + REALMS.put(key, realm); + } else { + StandardRealm removedRealm = REALMS.remove(key); + if (removedRealm != null) + removedRealm.close(); + } + Listener> listener = getOrDisposeListener(key); + if(listener != null) { + listener.execute(realm); + } + } + + public NodeSupport getOrCreateNodeSupport(ReadGraph graph, String id) throws DatabaseException { + synchronized(SUPPORTS) { + NodeSupport result = SUPPORTS.get(id); + if(result == null) { + StandardRealm realm = getOrCreateRealm(graph, id); + NodeManager nodeManager = realm.getNodeManager(); + if(!(nodeManager instanceof StandardVariableNodeManager)) + throw new DatabaseException("StandardVariableSessionManager requires an instance of StandardVariableNodeManager, got " + nodeManager.getClass()); + StandardVariableNodeManager svnm = (StandardVariableNodeManager)nodeManager; + result = svnm.support; + SUPPORTS.put(id, result); + } + return result; + } + } + + public StandardRealm getOrCreateRealm(ReadGraph graph, String id) throws DatabaseException { + synchronized(REALMS) { + return graph.syncRequest(new RealmRequest(id)); + } + } + + protected abstract Engine createEngine(ReadGraph graph, String id) throws DatabaseException; + protected abstract StandardRealm createRealm(Engine engine, String id); + + public void removeRealm(WriteGraph graph, String id) throws DatabaseException { + modifyRealms(id, null); + // remove listeners from this realm + realmListeners.remove(id); + // if node support has been created remove it as well + NodeSupport support = SUPPORTS.remove(id); + if (support != null) + support.dispose(); + } + + public Collection getRealms() { + return REALMS.keySet(); + } +} diff --git a/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardNodeManager.java b/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardNodeManager.java index 8a51fd330..b8a549087 100644 --- a/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardNodeManager.java +++ b/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardNodeManager.java @@ -13,6 +13,7 @@ package org.simantics.simulator.toolkit; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -46,7 +47,7 @@ import gnu.trove.set.hash.THashSet; * * @author Antti Villberg */ -public abstract class StandardNodeManager> implements NodeManager { +public class StandardNodeManager> implements NodeManager { private static final Logger LOGGER = LoggerFactory.getLogger(StandardNodeManager.class); @@ -424,4 +425,9 @@ public abstract class StandardNodeManager getClassifications(Node node) throws NodeManagerException { + return Collections.emptySet(); + } + } \ No newline at end of file diff --git a/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardRealm.java b/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardRealm.java index e228b603d..8551222b2 100644 --- a/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardRealm.java +++ b/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/StandardRealm.java @@ -46,7 +46,21 @@ abstract public class StandardRealm createManager(); + protected StandardNodeManager createManager(Node root) { + return new StandardNodeManager(this, root); + } + + protected StandardNodeManager createManager() { + return createManager(createRootNode()); + } + + /* + * For compatibility reasons. Existing implementations implement createManager() directly and in that case this is not needed. + * New implementations should not implement createManager() but rather implement this. + */ + protected Node createRootNode() { + throw new UnsupportedOperationException(); + } protected String getSCLContextKey() { return getClass().getSimpleName(); diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java index 5a7dcd5ee..d741d4c7a 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetBook.java @@ -24,12 +24,12 @@ import org.simantics.spreadsheet.graph.synchronization.LineUpdater; import org.simantics.spreadsheet.graph.synchronization.NullUpdater; import org.simantics.spreadsheet.graph.synchronization.SheetLineComponent; import org.simantics.spreadsheet.graph.synchronization.StyleUpdater; -import org.simantics.structural.synchronization.base.ComponentFactory; -import org.simantics.structural.synchronization.base.MappingBase; import org.simantics.structural.synchronization.base.ModuleUpdaterBase; import org.simantics.structural.synchronization.base.ModuleUpdaterFactoryBase; -import org.simantics.structural.synchronization.base.Solver; import org.simantics.structural.synchronization.base.SolverNameUtil; +import org.simantics.structural.synchronization.utils.ComponentFactory; +import org.simantics.structural.synchronization.utils.MappingBase; +import org.simantics.structural.synchronization.utils.Solver; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.longs.AbstractLongList; diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetMapping.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetMapping.java index 23ce1cf11..64079d2b0 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetMapping.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetMapping.java @@ -3,10 +3,10 @@ package org.simantics.spreadsheet.graph; import java.io.Serializable; import org.simantics.spreadsheet.graph.synchronization.SheetLineComponent; -import org.simantics.structural.synchronization.base.ComponentFactory; -import org.simantics.structural.synchronization.base.MappingBase; -import org.simantics.structural.synchronization.base.Solver; -import org.simantics.structural.synchronization.base.StateUndoContextBase; +import org.simantics.structural.synchronization.utils.ComponentFactory; +import org.simantics.structural.synchronization.utils.MappingBase; +import org.simantics.structural.synchronization.utils.Solver; +import org.simantics.structural.synchronization.utils.StateUndoContextBase; public class SpreadsheetMapping extends MappingBase implements Serializable { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java index 6428f9b83..6c3c0b17c 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetReferenceResolver.java @@ -2,7 +2,7 @@ package org.simantics.spreadsheet.graph; import org.simantics.spreadsheet.graph.synchronization.SheetLineComponent; import org.simantics.structural.synchronization.base.ReferenceResolverBase; -import org.simantics.structural.synchronization.base.Solver; +import org.simantics.structural.synchronization.utils.Solver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetSessionManager.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetSessionManager.java index 19c994806..f50463ef0 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetSessionManager.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/SpreadsheetSessionManager.java @@ -19,7 +19,7 @@ import org.simantics.db.layer0.variable.ProxyVariables; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.layer0.variable.Variables; import org.simantics.simulator.toolkit.StandardRealm; -import org.simantics.simulator.toolkit.db.StandardSessionManager; +import org.simantics.simulator.toolkit.db.StandardVariableSessionManager; import org.simantics.spreadsheet.graph.formula.SpreadsheetEvaluationEnvironment; import org.simantics.spreadsheet.graph.synchronization.SpreadsheetSynchronizationEventHandler; import org.simantics.spreadsheet.resource.SpreadsheetResource; @@ -27,7 +27,7 @@ import org.simantics.structural.synchronization.Synchronizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SpreadsheetSessionManager extends StandardSessionManager { +public class SpreadsheetSessionManager extends StandardVariableSessionManager { private static final Logger LOGGER = LoggerFactory.getLogger(SpreadsheetSessionManager.class); diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineCommandBuilder.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineCommandBuilder.java index 6e1914361..90c96cc2d 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineCommandBuilder.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineCommandBuilder.java @@ -18,7 +18,7 @@ import org.simantics.spreadsheet.graph.parser.SheetFormulaParser; import org.simantics.spreadsheet.graph.parser.ast.AstArrayFormulaReference; import org.simantics.spreadsheet.graph.parser.ast.AstValue; import org.simantics.structural.synchronization.base.CommandBuilder; -import org.simantics.structural.synchronization.base.Solver; +import org.simantics.structural.synchronization.utils.Solver; public class LineCommandBuilder implements CommandBuilder { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineUpdater.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineUpdater.java index 3462b247f..baa0851b2 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineUpdater.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LineUpdater.java @@ -10,7 +10,7 @@ import org.simantics.structural.synchronization.base.CommandBuilder; import org.simantics.structural.synchronization.base.ModuleUpdateContext; import org.simantics.structural.synchronization.base.ModuleUpdaterBase; import org.simantics.structural.synchronization.base.PropertyUpdateRule; -import org.simantics.structural.synchronization.base.Solver; +import org.simantics.structural.synchronization.utils.Solver; public class LineUpdater extends ModuleUpdaterBase { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java index be7f25c9e..4cf804c2d 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/LinesCommandBuilder.java @@ -3,7 +3,7 @@ package org.simantics.spreadsheet.graph.synchronization; import org.simantics.spreadsheet.graph.SpreadsheetBook; import org.simantics.spreadsheet.graph.SpreadsheetLines; import org.simantics.structural.synchronization.base.CommandBuilder; -import org.simantics.structural.synchronization.base.Solver; +import org.simantics.structural.synchronization.utils.Solver; public class LinesCommandBuilder implements CommandBuilder { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/NullCommandBuilder.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/NullCommandBuilder.java index 6e16386f7..80ed1ca13 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/NullCommandBuilder.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/NullCommandBuilder.java @@ -1,7 +1,7 @@ package org.simantics.spreadsheet.graph.synchronization; import org.simantics.structural.synchronization.base.CommandBuilder; -import org.simantics.structural.synchronization.base.Solver; +import org.simantics.structural.synchronization.utils.Solver; public class NullCommandBuilder implements CommandBuilder { diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/SheetLineComponent.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/SheetLineComponent.java index c3b40737d..5edea565f 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/SheetLineComponent.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/SheetLineComponent.java @@ -2,7 +2,7 @@ package org.simantics.spreadsheet.graph.synchronization; import java.io.Serializable; -import org.simantics.structural.synchronization.base.ComponentBase; +import org.simantics.structural.synchronization.utils.ComponentBase; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectProcedure; diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/StyleUpdater.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/StyleUpdater.java index de5b47cc8..4451d1314 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/StyleUpdater.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/synchronization/StyleUpdater.java @@ -12,7 +12,7 @@ import org.simantics.structural.synchronization.base.CommandBuilder; import org.simantics.structural.synchronization.base.ModuleUpdateContext; import org.simantics.structural.synchronization.base.ModuleUpdaterBase; import org.simantics.structural.synchronization.base.PropertyUpdateRule; -import org.simantics.structural.synchronization.base.Solver; +import org.simantics.structural.synchronization.utils.Solver; public class StyleUpdater extends ModuleUpdaterBase { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/CommandBuilder.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/CommandBuilder.java index 45f2791a8..57b8d9a06 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/CommandBuilder.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/CommandBuilder.java @@ -1,5 +1,7 @@ package org.simantics.structural.synchronization.base; +import org.simantics.structural.synchronization.utils.Solver; + public interface CommandBuilder { void apply(Solver solver); diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ConnectionUpdateRule.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ConnectionUpdateRule.java index dd59baa55..144833a7a 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ConnectionUpdateRule.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ConnectionUpdateRule.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.Map; import org.simantics.databoard.binding.mutable.Variant; +import org.simantics.structural.synchronization.utils.ComponentBase; public interface ConnectionUpdateRule> { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java index 1615aaf2b..854a22d23 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdateContext.java @@ -5,6 +5,8 @@ import gnu.trove.map.hash.THashMap; import java.util.ArrayList; import org.simantics.databoard.binding.mutable.Variant; +import org.simantics.structural.synchronization.utils.ComponentBase; +import org.simantics.structural.synchronization.utils.Solver; public class ModuleUpdateContext> { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterBase.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterBase.java index 9ec63c061..45ea7400f 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterBase.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterBase.java @@ -9,6 +9,7 @@ import java.util.Map; import org.simantics.databoard.binding.mutable.Variant; import org.simantics.structural.synchronization.protocol.Connection; import org.simantics.structural.synchronization.protocol.SerializedVariable; +import org.simantics.structural.synchronization.utils.ComponentBase; abstract public class ModuleUpdaterBase> { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterFactoryBase.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterFactoryBase.java index 04320c946..f30527e3d 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterFactoryBase.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ModuleUpdaterFactoryBase.java @@ -1,6 +1,7 @@ package org.simantics.structural.synchronization.base; import org.simantics.db.exception.DatabaseException; +import org.simantics.structural.synchronization.utils.ComponentBase; public interface ModuleUpdaterFactoryBase> { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/PropertyUpdateRule.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/PropertyUpdateRule.java index 32f94c27c..a0b734d15 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/PropertyUpdateRule.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/PropertyUpdateRule.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.Map; import org.simantics.databoard.binding.mutable.Variant; +import org.simantics.structural.synchronization.utils.ComponentBase; public interface PropertyUpdateRule> { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java index 7fabc6747..33b5d9bdc 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ReferenceResolverBase.java @@ -8,6 +8,8 @@ import java.util.Collections; import org.simantics.databoard.util.URIStringUtils; import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler; +import org.simantics.structural.synchronization.utils.ComponentBase; +import org.simantics.structural.synchronization.utils.Solver; import org.slf4j.Logger; abstract public class ReferenceResolverBase> { @@ -116,7 +118,7 @@ abstract public class ReferenceResolverBase> { private static void fullPathOfComponent(StringBuilder b, ComponentBase component) { if(component != null) { - fullPathOfComponent(b, component.parent); + fullPathOfComponent(b, component.getParent()); b.append("/").append(component.solverComponentName); } } diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java index 82dd224b6..7be353a02 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/SynchronizationEventHandlerBase.java @@ -15,6 +15,10 @@ import org.simantics.structural.synchronization.protocol.Connection; import org.simantics.structural.synchronization.protocol.SerializedVariable; import org.simantics.structural.synchronization.protocol.SynchronizationEventHandler; import org.simantics.structural.synchronization.protocol.SynchronizationException; +import org.simantics.structural.synchronization.utils.ComponentBase; +import org.simantics.structural.synchronization.utils.ComponentFactory; +import org.simantics.structural.synchronization.utils.MappingBase; +import org.simantics.structural.synchronization.utils.Solver; import org.slf4j.Logger; import gnu.trove.map.hash.THashMap; diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/UpdateComponentUids.java b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/UpdateComponentUids.java index 0c051ecef..df63ada05 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/UpdateComponentUids.java +++ b/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/UpdateComponentUids.java @@ -5,6 +5,7 @@ import org.simantics.db.ReadGraph; import org.simantics.db.exception.CancelTransactionException; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; +import org.simantics.structural.synchronization.utils.ComponentBase; import gnu.trove.map.hash.THashMap; diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ComponentBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/ComponentBase.java similarity index 98% rename from bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ComponentBase.java rename to bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/ComponentBase.java index 943b79704..ae0ae7720 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ComponentBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/ComponentBase.java @@ -1,4 +1,4 @@ -package org.simantics.structural.synchronization.base; +package org.simantics.structural.synchronization.utils; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectObjectProcedure; diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ComponentFactory.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/ComponentFactory.java similarity index 62% rename from bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ComponentFactory.java rename to bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/ComponentFactory.java index 82ffe07cb..1bd604f8b 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/ComponentFactory.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/ComponentFactory.java @@ -1,4 +1,4 @@ -package org.simantics.structural.synchronization.base; +package org.simantics.structural.synchronization.utils; public interface ComponentFactory> { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/MappingBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java similarity index 99% rename from bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/MappingBase.java rename to bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java index 78678b505..3c96a3fef 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/MappingBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/MappingBase.java @@ -1,12 +1,12 @@ -package org.simantics.structural.synchronization.base; +package org.simantics.structural.synchronization.utils; + +import java.io.PrintWriter; import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TObjectObjectProcedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; -import java.io.PrintWriter; - /** * The entry point to the mapping structure between Simantics database and a * designated solver. It is used to synchronize changes from Simantics to the diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/Solver.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/Solver.java similarity index 85% rename from bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/Solver.java rename to bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/Solver.java index 6bda54418..a448821a8 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/Solver.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/Solver.java @@ -1,4 +1,4 @@ -package org.simantics.structural.synchronization.base; +package org.simantics.structural.synchronization.utils; public interface Solver { diff --git a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/StateUndoContextBase.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/StateUndoContextBase.java similarity index 83% rename from bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/StateUndoContextBase.java rename to bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/StateUndoContextBase.java index b268104e3..8c5730428 100644 --- a/bundles/org.simantics.structural.synchronization.client/src/org/simantics/structural/synchronization/base/StateUndoContextBase.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/utils/StateUndoContextBase.java @@ -1,5 +1,4 @@ -package org.simantics.structural.synchronization.base; - +package org.simantics.structural.synchronization.utils; /** * Stores state information of removed modules.