Search in sources :

Example 1 with LWTitledDialog

use of org.vcell.client.logicalwindow.LWTitledDialog in project vcell by virtualcell.

the class GeometrySubVolumePanel method createAnalyticSubVolume.

public static AnalyticSubVolume createAnalyticSubVolume(Component requester, int dimensions, Coordinate center, String newSubVolName) throws UserCancelException {
    // Geometry g = getGeometry();
    // final int dim = g.getDimension();
    AddShapeJPanel addShapeJPanel = new AddShapeJPanel(dimensions);
    addShapeJPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    addShapeJPanel.setDefaultCenter(center.getX(), center.getY(), center.getZ());
    // (getGeometry().getDimension() > 2?getGeometry().getOrigin().getZ()+getGeometry().getExtent().getZ()/2:null));
    while (true) {
        try {
            final boolean[] acceptFlag = new boolean[] { false };
            LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
            final JDialog d = new LWTitledDialog(lwParent, "Define New Subdomain Shape");
            // BeanUtils.centerOnComponent(d, GeometrySubVolumePanel.this);
            JPanel main = new JPanel();
            BoxLayout mainBoxLayout = new BoxLayout(main, BoxLayout.Y_AXIS);
            main.setLayout(mainBoxLayout);
            JPanel menuPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
            menuPanel.add(LWNamespace.createRightSideIconMenuBar());
            main.add(menuPanel);
            JPanel addCancelJPanel = new JPanel();
            addCancelJPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
            BoxLayout addCancelBoxLayout = new BoxLayout(addCancelJPanel, BoxLayout.X_AXIS);
            addCancelJPanel.setLayout(addCancelBoxLayout);
            {
                JButton helpButton = new JButton("Help");
                helpButton.addActionListener(ae -> {
                    VcellHelpViewer.showStandaloneViewer();
                });
                addCancelJPanel.add(helpButton);
            }
            JButton addJButton = new JButton("New Subdomain");
            addJButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    d.dispose();
                    acceptFlag[0] = true;
                }
            });
            addCancelJPanel.add(addJButton);
            JButton cancelJButton = new JButton("Cancel");
            cancelJButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    d.dispose();
                }
            });
            addCancelJPanel.add(cancelJButton);
            main.add(addShapeJPanel);
            main.add(Box.createVerticalStrut(10));
            main.add(addCancelJPanel);
            main.add(Box.createVerticalStrut(10));
            addShapeJPanel.addPropertyChangeListener(new PropertyChangeListener() {

                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals(AddShapeJPanel.PROPCHANGE_VALID_ANALYTIC)) {
                        addJButton.setEnabled(((Boolean) evt.getNewValue()));
                    }
                }
            });
            d.setModalityType(ModalityType.DOCUMENT_MODAL);
            // d.setModal(true);
            d.getContentPane().add(main);
            d.pack();
            d.setSize(new Dimension(400, 400));
            d.setVisible(true);
            if (acceptFlag[0]) {
                // new Expression(addShapeJPanel.getCurrentAnalyticExpression()), -1));
                return new AnalyticSubVolume(null, newSubVolName, new Expression(addShapeJPanel.getCurrentAnalyticExpression()), -1);
            } else {
                throw UserCancelException.CANCEL_GENERIC;
            }
        } catch (UserCancelException uce) {
            throw uce;
        } catch (Exception e1) {
            e1.printStackTrace();
            DialogUtils.showErrorDialog(requester, "Error adding shape:\n" + e1.getMessage(), e1);
        }
    }
}
Also used : SubVolume(cbit.vcell.geometry.SubVolume) ActionListener(java.awt.event.ActionListener) JDialog(javax.swing.JDialog) JTextField(javax.swing.JTextField) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) ModalityType(java.awt.Dialog.ModalityType) CSGObject(cbit.vcell.geometry.CSGObject) Geometry(cbit.vcell.geometry.Geometry) GeometrySpec(cbit.vcell.geometry.GeometrySpec) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) JMenuItem(javax.swing.JMenuItem) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) ScrollTable(org.vcell.util.gui.ScrollTable) DocumentEditorSubPanel(cbit.vcell.client.desktop.biomodel.DocumentEditorSubPanel) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) PropertyChangeEvent(java.beans.PropertyChangeEvent) Hashtable(java.util.Hashtable) LWNamespace(org.vcell.client.logicalwindow.LWNamespace) BoxLayout(javax.swing.BoxLayout) VcellHelpViewer(org.vcell.documentation.VcellHelpViewer) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) JPopupMenu(javax.swing.JPopupMenu) LWTitledDialog(org.vcell.client.logicalwindow.LWTitledDialog) UtilCancelException(org.vcell.util.UtilCancelException) BorderFactory(javax.swing.BorderFactory) GridBagConstraints(java.awt.GridBagConstraints) Component(java.awt.Component) ActionEvent(java.awt.event.ActionEvent) DefaultCellEditor(javax.swing.DefaultCellEditor) Box(javax.swing.Box) TokenMangler(org.vcell.util.TokenMangler) Coordinate(org.vcell.util.Coordinate) Dimension(java.awt.Dimension) PropertyChangeListener(java.beans.PropertyChangeListener) DialogUtils(org.vcell.util.gui.DialogUtils) ClientTaskDispatcher(cbit.vcell.client.task.ClientTaskDispatcher) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) IssueManager(cbit.vcell.client.desktop.biomodel.IssueManager) JTable(javax.swing.JTable) EmptyBorder(javax.swing.border.EmptyBorder) Expression(cbit.vcell.parser.Expression) EtchedBorder(javax.swing.border.EtchedBorder) JPanel(javax.swing.JPanel) UserCancelException(org.vcell.util.UserCancelException) JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) FlowLayout(java.awt.FlowLayout) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) JButton(javax.swing.JButton) UserCancelException(org.vcell.util.UserCancelException) Dimension(java.awt.Dimension) UtilCancelException(org.vcell.util.UtilCancelException) UserCancelException(org.vcell.util.UserCancelException) ActionListener(java.awt.event.ActionListener) Expression(cbit.vcell.parser.Expression) EmptyBorder(javax.swing.border.EmptyBorder) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) JDialog(javax.swing.JDialog) LWTitledDialog(org.vcell.client.logicalwindow.LWTitledDialog)

Aggregations

DocumentEditorSubPanel (cbit.vcell.client.desktop.biomodel.DocumentEditorSubPanel)1 IssueManager (cbit.vcell.client.desktop.biomodel.IssueManager)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 ClientTaskDispatcher (cbit.vcell.client.task.ClientTaskDispatcher)1 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)1 CSGObject (cbit.vcell.geometry.CSGObject)1 Geometry (cbit.vcell.geometry.Geometry)1 GeometrySpec (cbit.vcell.geometry.GeometrySpec)1 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)1 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)1 SubVolume (cbit.vcell.geometry.SubVolume)1 Expression (cbit.vcell.parser.Expression)1 Component (java.awt.Component)1 ModalityType (java.awt.Dialog.ModalityType)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1