diff --git a/src/net/apocalypselabs/symat/Main.java b/src/net/apocalypselabs/symat/Main.java index 2f96919..fdf925a 100644 --- a/src/net/apocalypselabs/symat/Main.java +++ b/src/net/apocalypselabs/symat/Main.java @@ -341,9 +341,8 @@ public class Main extends JRibbonFrame { JRibbon ribbon = getRibbon(); JRibbonBand coreband = new JRibbonBand("Core", null); JRibbonBand appsband = new JRibbonBand("Apps", null); - JRibbonBand webband = new JRibbonBand("Community", null); + JRibbonBand webband = new JRibbonBand("Online", null); JRibbonBand collabband = new JRibbonBand("Team", null); - //JRibbonBand getpluginband = new JRibbonBand("Install", null); try { loadPlugins(); @@ -385,12 +384,10 @@ public class Main extends JRibbonFrame { WebBrowser.WIKI_LOGO)); } }); - forumbtn.addActionListener(new ActionListener() { + browserbtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - loadFrame(new WebBrowser("Community Forum", - "http://forum.symatapp.com/", - WebBrowser.FORUM_LOGO)); + loadFrame(new WebBrowser()); } }); padsbtn.addActionListener(new ActionListener() { @@ -416,8 +413,8 @@ public class Main extends JRibbonFrame { "Write quick notes on a virtual napkin.")); wikibtn.setActionRichTooltip(new RichTooltip("SyMAT Wiki", "View and edit online documentation and tutorials.")); - forumbtn.setActionRichTooltip(new RichTooltip("Support Forum", - "Discuss and share with the SyMAT community.")); + browserbtn.setActionRichTooltip(new RichTooltip("Web Browser", + "Go online and browse the web.")); padsbtn.setActionRichTooltip(new RichTooltip("Code Pads", "Collaborate over the Internet on projects.")); tasksbtn.setActionRichTooltip(new RichTooltip("Task List", @@ -428,12 +425,11 @@ public class Main extends JRibbonFrame { appsband.addCommandButton(graphbtn, RibbonElementPriority.MEDIUM); appsband.addCommandButton(notepadbtn, RibbonElementPriority.MEDIUM); + appsband.addCommandButton(tasksbtn, RibbonElementPriority.MEDIUM); webband.addCommandButton(wikibtn, RibbonElementPriority.LOW); - webband.addCommandButton(forumbtn, RibbonElementPriority.LOW); - - collabband.addCommandButton(padsbtn, RibbonElementPriority.MEDIUM); - collabband.addCommandButton(tasksbtn, RibbonElementPriority.MEDIUM); + webband.addCommandButton(browserbtn, RibbonElementPriority.LOW); + webband.addCommandButton(padsbtn, RibbonElementPriority.MEDIUM); coreband.setResizePolicies((List) Arrays.asList( new CoreRibbonResizePolicies.None(coreband.getControlPanel()), @@ -454,14 +450,14 @@ public class Main extends JRibbonFrame { // new CoreRibbonResizePolicies.None(appsband.getControlPanel()), // new IconRibbonBandResizePolicy(pluginband.getControlPanel()))); - RibbonTask hometask = new RibbonTask("Home", coreband, appsband); - RibbonTask webtask = new RibbonTask("Tools", webband, collabband); + RibbonTask hometask = new RibbonTask("Home", coreband, appsband, webband); + //RibbonTask webtask = new RibbonTask("Tools", webband, collabband); RibbonTask plugintask = new RibbonTask("Plugins", pluginband); loadRibbonMenu(null); ribbon.addTask(hometask); - ribbon.addTask(webtask); + //ribbon.addTask(webtask); ribbon.addTask(plugintask); } @@ -1161,8 +1157,8 @@ public class Main extends JRibbonFrame { /** * */ - public static JCommandButton forumbtn - = new JCommandButton("Forum", getRibbonIcon("forum")); + public static JCommandButton browserbtn + = new JCommandButton("Web", getRibbonIcon("browser")); /** * diff --git a/src/net/apocalypselabs/symat/WebBrowser.java b/src/net/apocalypselabs/symat/WebBrowser.java index 09d8fdb..abe6457 100644 --- a/src/net/apocalypselabs/symat/WebBrowser.java +++ b/src/net/apocalypselabs/symat/WebBrowser.java @@ -190,27 +190,6 @@ public class WebBrowser extends javax.swing.JInternalFrame { loadURL("http://wiki.symatapp.com/"); } - /** - * - * @return - */ - public String homepage() { - try { - String text = ""; - BufferedReader reader = new BufferedReader( - new InputStreamReader( - WebBrowser.class - .getResourceAsStream("resources/homepage.html"))); - String line; - while ((line = reader.readLine()) != null) { - text += line; - } - return text; - } catch (IOException ex) { - return "Error: " + ex.getMessage(); - } - } - /** * * @param title @@ -274,14 +253,90 @@ public class WebBrowser extends javax.swing.JInternalFrame { * @param url */ public void loadURL(final String url) { - Platform.runLater(new Runnable() { - @Override - public void run() { - webEngine.load(url); - resizeAll(); + if (url.startsWith("about:")) { + final String action = url.replace("about:", ""); + Platform.runLater(new Runnable() { + @Override + public void run() { + switch (action) { + case "home": + webEngine.loadContent(homepage()); + break; + case "blank": + webEngine.loadContent(""); + break; + case "new": + Main.loadFrame(new WebBrowser()); + break; + default: + webEngine.loadContent(errorpage("Invalid URL", "That isn't a valid address.")); + } + resizeAll(); + } + }); + urlBox.setText(url); + } else { + Platform.runLater(new Runnable() { + @Override + public void run() { + webEngine.load(url); + resizeAll(); + } + }); + urlBox.setText(url); + } + } + + /** + * Get the homepage/startpage HTML. + * + * @return + */ + public String homepage() { + try { + String text = ""; + BufferedReader reader = new BufferedReader( + new InputStreamReader( + WebBrowser.class + .getResourceAsStream("resources/homepage.html"))); + String line; + while ((line = reader.readLine()) != null) { + text += line; } - }); - urlBox.setText(url); + return text; + } catch (IOException ex) { + return errorpage("Error: " + ex.getMessage(), ex.toString()); + } + } + + /** + * Returns a webpage suitable for showing error messages. + * + * @param error Short error message + * @param details Error information + * @return HTML page content + */ + public String errorpage(String error, String details) { + try { + String text = ""; + BufferedReader reader = new BufferedReader( + new InputStreamReader( + WebBrowser.class + .getResourceAsStream("resources/errorpage.html"))); + String line; + while ((line = reader.readLine()) != null) { + text += line; + } + text = text.replaceAll("<<>>", error); + text = text.replaceAll("<<
>>", details); + return text; + } catch (IOException ex) { + return "Oh, no! Something bad happened:
" + + error + + "
Also, an error occured " + + "while displaying the error page: " + + ex.getMessage(); + } } /** @@ -437,7 +492,7 @@ public class WebBrowser extends javax.swing.JInternalFrame { if (urlBox.getText().equals("about:home")) { loadString(homepage()); } else { - if (!urlBox.getText().startsWith("http")) { + if (!urlBox.getText().startsWith("http") && !urlBox.getText().startsWith("about:")) { urlBox.setText("http://" + urlBox.getText()); } loadURL(urlBox.getText()); diff --git a/src/net/apocalypselabs/symat/images/browser.png b/src/net/apocalypselabs/symat/images/browser.png new file mode 100644 index 0000000..ee28b8f Binary files /dev/null and b/src/net/apocalypselabs/symat/images/browser.png differ diff --git a/src/net/apocalypselabs/symat/resources/errorpage.html b/src/net/apocalypselabs/symat/resources/errorpage.html new file mode 100644 index 0000000..d2a952f --- /dev/null +++ b/src/net/apocalypselabs/symat/resources/errorpage.html @@ -0,0 +1,90 @@ + + + + + Error + + + + + +
+

Oh, no!

+

An error occurred:

+

<<>>

+

<<

>>

+
+ + diff --git a/src/net/apocalypselabs/symat/resources/homepage.html b/src/net/apocalypselabs/symat/resources/homepage.html index d7a7971..995ad7b 100644 --- a/src/net/apocalypselabs/symat/resources/homepage.html +++ b/src/net/apocalypselabs/symat/resources/homepage.html @@ -46,10 +46,15 @@ you permission, that decision is considered final and binding. --> - SyMAT Homepage + SyMAT Browser
-

SyMAT

-

Home | - Wiki | - Forums

+

Welcome to SyMAT!

+
+ + +
+

SyMAT Wiki | WolframAlpha | Changelogs

+