import org.simantics.browsing.ui.swt.ComparableTabContributor;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
import org.simantics.db.exception.ServiceException;\r
+import org.simantics.diagram.stubs.DiagramResource;\r
+import org.simantics.modeling.ModelingResources;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.ui.utils.AdaptionUtils;\r
\r
public class ResourceSelectionProcessor implements SelectionProcessor<ISelection, ReadGraph> {\r
- \r
+\r
@Override\r
public Collection<?> process(ISelection selection, ReadGraph backend) {\r
Resource r = AdaptionUtils.adaptToSingle(selection, Resource.class);\r
- if(r != null)\r
+ if(r == null)\r
+ return Collections.emptyList();\r
+\r
try {\r
SysdynResource sr = SysdynResource.getInstance(backend);\r
+ DiagramResource dr = DiagramResource.getInstance(backend);\r
+ ModelingResources mr = ModelingResources.getInstance(backend);\r
Collection<ComparableTabContributor> tabs = new ArrayList<ComparableTabContributor>();\r
+ if (backend.isInstanceOf(r, dr.Element)) {\r
+ Resource component = backend.getPossibleObject(r, mr.ElementToComponent);\r
+ if (component != null)\r
+ r = component;\r
+ }\r
if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
tabs.add(new ComparableTabContributor(\r
new EquationTab(),\r
new VariableInformationTab(),\r
1,\r
r,\r
- "Additional Information")); \r
+ "Additional Information"));\r
return tabs;\r
}\r
if (backend.isInstanceOf(r, sr.Configuration))\r
return Collections.singleton(\r
new ComparableTabContributor(\r
- new ConfigurationTab(),\r
- 0,\r
- r,\r
- "Configuration Properties"));\r
+ new ConfigurationTab(),\r
+ 0,\r
+ r,\r
+ "Configuration Properties"));\r
if (backend.isInstanceOf(r, sr.Experiment))\r
return Collections.singleton(\r
new ComparableTabContributor(\r
- new ExperimentTab(),\r
- 0,\r
- r,\r
- "Experiment Properties"));\r
+ new ExperimentTab(),\r
+ 0,\r
+ r,\r
+ "Experiment Properties"));\r
if (backend.isInstanceOf(r, sr.SysdynModel))\r
return Collections.singleton(\r
new ComparableTabContributor(\r
- new ModelTab(),\r
- 0,\r
- r,\r
- "Model Properties"));\r
+ new ModelTab(),\r
+ 0,\r
+ r,\r
+ "Model Properties"));\r
if (backend.isInstanceOf(r, sr.Result))\r
return Collections.singleton(\r
new ComparableTabContributor(\r
- new ResultTab(),\r
- 0,\r
- r,\r
- "Result Properties"));\r
+ new ResultTab(),\r
+ 0,\r
+ r,\r
+ "Result Properties"));\r
} catch (ServiceException e) {\r
e.printStackTrace();\r
+ } catch (ManyObjectsForFunctionalRelationException e) {\r
+ e.printStackTrace();\r
}\r
return Collections.emptyList();\r
}\r