From: Ben Soares Date: Tue, 12 Sep 2023 11:32:00 +0000 (+0100) Subject: JAL-4262 Allow HTML in the dialog box for link to CLI documentation X-Git-Tag: Release_2_11_4_0~174^2~25 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=29bb043dfab1b0bdc1efca22f2e5e3d3e8549368;p=jalview.git JAL-4262 Allow HTML in the dialog box for link to CLI documentation --- diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 2c07296..a05c995 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -2061,13 +2061,13 @@ public class Jalview { String warning = MessageManager .getString("warning.using_old_command_line_arguments"); - String url = "https://www.jalview.org/help/html/features/commandline.html"; + String url = "https://www.jalview.org/help/html/features/commandline.html"; if (Desktop.instance != null) { String cont = MessageManager.getString("label.continue"); Desktop.instance.nonBlockingDialog(32, 2, title, warning, url, cont, - JvOptionPane.WARNING_MESSAGE, false, false); + JvOptionPane.WARNING_MESSAGE, false, true, false); } } if (j.getCommands() != null && j.getCommands().getErrors().size() > 0) @@ -2087,7 +2087,7 @@ public class Jalview Math.max(message.length(), Math.min(60, shortest)), Math.min(errors.size(), 20), title, message, j.getCommands().errorsToString(), ok, - JvOptionPane.WARNING_MESSAGE, true, true); + JvOptionPane.WARNING_MESSAGE, true, false, true); } } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index ee24c25..e785431 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -95,6 +95,7 @@ import javax.swing.JProgressBar; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.JTextPane; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; @@ -102,6 +103,7 @@ import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent.EventType; import javax.swing.event.InternalFrameAdapter; import javax.swing.event.InternalFrameEvent; +import javax.swing.text.JTextComponent; import org.stackoverflowusers.file.WindowsShortcut; @@ -3746,12 +3748,12 @@ public class Desktop extends jalview.jbgui.GDesktop int type, boolean scrollable, boolean modal) { nonBlockingDialog(32, 2, title, message, null, button, type, scrollable, - modal); + false, modal); } public void nonBlockingDialog(int width, int height, String title, String message, String boxtext, String button, int type, - boolean scrollable, boolean modal) + boolean scrollable, boolean html, boolean modal) { if (type < 0) { @@ -3759,15 +3761,31 @@ public class Desktop extends jalview.jbgui.GDesktop } JLabel jl = new JLabel(message); - JTextArea jta = new JTextArea(height, width); - // jta.setLineWrap(true); - jta.setEditable(false); - jta.setWrapStyleWord(true); - jta.setAutoscrolls(true); - jta.setText(boxtext); + JTextComponent jtc = null; + if (html) + { + JTextPane jtp = new JTextPane(); + jtp.setContentType("text/html"); + jtp.setEditable(false); + jtp.setAutoscrolls(true); + jtp.setText(boxtext); + + jtc = jtp; + } + else + { + JTextArea jta = new JTextArea(height, width); + // jta.setLineWrap(true); + jta.setEditable(false); + jta.setWrapStyleWord(true); + jta.setAutoscrolls(true); + jta.setText(boxtext); + + jtc = jta; + } JScrollPane jsp = scrollable - ? new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + ? new JScrollPane(jtc, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) : null; @@ -3790,8 +3808,8 @@ public class Desktop extends jalview.jbgui.GDesktop } else { - jta.setAlignmentX(Component.LEFT_ALIGNMENT); - jp.add(jta); + jtc.setAlignmentX(Component.LEFT_ALIGNMENT); + jp.add(jtc); } }