package org.simantics.sysdyn.ui.editor;\r
\r
+import java.util.ArrayList;\r
import java.util.Collections;\r
import java.util.Set;\r
\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.StructuredSelection;\r
import org.eclipse.ui.IWorkbenchPartSite;\r
+import org.simantics.browsing.ui.swt.AdaptableHintContext;\r
import org.simantics.browsing.ui.swt.IPropertyPage;\r
import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
import org.simantics.db.Session;\r
+import org.simantics.db.layer0.SelectionHints;\r
import org.simantics.diagram.adapter.FlagClassFactory;\r
import org.simantics.diagram.handler.CopyPasteHandler;\r
import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.diagram.synchronization.IModifiableSynchronizationContext;\r
+import org.simantics.diagram.ui.DiagramModelHints;\r
+import org.simantics.diagram.ui.WorkbenchSelectionProvider;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
import org.simantics.g2d.canvas.impl.CanvasContext;\r
import org.simantics.g2d.connection.IConnectionAdvisor;\r
import org.simantics.g2d.diagram.DiagramHints;\r
import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;\r
import org.simantics.g2d.element.ElementClassProviders;\r
import org.simantics.g2d.element.ElementClasses;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.IElement;\r
import org.simantics.g2d.element.IElementClassProvider;\r
import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.modeling.ui.diagramEditor.handlers.LinkBrowsingHandler;\r
import org.simantics.structural2.modelingRules.IModelingRules;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.elements2.connections.ConnectionClasses;\r
import org.simantics.sysdyn.ui.elements2.connections.SysdynConnectionClass;\r
import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
+import org.simantics.utils.datastructures.hints.HintContext;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
\r
/**\r
* @author Tuukka Lehtonen\r
SysdynResource.getInstance(graph);\r
}\r
\r
-// @Override\r
-// protected void addStructureParticipants(ICanvasContext ctx) {\r
-//// structuralPath = getResourceInput().getResourceArray().removeFromBeginning(1);\r
-// ctx.add(new WorkbenchStructuralSelectionProvider2(swt, getSite(), ResourceArray.EMPTY));\r
-// }\r
+ @Override\r
+ protected void addStructureParticipants(ICanvasContext ctx) {\r
+\r
+ ctx.add(new WorkbenchSelectionProvider(swt, getSite()) {\r
+\r
+ @Override\r
+ protected ISelection constructAdaptableSelection(Iterable<?> selection) {\r
+ ArrayList<Object> objects = new ArrayList<Object>();\r
+ Resource runtime = sourceDiagram.getHint(DiagramModelHints.KEY_DIAGRAM_RUNTIME_RESOURCE);\r
+ for (Object o : selection) {\r
+ if (o instanceof IElement) {\r
+ IElement e = (IElement) o;\r
+ Object object = e.getHint(ElementHints.KEY_OBJECT);\r
+ if (object != null && runtime != null) {\r
+ IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN);\r
+ context.setHint(SelectionHints.KEY_MAIN, object);\r
+ if (runtime != null)\r
+ context.setHint(SelectionHints.KEY_VARIABLE_RESOURCE, runtime);\r
+ objects.add(context);\r
+ }\r
+ } else {\r
+ System.out.println(" unrecognized selection: " + o.getClass() + ": " + o);\r
+ }\r
+ }\r
+ if(objects.isEmpty() && runtime != null) {\r
+ HintContext context = new HintContext();\r
+ context.setHint(SelectionHints.KEY_VARIABLE_RESOURCE, runtime);\r
+ objects.add(context);\r
+ }\r
+ return new StructuredSelection(objects);\r
+ }\r
+\r
+ });\r
+ // Add visual browsing capabilities for structural models\r
+ \r
+// Remove double click handler, because it is not working properly\r
+// ctx.add(new StructuralBrowsingHandler(getSite(), sessionContext, getResourceInput2()));\r
+ ctx.add(new LinkBrowsingHandler(getSite(), this, sessionContext));\r
+\r
+ }\r
\r
@Override\r
protected void addOtherParticipants(CanvasContext ctx) {\r