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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations