*/\r
public class ResourceSelectionProcessor implements SelectionProcessor<Object, ReadGraph> {\r
\r
- private SpecialNodeType sharedFunctionsTestNode;\r
-\r
- @Override\r
- public Collection<?> process(Object selection, ReadGraph backend) {\r
- Collection<ComparableTabContributor> tabs = new ArrayList<ComparableTabContributor>();\r
- SysdynResource sr = SysdynResource.getInstance(backend);\r
- DiagramResource dr = DiagramResource.getInstance(backend);\r
- ModelingResources mr = ModelingResources.getInstance(backend);\r
- SimulationResource simu = SimulationResource.getInstance(backend);\r
- JFreeChartResource jfree = JFreeChartResource.getInstance(backend);\r
-\r
- // Test nodes\r
- if(sharedFunctionsTestNode == null)\r
- sharedFunctionsTestNode = new SpecialNodeType(sr.ModelingBrowseContext_SharedFunctionsFolder, Resource.class);\r
-\r
- try {\r
- // Many elements \r
- if (selection instanceof ArrayList<?> && ((ArrayList<?>) selection).size() > 1) {\r
- List<Resource> independentVariables = new ArrayList<Resource>();\r
- Resource model = null;\r
- for(Object o : (ArrayList<?>)selection) {\r
- Resource r = AdaptionUtils.adaptToSingle(o, Resource.class);\r
- if(r != null && backend.isInstanceOf(r, sr.IndependentVariable)) {\r
- if(model == null)\r
- model = backend.getSingleObject(r, Layer0.getInstance(backend).PartOf);\r
- if(model.equals( backend.getSingleObject(r, Layer0.getInstance(backend).PartOf)))\r
- independentVariables.add(r);\r
- }\r
- }\r
-\r
- tabs.add(new ComparableTabContributor(\r
- new ArrayIndexesTab(),\r
- 1,\r
- independentVariables,\r
- "Indexes"));\r
-\r
- return tabs;\r
- }\r
-\r
- // Single element\r
- Variable var = null; \r
- WorkbenchSelectionElement wse = ISelectionUtils.filterSingleSelection(selection, WorkbenchSelectionElement.class);\r
- if(wse != null) {\r
- var = wse.getContent(new AnyVariable(backend));\r
- if(var == null) {\r
- var = AdaptionUtils.adaptToSingle(selection, Variable.class);\r
- if(var != null) {\r
- Variable possibleActiveVariable = backend.syncRequest(new PossibleActiveVariableFromVariable(var));\r
- if(possibleActiveVariable != null)\r
- var = possibleActiveVariable;\r
- }\r
- }\r
- }\r
-\r
- Resource r = AdaptionUtils.adaptToSingle(selection, Resource.class);\r
- if(r == null) {\r
- // Selection is not directly a resource, try if it is a variable \r
- var = AdaptionUtils.adaptToSingle(selection, Variable.class);\r
- r = var.getRepresents(backend);\r
- }\r
-\r
- if(r == null) {\r
- // SharedFunctionsFolder has properties but no adapted resource\r
- SharedFunctionsFolder sff = AdaptionUtils.adaptToSingle(selection, SharedFunctionsFolder.class);\r
- if (sff != null) {\r
- return Collections.singleton(new ComparableTabContributor(\r
- new SharedFunctionLibrariesTab(),\r
- 2,\r
- sff.data,\r
- "Shared Functions"));\r
- }\r
-\r
- return Collections.emptyList();\r
- }\r
-\r
- NodeContext nc = AdaptionUtils.adaptToSingle(selection, NodeContext.class);\r
- if(nc != null) {\r
- NodeType type = nc.getConstant(NodeType.TYPE);\r
- if(type != null && type.equals(sharedFunctionsTestNode)) {\r
- return Collections.singleton(new ComparableTabContributor(\r
- new SharedFunctionLibrariesTab(),\r
- 2,\r
- r,\r
- "Shared Functions"));\r
- }\r
- }\r
- \r
- // SVG elements in symbol editor\r
+ private SpecialNodeType sharedFunctionsTestNode;\r
+\r
+ @Override\r
+ public Collection<?> process(Object selection, ReadGraph backend) {\r
+ Collection<ComparableTabContributor> tabs = new ArrayList<ComparableTabContributor>();\r
+ SysdynResource sr = SysdynResource.getInstance(backend);\r
+ DiagramResource dr = DiagramResource.getInstance(backend);\r
+ ModelingResources mr = ModelingResources.getInstance(backend);\r
+ SimulationResource simu = SimulationResource.getInstance(backend);\r
+ JFreeChartResource jfree = JFreeChartResource.getInstance(backend);\r
+\r
+ // Test nodes\r
+ if(sharedFunctionsTestNode == null)\r
+ sharedFunctionsTestNode = new SpecialNodeType(sr.ModelingBrowseContext_SharedFunctionsFolder, Resource.class);\r
+\r
+ try {\r
+ // Many elements \r
+ if (selection instanceof ArrayList<?> && ((ArrayList<?>) selection).size() > 1) {\r
+ List<Resource> independentVariables = new ArrayList<Resource>();\r
+ Resource model = null;\r
+ for(Object o : (ArrayList<?>)selection) {\r
+ Resource r = AdaptionUtils.adaptToSingle(o, Resource.class);\r
+ if(r != null && backend.isInstanceOf(r, sr.IndependentVariable)) {\r
+ if(model == null)\r
+ model = backend.getSingleObject(r, Layer0.getInstance(backend).PartOf);\r
+ if(model.equals( backend.getSingleObject(r, Layer0.getInstance(backend).PartOf)))\r
+ independentVariables.add(r);\r
+ }\r
+ }\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new ArrayIndexesTab(),\r
+ 1,\r
+ independentVariables,\r
+ "Indexes"));\r
+\r
+ return tabs;\r
+ }\r
+\r
+ // Single element\r
+ Variable var = null; \r
+ WorkbenchSelectionElement wse = ISelectionUtils.filterSingleSelection(selection, WorkbenchSelectionElement.class);\r
+ if(wse != null) {\r
+ var = wse.getContent(new AnyVariable(backend));\r
+ if(var == null) {\r
+ var = AdaptionUtils.adaptToSingle(selection, Variable.class);\r
+ if(var != null) {\r
+ Variable possibleActiveVariable = backend.syncRequest(new PossibleActiveVariableFromVariable(var));\r
+ if(possibleActiveVariable != null)\r
+ var = possibleActiveVariable;\r
+ }\r
+ }\r
+ }\r
+\r
+ Resource r = AdaptionUtils.adaptToSingle(selection, Resource.class);\r
+ if(r == null) {\r
+ // Selection is not directly a resource, try if it is a variable \r
+ var = AdaptionUtils.adaptToSingle(selection, Variable.class);\r
+ r = var.getRepresents(backend);\r
+ }\r
+\r
+ if(r == null) {\r
+ // SharedFunctionsFolder has properties but no adapted resource\r
+ SharedFunctionsFolder sff = AdaptionUtils.adaptToSingle(selection, SharedFunctionsFolder.class);\r
+ if (sff != null) {\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new SharedFunctionLibrariesTab(),\r
+ 2,\r
+ sff.data,\r
+ "Shared Functions"));\r
+ }\r
+\r
+ return Collections.emptyList();\r
+ }\r
+\r
+ NodeContext nc = AdaptionUtils.adaptToSingle(selection, NodeContext.class);\r
+ if(nc != null) {\r
+ NodeType type = nc.getConstant(NodeType.TYPE);\r
+ if(type != null && type.equals(sharedFunctionsTestNode)) {\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new SharedFunctionLibrariesTab(),\r
+ 2,\r
+ r,\r
+ "Shared Functions"));\r
+ }\r
+ }\r
+\r
+ // SVG elements in symbol editor\r
if (backend.isInstanceOf(r, dr.SVGElement))\r
return Collections.singleton(SVGElementComposite.make(r, 1, "SVG"));\r
\r
- // if r == diagram element, change it to component\r
- if (backend.isInstanceOf(r, dr.Element)) {\r
- Resource component = backend.getPossibleObject(r, mr.ElementToComponent);\r
- if (component != null) {\r
- r = component;\r
- } else {\r
- Resource connection = backend.getPossibleObject(r, mr.DiagramConnectionToConnection);\r
- if(connection != null)\r
- r = connection;\r
- }\r
- }\r
-\r
- // Independent variable\r
- if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
- Resource activeExpression = backend.getPossibleObject(r, sr.IndependentVariable_activeExpression);\r
- Resource expression = null;\r
- if(activeExpression != null)\r
- // if variable has active expression, display it\r
- expression = activeExpression;\r
- else if (backend.hasStatement(r, sr.Variable_expressions)){\r
- // else display the first expression of the variable\r
- Resource expressions = backend.getPossibleObject(r, sr.Variable_expressions);\r
- List<Resource> expressionList = OrderedSetUtils.toList(backend, expressions);\r
- if(expressionList.isEmpty()) {\r
- System.err.println("expressionList is empty for " + r);\r
- return Collections.emptyList();\r
- }\r
- expression = expressionList.get(0);\r
- }\r
- tabs.add(new ComparableTabContributor(\r
- new EquationTab(),\r
- 3,\r
- var != null ? var : r,\r
- "Equation"));\r
- if(expression != null && backend.isInstanceOf(expression, sr.WithLookupExpression)) {\r
- // WithLookupExpression has its own extra tab for visual configuration\r
- tabs.add(new ComparableTabContributor(\r
- new LookupTableTab(),\r
- 2,\r
- expression,\r
- "Lookup Table"));\r
- }\r
-\r
- tabs.add(new ComparableTabContributor(\r
- new ArrayIndexesTab(),\r
- 1,\r
- r,\r
- "Indexes"));\r
-\r
- tabs.add(new ComparableTabContributor(\r
- new VariableInformationTab(),\r
- 0,\r
- r,\r
- "Additional Information"));\r
- return tabs;\r
- }\r
-\r
- // Input variable\r
- if (backend.isInstanceOf(r, sr.Input)) {\r
- tabs.add(new ComparableTabContributor(\r
- new InputVariableTab(),\r
- 2,\r
- r,\r
- "Input"));\r
-\r
- tabs.add(new ComparableTabContributor(\r
- new ArrayIndexesTab(),\r
- 1,\r
- r,\r
- "Indexes"));\r
-\r
- tabs.add(new ComparableTabContributor(\r
- new VariableInformationTab(),\r
- 0,\r
- r,\r
- "Additional Information"));\r
- return tabs;\r
- }\r
-\r
- // Enumeration\r
- if (backend.isInstanceOf(r, sr.Enumeration)) {\r
- Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
- if(s == null)\r
- s = r;\r
- // give either variable or the actual resource\r
- return Collections.singleton(new ComparableTabContributor(\r
- new EnumerationTab(),\r
- 2,\r
- s,\r
- "Enumeration"));\r
- }\r
-\r
- // Configuration and model. They both show the properties of the configuration\r
- if ( backend.isInstanceOf(r, sr.Configuration) || backend.isInstanceOf(r, sr.SysdynModel)) {\r
- if(!backend.isInstanceOf(r, sr.SysdynModel))\r
- r = backend.getPossibleObject(r, SimulationResource.getInstance(backend).IsConfigurationOf);\r
- if (r != null)\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new ConfigurationTab(),\r
- 0,\r
- r,\r
- "Model Properties"));\r
- }\r
-\r
- // Module\r
- if (backend.isInstanceOf(r, sr.Module)){\r
- tabs.add(new ComparableTabContributor(\r
- new ModuleTab(),\r
- 10,\r
- r,\r
- "Module Properties"));\r
- tabs.add(new ComparableTabContributor(\r
- new ModuleParameterTab(),\r
- 9,\r
- r,\r
- "Parameters"));\r
- tabs.add(new ComparableTabContributor(\r
- new ModuleInputTab(),\r
- 2,\r
- r,\r
- "Inputs"));\r
- tabs.add(new ComparableTabContributor(\r
- new ModuleOutputTab(),\r
- 1,\r
- r,\r
- "Outputs"));\r
- return tabs;\r
- }\r
-\r
- // Playback experiment\r
- if (backend.isInstanceOf(r, sr.PlaybackExperiment))\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new PlaybackExperimentTab(),\r
- 0,\r
- r,\r
- "Experiment Properties"));\r
- \r
- // Game experiment\r
- if (backend.isInstanceOf(r, sr.GameExperiment))\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new GameExperimentTab(),\r
- 0,\r
- r,\r
- "Experiment Properties"));\r
- \r
- // Default experiment\r
- if (backend.isInstanceOf(r, simu.Experiment))\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new ExperimentTab(),\r
- 0,\r
- r,\r
- "Experiment Properties"));\r
-\r
- // History data\r
- if (backend.isInstanceOf(r, sr.HistoryDataset))\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new HistoryDataTab(),\r
- 0,\r
- r,\r
- "History Data Properties"));\r
-\r
- // Saved simulation result\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
-\r
- // Dependency\r
- if (backend.isInstanceOf(r, sr.Dependency))\r
- if (backend.hasStatement(r, sr.Dependency_refersTo))\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new ReferenceDependencyTab(),\r
- 0,\r
- r,\r
- "Reference Properties"));\r
- else {\r
- Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new DependencyTab(),\r
- 0,\r
- diaConnection,\r
- "Dependency Properties"));\r
- }\r
-\r
- // Module symbol. Modules in modules-folder are actually symbol resources\r
- if (backend.isInheritedFrom(r, sr.ModuleSymbol)) {\r
- // Find the component resource\r
- r = backend.getPossibleObject(r, mr.SymbolToComponentType);\r
- if(r != null)\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new ModuleTypeTab(),\r
- 0,\r
- r,\r
- "Module Type Properties"));\r
- }\r
-\r
- // Function\r
- if (backend.isInstanceOf(r, sr.SysdynModelicaFunction)) {\r
- tabs.add(new ComparableTabContributor(\r
- new FunctionTab(),\r
- 2,\r
- r,\r
- "Function"));\r
- tabs.add(new ComparableTabContributor(\r
- new ExternalFilesTab(),\r
- 1,\r
- r,\r
- "External files"));\r
- return tabs;\r
- }\r
-\r
- // Function library\r
- if (backend.isInstanceOf(r, sr.SysdynModelicaFunctionLibrary)) {\r
- Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
- if(s == null)\r
- s = r;\r
- // give either variable or the actual resource\r
- return Collections.singleton(new ComparableTabContributor(\r
- new FunctionLibraryTab(),\r
- 2,\r
- s,\r
- "Function library"));\r
- }\r
-\r
- // Chart Element\r
- if(backend.isInstanceOf(r, jfree.ChartElement)) {\r
- if(backend.hasStatement(r, jfree.ChartElement_component))\r
- r = backend.getSingleObject(r, jfree.ChartElement_component);\r
- }\r
- // Chart\r
- if (backend.isInstanceOf(r, jfree.Chart)) {\r
-\r
- Collection<Resource> plots = backend.syncRequest(new ObjectsWithType(r, Layer0.getInstance(backend).ConsistsOf, jfree.Plot));\r
- if(!plots.isEmpty()) {\r
- Resource plot = plots.iterator().next();\r
-\r
- if(backend.isInstanceOf(plot, jfree.XYPlot)) {\r
- tabs.add(new ComparableTabContributor(\r
- new XYLineGeneralPropertiesTab(),\r
- 10,\r
- r,\r
- "General"));\r
- tabs.add(new ComparableTabContributor(\r
- new XYLineAxisAndVariablesTab(),\r
- 9,\r
- r,\r
- "Axis and Variables"));\r
- } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
- tabs.add(new ComparableTabContributor(\r
- new BarGeneralPropertiesTab(),\r
- 10,\r
- r,\r
- "General"));\r
- tabs.add(new ComparableTabContributor(\r
- new BarSeriesTab(),\r
- 9,\r
- r,\r
- "Variables"));\r
- tabs.add(new ComparableTabContributor(\r
- new BarAxisTab(),\r
- 8,\r
- r,\r
- "Axis")); \r
- } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
- tabs.add(new ComparableTabContributor(\r
- new PieGeneralPropertiesTab(),\r
- 10,\r
- r,\r
- "General"));\r
- tabs.add(new ComparableTabContributor(\r
- new PieSeriesTab(),\r
- 9,\r
- r,\r
- "Variables"));\r
- }\r
-\r
- tabs.add(new ComparableTabContributor(\r
- new ChartTab(),\r
- 1,\r
- r,\r
- "Chart"));\r
- return tabs;\r
-\r
- } \r
- }\r
-\r
- // Default experiment\r
- if (backend.isInstanceOf(r, sr.AdditionalSymbols_MultilineText))\r
- return Collections.singleton(\r
- new ComparableTabContributor(\r
- new CommentTab(),\r
- 0,\r
- r,\r
- "Comment"));\r
-\r
- } catch (ServiceException e) {\r
- e.printStackTrace();\r
- } catch (ManyObjectsForFunctionalRelationException e) {\r
- e.printStackTrace();\r
- } catch (DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
- return Collections.emptyList();\r
- }\r
+ // if r == diagram element, change it to component\r
+ if (backend.isInstanceOf(r, dr.Element)) {\r
+ Resource component = backend.getPossibleObject(r, mr.ElementToComponent);\r
+ if (component != null) {\r
+ r = component;\r
+ } else {\r
+ Resource connection = backend.getPossibleObject(r, mr.DiagramConnectionToConnection);\r
+ if(connection != null)\r
+ r = connection;\r
+ }\r
+ }\r
+\r
+ // Independent variable\r
+ if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
+ Resource activeExpression = backend.getPossibleObject(r, sr.IndependentVariable_activeExpression);\r
+ Resource expression = null;\r
+ if(activeExpression != null)\r
+ // if variable has active expression, display it\r
+ expression = activeExpression;\r
+ else if (backend.hasStatement(r, sr.Variable_expressions)){\r
+ // else display the first expression of the variable\r
+ Resource expressions = backend.getPossibleObject(r, sr.Variable_expressions);\r
+ List<Resource> expressionList = OrderedSetUtils.toList(backend, expressions);\r
+ if(expressionList.isEmpty()) {\r
+ System.err.println("expressionList is empty for " + r);\r
+ return Collections.emptyList();\r
+ }\r
+ expression = expressionList.get(0);\r
+ }\r
+ tabs.add(new ComparableTabContributor(\r
+ new EquationTab(),\r
+ 3,\r
+ var != null ? var : r,\r
+ "Equation"));\r
+ if(expression != null && backend.isInstanceOf(expression, sr.WithLookupExpression)) {\r
+ // WithLookupExpression has its own extra tab for visual configuration\r
+ tabs.add(new ComparableTabContributor(\r
+ new LookupTableTab(),\r
+ 2,\r
+ expression,\r
+ "Lookup Table"));\r
+ }\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new ArrayIndexesTab(),\r
+ 1,\r
+ r,\r
+ "Indexes"));\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new VariableInformationTab(),\r
+ 0,\r
+ r,\r
+ "Additional Information"));\r
+ return tabs;\r
+ }\r
+\r
+ // Input variable\r
+ if (backend.isInstanceOf(r, sr.Input)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new InputVariableTab(),\r
+ 2,\r
+ r,\r
+ "Input"));\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new ArrayIndexesTab(),\r
+ 1,\r
+ r,\r
+ "Indexes"));\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new VariableInformationTab(),\r
+ 0,\r
+ r,\r
+ "Additional Information"));\r
+ return tabs;\r
+ }\r
+\r
+ // Enumeration\r
+ if (backend.isInstanceOf(r, sr.Enumeration)) {\r
+ Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
+ if(s == null)\r
+ s = r;\r
+ // give either variable or the actual resource\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new EnumerationTab(),\r
+ 2,\r
+ s,\r
+ "Enumeration"));\r
+ }\r
+\r
+ // Configuration and model. They both show the properties of the configuration\r
+ if ( backend.isInstanceOf(r, sr.Configuration) || backend.isInstanceOf(r, sr.SysdynModel)) {\r
+ if(!backend.isInstanceOf(r, sr.SysdynModel))\r
+ r = backend.getPossibleObject(r, SimulationResource.getInstance(backend).IsConfigurationOf);\r
+ if (r != null)\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ConfigurationTab(),\r
+ 0,\r
+ r,\r
+ "Model Properties"));\r
+ }\r
+\r
+ // Module\r
+ if (backend.isInstanceOf(r, sr.Module)){\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleTab(),\r
+ 10,\r
+ r,\r
+ "Module Properties"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleParameterTab(),\r
+ 9,\r
+ r,\r
+ "Parameters"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleInputTab(),\r
+ 2,\r
+ r,\r
+ "Inputs"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ModuleOutputTab(),\r
+ 1,\r
+ r,\r
+ "Outputs"));\r
+ return tabs;\r
+ }\r
+\r
+ // Playback experiment\r
+ if (backend.isInstanceOf(r, sr.PlaybackExperiment))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new PlaybackExperimentTab(),\r
+ 0,\r
+ r,\r
+ "Experiment Properties"));\r
+\r
+ // Game experiment\r
+ if (backend.isInstanceOf(r, sr.GameExperiment))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new GameExperimentTab(),\r
+ 0,\r
+ r,\r
+ "Experiment Properties"));\r
+\r
+ // Default experiment\r
+ if (backend.isInstanceOf(r, simu.Experiment))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ExperimentTab(),\r
+ 0,\r
+ r,\r
+ "Experiment Properties"));\r
+\r
+ // History data\r
+ if (backend.isInstanceOf(r, sr.HistoryDataset))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new HistoryDataTab(),\r
+ 0,\r
+ r,\r
+ "History Data Properties"));\r
+\r
+ // Saved simulation result\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
+\r
+ // Dependency\r
+ if (backend.isInstanceOf(r, sr.Dependency))\r
+ if (backend.hasStatement(r, sr.Dependency_refersTo))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ReferenceDependencyTab(),\r
+ 0,\r
+ r,\r
+ "Reference Properties"));\r
+ else {\r
+ Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new DependencyTab(),\r
+ 0,\r
+ diaConnection,\r
+ "Dependency Properties"));\r
+ }\r
+\r
+ // Module symbol. Modules in modules-folder are actually symbol resources\r
+ if (backend.isInheritedFrom(r, sr.ModuleSymbol)) {\r
+ // Find the component resource\r
+ r = backend.getPossibleObject(r, mr.SymbolToComponentType);\r
+ if(r != null)\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ModuleTypeTab(),\r
+ 0,\r
+ r,\r
+ "Module Type Properties"));\r
+ }\r
+\r
+ // Function\r
+ if (backend.isInstanceOf(r, sr.SysdynModelicaFunction)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new FunctionTab(),\r
+ 2,\r
+ r,\r
+ "Function"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new ExternalFilesTab(),\r
+ 1,\r
+ r,\r
+ "External files"));\r
+ return tabs;\r
+ }\r
+\r
+ // Function library\r
+ if (backend.isInstanceOf(r, sr.SysdynModelicaFunctionLibrary)) {\r
+ Object s = AdaptionUtils.adaptToSingle(selection, ISelection.class);\r
+ if(s == null)\r
+ s = r;\r
+ // give either variable or the actual resource\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new FunctionLibraryTab(),\r
+ 2,\r
+ s,\r
+ "Function library"));\r
+ }\r
+\r
+ // Chart Element\r
+ if(backend.isInstanceOf(r, jfree.ChartElement)) {\r
+ if(backend.hasStatement(r, jfree.ChartElement_component))\r
+ r = backend.getSingleObject(r, jfree.ChartElement_component);\r
+ }\r
+ // Chart\r
+ if (backend.isInstanceOf(r, jfree.Chart)) {\r
+\r
+ Collection<Resource> plots = backend.syncRequest(new ObjectsWithType(r, Layer0.getInstance(backend).ConsistsOf, jfree.Plot));\r
+ if(!plots.isEmpty()) {\r
+ Resource plot = plots.iterator().next();\r
+\r
+ if(backend.isInstanceOf(plot, jfree.XYPlot)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new XYLineGeneralPropertiesTab(),\r
+ 10,\r
+ r,\r
+ "General"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new XYLineAxisAndVariablesTab(),\r
+ 9,\r
+ r,\r
+ "Axis and Variables"));\r
+ } else if(backend.isInstanceOf(plot, jfree.CategoryPlot)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new BarGeneralPropertiesTab(),\r
+ 10,\r
+ r,\r
+ "General"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new BarSeriesTab(),\r
+ 9,\r
+ r,\r
+ "Variables"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new BarAxisTab(),\r
+ 8,\r
+ r,\r
+ "Axis")); \r
+ } else if(backend.isInstanceOf(plot, jfree.PiePlot)) {\r
+ tabs.add(new ComparableTabContributor(\r
+ new PieGeneralPropertiesTab(),\r
+ 10,\r
+ r,\r
+ "General"));\r
+ tabs.add(new ComparableTabContributor(\r
+ new PieSeriesTab(),\r
+ 9,\r
+ r,\r
+ "Variables"));\r
+ }\r
+\r
+ tabs.add(new ComparableTabContributor(\r
+ new ChartTab(),\r
+ 1,\r
+ r,\r
+ "Chart"));\r
+ return tabs;\r
+\r
+ } \r
+ }\r
+\r
+ // Default experiment\r
+ if (backend.isInstanceOf(r, sr.AdditionalSymbols_MultilineText))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new CommentTab(),\r
+ 0,\r
+ r,\r
+ "Comment"));\r
+\r
+ } catch (ServiceException e) {\r
+ e.printStackTrace();\r
+ } catch (ManyObjectsForFunctionalRelationException e) {\r
+ e.printStackTrace();\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ return Collections.emptyList();\r
+ }\r
}\r