diff --git a/lib/bsh-2.0b5.jar b/lib/bsh-2.0b5.jar
new file mode 100644
index 0000000..e326510
Binary files /dev/null and b/lib/bsh-2.0b5.jar differ
diff --git a/nbproject/project.properties b/nbproject/project.properties
index d83890d..1169d13 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -35,6 +35,7 @@ endorsed.classpath=
excludes=
file.reference.autocomplete-2.5.4.jar=lib/autocomplete-2.5.4.jar
file.reference.beautyeye_lnf.jar=lib/beautyeye_lnf.jar
+file.reference.bsh-2.0b5.jar=lib\\bsh-2.0b5.jar
file.reference.commons-codec-1.9.jar=lib/commons-codec-1.9.jar
file.reference.commons-logging-1.2.jar=lib/commons-logging-1.2.jar
file.reference.flamingo-6.3.jar=lib/flamingo-6.3.jar
@@ -90,7 +91,8 @@ javac.classpath=\
${file.reference.httpmime-4.5.jar}:\
${file.reference.jna-4.1.0.jar}:\
${file.reference.jna-platform-4.1.0.jar}:\
- ${file.reference.jython-standalone-2.7.0.jar}
+ ${file.reference.jython-standalone-2.7.0.jar}:\
+ ${file.reference.bsh-2.0b5.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/src/net/apocalypselabs/symat/CodeRunner.java b/src/net/apocalypselabs/symat/CodeRunner.java
index 87ff6af..bd1058d 100644
--- a/src/net/apocalypselabs/symat/CodeRunner.java
+++ b/src/net/apocalypselabs/symat/CodeRunner.java
@@ -92,7 +92,7 @@ public class CodeRunner {
}
public CodeRunner(int lang) {
- this(lang == 0 ? "js" : "py");
+ this(lang == 0 ? "js" : (lang == 2 ? "ja" : "py"));
}
public CodeRunner(String lang) {
@@ -137,6 +137,26 @@ public class CodeRunner {
initError(ex);
}
break;
+ case "java":
+ case "ja":
+ case "beanshell":
+ case "bsh":
+ scriptLang = "java";
+ se = new ScriptEngineManager().getEngineByName("java");
+ try {
+ // Add custom functions.
+ /*se.eval("importClass(net.apocalypselabs.symat.Functions);"
+ + "SyMAT_Functions = new net.apocalypselabs.symat.Functions();"
+ + "SyMAT_Functions.setLang('js');\n"
+ + getFunctions("js")
+ + loadToolkits());*/
+ // Allow engine access from scripts.
+ se.put("engine", se);
+ attachWriters();
+ } catch (Exception ex) {
+ initError(ex);
+ }
+ break;
default:
throw new UnsupportedOperationException("Script language " + lang + " not supported.");
}
@@ -298,17 +318,20 @@ public class CodeRunner {
private String getFunctions(String lang) {
String text = "";
- try {
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(
- CodeRunner.class
- .getResourceAsStream("functions." + lang)));
- String line;
- while ((line = reader.readLine()) != null) {
- text += line + "\n";
+ if (!lang.equals("java")) {
+ try {
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(
+ CodeRunner.class
+ .getResourceAsStream("functions." + lang)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ text += line + "\n";
+ }
+ } catch (Exception e) {
}
- } catch (Exception e) {
+ return text;
}
- return text;
+ return "";
}
}
diff --git a/src/net/apocalypselabs/symat/Editor.form b/src/net/apocalypselabs/symat/Editor.form
index 4781cb4..18ea93c 100644
--- a/src/net/apocalypselabs/symat/Editor.form
+++ b/src/net/apocalypselabs/symat/Editor.form
@@ -274,6 +274,17 @@
iTextPDF, Symja (core):
+iTextPDF, Symja (core), BeanShell:
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
diff --git a/src/net/apocalypselabs/symat/plugin/LoadPlugin.java b/src/net/apocalypselabs/symat/plugin/LoadPlugin.java
index 10dc3ab..264f4a1 100644
--- a/src/net/apocalypselabs/symat/plugin/LoadPlugin.java
+++ b/src/net/apocalypselabs/symat/plugin/LoadPlugin.java
@@ -62,9 +62,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InvalidClassException;
import java.io.ObjectInputStream;
import net.apocalypselabs.symat.CodeRunner;
-import net.apocalypselabs.symat.Debug;
import net.apocalypselabs.symat.Main;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.JCommandToggleButton;
@@ -79,9 +79,9 @@ import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
*/
public class LoadPlugin {
- private Plugin p = new Plugin();
+ private Plugin p;
- public LoadPlugin(File f) throws FileNotFoundException, IOException, ClassNotFoundException {
+ public LoadPlugin(File f) throws FileNotFoundException, IOException, ClassNotFoundException, InvalidClassException {
FileInputStream fin = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fin);
p = (Plugin) ois.readObject();
diff --git a/src/net/apocalypselabs/symat/plugin/Plugin.java b/src/net/apocalypselabs/symat/plugin/Plugin.java
index 40e838a..4660093 100644
--- a/src/net/apocalypselabs/symat/plugin/Plugin.java
+++ b/src/net/apocalypselabs/symat/plugin/Plugin.java
@@ -61,12 +61,13 @@ import javax.swing.ImageIcon;
/**
* Plugin container class.
*/
-public class Plugin implements Serializable {
+public class Plugin extends PluginParent implements Serializable {
private static final long serialVersionUID = 13371L;
public final int LANG_JS = 0;
public final int LANG_PY = 1;
+ public final int LANG_JAVA = 2;
private ImageIcon icon;
private String packageName = "";
diff --git a/src/net/apocalypselabs/symat/plugin/PluginParent.java b/src/net/apocalypselabs/symat/plugin/PluginParent.java
new file mode 100644
index 0000000..3c590ae
--- /dev/null
+++ b/src/net/apocalypselabs/symat/plugin/PluginParent.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2015, Netsyms Technologies
+ * All rights reserved.
+ *
+ *
+ * CODE LICENSE ==========
+ * 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 ("media") 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 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.
+ *
+ * You may only use the media for personal,
+ * non-commercial, non-educational use unless:
+ * 1, You have paid for the software and media via the SyMAT website,
+ * or 2, you are using it as part of the 15-day trial period.
+ * Other uses are prohibited without permission.
+ * If any part of this license is deemed unenforcable, the remainder
+ * of the license remains in full effect.
+ */
+package net.apocalypselabs.symat.plugin;
+
+import javax.swing.ImageIcon;
+
+/**
+ *
+ * @author Skylar
+ */
+public abstract class PluginParent {
+
+ public abstract String getVersion();
+
+ public abstract void setVersion(String v);
+
+ public abstract String getPackage();
+
+ public abstract void setPackage(String pkg);
+
+ public abstract String getAuthor();
+
+ public abstract void setAuthor(String s);
+
+ public abstract String getWebsite();
+
+ public abstract void setWebsite(String url);
+
+ public abstract String getOther();
+
+ public abstract void setOther(String o);
+
+ public abstract ImageIcon getIcon();
+
+ public abstract void setIcon(ImageIcon i);
+
+ public abstract String getScript();
+
+ public abstract void setScript(String s);
+
+ public abstract String getTitle();
+
+ public abstract void setTitle(String n);
+
+ public abstract String getDesc();
+
+ public abstract void setDesc(String d);
+
+ public abstract String getLongTitle();
+
+ public abstract void setLongTitle(String t);
+
+ public abstract int getLang();
+
+}