diff --git a/src/net/apocalypselabs/symat/Help.java b/src/net/apocalypselabs/symat/Help.java index 184ea45..c7f1b0b 100644 --- a/src/net/apocalypselabs/symat/Help.java +++ b/src/net/apocalypselabs/symat/Help.java @@ -31,6 +31,7 @@ import java.awt.Color; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Calendar; +import javax.swing.SwingUtilities; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; @@ -95,56 +96,11 @@ public class Help extends javax.swing.JInternalFrame { /** * Load a help topic from the help package. - * @param name The name of the help file, without the ".html". + * + * @param topicName The name of the help file, without the ".html". */ - public void loadTopic(String name) { - if (name.equals("welcome")) { - String text = "About SyMAT" - + "" - + "

Welcome to SyMAT!

" - + "

SyMAT is a Java-based algebra and calculus system. " - + "Scripts and commands can be written in " - + "JavaScript or Python.

" - + "

This is SyMAT version " - + MainGUI.VERSION_NAME + " (" + (int) MainGUI.APP_CODE + ")." - + "

" - + "

SyMAT is copyright © " - + Calendar.getInstance().get(Calendar.YEAR) - + " Apocalypse Laboratories. Some rights reserved." - + "

" - + "

Internal help documentation is " - + "licensed under the Creative Commons " - + "Attribution-NonCommercial 4.0 International" - + " license (CC-BY-NC). " - + "You can use it in part or in whole " - + "for any purpose, excepting commercial, as long as " - + "you attribute Apocalypse Laboratories. See " - + "http://creativecommons.org/licenses/by-nc/4.0/" - + " for more information.

"; - topicBrowser.setText(text); - topicBrowser.setCaretPosition(0); - setTitle("Manual"); - } else { - try { - String text = ""; - BufferedReader reader = new BufferedReader( - new InputStreamReader( - CodeRunner.class - .getResourceAsStream("help/" + name + ".html"))); - String line; - while ((line = reader.readLine()) != null) { - text += line; - } - topicBrowser.setText(text); - topicBrowser.setCaretPosition(0); - setTitle("Manual (" + topicList.getSelectedValue().toString() + ")"); - } catch (Exception e) { - //JOptionPane.showInternalMessageDialog(MainGUI.mainPane, - //"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); - topicBrowser.setText("

Error:
Cannot get help topic \"" - + name + "\".
(" + e.getMessage() + ")

"); - } - } + public void loadTopic(String topicName) { + new LoadThread(topicName).start(); } /** @@ -244,6 +200,77 @@ public class Help extends javax.swing.JInternalFrame { loadTheme(); }//GEN-LAST:event_topicBrowserMouseClicked + private class LoadThread extends Thread { + + String name; + + public LoadThread(String topic) { + name = topic; + } + + @Override + public void run() { + setText("

Loading...

", "Manual"); + if (name.equals("welcome")) { + final String text = "About SyMAT" + + "" + + "

Welcome to SyMAT!

" + + "

SyMAT is a Java-based algebra and calculus system. " + + "Scripts and commands can be written in " + + "JavaScript or Python.

" + + "

This is SyMAT version " + + MainGUI.VERSION_NAME + " (" + (int) MainGUI.APP_CODE + ")." + + "

" + + "

SyMAT is copyright © " + + Calendar.getInstance().get(Calendar.YEAR) + + " Apocalypse Laboratories. Some rights reserved." + + "

" + + "

Internal help documentation is " + + "licensed under the Creative Commons " + + "Attribution-NonCommercial 4.0 International" + + " license (CC-BY-NC). " + + "You can use it in part or in whole " + + "for any purpose, excepting commercial, as long as " + + "you attribute Apocalypse Laboratories. See " + + "http://creativecommons.org/licenses/by-nc/4.0/" + + " for more information.

"; + setText(text, "Manual"); + } else { + try { + String text = ""; + BufferedReader reader = new BufferedReader( + new InputStreamReader( + CodeRunner.class + .getResourceAsStream("help/" + name + ".html"))); + String line; + while ((line = reader.readLine()) != null) { + text += line; + } + setText(text, "Manual (" + topicList.getSelectedValue().toString() + ")"); + } catch (Exception e) { + //JOptionPane.showInternalMessageDialog(MainGUI.mainPane, + //"Error: Cannot load help topic "+name+".\n\n"+e.getMessage()); + setText("

Error:
Cannot get help topic \"" + + name + "\".
(" + e.getMessage() + ")

", "Manual"); + } + } + } + + private void setText(String string, String wintitle) { + final String text = string; + final String title = wintitle; + SwingUtilities.invokeLater( + new Runnable() { + @Override + public void run() { + topicBrowser.setText(text); + topicBrowser.setCaretPosition(0); + setTitle(title); + } + }); + } + } + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2;