use of org.vcell.util.gui.VCSwingFunction.Doer 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.util.gui.VCSwingFunction.Doer in project vcell by virtualcell.
the class DialogUtils method showErrorDialog.
/**
* show error dialog in standard way. If modelInfo is not null user is prompted to allow sending of context information
* @param requester parent Component, may be null
* @param message message to display
* @param exception exception to dialog and possibility email to VCellSupport; may be null
* @param modelInfo information to include in email to VCellSupport; may be null
*/
public static void showErrorDialog(final Component requester, final String message, final Throwable exception, final ErrorContext errorContext) {
checkForNull(requester);
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
Doer doer = () -> {
String errMsg = message;
boolean sendErrorReport = false;
if (errMsg == null || errMsg.trim().length() == 0) {
errMsg = "Virtual Cell has encountered a problem. Please tell Virtual Cell about this problem to help improve Virtual Cell.";
if (exception != null) {
sendErrorReport = true;
}
}
if (exception instanceof ClassCastException || exception instanceof ArrayIndexOutOfBoundsException || exception instanceof NullPointerException || exception instanceof Error) {
sendErrorReport = true;
}
final boolean goingToEmail = sendErrorReport && VCellClientTest.getVCellClient() != null;
DialogMessagePanel dialogMessagePanel;
if (goingToEmail) {
dialogMessagePanel = MessagePanelFactory.createExtended(errMsg, errorContext);
} else {
dialogMessagePanel = MessagePanelFactory.createNonSending(errMsg);
}
Collection<String> suggestions = ExceptionInterpreter.instance().suggestions(message);
if (suggestions != null) {
SuggestionPanel sp = new SuggestionPanel();
sp.setSuggestedSolution(suggestions);
dialogMessagePanel.add(sp, BorderLayout.NORTH);
}
JOptionPane pane = new JOptionPane(dialogMessagePanel, JOptionPane.ERROR_MESSAGE, dialogMessagePanel.optionType());
JDialog dialog = new LWTitledOptionPaneDialog(lwParent, "Error", pane);
dialog.setResizable(true);
try {
dialog.setVisible(true);
if (goingToEmail) {
Object ro = pane.getValue();
Integer reply = BeanUtils.downcast(Integer.class, ro);
boolean userSaidYes = reply != null ? reply == JOptionPane.YES_OPTION : false;
if (userSaidYes) {
Throwable throwableToSend = exception;
String extra = dialogMessagePanel.getSupplemental();
extra = BeanUtils.PLAINTEXT_EMAIL_NEWLINE + (extra == null ? "" : extra) + collectRecordedUserEvents();
throwableToSend = new RuntimeException(extra, exception);
VCellClientTest.getVCellClient().getClientServerManager().sendErrorReport(throwableToSend);
}
}
} finally {
dialog.dispose();
}
};
VCSwingFunction.executeConsumeException(doer);
}
use of org.vcell.util.gui.VCSwingFunction.Doer in project vcell by virtualcell.
the class DialogUtils method showComponentCloseDialog.
/**
* 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 showComponentCloseDialog(final Component requester, final Component stayOnTopComponent, final String title) {
checkForNull(requester);
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
Doer doer = () -> {
JOptionPane inputDialog = new JOptionPane(stayOnTopComponent, JOptionPane.PLAIN_MESSAGE, 0, null, new Object[] { "Close" });
final JDialog d = new LWTitledOptionPaneDialog(lwParent, title, inputDialog);
d.setResizable(true);
try {
d.setVisible(true);
} finally {
d.dispose();
}
};
VCSwingFunction.executeAsRuntimeException(doer);
}
use of org.vcell.util.gui.VCSwingFunction.Doer in project vcell by virtualcell.
the class DialogUtils method showReportDialog.
/**
* 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 void showReportDialog(final Component requester, final String reportText) {
checkForNull(requester);
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
Doer doer = () -> {
JPanel panel = new JPanel(new BorderLayout());
JScrollPane scroller = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JTextArea textArea = new JTextArea(reportText);
scroller.setViewportView(textArea);
scroller.getViewport().setPreferredSize(new Dimension(600, 400));
panel.add(scroller, BorderLayout.CENTER);
JOptionPane pane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION);
final JDialog dialog = new LWTitledOptionPaneDialog(lwParent, "Complete Report", pane);
showOnce(dialog);
};
VCSwingFunction.executeAsRuntimeException(doer);
}
use of org.vcell.util.gui.VCSwingFunction.Doer 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