import org.simantics.databoard.Bindings;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
+import org.simantics.db.Session;
import org.simantics.db.common.ResourceArray;
import org.simantics.db.common.primitiverequest.PossibleAdapter;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
import org.simantics.db.exception.NoSingleResultException;
import org.simantics.db.exception.ServiceException;
+import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.management.ISessionContext;
import org.simantics.db.request.Read;
import org.simantics.diagram.adapter.DefaultConnectionClassFactory;
import org.simantics.g2d.participant.TransformUtil;
import org.simantics.g2d.participant.ZoomToAreaHandler;
import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider;
+import org.simantics.g2d.scenegraph.ICanvasSceneGraphProvider2;
import org.simantics.modeling.ModelingResources;
import org.simantics.modeling.mapping.ComponentCopyAdvisor;
import org.simantics.modeling.mapping.ElementCopyAdvisor;
* @author J-P Laine
*
*/
-public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider, IDiagramUpdateSupport {
+public class DiagramSceneGraphProvider implements ICanvasSceneGraphProvider2, IDiagramUpdateSupport {
protected boolean isSymbol = false;
protected Resource resource;
protected AWTRemoteEventAdapter listener = null;
- final IHintContext initialHints = new HintContext();
+ protected final IHintContext initialHints = new HintContext();
public DiagramSceneGraphProvider(ReadGraph g, final Resource diagramOrComposite) {
this.structuralPath = new ResourceArray();
}
}
+ public GraphToDiagramSynchronizer getGraphToDiagramSynchronizer() {
+ return synchronizer;
+ }
+
protected CopyPasteStrategy getCopyPasteStrategy() {
try {
CopyPasteStrategy cpStrategy = Simantics.getSession().syncRequest(new PossibleAdapter<CopyPasteStrategy>(resource, CopyPasteStrategy.class));
ctx.add( new ElementInteractor() );
ctx.add( new Selection() );
ctx.add( new DiagramParticipant() );
- ctx.add( new ElementPainter(false) );
+ ctx.add( new ElementPainter(true) );
//ctx.add( new ElementHeartbeater() );
ctx.add( new ZOrderHandler() );
@Override
public G2DSceneGraph initializeSceneGraph(ICanvasContext context, String modelURI, String RVI) {
G2DSceneGraph sg = context.getSceneGraph();
- return initializeSceneGraph(context, sg, modelURI, RVI, "");
+ return initializeSceneGraph(context, sg, modelURI, RVI, "", null);
+ }
+
+
+ @Override
+ public G2DSceneGraph initializeSceneGraph(ICanvasContext context, String modelURI, String RVI,
+ Variable experiment) {
+ G2DSceneGraph sg = context.getSceneGraph();
+ return initializeSceneGraph(context, sg, modelURI, RVI, "", experiment);
}
+
/**
* @param sg
* @param view
private G2DSceneGraph initializeSceneGraph(G2DSceneGraph sg, String modelURI, String RVI, String view) {
IThreadWorkQueue thread = AWTThread.getThreadAccess();
ctx = new CanvasContext(thread, sg); // By giving the scene graph instance as parameter, we can use external serializer
- return initializeSceneGraph(ctx, sg, modelURI, RVI, view);
+ return initializeSceneGraph(ctx, sg, modelURI, RVI, view, null);
+ }
+
+ protected GraphToDiagramSynchronizer createSynchronizer(ReadGraph graph) throws DatabaseException {
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+ return new GraphToDiagramSynchronizer(graph, ctx,
+ ElementClassProviders.mappedProvider(
+ ElementClasses.CONNECTION, DefaultConnectionClassFactory.CLASS.newClassWith(new StaticObjectAdapter(DIA.RouteGraphConnection)),
+ ElementClasses.FLAG, FlagClassFactory.createFlagClass(DIA.Flag, DIA.Flag_Terminal)
+ )
+ );
+ }
+
+ protected RuntimeDiagramManager createRuntimeDiagramManager(Session session, Resource resource, String modelURI, String RVI, Variable experiment) throws DatabaseException {
+ return RuntimeDiagramManager.create(session, resource, modelURI, RVI);
}
/**
* @param initialHints
* @return
*/
- private G2DSceneGraph initializeSceneGraph(ICanvasContext context, G2DSceneGraph sg, String modelURI, String RVI, String view) {
+ private G2DSceneGraph initializeSceneGraph(ICanvasContext context, G2DSceneGraph sg, String modelURI, String RVI, String view, Variable run) {
this.ctx = (CanvasContext) context;
this.view = view;
if(view != null) {
initialHints.setHint(SynchronizationHints.COPY_ADVISOR, getCopyAdvisor());
- final RuntimeDiagramManager runtimeDiagramManager = RuntimeDiagramManager.create(Simantics.getSession(), resource, modelURI, RVI);
+ final RuntimeDiagramManager runtimeDiagramManager = createRuntimeDiagramManager(Simantics.getSession(), resource, modelURI, RVI, run);
synchronizer = Simantics.getSession().syncRequest(new Read<GraphToDiagramSynchronizer>() {
@Override
if(val != null && navigation == null) { // Set only if navigation has not been set manually
navigation = val;
}
- GraphToDiagramSynchronizer sync = new GraphToDiagramSynchronizer(graph, ctx,
- ElementClassProviders.mappedProvider(
- ElementClasses.CONNECTION, DefaultConnectionClassFactory.CLASS.newClassWith(new StaticObjectAdapter(dr.Connection)),
- ElementClasses.FLAG, FlagClassFactory.createFlagClass(dr.Flag, dr.Flag_Terminal)
- )
- );
+ GraphToDiagramSynchronizer sync = createSynchronizer(graph);
sync.set(ModelingSynchronizationHints.MODELING_RESOURCE, ModelingResources.getInstance(graph));
diagram = sync.loadDiagram(new NullProgressMonitor(), graph, null, resource, runtimeDiagramManager.getRuntimeDiagram(), structuralPath, initialHints); // FIXME
return sync;
try {
// FIXME: I have no idea if this works or not..
- diagram = SimanticsUI.getSession().syncRequest(new Read<IDiagram>() {
+ diagram = Simantics.getSession().syncRequest(new Read<IDiagram>() {
@Override
public IDiagram perform(ReadGraph graph) throws DatabaseException {
IDiagram d = synchronizer.loadDiagram(new NullProgressMonitor(), graph, null, structuralPath.resources[0], null, structuralPath.removeFromBeginning(0), hints);