From: lempinen Date: Mon, 2 Aug 2010 13:19:53 +0000 (+0000) Subject: Removed double click handler for structural browsing, because it is not working prope... X-Git-Tag: simantics-1.2.0~140 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=4ab681b98e23335172cb7703d8b826cd73a7e4be;p=simantics%2Fsysdyn.git Removed double click handler for structural browsing, because it is not working properly. (No RVI) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16904 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java index 54c58832..fa546979 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/DiagramViewer.java @@ -1,16 +1,25 @@ package org.simantics.sysdyn.ui.editor; +import java.util.ArrayList; import java.util.Collections; import java.util.Set; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ui.IWorkbenchPartSite; +import org.simantics.browsing.ui.swt.AdaptableHintContext; import org.simantics.browsing.ui.swt.IPropertyPage; import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; import org.simantics.db.Session; +import org.simantics.db.layer0.SelectionHints; import org.simantics.diagram.adapter.FlagClassFactory; import org.simantics.diagram.handler.CopyPasteHandler; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.diagram.synchronization.IModifiableSynchronizationContext; +import org.simantics.diagram.ui.DiagramModelHints; +import org.simantics.diagram.ui.WorkbenchSelectionProvider; +import org.simantics.g2d.canvas.ICanvasContext; import org.simantics.g2d.canvas.impl.CanvasContext; import org.simantics.g2d.connection.IConnectionAdvisor; import org.simantics.g2d.diagram.DiagramHints; @@ -18,13 +27,18 @@ import org.simantics.g2d.diagram.participant.DeleteHandler; import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor; import org.simantics.g2d.element.ElementClassProviders; import org.simantics.g2d.element.ElementClasses; +import org.simantics.g2d.element.ElementHints; +import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.IElementClassProvider; import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; +import org.simantics.modeling.ui.diagramEditor.handlers.LinkBrowsingHandler; import org.simantics.structural2.modelingRules.IModelingRules; import org.simantics.sysdyn.SysdynResource; import org.simantics.sysdyn.ui.elements2.connections.ConnectionClasses; import org.simantics.sysdyn.ui.elements2.connections.SysdynConnectionClass; import org.simantics.sysdyn.ui.properties.SysdynPropertyPage; +import org.simantics.utils.datastructures.hints.HintContext; +import org.simantics.utils.datastructures.hints.IHintContext; /** * @author Tuukka Lehtonen @@ -79,11 +93,46 @@ public class DiagramViewer extends org.simantics.modeling.ui.diagramEditor.Diagr SysdynResource.getInstance(graph); } -// @Override -// protected void addStructureParticipants(ICanvasContext ctx) { -//// structuralPath = getResourceInput().getResourceArray().removeFromBeginning(1); -// ctx.add(new WorkbenchStructuralSelectionProvider2(swt, getSite(), ResourceArray.EMPTY)); -// } + @Override + protected void addStructureParticipants(ICanvasContext ctx) { + + ctx.add(new WorkbenchSelectionProvider(swt, getSite()) { + + @Override + protected ISelection constructAdaptableSelection(Iterable selection) { + ArrayList objects = new ArrayList(); + Resource runtime = sourceDiagram.getHint(DiagramModelHints.KEY_DIAGRAM_RUNTIME_RESOURCE); + for (Object o : selection) { + if (o instanceof IElement) { + IElement e = (IElement) o; + Object object = e.getHint(ElementHints.KEY_OBJECT); + if (object != null && runtime != null) { + IHintContext context = new AdaptableHintContext(SelectionHints.KEY_MAIN); + context.setHint(SelectionHints.KEY_MAIN, object); + if (runtime != null) + context.setHint(SelectionHints.KEY_VARIABLE_RESOURCE, runtime); + objects.add(context); + } + } else { + System.out.println(" unrecognized selection: " + o.getClass() + ": " + o); + } + } + if(objects.isEmpty() && runtime != null) { + HintContext context = new HintContext(); + context.setHint(SelectionHints.KEY_VARIABLE_RESOURCE, runtime); + objects.add(context); + } + return new StructuredSelection(objects); + } + + }); + // Add visual browsing capabilities for structural models + +// Remove double click handler, because it is not working properly +// ctx.add(new StructuralBrowsingHandler(getSite(), sessionContext, getResourceInput2())); + ctx.add(new LinkBrowsingHandler(getSite(), this, sessionContext)); + + } @Override protected void addOtherParticipants(CanvasContext ctx) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java index d59bc3b3..1977dfb0 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java @@ -110,7 +110,7 @@ public class InputFactory extends SysdynElementFactory { String variable = (String)graph.getRelatedValue(runtime, dr.HasVariable); Resource moduleRepresentation = graph.getPossibleResource(variable); if(moduleRepresentation != null) - module = graph.getSingleObject(moduleRepresentation, b.Represents); + module = graph.getPossibleObject(moduleRepresentation, b.Represents); if(module != null) for(Resource dep : graph.getObjects(module, sr.IsHeadOf)) { Resource reference = graph.getPossibleObject(dep, sr.RefersTo);