Search in sources :

Example 1 with UtilCancelException

use of org.vcell.util.UtilCancelException in project vcell by virtualcell.

the class MIRIAMAnnotationEditor method showEditFreehandText.

private void showEditFreehandText(DefaultMutableTreeNode node) {
    final IdentifiableNode parentIdentifiableNode = (IdentifiableNode) ((BioModelNode) node).getParent();
    final Annotation oldAnnotation = (Annotation) ((BioModelNode) node).getUserObject();
    try {
        String newAnnotation = DialogUtils.showAnnotationDialog(MIRIAMAnnotationEditor.this, oldAnnotation.toString());
        if (BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
            vcMetaData.setFreeTextAnnotation(parentIdentifiableNode.getIdentifiable(), newAnnotation);
        }
    } catch (UtilCancelException uce) {
    // ignore
    } catch (Exception exc) {
        exc.printStackTrace();
        DialogUtils.showErrorDialog(MIRIAMAnnotationEditor.this, "Error editing Annotation:\n" + exc.getMessage(), exc);
    }
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) Annotation(cbit.vcell.desktop.Annotation) UtilCancelException(org.vcell.util.UtilCancelException) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)

Example 2 with UtilCancelException

use of org.vcell.util.UtilCancelException in project vcell by virtualcell.

the class TestingFrameworkPanel method getLoadTestMenu.

private JPopupMenu getLoadTestMenu() {
    JPopupMenu mainLoadTestMenu = new JPopupMenu();
    if (getTreeSelection() instanceof String && ((String) getTreeSelection()).equals(TestingFrmwkTreeModel.LOAD_TEST_SUBTREE_NAME)) {
        JMenuItem refreshThresholdMenuItem = new JMenuItem("Refresh (with load time threshold)...");
        refreshThresholdMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                try {
                    String result = DialogUtils.showInputDialog0(TestingFrameworkPanel.this, "Enter load time threshold (millseconds)", "10000");
                    slowLoadThreshold = (result == null || result.length() == 0 ? null : new Integer(result));
                    ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.REFRESH_XML_LOAD_TEST);
                    TestingFrameworkPanel.this.refireActionPerformed(refresh);
                } catch (UtilCancelException uce) {
                // ignore
                } catch (Exception e2) {
                    e2.printStackTrace();
                    DialogUtils.showErrorDialog(TestingFrameworkPanel.this, e2.getMessage(), e2);
                }
            }
        });
        mainLoadTestMenu.add(refreshThresholdMenuItem);
        JMenuItem loadTestSQLMenuItem = new JMenuItem("Add SQL Condition...");
        loadTestSQLMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                try {
                    String result = DialogUtils.showInputDialog0(TestingFrameworkPanel.this, "Enter SQL Condition", loadTestSQLCondition);
                    loadTestSQLCondition = (result == null || result.length() == 0 ? null : result);
                    ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.REFRESH_XML_LOAD_TEST);
                    TestingFrameworkPanel.this.refireActionPerformed(refresh);
                } catch (UtilCancelException uce) {
                // ignore
                } catch (Exception e2) {
                    e2.printStackTrace();
                    DialogUtils.showErrorDialog(TestingFrameworkPanel.this, e2.getMessage(), e2);
                }
            }
        });
        mainLoadTestMenu.add(loadTestSQLMenuItem);
        JMenuItem runXMLLoadTestAllMenuItem = new JMenuItem("Run XML Load Test for all models...");
        runXMLLoadTestAllMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.RUN_XML_LOAD_TEST_All);
                TestingFrameworkPanel.this.refireActionPerformed(refresh);
            }
        });
        mainLoadTestMenu.add(runXMLLoadTestAllMenuItem);
    }
    if (getTreeSelection() instanceof LoadTestTreeInfo && ((LoadTestTreeInfo) getTreeSelection()).userid == null) {
        JMenuItem deleteLoadTestMenuItem = new JMenuItem("Delete Load Test...");
        deleteLoadTestMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.DELETE_XML_LOAD_TEST);
                TestingFrameworkPanel.this.refireActionPerformed(refresh);
            }
        });
        mainLoadTestMenu.add(deleteLoadTestMenuItem);
    }
    if (getTreeSelection() instanceof LoadTestTreeInfo && ((LoadTestTreeInfo) getTreeSelection()).userid != null) {
        JMenuItem loadModelSelectedMenuItem = new JMenuItem(TestingFrameworkPanel.LOAD_MODEL);
        loadModelSelectedMenuItem.setEnabled(getJTree1().getSelectionCount() == 1);
        loadModelSelectedMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.LOAD_MODEL);
                TestingFrameworkPanel.this.refireActionPerformed(refresh);
            }
        });
        mainLoadTestMenu.add(loadModelSelectedMenuItem);
        JMenuItem runXMLLoadTestModelsSelectedMenuItem = new JMenuItem("Run XML Load Test for selected models...");
        runXMLLoadTestModelsSelectedMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.RUN_XML_LOAD_TEST_MODELS);
                TestingFrameworkPanel.this.refireActionPerformed(refresh);
            }
        });
        mainLoadTestMenu.add(runXMLLoadTestModelsSelectedMenuItem);
        JMenuItem runXMLLoadTestUsersSelectedMenuItem = new JMenuItem("Run XML Load Test for selected Users...");
        runXMLLoadTestUsersSelectedMenuItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                ActionEvent refresh = new ActionEvent(TestingFrameworkPanel.this, ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.RUN_XML_LOAD_TEST_USERS);
                TestingFrameworkPanel.this.refireActionPerformed(refresh);
            }
        });
        mainLoadTestMenu.add(runXMLLoadTestUsersSelectedMenuItem);
    }
    return mainLoadTestMenu;
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) LoadTestTreeInfo(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.LoadTestTreeInfo) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu) UtilCancelException(org.vcell.util.UtilCancelException)

Example 3 with UtilCancelException

use of org.vcell.util.UtilCancelException in project vcell by virtualcell.

the class GeometrySubVolumePanel method geometrySubVolumePanel_Initialize.

/**
 * Comment
 */
private void geometrySubVolumePanel_Initialize() {
    getScrollPaneTable().setDefaultRenderer(SubVolume.class, new GeometrySubVolumeTableCellRenderer());
    getScrollPaneTable().setDefaultEditor(SubVolume.class, new DefaultCellEditor(new JTextField()) {

        private int lastRow = -1;

        private int lastCol = -1;

        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
            lastRow = row;
            lastCol = column;
            delegate.setValue(((SubVolume) value).getName());
            return editorComponent;
        }

        public final boolean stopCellEditing() {
            // 
            try {
                String name = (String) delegate.getCellEditorValue();
                while (true) {
                    if (name.equals(TokenMangler.fixTokenStrict(name))) {
                        break;
                    }
                    name = DialogUtils.showInputDialog0(getComponent(), "Subdomain name " + name + " has illegal characters." + "\nProvide new value.", name);
                }
                // VALIDATE_OK, delegate gets New Good value
                delegate.setValue(name);
            } catch (UtilCancelException e) {
                // delegate gets Last Good value
                delegate.setValue(((SubVolume) getScrollPaneTable().getValueAt(lastRow, lastCol)).getName());
            } catch (Throwable e) {
            // Delegate keeps UNVALIDATED value
            }
            return super.stopCellEditing();
        }
    });
    getScrollPaneTable().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    refreshButtons();
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) SubVolume(cbit.vcell.geometry.SubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) JTable(javax.swing.JTable) CSGObject(cbit.vcell.geometry.CSGObject) JTextField(javax.swing.JTextField) Component(java.awt.Component) DefaultCellEditor(javax.swing.DefaultCellEditor)

Example 4 with UtilCancelException

use of org.vcell.util.UtilCancelException in project vcell by virtualcell.

the class ROIMultiPaintManager method duplicateROIDataAsk.

private void duplicateROIDataAsk() {
    String extraInfo = null;
    while (true) {
        try {
            String zCountS = DialogUtils.showInputDialog0(overlayEditorPanelJAI, "Convert 2D to 3D. Enter desired Z count:" + (extraInfo == null ? "" : "\n" + extraInfo), "1");
            int zCount = Integer.parseInt(zCountS);
            if (zCount == 1) {
                throw UtilCancelException.CANCEL_GENERIC;
            }
            duplicateROIData(zCount);
            break;
        } catch (UtilCancelException uce) {
            throw UserCancelException.CANCEL_GENERIC;
        } catch (Exception e) {
            extraInfo = "Error: Z count must be >= 1:\n'" + e.getMessage() + "'";
        }
    }
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

Example 5 with UtilCancelException

use of org.vcell.util.UtilCancelException in project vcell by virtualcell.

the class ROIMultiPaintManager method padCropDataset.

private void padCropDataset() {
    int xm = 0;
    int ym = 0;
    int zm = 0;
    int xp = 0;
    int yp = 0;
    int zp = 0;
    String result = null;
    do {
        try {
            result = DialogUtils.showInputDialog0(overlayEditorPanelJAI, "Enter the number of pixels to add or crop (negative number) at each border: (xlow,ylow,zlow,xhigh,yhigh,zhigh)", xm + "," + ym + "," + zm + "," + xp + "," + yp + "," + zp);
            if (result != null) {
                final String SEP = ",";
                result = result.trim();
                StringTokenizer st = new StringTokenizer(result, SEP);
                xm = Integer.parseInt(st.nextToken());
                ym = Integer.parseInt(st.nextToken());
                zm = Integer.parseInt(st.nextToken());
                xp = Integer.parseInt(st.nextToken());
                yp = Integer.parseInt(st.nextToken());
                zp = Integer.parseInt(st.nextToken());
                if (st.hasMoreElements() || result.endsWith(SEP)) {
                    throw new Exception("Some input was not parsed, check input.");
                }
                break;
            }
        } catch (UtilCancelException e) {
            throw UserCancelException.CANCEL_GENERIC;
        } catch (Exception e) {
            DialogUtils.showErrorDialog(overlayEditorPanelJAI, "Error parsing '" + result + "' Resetting to valid values.  Enter 6 comma separated integers.");
        }
    } while (true);
    final CoordinateIndex low = new CoordinateIndex(xm, ym, zm);
    final CoordinateIndex high = new CoordinateIndex(xp, yp, zp);
    final AsynchClientTask padTask = new AsynchClientTask("Changeing borders...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            resizeImpl(ResizeInfo.createPadCropResizeInfo(getImageDataSetChannel().getISize(), low, high), getClientTaskStatusSupport());
        }
    };
    final AsynchClientTask updatePanelTask = getUpdateDisplayAfterCropTask();
    ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { padTask, updatePanelTask }, false, false, null, true);
}
Also used : StringTokenizer(java.util.StringTokenizer) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) UtilCancelException(org.vcell.util.UtilCancelException) Hashtable(java.util.Hashtable) CoordinateIndex(org.vcell.util.CoordinateIndex) Point(java.awt.Point) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException)

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