branch develop-2.x updated (a7b4c9a -> 3181dfa)
This is an automated email from the git hooks/post-receive script. New change to branch develop-2.x in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git from a7b4c9a move to 2.38-SNAPSHOT new 3181dfa fixes #4123: Use JTextPane to display HTML in dialog box The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 3181dfa9f4e01edb446b6d3dece6cd0dc397cf82 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Tue Jan 3 18:11:45 2017 +0100 fixes #4123: Use JTextPane to display HTML in dialog box Summary of changes: .../swing/util/ApplicationErrorHelper.java | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop-2.x in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit 3181dfa9f4e01edb446b6d3dece6cd0dc397cf82 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Tue Jan 3 18:11:45 2017 +0100 fixes #4123: Use JTextPane to display HTML in dialog box --- .../swing/util/ApplicationErrorHelper.java | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java index 7b9d4fc..06c6e94 100644 --- a/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java +++ b/jaxx-application-swing/src/main/java/org/nuiton/jaxx/application/swing/util/ApplicationErrorHelper.java @@ -22,6 +22,8 @@ package org.nuiton.jaxx.application.swing.util; * #L% */ +import java.awt.Component; +import java.awt.Dimension; import org.jdesktop.swingx.JXErrorPane; import org.jdesktop.swingx.error.ErrorInfo; import org.jdesktop.swingx.error.ErrorReporter; @@ -31,6 +33,9 @@ import org.nuiton.jaxx.application.swing.ApplicationUIContext; import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import org.apache.commons.lang3.StringUtils; import static org.nuiton.i18n.I18n.t; @@ -49,6 +54,32 @@ public class ApplicationErrorHelper implements ErrorReporter { } /** + * Create JPane with scroll to prevent windows bigger than screen resolution + * + * @param html + * @return + */ + protected Component createHTML(String html) { + //Create a text pane. + JTextPane textPane = new JTextPane(); + textPane.setContentType("text/html"); + textPane.setEditable(false); + + JScrollPane paneScrollPane = new JScrollPane(textPane); + paneScrollPane.setVerticalScrollBarPolicy( + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + paneScrollPane.setPreferredSize(new Dimension(700, 500)); + paneScrollPane.setMinimumSize(new Dimension(100, 100)); + + if (!StringUtils.startsWith(html, "<html>")) { + html = "<html><body>" + StringUtils.replace(html, "\n", "<br/>") + "</body></html>"; + } + + textPane.setText(html); + return paneScrollPane; + } + + /** * Display a user friendly error frame. * * @param message message for user @@ -57,15 +88,15 @@ public class ApplicationErrorHelper implements ErrorReporter { public void showErrorDialog(String message, Throwable cause) { if (cause == null) { - JOptionPane.showMessageDialog(context.getMainUI(), "<html><body>" + message + "</body></html>", + JOptionPane.showMessageDialog(context.getMainUI(), createHTML(message), t("jaxx.application.error.ui.business.error"), JOptionPane.ERROR_MESSAGE); } else if (cause instanceof ApplicationBusinessException) { - JOptionPane.showMessageDialog(context.getMainUI(), "<html><body>" + cause.getMessage() + "</body></html>", + JOptionPane.showMessageDialog(context.getMainUI(), createHTML(cause.getMessage()), t("jaxx.application.error.ui.business.error"), JOptionPane.ERROR_MESSAGE); } else if (cause instanceof ImportRuntimeException) { - JOptionPane.showMessageDialog(context.getMainUI(), cause.getMessage(), + JOptionPane.showMessageDialog(context.getMainUI(), createHTML(cause.getMessage()), t("jaxx.application.error.ui.business.error"), JOptionPane.ERROR_MESSAGE); } else { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm