Search in sources :

Example 1 with LWDialog

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

the class DialogUtils method showWarningDialog.

public static void showWarningDialog(final Component requester, final String message) {
    checkForNull(requester);
    LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
    Doer doer = () -> {
        JPanel panel = MessagePanelFactory.createSimple(message);
        JOptionPane pane = new JOptionPane(panel, JOptionPane.WARNING_MESSAGE);
        LWDialog dialog = new LWTitledOptionPaneDialog(lwParent, "Warning", 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 2 with LWDialog

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

the class DialogUtils method showDialog.

/**
 * 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
 */
protected static String showDialog(final Component requester, final UserPreferences preferences, final UserMessage userMessage, final String replacementText, final int jOptionPaneMessageType) {
    checkForNull(requester);
    LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
    Producer<String> prod = () -> {
        // 
        if (userMessage.getUserPreferenceWarning() > -1 && preferences != null && !preferences.getShowWarning(userMessage.getUserPreferenceWarning())) {
            return userMessage.getDefaultSelection();
        }
        String message = userMessage.getMessage(replacementText);
        JPanel panel = MessagePanelFactory.createSimple(message);
        JCheckBox checkBox = null;
        if (userMessage.getUserPreferenceWarning() >= 0) {
            checkBox = new JCheckBox("Do not show this warning again");
            panel.add(checkBox, BorderLayout.SOUTH);
        }
        JOptionPane pane = new JOptionPane(panel, jOptionPaneMessageType, 0, null, userMessage.getOptions(), userMessage.getDefaultSelection());
        String title;
        switch(jOptionPaneMessageType) {
            case JOptionPane.WARNING_MESSAGE:
                title = "WARNING:";
                break;
            case JOptionPane.ERROR_MESSAGE:
                title = "ERROR:";
                break;
            case JOptionPane.INFORMATION_MESSAGE:
                title = "INFO:";
                break;
            default:
                title = null;
        }
        LWDialog dialog = new LWTitledOptionPaneDialog(lwParent, title, pane);
        dialog.setResizable(true);
        try {
            dialog.setVisible(true);
            if (checkBox != null) {
                preferences.setShowWarning(userMessage.getUserPreferenceWarning(), !checkBox.isSelected());
            }
            Object selectedValue = pane.getValue();
            if (selectedValue == null || selectedValue.equals(JOptionPane.UNINITIALIZED_VALUE)) {
                return UserMessage.OPTION_CANCEL;
            } else {
                return objectToString(selectedValue);
            }
        } finally {
            dialog.dispose();
        }
    };
    return VCSwingFunction.executeAsRuntimeException(prod);
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) LWDialog(org.vcell.client.logicalwindow.LWDialog) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) LWTitledOptionPaneDialog(org.vcell.client.logicalwindow.LWTitledOptionPaneDialog) JOptionPane(javax.swing.JOptionPane)

Example 3 with LWDialog

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

the class DialogUtils method showModalJDialogOnTop.

/**
 * @deprecated -- use setVisible on LWDialog
 * @param jdialog
 * @param component
 */
public static void showModalJDialogOnTop(JDialog jdialog, Component component) {
    if (jdialog instanceof LWDialog) {
        jdialog.setVisible(true);
        return;
    }
    LWContainerHandle lwParent = LWNamespace.findLWOwner(component);
    LWJDialogDecorator deco = LWJDialogDecorator.decoratorFor(jdialog);
    lwParent.manage(deco);
    deco.getWindow().setVisible(true);
}
Also used : LWDialog(org.vcell.client.logicalwindow.LWDialog) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) LWJDialogDecorator(org.vcell.client.logicalwindow.transition.LWJDialogDecorator)

Example 4 with LWDialog

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

the class DialogUtils method showAnnotationDialog.

public static String showAnnotationDialog(final Component requester, final String oldAnnotation) throws Exception {
    checkForNull(requester);
    LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
    Producer<String> prod = () -> {
        JPanel panel = new JPanel(new BorderLayout());
        JScrollPane scroller = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        JTextArea textArea = new JTextArea(oldAnnotation, 8, 60);
        textArea.setEditable(true);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        scroller.setViewportView(textArea);
        scroller.getViewport().setPreferredSize(new Dimension(400, 200));
        panel.add(scroller, BorderLayout.CENTER);
        JOptionPane pane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
        final LWDialog dialog = new LWTitledOptionPaneDialog(lwParent, "Edit Annotation:", 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)) {
                throw UtilCancelException.CANCEL_GENERIC;
            } else {
                return textArea.getText();
            }
        } finally {
            dialog.dispose();
        }
    };
    return VCSwingFunction.execute(prod);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) LWDialog(org.vcell.client.logicalwindow.LWDialog) LWContainerHandle(org.vcell.client.logicalwindow.LWContainerHandle) Dimension(java.awt.Dimension) LWTitledOptionPaneDialog(org.vcell.client.logicalwindow.LWTitledOptionPaneDialog) JOptionPane(javax.swing.JOptionPane) BorderLayout(java.awt.BorderLayout)

Example 5 with LWDialog

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

Aggregations

LWContainerHandle (org.vcell.client.logicalwindow.LWContainerHandle)5 LWDialog (org.vcell.client.logicalwindow.LWDialog)5 JOptionPane (javax.swing.JOptionPane)4 JPanel (javax.swing.JPanel)4 LWTitledOptionPaneDialog (org.vcell.client.logicalwindow.LWTitledOptionPaneDialog)4 Doer (org.vcell.util.gui.VCSwingFunction.Doer)2 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 JCheckBox (javax.swing.JCheckBox)1 JScrollPane (javax.swing.JScrollPane)1 JTextArea (javax.swing.JTextArea)1 LWJDialogDecorator (org.vcell.client.logicalwindow.transition.LWJDialogDecorator)1