Add error pages, about: urls to Browser
This commit is contained in:
parent
8236b13c2a
commit
85ab7974cb
@ -341,9 +341,8 @@ public class Main extends JRibbonFrame {
|
|||||||
JRibbon ribbon = getRibbon();
|
JRibbon ribbon = getRibbon();
|
||||||
JRibbonBand coreband = new JRibbonBand("Core", null);
|
JRibbonBand coreband = new JRibbonBand("Core", null);
|
||||||
JRibbonBand appsband = new JRibbonBand("Apps", 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 collabband = new JRibbonBand("Team", null);
|
||||||
//JRibbonBand getpluginband = new JRibbonBand("Install", null);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadPlugins();
|
loadPlugins();
|
||||||
@ -385,12 +384,10 @@ public class Main extends JRibbonFrame {
|
|||||||
WebBrowser.WIKI_LOGO));
|
WebBrowser.WIKI_LOGO));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
forumbtn.addActionListener(new ActionListener() {
|
browserbtn.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
loadFrame(new WebBrowser("Community Forum",
|
loadFrame(new WebBrowser());
|
||||||
"http://forum.symatapp.com/",
|
|
||||||
WebBrowser.FORUM_LOGO));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
padsbtn.addActionListener(new ActionListener() {
|
padsbtn.addActionListener(new ActionListener() {
|
||||||
@ -416,8 +413,8 @@ public class Main extends JRibbonFrame {
|
|||||||
"Write quick notes on a virtual napkin."));
|
"Write quick notes on a virtual napkin."));
|
||||||
wikibtn.setActionRichTooltip(new RichTooltip("SyMAT Wiki",
|
wikibtn.setActionRichTooltip(new RichTooltip("SyMAT Wiki",
|
||||||
"View and edit online documentation and tutorials."));
|
"View and edit online documentation and tutorials."));
|
||||||
forumbtn.setActionRichTooltip(new RichTooltip("Support Forum",
|
browserbtn.setActionRichTooltip(new RichTooltip("Web Browser",
|
||||||
"Discuss and share with the SyMAT community."));
|
"Go online and browse the web."));
|
||||||
padsbtn.setActionRichTooltip(new RichTooltip("Code Pads",
|
padsbtn.setActionRichTooltip(new RichTooltip("Code Pads",
|
||||||
"Collaborate over the Internet on projects."));
|
"Collaborate over the Internet on projects."));
|
||||||
tasksbtn.setActionRichTooltip(new RichTooltip("Task List",
|
tasksbtn.setActionRichTooltip(new RichTooltip("Task List",
|
||||||
@ -428,12 +425,11 @@ public class Main extends JRibbonFrame {
|
|||||||
|
|
||||||
appsband.addCommandButton(graphbtn, RibbonElementPriority.MEDIUM);
|
appsband.addCommandButton(graphbtn, RibbonElementPriority.MEDIUM);
|
||||||
appsband.addCommandButton(notepadbtn, RibbonElementPriority.MEDIUM);
|
appsband.addCommandButton(notepadbtn, RibbonElementPriority.MEDIUM);
|
||||||
|
appsband.addCommandButton(tasksbtn, RibbonElementPriority.MEDIUM);
|
||||||
|
|
||||||
webband.addCommandButton(wikibtn, RibbonElementPriority.LOW);
|
webband.addCommandButton(wikibtn, RibbonElementPriority.LOW);
|
||||||
webband.addCommandButton(forumbtn, RibbonElementPriority.LOW);
|
webband.addCommandButton(browserbtn, RibbonElementPriority.LOW);
|
||||||
|
webband.addCommandButton(padsbtn, RibbonElementPriority.MEDIUM);
|
||||||
collabband.addCommandButton(padsbtn, RibbonElementPriority.MEDIUM);
|
|
||||||
collabband.addCommandButton(tasksbtn, RibbonElementPriority.MEDIUM);
|
|
||||||
|
|
||||||
coreband.setResizePolicies((List) Arrays.asList(
|
coreband.setResizePolicies((List) Arrays.asList(
|
||||||
new CoreRibbonResizePolicies.None(coreband.getControlPanel()),
|
new CoreRibbonResizePolicies.None(coreband.getControlPanel()),
|
||||||
@ -454,14 +450,14 @@ public class Main extends JRibbonFrame {
|
|||||||
// new CoreRibbonResizePolicies.None(appsband.getControlPanel()),
|
// new CoreRibbonResizePolicies.None(appsband.getControlPanel()),
|
||||||
// new IconRibbonBandResizePolicy(pluginband.getControlPanel())));
|
// new IconRibbonBandResizePolicy(pluginband.getControlPanel())));
|
||||||
|
|
||||||
RibbonTask hometask = new RibbonTask("Home", coreband, appsband);
|
RibbonTask hometask = new RibbonTask("Home", coreband, appsband, webband);
|
||||||
RibbonTask webtask = new RibbonTask("Tools", webband, collabband);
|
//RibbonTask webtask = new RibbonTask("Tools", webband, collabband);
|
||||||
RibbonTask plugintask = new RibbonTask("Plugins", pluginband);
|
RibbonTask plugintask = new RibbonTask("Plugins", pluginband);
|
||||||
|
|
||||||
loadRibbonMenu(null);
|
loadRibbonMenu(null);
|
||||||
|
|
||||||
ribbon.addTask(hometask);
|
ribbon.addTask(hometask);
|
||||||
ribbon.addTask(webtask);
|
//ribbon.addTask(webtask);
|
||||||
ribbon.addTask(plugintask);
|
ribbon.addTask(plugintask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1161,8 +1157,8 @@ public class Main extends JRibbonFrame {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static JCommandButton forumbtn
|
public static JCommandButton browserbtn
|
||||||
= new JCommandButton("Forum", getRibbonIcon("forum"));
|
= new JCommandButton("Web", getRibbonIcon("browser"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -190,27 +190,6 @@ public class WebBrowser extends javax.swing.JInternalFrame {
|
|||||||
loadURL("http://wiki.symatapp.com/");
|
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
|
* @param title
|
||||||
@ -274,14 +253,90 @@ public class WebBrowser extends javax.swing.JInternalFrame {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
public void loadURL(final String url) {
|
public void loadURL(final String url) {
|
||||||
Platform.runLater(new Runnable() {
|
if (url.startsWith("about:")) {
|
||||||
@Override
|
final String action = url.replace("about:", "");
|
||||||
public void run() {
|
Platform.runLater(new Runnable() {
|
||||||
webEngine.load(url);
|
@Override
|
||||||
resizeAll();
|
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;
|
||||||
}
|
}
|
||||||
});
|
return text;
|
||||||
urlBox.setText(url);
|
} 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>>>", error);
|
||||||
|
text = text.replaceAll("<<<DETAILS>>>", details);
|
||||||
|
return text;
|
||||||
|
} catch (IOException ex) {
|
||||||
|
return "Oh, no! Something bad happened:<br />"
|
||||||
|
+ error
|
||||||
|
+ "<br />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")) {
|
if (urlBox.getText().equals("about:home")) {
|
||||||
loadString(homepage());
|
loadString(homepage());
|
||||||
} else {
|
} else {
|
||||||
if (!urlBox.getText().startsWith("http")) {
|
if (!urlBox.getText().startsWith("http") && !urlBox.getText().startsWith("about:")) {
|
||||||
urlBox.setText("http://" + urlBox.getText());
|
urlBox.setText("http://" + urlBox.getText());
|
||||||
}
|
}
|
||||||
loadURL(urlBox.getText());
|
loadURL(urlBox.getText());
|
||||||
|
BIN
src/net/apocalypselabs/symat/images/browser.png
Normal file
BIN
src/net/apocalypselabs/symat/images/browser.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
90
src/net/apocalypselabs/symat/resources/errorpage.html
Normal file
90
src/net/apocalypselabs/symat/resources/errorpage.html
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
CODE LICENSE =====================
|
||||||
|
Copyright (c) 2015, Netsyms Technologies
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
4. You adhere to the Media License detailed below. If you do not, this license
|
||||||
|
is automatically revoked and you must purge all copies of the software you
|
||||||
|
possess, in source or binary form.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
MEDIA LICENSE ====================
|
||||||
|
All images and other graphical files (the "graphics") included with this
|
||||||
|
software are copyright (c) 2015 Netsyms Technologies. You may not distribute
|
||||||
|
the graphics or any program, source code repository, or other digital storage
|
||||||
|
media containing them without written permission from Netsyms Technologies.
|
||||||
|
This ban on distribution only applies to publicly available systems.
|
||||||
|
A password-protected network file share, USB drive, or other storage scheme that
|
||||||
|
cannot be easily accessed by the public is generally allowed. If in doubt,
|
||||||
|
contact Netsyms Technologies. If Netsyms Technologies allows or denies
|
||||||
|
you permission, that decision is considered final and binding.
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Error</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
background-color: #fff;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
text-align: center;
|
||||||
|
font-family: ubuntu, arial, sans-serif;
|
||||||
|
width: 80%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
background-color: #ffe55f;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="main">
|
||||||
|
<h1>Oh, no!</h1>
|
||||||
|
<h2>An error occurred:</h2>
|
||||||
|
<p><<<ERROR>>></p>
|
||||||
|
<p><i><<<DETAILS>>></i></p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -46,10 +46,15 @@ you permission, that decision is considered final and binding.
|
|||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SyMAT Homepage</title>
|
<title>SyMAT Browser</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<style>
|
<style>
|
||||||
|
html, body {
|
||||||
|
background-color: #0099cc;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-family: ubuntu, arial, sans-serif;
|
font-family: ubuntu, arial, sans-serif;
|
||||||
@ -57,25 +62,28 @@ you permission, that decision is considered final and binding.
|
|||||||
|
|
||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #000;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
color: #000;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:visited {
|
a:visited {
|
||||||
color: #000;
|
color: #fff;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<h1>SyMAT</h1>
|
<h1>Welcome to SyMAT!</h1>
|
||||||
<p><a href="http://symatapp.com">Home</a> |
|
<form action="https://duckduckgo.com/" method="GET">
|
||||||
<a href="http://wiki.symatapp.com/doku.php">Wiki</a> |
|
<input type="text" name="q" placeholder="Web Search" />
|
||||||
<a href="http://forum.symatapp.com">Forums</a></p>
|
<input type="submit" value="Search" />
|
||||||
|
</form>
|
||||||
|
<p><a href="http://wiki.symatapp.com/doku.php">SyMAT Wiki</a> | <a href="http://m.wolframalpha.com/">WolframAlpha</a> | <a href="http://apis.symatapp.com/changelog.php">Changelogs</a></p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user