use of cbit.vcell.client.desktop.mathmodel.MathModelEditor in project vcell by virtualcell.
the class DocumentEditor method getSelectedSimulationContext.
protected SimulationContext getSelectedSimulationContext() {
if (this instanceof MathModelEditor) {
return null;
}
// make sure only one simulation context is selected
TreePath[] selectedPaths = documentEditorTree.getSelectionPaths();
SimulationContext simulationContext = null;
for (TreePath path : selectedPaths) {
Object node = path.getLastPathComponent();
if (!(node instanceof BioModelNode)) {
return null;
}
BioModelNode n = (BioModelNode) node;
while (true) {
Object userObject = n.getUserObject();
if (userObject instanceof SimulationContext) {
if (simulationContext == null) {
simulationContext = (SimulationContext) userObject;
break;
} else if (simulationContext != userObject) {
return null;
}
}
TreeNode parent = n.getParent();
if (parent == null || !(parent instanceof BioModelNode)) {
break;
}
n = (BioModelNode) parent;
}
}
return simulationContext;
}
Aggregations