Search in sources :

Example 16 with UtilCancelException

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);
    }
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) SimulationContext(cbit.vcell.mapping.SimulationContext) UtilCancelException(org.vcell.util.UtilCancelException)

Aggregations

UtilCancelException (org.vcell.util.UtilCancelException)16 UserCancelException (org.vcell.util.UserCancelException)6 Point (java.awt.Point)4 Hashtable (java.util.Hashtable)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 BioModel (cbit.vcell.biomodel.BioModel)2 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)2 LoadTestTreeInfo (cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.LoadTestTreeInfo)2 SimulationContext (cbit.vcell.mapping.SimulationContext)2 Simulation (cbit.vcell.solver.Simulation)2 ActionEvent (java.awt.event.ActionEvent)2 PropertyVetoException (java.beans.PropertyVetoException)2 ContainerShape (cbit.gui.graph.ContainerShape)1 ElipseShape (cbit.gui.graph.ElipseShape)1 RubberBandEdgeShape (cbit.gui.graph.RubberBandEdgeShape)1 RubberBandRectShape (cbit.gui.graph.RubberBandRectShape)1 Shape (cbit.gui.graph.Shape)1 ImageException (cbit.image.ImageException)1 TestingFrmwkTreeModel (cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel)1 TFAddTestSuite (cbit.vcell.client.task.TFAddTestSuite)1