protected HashMap<String, String> rvis;\r
protected String indexes;\r
protected VariableSubscriptionManager subscriptionManager;\r
+ protected Pair<ArrayList<String>,ArrayList<String>> variableNameArrays;\r
\r
public IndexVariable(ReadGraph graph, Variable parent, String indexes) throws DatabaseException {\r
this.parent = parent;\r
}\r
\r
protected void ensureInformationAvailable(ReadGraph graph) throws DatabaseException {\r
- SimulationResource SIMU = SimulationResource.getInstance(graph);\r
- ModelingResources MOD = ModelingResources.getInstance(graph);\r
\r
if(model == null) {\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
Resource modelResource = Variables.getModel(graph, parent);\r
Resource configuration = graph.getPossibleObject(modelResource, SIMU.HasConfiguration);\r
model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
}\r
- \r
- Variable var = parent.getParent(graph);\r
- Resource represents = var.getRepresents(graph);\r
- \r
- Resource activeRun = null;\r
- if(represents != null) {\r
- do {\r
- if(graph.isInstanceOf(represents, SIMU.Run)) {\r
- activeRun = represents;\r
- break;\r
- }\r
- var = var.getParent(graph);\r
- represents = var.getRepresents(graph);\r
- } while(represents != null && !graph.isInstanceOf(represents, MOD.StructuralModel));\r
- }\r
\r
- IProject project = Simantics.peekProject();\r
- if(activeRun != null && project != null) {\r
- IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
- IExperiment e = expMan.getExperiment(NameUtils.getSafeName(graph, activeRun));\r
- if(e instanceof SysdynExperiment)\r
- this.experiment = (SysdynExperiment)e;\r
+ if(this.experiment == null || this.subscriptionManager == null) {\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ ModelingResources MOD = ModelingResources.getInstance(graph);\r
+ Variable var = parent.getParent(graph);\r
+ Resource represents = var.getRepresents(graph);\r
+ Resource activeRun = null;\r
+ if(represents != null) {\r
+ do {\r
+ if(graph.isInstanceOf(represents, SIMU.Run)) {\r
+ activeRun = represents;\r
+ break;\r
+ }\r
+ var = var.getParent(graph);\r
+ represents = var.getRepresents(graph);\r
+ } while(represents != null && !graph.isInstanceOf(represents, MOD.StructuralModel));\r
+ }\r
+\r
+ IProject project = Simantics.peekProject();\r
+ if(activeRun != null && project != null) {\r
+ IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+ IExperiment e = expMan.getExperiment(NameUtils.getSafeName(graph, activeRun));\r
+ if(e instanceof SysdynExperiment)\r
+ this.experiment = (SysdynExperiment)e;\r
+ }\r
+ this.subscriptionManager = getSubscriptionManager();\r
}\r
\r
- this.subscriptionManager = getSubscriptionManager();\r
- rvi = Variables.getPossibleRVI(graph, this);\r
+ if(rvi == null)\r
+ rvi = Variables.getPossibleRVI(graph, this);\r
+ \r
if(rvi != null)\r
- rvis = graph.syncRequest(new VariableRVIUtils.GetActiveRVIs(parent.getParent(graph))); //VariableRVIUtils.getActiveRVIs(graph, parent.getParent(graph)); \r
+ rvis = graph.syncRequest(new VariableRVIUtils.GetActiveRVIs(parent.getParent(graph))); //VariableRVIUtils.getActiveRVIs(graph, parent.getParent(graph));\r
+ \r
}\r
\r
private Pair<ArrayList<String>,ArrayList<String>> getVariableNameArrays() {\r
- Pair<ArrayList<String>,ArrayList<String>> result = new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
- if(rvi == null || rvis == null)\r
- return result;\r
\r
- if(rvi.indexOf('#') > 0)\r
- rvi = rvi.substring(0, rvi.indexOf('#'));\r
- \r
- String test = rvi;\r
- if(indexes != null && !indexes.isEmpty()) {\r
- String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012\r
- test = rvi + "\\[" + regexIndexes + "\\]";\r
- } else {\r
- test = rvi + "(\\[.*\\])?";\r
- }\r
- for(String k : rvis.keySet()) {\r
- String value = rvis.get(k);\r
- if(k.matches(test) || value.matches(test)) {\r
- result.first.add(k.substring(1).replace("/", ".").replace("%20", "_"));\r
- result.second.add(value.substring(1).replace("/", ".").replace("%20", " "));\r
- }\r
- }\r
- \r
- return result;\r
+ if(variableNameArrays == null) {\r
+ \r
+ Pair<ArrayList<String>,ArrayList<String>> result = new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
+ if(rvi != null && rvis != null) {\r
+ \r
+ if(rvi.indexOf('#') > 0)\r
+ rvi = rvi.substring(0, rvi.indexOf('#'));\r
+ \r
+ String test = rvi;\r
+ if(indexes != null && !indexes.isEmpty()) {\r
+ String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012\r
+ test = rvi + "\\[" + regexIndexes + "\\]";\r
+ } else {\r
+ test = rvi + "(\\[.*\\])?";\r
+ }\r
+ for(String k : rvis.keySet()) {\r
+ String value = rvis.get(k);\r
+ if(k.matches(test) || value.matches(test)) {\r
+ result.first.add(k.substring(1).replace("/", ".").replace("%20", "_"));\r
+ result.second.add(value.substring(1).replace("/", ".").replace("%20", " "));\r
+ }\r
+ }\r
+ \r
+ variableNameArrays = result;\r
+\r
+ }\r
+ \r
+ }\r
+ \r
+ if(variableNameArrays == null) return new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
+ \r
+ return variableNameArrays;\r
\r
}\r
\r