Search in sources :

Example 11 with LWContainerHandle

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

the class DialogUtils method showOptionsDialog.

private static String showOptionsDialog(final Component requester, Component showComponent, final int JOptionPaneMessageType, String[] options, String initOption, OKEnabler okEnabler, String title) {
    VCellThreadChecker.checkSwingInvocation();
    checkForNull(requester);
    LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
    JOptionPane pane = new JOptionPane(showComponent, JOptionPaneMessageType, 0, null, options, initOption);
    final JDialog dialog = new LWTitledOptionPaneDialog(lwParent, title, pane);
    dialog.setResizable(true);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    if (okEnabler != null) {
        okEnabler.setJOptionPane(pane);
    }
    try {
        dialog.setVisible(true);
        Object selectedValue = pane.getValue();
        if (selectedValue == null || selectedValue.equals(JOptionPane.UNINITIALIZED_VALUE)) {
            return SimpleUserMessage.OPTION_CANCEL;
        } else {
            return selectedValue.toString();
        }
    } finally {
        dialog.dispose();
    }
}
Also used : LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) LWTitledOptionPaneDialog(org.vcell.client.logicalwindow.LWTitledOptionPaneDialog) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 12 with LWContainerHandle

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

the class DialogUtils method showInfoDialog.

/**
 * Insert the method's description here.
 * Creation date: (5/21/2004 3:17:45 AM)
 * @param owner java.awt.Component
 * @param message java.lang.Object
 */
public static void showInfoDialog(final Component requester, final String title, final String message) {
    checkForNull(requester);
    LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
    Doer doer = () -> {
        JPanel panel = MessagePanelFactory.createSimple(message);
        JOptionPane pane = new JOptionPane(panel, JOptionPane.INFORMATION_MESSAGE);
        LWDialog dialog = new LWTitledOptionPaneDialog(lwParent, title, pane);
        dialog.setResizable(true);
        showOnce(dialog);
    };
    VCSwingFunction.executeAsRuntimeException(doer);
}
Also used : JPanel(javax.swing.JPanel) LWDialog(org.vcell.client.logicalwindow.LWDialog) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) Doer(org.vcell.util.gui.VCSwingFunction.Doer) LWTitledOptionPaneDialog(org.vcell.client.logicalwindow.LWTitledOptionPaneDialog) JOptionPane(javax.swing.JOptionPane)

Example 13 with LWContainerHandle

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

the class DialogUtils method showListDialog.

/**
 * Insert the method's description here.
 * Creation date: (5/21/2004 3:23:18 AM)
 * @return int
 * @param owner java.awt.Component
 * @param message java.lang.String
 * @param preferences cbit.vcell.client.UserPreferences
 * @param preferenceName java.lang.String
 */
public static Object showListDialog(final Component requester, final Object[] names, final String dialogTitle, final ListCellRenderer<Object> listCellRenderer) {
    checkForNull(requester);
    LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
    Producer<Object> prod = () -> {
        JPanel panel = new JPanel(new BorderLayout());
        final JOptionPane pane = new JOptionPane(null, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
        JScrollPane scroller = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        final JList<Object> list = new JList<>(names);
        if (listCellRenderer != null) {
            list.setCellRenderer(listCellRenderer);
        }
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        scroller.setViewportView(list);
        Dimension size = new Dimension(list.getPreferredSize());
        size.width = Math.max(80, Math.min(500, size.width + 40));
        size.height = Math.max(75, Math.min(500, size.height + 40));
        scroller.getViewport().setPreferredSize(size);
        panel.add(scroller, BorderLayout.CENTER);
        pane.setMessage(panel);
        setInternalNotCancelEnabled(pane, false, false);
        list.addListSelectionListener(new javax.swing.event.ListSelectionListener() {

            public void valueChanged(javax.swing.event.ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    DialogUtils.setInternalNotCancelEnabled(pane, list.getSelectedIndex() != -1, false);
                }
            }
        });
        final JDialog dialog = new LWTitledOptionPaneDialog(lwParent, dialogTitle, pane);
        dialog.setResizable(true);
        try {
            dialog.setVisible(true);
            Object selectedValue = pane.getValue();
            if (selectedValue == null || (((Integer) selectedValue).intValue() == JOptionPane.CLOSED_OPTION) || (((Integer) selectedValue).intValue() == JOptionPane.CANCEL_OPTION)) {
                return null;
            } else {
                int index = list.getSelectedIndex();
                if (index >= 0 && index < names.length) {
                    return names[index];
                }
                // Should never get here
                return null;
            }
        } finally {
            dialog.dispose();
        }
    };
    return VCSwingFunction.executeAsRuntimeException(prod);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Dimension(java.awt.Dimension) LWTitledOptionPaneDialog(org.vcell.client.logicalwindow.LWTitledOptionPaneDialog) JOptionPane(javax.swing.JOptionPane) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) JList(javax.swing.JList) JDialog(javax.swing.JDialog)

Example 14 with LWContainerHandle

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

the class AsynchProgressPopup method getDialog.

/**
 * select and created dialog based on {@link #knowsProgress} value
 * @return {@link DefaultProgressDialog} or {@link IndefiniteProgressDialog}
 */
protected ProgressDialog getDialog() {
    if (dialog == null) {
        LWContainerHandle owner = LWNamespace.findLWOwner(requester);
        if (knowsProgress) {
            dialog = new LinearDefiniteProgressDialog(owner);
        } else {
            dialog = new IndefiniteProgressDialog(owner);
        }
        if (bCancelable && progressDialogListener != null) {
            dialog.setCancelButtonVisible(true);
            dialog.addProgressDialogListener(progressDialogListener);
        } else {
            dialog.setCancelButtonVisible(false);
        }
        BeanUtils.centerOnComponent(dialog, owner.getWindow());
        dialog.setResizable(false);
        if (title != null) {
            dialog.setTitle(title);
        }
        if (message != null) {
            dialog.setMessage(message);
        }
        dialog.setModal(inputBlocking);
        if (!knowsProgress) {
            dialog.setProgressBarString("WORKING...");
        }
        dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }
    return dialog;
}
Also used : LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle)

Example 15 with LWContainerHandle

use of org.vcell.client.logicalwindow.LWContainerHandle 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

LWContainerHandle (org.vcell.client.logicalwindow.LWContainerHandle)15 JOptionPane (javax.swing.JOptionPane)12 LWTitledOptionPaneDialog (org.vcell.client.logicalwindow.LWTitledOptionPaneDialog)12 JDialog (javax.swing.JDialog)9 JPanel (javax.swing.JPanel)9 LWDialog (org.vcell.client.logicalwindow.LWDialog)5 Doer (org.vcell.util.gui.VCSwingFunction.Doer)5 BorderLayout (java.awt.BorderLayout)4 Dimension (java.awt.Dimension)4 JScrollPane (javax.swing.JScrollPane)3 Hashtable (java.util.Hashtable)2 JTextArea (javax.swing.JTextArea)2 UserCancelException (org.vcell.util.UserCancelException)2 UtilCancelException (org.vcell.util.UtilCancelException)2 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