org.simantics.browsing.ui.common.node,
org.simantics.browsing.ui.common.processors,
org.simantics.browsing.ui.common.property,
+ org.simantics.browsing.ui.common.state,
org.simantics.browsing.ui.common.viewpoints,
org.simantics.browsing.ui.common.views
Bundle-Vendor: VTT Technical Research Center of Finland
--- /dev/null
+package org.simantics.browsing.ui.common.state;
+
+import java.io.File;
+import java.util.concurrent.CompletableFuture;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.simantics.DatabaseJob;
+import org.simantics.browsing.ui.ExplorerState;
+import org.simantics.browsing.ui.NodeContext;
+import org.simantics.browsing.ui.StatePersistor;
+import org.simantics.browsing.ui.common.Activator;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.36.0
+ */
+public class ExplorerStates {
+
+ public static File explorerStateLocation() {
+ return Platform.getStateLocation(Activator.getDefault().getBundle()).toFile();
+ }
+
+ public static CompletableFuture<ExplorerState> scheduleRead(NodeContext root, StatePersistor persistor) {
+ CompletableFuture<ExplorerState> result = new CompletableFuture<>();
+ new ReaderJob(root, persistor, result).schedule();
+ return result;
+ }
+
+ private static class ReaderJob extends DatabaseJob {
+
+ private NodeContext root;
+ private StatePersistor persistor;
+ private CompletableFuture<ExplorerState> consumer;
+
+ public ReaderJob(NodeContext root, StatePersistor persistor, CompletableFuture<ExplorerState> consumer) {
+ super("Reading previous graph explorer state");
+ this.root = root;
+ this.persistor = persistor;
+ this.consumer = consumer;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ monitor.beginTask("Loading persisted data", 1);
+ ExplorerState state = persistor.deserialize(explorerStateLocation(), root);
+ monitor.worked(1);
+ consumer.complete(state);
+ return Status.OK_STATUS;
+ } finally {
+ monitor.done();
+ }
+ }
+
+ }
+
+}
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
*******************************************************************************/
-package org.simantics.browsing.ui.swt;
+package org.simantics.browsing.ui.common.state;
import java.util.Map;
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
*******************************************************************************/
-package org.simantics.browsing.ui.swt;
+package org.simantics.browsing.ui.common.state;
import java.util.TreeMap;
-package org.simantics.browsing.ui.swt;
+package org.simantics.browsing.ui.common.state;
import java.io.File;
import java.nio.file.Files;
import org.simantics.browsing.ui.NodeContext;
import org.simantics.browsing.ui.StatePersistor;
import org.simantics.databoard.util.StringUtil;
-import org.simantics.db.common.utils.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Tuukka Lehtonen
*/
public class IdentifiedStatePersistor implements StatePersistor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(IdentifiedStatePersistor.class);
+
protected final String id;
public IdentifiedStatePersistor(String id) {
if (bean != null && memento != null)
Files.write(memento, bean.serialize());
} catch (Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("Failed to serialize ExplorerState " + state, t);
}
}
stateBean.deserialize( Files.readAllBytes(path) );
return toState(stateBean);
} catch (Throwable t) {
- Logger.defaultLogError(t);
+ LOGGER.error("Failed to deserialize ExplorerState from " + path, t);
return ExplorerState.EMPTY;
}
}
* Contributors:
* Semantum Oy - initial API and implementation
*******************************************************************************/
-package org.simantics.browsing.ui.swt;
+package org.simantics.browsing.ui.common.state;
import org.simantics.databoard.annotations.Optional;
import org.simantics.databoard.util.Bean;
* Contributors:
* Semantum Oy - initial API and implementation
*******************************************************************************/
-package org.simantics.browsing.ui.swt;
+package org.simantics.browsing.ui.common.state;
import org.simantics.databoard.annotations.Optional;
import org.simantics.databoard.util.Bean;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.ColorDescriptor;
import org.simantics.browsing.ui.common.processors.IsExpandedProcessor;
import org.simantics.browsing.ui.common.processors.NoSelectionRequestProcessor;
import org.simantics.browsing.ui.common.processors.ProcessorLifecycle;
+import org.simantics.browsing.ui.common.state.ExplorerStates;
import org.simantics.browsing.ui.content.Labeler;
import org.simantics.browsing.ui.content.Labeler.CustomModifier;
import org.simantics.browsing.ui.content.Labeler.DialogModifier;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.AdaptionUtils;
import org.simantics.utils.ui.ISelectionUtils;
+import org.simantics.utils.ui.SWTUtils;
import org.simantics.utils.ui.jface.BasePostSelectionProvider;
import gnu.trove.map.hash.THashMap;
private void initializeState() {
if (persistor == null)
return;
+ ExplorerStates.scheduleRead(getRoot(), persistor)
+ .thenAccept(state -> SWTUtils.asyncExec(natTable, () -> restoreState(state)));
+ }
- ExplorerState state = persistor.deserialize(
- Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
- getRoot());
-
-
+ private void restoreState(ExplorerState state) {
Object processor = getPrimitiveProcessor(BuiltinKeys.IS_EXPANDED);
if (processor instanceof DefaultIsExpandedProcessor) {
DefaultIsExpandedProcessor isExpandedProcessor = (DefaultIsExpandedProcessor)processor;
for(NodeContext expanded : state.expandedNodes) {
- isExpandedProcessor.setExpanded(expanded, true);
+ isExpandedProcessor.replaceExpanded(expanded, true);
}
}
}
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IStatusLineManager;
import org.simantics.browsing.ui.common.processors.IsExpandedProcessor;
import org.simantics.browsing.ui.common.processors.NoSelectionRequestProcessor;
import org.simantics.browsing.ui.common.processors.ProcessorLifecycle;
+import org.simantics.browsing.ui.common.state.ExplorerStates;
import org.simantics.browsing.ui.content.ImageDecorator;
import org.simantics.browsing.ui.content.Imager;
import org.simantics.browsing.ui.content.LabelDecorator;
import org.simantics.utils.threads.SWTThread;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.ISelectionUtils;
+import org.simantics.utils.ui.SWTUtils;
import org.simantics.utils.ui.jface.BasePostSelectionProvider;
import org.simantics.utils.ui.widgets.VetoingEventHandler;
import org.simantics.utils.ui.workbench.WorkbenchUtils;
});
}
}
-
+
private void initializeState() {
if (persistor == null)
return;
+ ExplorerStates.scheduleRead(getRoot(), persistor)
+ .thenAccept(state -> SWTUtils.asyncExec(tree, () -> restoreState(state)));
+ }
- ExplorerState state = persistor.deserialize(
- Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
- getRoot());
-
+ private void restoreState(ExplorerState state) {
// topNodeToSet will be processed by #setData when it encounters a
// NodeContext that matches this one.
// topNodePath = state.topNodePath;
if (processor instanceof DefaultIsExpandedProcessor) {
DefaultIsExpandedProcessor isExpandedProcessor = (DefaultIsExpandedProcessor)processor;
for(NodeContext expanded : state.expandedNodes) {
- isExpandedProcessor.setExpanded(expanded, true);
+ isExpandedProcessor.replaceExpanded(expanded, true);
}
}
}
}
persistor.serialize(
- Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
+ ExplorerStates.explorerStateLocation(),
getRoot(),
new ExplorerState(topNodePath, topNodePathChildIndex, expandedNodes, columnWidths));
}
*/
private void doSetColumns(Column[] cols, Consumer<Map<Column, Object>> callback) {
// Attempt to keep previous column widths.
- Map<String, Integer> prevWidths = new HashMap<String, Integer>();
+ Map<String, Integer> prevWidths = new HashMap<>();
for (TreeColumn column : tree.getColumns()) {
- prevWidths.put(column.getText(), column.getWidth());
- column.dispose();
+ Column c = (Column) column.getData();
+ if (c != null) {
+ prevWidths.put(c.getKey(), column.getWidth());
+ column.dispose();
+ }
}
- HashMap<String, Integer> keyToIndex = new HashMap<String, Integer>();
+ HashMap<String, Integer> keyToIndex = new HashMap<>();
for (int i = 0; i < cols.length; ++i) {
keyToIndex.put(cols[i].getKey(), i);
}
this.columnImageArray = new Image[cols.length];
this.columnDescOrImageArray = new Object[cols.length];
- Map<Column, Object> map = new HashMap<Column, Object>();
+ Map<Column, Object> map = new HashMap<>();
tree.setHeaderVisible(columnsAreVisible);
for (Column column : columns) {
int cw = column.getWidth();
// Try to keep previous widths
- Integer w = prevWidths.get(column);
+ Integer w = prevWidths.get(column.getKey());
if (w != null)
c.setWidth(w);
else if (cw != Column.DEFAULT_CONTROL_WIDTH)
if(callback != null) callback.accept(map);
// Make sure the explorer fits the columns properly after initialization.
- tree.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (tree.isDisposed())
- return;
+ SWTUtils.asyncExec(tree, () -> {
+ if (!tree.isDisposed())
refreshColumnSizes();
- }
});
}
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.layout.GridDataFactory;
import org.simantics.browsing.ui.common.processors.IsExpandedProcessor;
import org.simantics.browsing.ui.common.processors.NoSelectionRequestProcessor;
import org.simantics.browsing.ui.common.processors.ProcessorLifecycle;
+import org.simantics.browsing.ui.common.state.ExplorerStates;
import org.simantics.browsing.ui.content.ImageDecorator;
import org.simantics.browsing.ui.content.Imager;
import org.simantics.browsing.ui.content.LabelDecorator;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.AdaptionUtils;
import org.simantics.utils.ui.ISelectionUtils;
+import org.simantics.utils.ui.SWTUtils;
import org.simantics.utils.ui.jface.BasePostSelectionProvider;
import gnu.trove.map.hash.THashMap;
private void initializeState() {
if (persistor == null)
return;
+ ExplorerStates.scheduleRead(getRoot(), persistor)
+ .thenAccept(state -> SWTUtils.asyncExec(viewer.getTree(), () -> restoreState(state)));
+ }
- ExplorerState state = persistor.deserialize(
- Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
- getRoot());
-
-
+ private void restoreState(ExplorerState state) {
Object processor = getPrimitiveProcessor(BuiltinKeys.IS_EXPANDED);
if (processor instanceof DefaultIsExpandedProcessor) {
DefaultIsExpandedProcessor isExpandedProcessor = (DefaultIsExpandedProcessor)processor;
for(NodeContext expanded : state.expandedNodes) {
- isExpandedProcessor.setExpanded(expanded, true);
+ isExpandedProcessor.replaceExpanded(expanded, true);
}
}
}
private void doSetColumns(Column[] cols, Consumer<Map<Column, Object>> callback) {
// Attempt to keep previous column widths.
- Map<String, Integer> prevWidths = new HashMap<String, Integer>();
-
+ Map<String, Integer> prevWidths = new HashMap<>();
for (TreeViewerColumn c : treeViewerColumns) {
- prevWidths.put(c.getColumn().getText(), c.getColumn().getWidth());
- c.getColumn().dispose();
+ Column col = (Column) (c.getColumn().getData());
+ if (col != null)
+ prevWidths.put(col.getKey(), c.getColumn().getWidth());
+ c.getColumn().dispose();
}
-
+
treeViewerColumns.clear();
HashMap<String, Integer> keyToIndex = new HashMap<String, Integer>();
int cw = column.getWidth();
// Try to keep previous widths
- Integer w = prevWidths.get(column);
+ Integer w = prevWidths.get(column.getKey());
if (w != null)
c.setWidth(w);
else if (cw != Column.DEFAULT_CONTROL_WIDTH)
return context == null;
}
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == NodeContext.class)
- return context;
+ return (T) context;
return context.getAdapter(adapter);
}
* store the key, this is not used.
*/
NodeContext getNC = new NodeContext() {
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
/*******************************************************************************
- * Copyright (c) 2007, 2012 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 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
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
-import java.util.function.Consumer;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchSite;
import org.simantics.browsing.ui.common.processors.UserSelectedComparableFactoryQueryProcessor;
import org.simantics.browsing.ui.common.processors.UserSelectedViewpointFactoryQueryProcessor;
import org.simantics.browsing.ui.common.processors.ViewpointFactoryResolver;
+import org.simantics.browsing.ui.common.state.ExplorerStates;
import org.simantics.browsing.ui.common.views.FilterAreaSource;
import org.simantics.browsing.ui.common.views.IFilterArea;
import org.simantics.browsing.ui.common.views.IFilterAreaProvider;
import org.simantics.browsing.ui.graph.impl.SessionContextInputSource;
import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;
import org.simantics.browsing.ui.model.nodetypes.NodeType;
-import org.simantics.browsing.ui.swt.Activator;
import org.simantics.browsing.ui.swt.ComparatorSelector;
import org.simantics.browsing.ui.swt.ContextMenuInitializer;
import org.simantics.browsing.ui.swt.DefaultExplorerSelectionListener;
import org.simantics.utils.datastructures.hints.IHintListener;
import org.simantics.utils.datastructures.hints.IHintObservable;
import org.simantics.utils.datastructures.hints.IHintTracker;
+import org.simantics.utils.ui.SWTUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
private int getColumnWidth(Column column, ExplorerState state) {
- // Get saved width from the persistor if there is one.
+ // Get saved width from the persistor if there is one.
if (state != null && state.columnWidths != null) {
- Integer width = state.columnWidths.get(column.getLabel());
- if (width != null)
- return width;
+ Integer width = state.columnWidths.get(column.getLabel());
+ if (width != null)
+ return width;
}
return column.getWidth();
}
-
- public void setColumns(Column[] columns) {
-
- explorer.setColumns(columns, new Consumer<Map<Column, Object>>() {
-
- @Override
- public void accept(Map<Column, Object> objects) {
- ExplorerState state = null;
- if (persistor != null) {
- state = persistor.deserialize(
- Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
- explorer.getRoot());
- }
-
- for(Map.Entry<Column, Object> entry : objects.entrySet()) {
- Column column = entry.getKey();
- TreeColumn treeColumn = (TreeColumn)entry.getValue();
-
- if (column.getWidth() < 0) {
- throw new IllegalArgumentException("Column minimum width cannot be < 0, got " + column.getWidth());
- }
-
- int width = getColumnWidth(column, state);
- if(column.hasGrab()) {
-
- ad.setColumnData(treeColumn, new ColumnWeightData(column.getWeight(), width));
-
- } else {
-
- ad.setColumnData(treeColumn, new ColumnWeightData(0, width));
- }
-
- }
- }
+ protected void restoreColumnSizes(Map<Column, Object> columns) {
+ if (persistor != null) {
+ setColumnData(columns, null);
+ ExplorerStates.scheduleRead(explorer.getRoot(), persistor).thenAccept(state -> {
+ SWTUtils.asyncExec(GraphExplorerComposite.this, () -> {
+ if (explorerComposite.isDisposed())
+ setColumnData(columns, state);
+ });
+ });
+ } else {
+ setColumnData(columns, null);
+ }
+ }
+ protected void setColumnData(Map<Column, Object> columns, ExplorerState state) {
+ columns.forEach((column, widget) -> {
+ org.eclipse.swt.widgets.Widget columnWidget = (org.eclipse.swt.widgets.Widget) widget;
+ ad.setColumnData(columnWidget,
+ new ColumnWeightData(
+ column.hasGrab() ? column.getWeight() : 0,
+ getColumnWidth(column, state)));
});
+ }
+ public void setColumns(Column[] columns) {
+ // ColumnWeightData does not support column weight/width < 0
+ for (Column column : columns) {
+ if (column.getWeight() < 0)
+ throw new IllegalArgumentException("Column weight must be >= 0, got " + column.getWeight() + " for " + column);
+ if (column.getWidth() < 0)
+ throw new IllegalArgumentException("Column minimum width must be >= 0, got " + column.getWidth() + " for " + column);
+ }
+ explorer.setColumns(columns, this::restoreColumnSizes);
}
@Override
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;
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<StateNode, StateNodeManagerSupport> {
+public class StateNodeManager extends StandardVariableNodeManager<StateNode, StateNodeManagerSupport> {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StateNodeManager.class);
- private NodeSupport<StateNode> support;
-
public StateNodeManager(StandardRealm<StateNode, StateNodeManagerSupport> realm, StateNode root) {
super(realm, root);
}
- public void registerSupport(NodeSupport<StateNode> support) {
- this.support = support;
- }
-
- @Override
- public Set<String> 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(() -> {
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<StateNode, StateNodeManagerSupport> {
+public class StateSessionManager extends StandardVariableSessionManager<StateNode, StateNodeManagerSupport> {
private static StateSessionManager INSTANCE;
return new StateRealm(engine, id);
}
- @Override
- public void registerNodeSupport(StandardNodeManager<StateNode, StateNodeManagerSupport> manager,
- NodeSupport<StateNode> support) {
- ((StateNodeManager)manager).registerSupport(support);
- }
-
}
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;
import com.impossibl.postgres.api.jdbc.PGNotificationListener;
import com.impossibl.postgres.jdbc.PGDataSource;
-public class JDBCSessionManager extends StandardSessionManager<JDBCNode, JDBCNodeManagerSupport> {
+public class JDBCSessionManager extends StandardVariableSessionManager<JDBCNode, JDBCNodeManagerSupport> {
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCSessionManager.class);
private static JDBCSessionManager INSTANCE = new JDBCSessionManager();
combo.addListener(SWT.Traverse, listener);
}
- protected void editUnit(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column) {
+ public void editUnit(Table table, TableEditor editor, final ComponentTypeViewerPropertyInfo propertyInfo, TableItem selectedItem, int column) {
// Disallow unit editing for non-numeric configuration properties
if (propertyInfo.numberType == null && propertyInfo.sectionSpecificData == null)
return;
import org.simantics.databoard.type.NumberType;
import org.simantics.db.Resource;
import org.simantics.utils.strings.AlphanumComparator;
+import org.simantics.utils.strings.StringUtils;
public class ComponentTypeViewerPropertyInfo implements Comparable<ComponentTypeViewerPropertyInfo> {
public Resource resource;
return false;
return true;
}
-
-
+
+ public String unitString() {
+ String result = numberType == null ? null : numberType.getUnit();
+ if (result == null)
+ result = unit;
+ return StringUtils.safeString(result);
+ }
+
+ public String rangeString() {
+ return StringUtils.safeString(numberType == null ? null : numberType.getRangeStr());
+ }
+
}
\ No newline at end of file
item.setText(0, info.name);
item.setText(1, info.type);
item.setText(2, info.defaultValue);
- item.setText(3, unitStr(info));
- item.setText(4, rangeStr(info));
+ item.setText(3, info.unitString());
+ item.setText(4, info.rangeString());
item.setText(5, info.label);
item.setText(6, info.description);
}
}
- private String unitStr(ComponentTypeViewerPropertyInfo info) {
- String unit = info.numberType == null ? null : info.numberType.getUnit();
- if (unit == null)
- unit = info.unit;
- return unit != null ? unit : "";
- }
-
- private String rangeStr(ComponentTypeViewerPropertyInfo info) {
- String range = info.numberType == null ? null : info.numberType.getRangeStr();
- return range != null ? range : "";
- }
-
@Override
public void setReadOnly(boolean readOnly) {
boolean e = !readOnly;
public class DerivedPropertiesSection implements ComponentTypeViewerSection {
private static final String[] COLUMN_NAMES =
- new String[] {"Name", "Type", "Expression", "Label", "Description"};
+ new String[] {"Name", "Type", "Expression", "Unit", "Label", "Description"};
private static final int[] COLUMN_LENGTHS =
- new int[] { 120, 100, 100, 100, 100 };
+ new int[] { 120, 100, 100, 70, 100, 100 };
private static final int[] COLUMN_WEIGHTS =
- new int[] { 0, 0, 100, 0, 0 };
+ new int[] { 0, 0, 100, 0, 0, 0 };
private static Function4<RequestProcessor, Resource, Resource, String, String> VALIDATE_MONITOR_EXPRESSION =
new Function4<RequestProcessor, Resource, Resource, String, String>() {
@Override
}, VALIDATE_MONITOR_EXPRESSION);
break;
-// case 3:
-// editUnit(table2, editor2, propertyInfo, selectedItem, column);
-// break;
-
case 3:
+ data.editUnit(table, editor, propertyInfo, selectedItem, column);
+ break;
+
+ case 4:
data.editValue(table, editor, propertyInfo, selectedItem, column, propertyInfo.immutable ? null : new StringWriter() {
@Override
public void perform(WriteGraph graph, String newValue) throws DatabaseException {
}, null);
break;
- case 4:
+ case 5:
data.editMultilineText(table, editor, propertyInfo, selectedItem, selectedItemBounds, column, new StringWriter() {
@Override
public void perform(WriteGraph graph, String newValue) throws DatabaseException {
item.setText(0, info.valid != null ? info.name + " (!)" : info.name);
item.setText(1, info.type);
item.setText(2, info.expression);
- //item.setText(3, unitStr(info));
- item.setText(3, info.label);
- item.setText(4, info.description);
+ item.setText(3, info.unitString());
+ item.setText(4, info.label);
+ item.setText(5, info.description);
item.setForeground(fg);
return 100.0;
}
-}
+}
\ No newline at end of file
import org.simantics.browsing.ui.NodeContext.ConstantKey;
import org.simantics.browsing.ui.common.NodeContextBuilder;
import org.simantics.browsing.ui.common.NodeContextBuilder.MapNodeContext;
+import org.simantics.browsing.ui.common.state.GraphExplorerStateBean;
+import org.simantics.browsing.ui.common.state.GraphExplorerStateNodeBean;
+import org.simantics.browsing.ui.common.state.IdentifiedStatePersistor;
+import org.simantics.browsing.ui.common.state.StringArrayBean;
+import org.simantics.browsing.ui.common.state.StringBean;
import org.simantics.browsing.ui.model.actions.ActionBrowseContext;
import org.simantics.browsing.ui.model.browsecontexts.BrowseContext;
import org.simantics.browsing.ui.model.browsecontexts.BrowseContexts;
import org.simantics.browsing.ui.model.nodetypes.EntityNodeType;
import org.simantics.browsing.ui.model.nodetypes.NodeType;
import org.simantics.browsing.ui.model.nodetypes.SpecialNodeType;
-import org.simantics.browsing.ui.swt.GraphExplorerStateBean;
-import org.simantics.browsing.ui.swt.GraphExplorerStateNodeBean;
-import org.simantics.browsing.ui.swt.IdentifiedStatePersistor;
import org.simantics.browsing.ui.swt.NodeContextValueBean;
-import org.simantics.browsing.ui.swt.StringArrayBean;
-import org.simantics.browsing.ui.swt.StringBean;
import org.simantics.databoard.Bindings;
import org.simantics.databoard.binding.impl.ArrayListBinding;
import org.simantics.databoard.util.Bean;
*******************************************************************************/
package org.simantics.modeling.userComponent;
-import gnu.trove.map.hash.THashMap;
-
import java.util.Map;
import org.simantics.databoard.Bindings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import gnu.trove.map.hash.THashMap;
+
public class ComponentTypeCommands {
private static final Logger LOGGER = LoggerFactory.getLogger(ComponentTypeCommands.class);
return;
}
- Datatype dt = graph.getDataType(object);
- if (dt instanceof NumberType) {
- NumberType nt = (NumberType) dt;
- Binding ntb = Bindings.getBindingUnchecked(Datatype.class);
- nt.setUnit(unit);
+ Layer0X L0X = Layer0X.getInstance(graph);
+ boolean hasRequiresDataType = graph.hasStatement(relation, L0X.RequiresDataType);
+ if (hasRequiresDataType) {
+ Datatype dt = graph.getDataType(object);
+ if (dt instanceof NumberType) {
+ Layer0 L0 = Layer0.getInstance(graph);
+ NumberType nt = (NumberType) Bindings.DATATYPE.cloneUnchecked(dt);
+ nt.setUnit(unit);
+ graph.claimLiteral(object, L0.HasDataType, L0.DataType, nt, Bindings.DATATYPE);
+ graph.claimLiteral(relation, L0X.RequiresDataType, L0.DataType, nt, Bindings.DATATYPE);
+ }
+ }
- Layer0 L0 = Layer0.getInstance(graph);
- Layer0X L0X = Layer0X.getInstance(graph);
-
- String oldUnit = graph.getPossibleRelatedValue2(relation, L0X.HasUnit, Bindings.STRING);
+ String oldUnit = graph.getPossibleRelatedValue2(relation, L0X.HasUnit, Bindings.STRING);
+ graph.claimLiteral(relation, L0X.HasUnit, unit, Bindings.STRING);
- graph.claimLiteral(object, L0.HasDataType, L0.DataType, nt, ntb);
- graph.claimLiteral(relation, L0X.RequiresDataType, L0.DataType, nt, ntb);
- graph.claimLiteral(relation, L0X.HasUnit, unit, Bindings.STRING);
-
- CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
- graph.addMetadata(cm.add("Setted unit from " + oldUnit + " to " + unit + " for component/annotation " + type));
- }
+ CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
+ graph.addMetadata(cm.add("Set unit from " + oldUnit + " to " + unit + " for component/annotation " + type + " property " + relation));
}
/**
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
Automatic-Module-Name: org.simantics.simulator.toolkit.db
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<Node, Engine extends StandardNodeManagerSupport<Node>> {
-
- private ConcurrentHashMap<String, Listener<StandardRealm<Node,Engine>>> realmListeners = new ConcurrentHashMap<>();
- private ConcurrentHashMap<String, StandardRealm<Node,Engine>> REALMS = new ConcurrentHashMap<>();
- private ConcurrentHashMap<String, NodeSupport<Node>> 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<String, StandardRealm<Node, Engine>> {
-
- public RealmRequest(String parameter) {
- super(parameter);
- }
-
- @Override
- public void register(ReadGraph graph, Listener<StandardRealm<Node, Engine>> procedure) {
- StandardRealm<Node, Engine> 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<StandardRealm<Node,Engine>> existing = getOrDisposeListener(parameter);
- assert(existing == null);
- realmListeners.put(parameter, procedure);
- procedure.execute(realm);
- }
-
- private StandardRealm<Node,Engine> createRealmInner(ReadGraph graph, String id) throws DatabaseException {
- Engine engine = createEngine(graph, id);
- StandardRealm<Node,Engine> realm = createRealm(engine, id);
- modifyRealms(id, realm);
- return realm;
- }
- }
-
- protected StandardSessionManager() {
- }
-
- private Listener<StandardRealm<Node,Engine>> getOrDisposeListener(String key) {
- Listener<StandardRealm<Node,Engine>> listener = realmListeners.get(key);
- if(listener != null) {
- if(listener.isDisposed()) {
- realmListeners.remove(key);
- } else {
- return listener;
- }
- }
- return null;
- }
-
- private void modifyRealms(String key, StandardRealm<Node,Engine> realm) {
- if(realm != null) {
- REALMS.put(key, realm);
- } else {
- StandardRealm<Node, Engine> removedRealm = REALMS.remove(key);
- if (removedRealm != null)
- removedRealm.close();
- }
- Listener<StandardRealm<Node,Engine>> listener = getOrDisposeListener(key);
- if(listener != null) {
- listener.execute(realm);
- }
- }
-
- public void registerNodeSupport(StandardNodeManager<Node,Engine> realm, NodeSupport<Node> support) {
-
- }
-
- public NodeSupport<Node> getOrCreateNodeSupport(ReadGraph graph, String id) throws DatabaseException {
- synchronized(SUPPORTS) {
- NodeSupport<Node> result = SUPPORTS.get(id);
- if(result == null) {
- StandardRealm<Node,Engine> realm = getOrCreateRealm(graph, id);
- result = new NodeSupport<Node>(realm.getNodeManager());
- registerNodeSupport(realm.getNodeManager(), result);
- SUPPORTS.put(id, result);
- }
- return result;
- }
- }
-
- public StandardRealm<Node,Engine> 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<Node,Engine> 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<Node> support = SUPPORTS.remove(id);
- if (support != null)
- support.dispose();
- }
+public abstract class StandardSessionManager<Node, Engine extends StandardNodeManagerSupport<Node>> extends StandardVariableSessionManager<Node,Engine> {
- public Collection<String> getRealms() {
- return REALMS.keySet();
- }
}
--- /dev/null
+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);
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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<Node, Engine extends StandardNodeManagerSupport<Node>> extends StandardNodeManager<Node,Engine> {
+
+ protected NodeSupport<Node> support;
+
+ public StandardVariableNodeManager(StandardRealm<Node, Engine> realm, Node root) {
+ super(realm, root);
+ this.support = new NodeSupport<>(this);
+ }
+
+/* public void registerNodeSupport(NodeSupport<Node> support) {
+ this.support = support;
+ }
+
+
+ public void registerSupport(NodeSupport<Node> 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
--- /dev/null
+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<Node, Engine extends StandardNodeManagerSupport<Node>> extends StandardRealm<Node, Engine> {
+
+ protected StandardVariableRealm(Engine engine, String id) {
+ super(engine, id);
+ }
+
+ @Override
+ protected StandardNodeManager<Node, Engine> createManager(Node root) {
+ return new StandardVariableNodeManager<Node, Engine>(this, root);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+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<Node, Engine extends StandardNodeManagerSupport<Node>> {
+
+ private ConcurrentHashMap<String, Listener<StandardRealm<Node,Engine>>> realmListeners = new ConcurrentHashMap<>();
+ private ConcurrentHashMap<String, StandardRealm<Node,Engine>> REALMS = new ConcurrentHashMap<>();
+ private ConcurrentHashMap<String, NodeSupport<Node>> 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<String, StandardRealm<Node, Engine>> {
+
+ public RealmRequest(String parameter) {
+ super(parameter);
+ }
+
+ @Override
+ public void register(ReadGraph graph, Listener<StandardRealm<Node, Engine>> procedure) {
+ StandardRealm<Node, Engine> 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<StandardRealm<Node,Engine>> existing = getOrDisposeListener(parameter);
+ assert(existing == null);
+ realmListeners.put(parameter, procedure);
+ procedure.execute(realm);
+ }
+
+ private StandardRealm<Node,Engine> createRealmInner(ReadGraph graph, String id) throws DatabaseException {
+ Engine engine = createEngine(graph, id);
+ StandardRealm<Node,Engine> realm = createRealm(engine, id);
+ modifyRealms(id, realm);
+ return realm;
+ }
+ }
+
+ protected StandardVariableSessionManager() {
+ }
+
+ private Listener<StandardRealm<Node,Engine>> getOrDisposeListener(String key) {
+ Listener<StandardRealm<Node,Engine>> listener = realmListeners.get(key);
+ if(listener != null) {
+ if(listener.isDisposed()) {
+ realmListeners.remove(key);
+ } else {
+ return listener;
+ }
+ }
+ return null;
+ }
+
+ private void modifyRealms(String key, StandardRealm<Node,Engine> realm) {
+ if(realm != null) {
+ REALMS.put(key, realm);
+ } else {
+ StandardRealm<Node, Engine> removedRealm = REALMS.remove(key);
+ if (removedRealm != null)
+ removedRealm.close();
+ }
+ Listener<StandardRealm<Node,Engine>> listener = getOrDisposeListener(key);
+ if(listener != null) {
+ listener.execute(realm);
+ }
+ }
+
+ public NodeSupport<Node> getOrCreateNodeSupport(ReadGraph graph, String id) throws DatabaseException {
+ synchronized(SUPPORTS) {
+ NodeSupport<Node> result = SUPPORTS.get(id);
+ if(result == null) {
+ StandardRealm<Node,Engine> 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<Node,Engine> 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<Node,Engine> 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<Node> support = SUPPORTS.remove(id);
+ if (support != null)
+ support.dispose();
+ }
+
+ public Collection<String> getRealms() {
+ return REALMS.keySet();
+ }
+}
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;
*
* @author Antti Villberg
*/
-public abstract class StandardNodeManager<Node, Engine extends StandardNodeManagerSupport<Node>> implements NodeManager<Node> {
+public class StandardNodeManager<Node, Engine extends StandardNodeManagerSupport<Node>> implements NodeManager<Node> {
private static final Logger LOGGER = LoggerFactory.getLogger(StandardNodeManager.class);
listeners.clear();
}
+ @Override
+ public Set<String> getClassifications(Node node) throws NodeManagerException {
+ return Collections.emptySet();
+ }
+
}
\ No newline at end of file
this.nodeManager = createManager();
}
- abstract protected StandardNodeManager<Node, Engine> createManager();
+ protected StandardNodeManager<Node, Engine> createManager(Node root) {
+ return new StandardNodeManager<Node, Engine>(this, root);
+ }
+
+ protected StandardNodeManager<Node, Engine> 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();
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;
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<SheetLineComponent> implements Serializable {
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;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SpreadsheetSessionManager extends StandardSessionManager<SheetNode, SpreadsheetBook> {
+public class SpreadsheetSessionManager extends StandardVariableSessionManager<SheetNode, SpreadsheetBook> {
private static final Logger LOGGER = LoggerFactory.getLogger(SpreadsheetSessionManager.class);
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 {
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<SheetLineComponent> {
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 {
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 {
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;
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<SheetLineComponent> {
package org.simantics.structural.synchronization.base;
+import org.simantics.structural.synchronization.utils.Solver;
+
public interface CommandBuilder {
void apply(Solver solver);
import java.util.Map;
import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.structural.synchronization.utils.ComponentBase;
public interface ConnectionUpdateRule<T extends ComponentBase<T>> {
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<T extends ComponentBase<T>> {
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<T extends ComponentBase<T>> {
package org.simantics.structural.synchronization.base;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.structural.synchronization.utils.ComponentBase;
public interface ModuleUpdaterFactoryBase<T extends ComponentBase<T>> {
import java.util.Map;
import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.structural.synchronization.utils.ComponentBase;
public interface PropertyUpdateRule<T extends ComponentBase<T>> {
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<T extends ComponentBase<T>> {
private static void fullPathOfComponent(StringBuilder b, ComponentBase<?> component) {
if(component != null) {
- fullPathOfComponent(b, component.parent);
+ fullPathOfComponent(b, component.getParent());
b.append("/").append(component.solverComponentName);
}
}
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;
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;
-package org.simantics.structural.synchronization.base;
+package org.simantics.structural.synchronization.utils;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectObjectProcedure;
-package org.simantics.structural.synchronization.base;
+package org.simantics.structural.synchronization.utils;
public interface ComponentFactory<T extends ComponentBase<T>> {
-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
-package org.simantics.structural.synchronization.base;
+package org.simantics.structural.synchronization.utils;
public interface Solver {
-package org.simantics.structural.synchronization.base;
-
+package org.simantics.structural.synchronization.utils;
/**
* Stores state information of removed modules.