use of org.vcell.util.UtilCancelException in project vcell by virtualcell.
the class BioModelTreePanel method editAnnotation.
/**
* Comment
*/
private void editAnnotation() {
try {
DefaultMutableTreeNode currentTreeSelection = (DefaultMutableTreeNode) getJTree2().getLastSelectedPathComponent();
Object selectedObject = null;
Object parentObject = null;
if (currentTreeSelection != null) {
selectedObject = currentTreeSelection.getUserObject();
}
if (selectedObject instanceof BioModel || selectedObject instanceof SimulationContext || selectedObject instanceof Simulation) {
parentObject = selectedObject;
} else if (selectedObject instanceof Annotation) {
parentObject = ((DefaultMutableTreeNode) currentTreeSelection.getParent()).getUserObject();
}
if (parentObject instanceof BioModel) {
BioModel bioModel = (BioModel) parentObject;
String oldAnnotation = bioModel.getVCMetaData().getFreeTextAnnotation(bioModel);
try {
String newAnnotation = DialogUtils.showAnnotationDialog(this, oldAnnotation);
if (BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
bioModel.getVCMetaData().setFreeTextAnnotation(bioModel, newAnnotation);
}
} catch (UtilCancelException e) {
// Do Nothing
}
} else if (parentObject instanceof SimulationContext) {
String oldAnnotation = ((SimulationContext) parentObject).getDescription();
try {
String newAnnotation = DialogUtils.showAnnotationDialog(this, oldAnnotation);
if (BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
((SimulationContext) parentObject).setDescription(newAnnotation);
}
} catch (UtilCancelException e) {
// Do Nothing
}
} else if (parentObject instanceof Simulation) {
String oldAnnotation = ((Simulation) parentObject).getDescription();
try {
String newAnnotation = DialogUtils.showAnnotationDialog(this, oldAnnotation);
if (BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
((Simulation) parentObject).setDescription(newAnnotation);
}
} catch (UtilCancelException e) {
// Do Nothing
}
} else {
throw new Exception("Enexpected Edit Annotation Target=" + (parentObject != null ? parentObject.getClass().getName() : "null"));
}
} catch (Throwable exc) {
exc.printStackTrace(System.out);
DialogUtils.showErrorDialog(this, "Failed to edit annotation!\n" + exc.getMessage(), exc);
}
}
Aggregations