From: lehtonen Date: Sun, 20 Jun 2010 10:13:44 +0000 (+0000) Subject: Look for variable from diagram elements in sysdyn ResourceSelectionProcessor. X-Git-Tag: simantics-1.2.0~205 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=f112972d48772b7cbfc3250d03f386223721460f;p=simantics%2Fsysdyn.git Look for variable from diagram elements in sysdyn ResourceSelectionProcessor. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16246 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java index 86cfbf61..52404a86 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java @@ -9,19 +9,31 @@ import org.simantics.browsing.ui.SelectionProcessor; import org.simantics.browsing.ui.swt.ComparableTabContributor; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; +import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.ServiceException; +import org.simantics.diagram.stubs.DiagramResource; +import org.simantics.modeling.ModelingResources; import org.simantics.sysdyn.SysdynResource; import org.simantics.ui.utils.AdaptionUtils; public class ResourceSelectionProcessor implements SelectionProcessor { - + @Override public Collection process(ISelection selection, ReadGraph backend) { Resource r = AdaptionUtils.adaptToSingle(selection, Resource.class); - if(r != null) + if(r == null) + return Collections.emptyList(); + try { SysdynResource sr = SysdynResource.getInstance(backend); + DiagramResource dr = DiagramResource.getInstance(backend); + ModelingResources mr = ModelingResources.getInstance(backend); Collection tabs = new ArrayList(); + if (backend.isInstanceOf(r, dr.Element)) { + Resource component = backend.getPossibleObject(r, mr.ElementToComponent); + if (component != null) + r = component; + } if (backend.isInstanceOf(r, sr.IndependentVariable)) { tabs.add(new ComparableTabContributor( new EquationTab(), @@ -32,39 +44,41 @@ public class ResourceSelectionProcessor implements SelectionProcessor