import org.simantics.browsing.ui.model.nodetypes.SpecialNodeType;\r
import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.common.utils.ListUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
import org.simantics.db.layer0.variable.Variable;\r
import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.jfreechart.ChartSelectionTabContributor;\r
-import org.simantics.jfreechart.chart.properties.ChartTab;\r
-import org.simantics.jfreechart.chart.properties.bar.BarAxisTab;\r
-import org.simantics.jfreechart.chart.properties.bar.BarGeneralPropertiesTab;\r
-import org.simantics.jfreechart.chart.properties.bar.BarSeriesTab;\r
-import org.simantics.jfreechart.chart.properties.pie.PieGeneralPropertiesTab;\r
-import org.simantics.jfreechart.chart.properties.pie.PieSeriesTab;\r
-import org.simantics.jfreechart.chart.properties.xyline.XYLineAxisAndVariablesTab;\r
-import org.simantics.jfreechart.chart.properties.xyline.XYLineGeneralPropertiesTab;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.modeling.ModelingResources;\r
import org.simantics.modeling.ui.property.svg.SVGElementComposite;\r
import org.simantics.selectionview.ComparableTabContributor;\r
import org.simantics.selectionview.SelectionProcessor;\r
import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.sysdyn.JFreeChartResource;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
import org.simantics.ui.selection.AnyVariable;\r
* SelectionProcessor for processing selections for property view in system dynamics\r
* \r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
public class ResourceSelectionProcessor implements SelectionProcessor<Object, ReadGraph> {\r
\r
// Dependency\r
if (backend.isInstanceOf(r, sr.Dependency))\r
- if (backend.hasStatement(r, sr.Dependency_refersTo))\r
+ if (backend.hasStatement(r, sr.Dependency_refersTo)) {\r
+ Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
return Collections.singleton(\r
new ComparableTabContributor(\r
- new ReferenceDependencyTab(),\r
+ new DependencyTab(),\r
0,\r
- r,\r
+ diaConnection,\r
"Reference Properties"));\r
- else {\r
+ } else {\r
Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
return Collections.singleton(\r
new ComparableTabContributor(\r
connectedVariables[i].dispose();\r
TableItem item2 = new TableItem(variableTable, SWT.NONE, j);\r
item2.setText(values);\r
+ item2.setData(values);\r
connectedVariables = variableTable.getItems();\r
break;\r
}\r
import org.simantics.sysdyn.manager.SysdynModel;\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Model;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.ModuleType;\r
import org.simantics.sysdyn.representation.Variable;\r
import org.simantics.ui.SimanticsUI;\r
\r
Configuration configuration = model.getConfiguration();\r
if(configuration == null)\r
return true;\r
+ \r
+ // Browse through variables and modules within the current module\r
IElement current = model.getElement(variable);\r
for(IElement e : configuration.getElements()) {\r
if(e instanceof Variable) {\r
if(!v.equals(current) && v.getName() != null && v.getName().equals(name)) {\r
return true;\r
}\r
- }\r
+ } else if (e instanceof Module) {\r
+ Module m = (Module)e;\r
+ if(!m.equals(current) && m.getName() != null && m.getName().equals(name)) {\r
+ return true;\r
+ }\r
+ }\r
}\r
+ \r
+ // Browse through all ModuleTypes within the whole model\r
+ Model rootModel = null;\r
+ ModuleType moduleType = configuration.getModuleType();\r
+ if (moduleType != null) {\r
+ Object o = moduleType.getParent();\r
+ if (o instanceof Model) {\r
+ rootModel = (Model)o;\r
+ }\r
+ } else {\r
+ rootModel = configuration.getModel();\r
+ }\r
+ if (rootModel != null)\r
+ return rootModel.containsModuleType(name);\r
+ \r
+ // We should not go here I think\r
return false;\r
}\r
\r
*/\r
public class SysdynImportFormatHandler implements FormatHandler<Object> {\r
\r
- private Resource parent;\r
- private IProgressMonitor monitor;\r
- private String migrationURI;\r
- private DefaultPasteImportAdvisor importAdvisor;\r
+ private final Resource parent;\r
+ private final IProgressMonitor monitor;\r
+ private final String migrationURI;\r
+ private final DefaultPasteImportAdvisor importAdvisor;\r
\r
/**\r
* Works 2 (2 * 1) in the monitor\r
MigrationStep step = MigrationUtils.getStep(session, migrationURI);\r
MigrationState state = MigrationUtils.newState();\r
state.setProperty(MigrationStateKeys.CURRENT_TG, tg);\r
- step.applyTo(session, state);\r
+ step.applyTo(monitor, session, state);\r
// tg = state.getProperty(MigrationStateKeys.CURRENT_TG);\r
\r
worked(1);\r
/**\r
* Representation of a system dynamics model\r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
@GraphType(SysdynResource.URIs.SysdynModel)\r
public class Model {\r
\r
@RelatedValue(SysdynResource.URIs.SysdynModel_startTime)\r
- private Double startTime = 0.0;\r
+ private final Double startTime = 0.0;\r
\r
@RelatedValue(SysdynResource.URIs.SysdynModel_stopTime)\r
- private Double stopTime = 10.0;\r
+ private final Double stopTime = 10.0;\r
\r
@RelatedValue(SysdynResource.URIs.SysdynModel_outputInterval)\r
private Double outputInterval;\r
@RelatedElements(\r
value = Layer0.URIs.ConsistsOf,\r
composition = true)\r
- private ArrayList<Object> consistsOf = new ArrayList<Object>();\r
+ private final ArrayList<Object> consistsOf = new ArrayList<Object>();\r
\r
@RelatedElements(\r
value = Layer0.URIs.IsLinkedTo,\r
composition = true)\r
- private ArrayList<Object> linkedTo = new ArrayList<Object>();\r
+ private final ArrayList<Object> linkedTo = new ArrayList<Object>();\r
\r
\r
@BuiltinFunctions\r
return functions;\r
}\r
\r
+ /**\r
+ * Determine if this Model consists of a certain ModuleType.\r
+ * @param moduleType The name of the ModuleType that is sought \r
+ * @return true iff this consists of moduleType\r
+ */\r
+ public boolean containsModuleType(String moduleType) {\r
+ if(consistsOf != null ) {\r
+ for(Object o : consistsOf) {\r
+ if(o instanceof ModuleType) {\r
+ ModuleType mt = (ModuleType)o;\r
+ if (mt.getName().equals(moduleType)) \r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ \r
/**\r
* Add built-in functions to functions map. Built-in functions do not have any library path.\r
* @param library Built-in function library\r