From 552a3162a5bdfefb404405e718b54b5b8b57d31a Mon Sep 17 00:00:00 2001 From: skylarmt Date: Wed, 25 Mar 2015 14:48:21 -0600 Subject: [PATCH] Basic plugin creater and loader complete --- src/net/apocalypselabs/symat/CodeRunner.java | 4 + src/net/apocalypselabs/symat/Main.java | 4 +- .../apocalypselabs/symat/PackagePlugin.form | 391 ++++++++++++++++ .../apocalypselabs/symat/PackagePlugin.java | 417 ++++++++++++++++++ .../symat/plugin/LoadPlugin.java | 79 ++++ .../apocalypselabs/symat/plugin/Plugin.java | 25 +- 6 files changed, 914 insertions(+), 6 deletions(-) create mode 100644 src/net/apocalypselabs/symat/PackagePlugin.form create mode 100644 src/net/apocalypselabs/symat/PackagePlugin.java create mode 100644 src/net/apocalypselabs/symat/plugin/LoadPlugin.java diff --git a/src/net/apocalypselabs/symat/CodeRunner.java b/src/net/apocalypselabs/symat/CodeRunner.java index de5c852..c5a6f02 100644 --- a/src/net/apocalypselabs/symat/CodeRunner.java +++ b/src/net/apocalypselabs/symat/CodeRunner.java @@ -71,6 +71,10 @@ public class CodeRunner { this("javascript"); } + public CodeRunner(int lang) { + this(lang == 0 ? "js" : "py"); + } + public CodeRunner(String lang) { scriptLang = lang; switch (lang) { diff --git a/src/net/apocalypselabs/symat/Main.java b/src/net/apocalypselabs/symat/Main.java index b6732cf..9256220 100644 --- a/src/net/apocalypselabs/symat/Main.java +++ b/src/net/apocalypselabs/symat/Main.java @@ -98,7 +98,7 @@ public class Main extends JRibbonFrame { /** * Version name, as it should be displayed. */ - public static final String VERSION_NAME = "1.6"; + public static final String VERSION_NAME = "1.7"; /** * The word "SyMAT". @@ -111,7 +111,7 @@ public class Main extends JRibbonFrame { /** * Version number, for updates and //needs in scripts */ - public static final double APP_CODE = 18; + public static final double APP_CODE = 19; /** * Base URL for building API calls */ diff --git a/src/net/apocalypselabs/symat/PackagePlugin.form b/src/net/apocalypselabs/symat/PackagePlugin.form new file mode 100644 index 0000000..336c456 --- /dev/null +++ b/src/net/apocalypselabs/symat/PackagePlugin.form @@ -0,0 +1,391 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/PackagePlugin.java b/src/net/apocalypselabs/symat/PackagePlugin.java new file mode 100644 index 0000000..d6fcb5f --- /dev/null +++ b/src/net/apocalypselabs/symat/PackagePlugin.java @@ -0,0 +1,417 @@ +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * 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 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * 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 Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat; + +import java.awt.image.BufferedImage; +import java.io.FileOutputStream; +import java.io.ObjectOutputStream; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileNameExtensionFilter; +import net.apocalypselabs.symat.plugin.Plugin; + +/** + * + * @author Skylar + */ +public class PackagePlugin extends javax.swing.JInternalFrame { + + private JFileChooser fc = new JFileChooser(); + private ImageIcon icon; + + /** + * Creates new form PackagePlugin + */ + public PackagePlugin() { + fc.setFileFilter(new FileNameExtensionFilter( + "Image (jpeg,jpg,gif,png,bmp)", + "jpeg", "jpg", "gif", "png", "bmp")); + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanel1 = new javax.swing.JPanel(); + pluginName = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + packageID = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + website = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + author = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + version = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + shortDesc = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + longDesc = new javax.swing.JTextArea(); + jPanel4 = new javax.swing.JPanel(); + jLabel9 = new javax.swing.JLabel(); + iconPreview = new javax.swing.JLabel(); + openIconBtn = new javax.swing.JButton(); + jLabel10 = new javax.swing.JLabel(); + jPanel2 = new javax.swing.JPanel(); + jLabel8 = new javax.swing.JLabel(); + langSelect = new javax.swing.JComboBox(); + jScrollPane2 = new javax.swing.JScrollPane(); + codeBox = new javax.swing.JTextArea(); + jPanel3 = new javax.swing.JPanel(); + savePlugin = new javax.swing.JButton(); + + setClosable(true); + setIconifiable(true); + setMaximizable(true); + setResizable(true); + setTitle("Package Plugin"); + + jLabel1.setText("Plugin Name:"); + + jLabel2.setText("Package ID:"); + + jLabel3.setText("Website:"); + + jLabel4.setText("Author:"); + + jLabel5.setText("Version:"); + + jLabel6.setText("Description:"); + + jLabel7.setText("Long Description:"); + + longDesc.setColumns(20); + longDesc.setRows(5); + jScrollPane1.setViewportView(longDesc); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel7) + .addComponent(jScrollPane1) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(jLabel2) + .addComponent(jLabel3) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(website) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(version, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(pluginName, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(packageID) + .addComponent(shortDesc)))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(pluginName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4) + .addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(packageID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(website, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5) + .addComponent(version, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6) + .addComponent(shortDesc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel7) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE) + .addContainerGap()) + ); + + jTabbedPane1.addTab("Metadata", jPanel1); + + jLabel9.setText("Icon:"); + + iconPreview.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + + openIconBtn.setText("Open Icon..."); + openIconBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + openIconBtnActionPerformed(evt); + } + }); + + jLabel10.setText("Recommended icon size is 100x76."); + jLabel10.setVerticalAlignment(javax.swing.SwingConstants.TOP); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(openIconBtn)) + .addComponent(jLabel9)) + .addGap(0, 194, Short.MAX_VALUE))) + .addContainerGap()) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel9) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(openIconBtn) + .addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE) + .addContainerGap()) + ); + + jTabbedPane1.addTab("Icon", jPanel4); + + jLabel8.setText("Language:"); + + langSelect.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "JavaScript", "Python" })); + + codeBox.setColumns(20); + codeBox.setRows(5); + jScrollPane2.setViewportView(codeBox); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel8) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(langSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8) + .addComponent(langSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE) + .addContainerGap()) + ); + + jTabbedPane1.addTab("Code", jPanel2); + + savePlugin.setText("Save Plugin"); + savePlugin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + savePluginActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(28, 28, 28) + .addComponent(savePlugin, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(235, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(27, 27, 27) + .addComponent(savePlugin, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(131, Short.MAX_VALUE)) + ); + + jTabbedPane1.addTab("Publish", jPanel3); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTabbedPane1) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTabbedPane1) + ); + + pack(); + }// //GEN-END:initComponents + + private void savePluginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savePluginActionPerformed + Plugin p = new Plugin(); + try { + p.setTitle(pluginName.getText()); + p.setAuthor(author.getText()); + p.setLongTitle(shortDesc.getText()); + p.setDesc(longDesc.getText()); + p.setPackage(packageID.getText()); + p.setVersion(version.getText()); + p.setWebsite(website.getText()); + p.setLang(langSelect.getSelectedIndex()); + p.setScript(codeBox.getText()); + p.setIcon(icon); + } catch (Exception ex) { + Debug.stacktrace(ex); + JOptionPane.showInternalMessageDialog(this, + "Error. Please check your data.\n\n" + ex.getMessage()); + return; + } + fc.setFileFilter(new FileNameExtensionFilter( + "Plugin (sypl)", + "sypl")); + int result = fc.showDialog(this, "Publish"); + if (result == JFileChooser.APPROVE_OPTION) { + try { + FileOutputStream fout = new FileOutputStream(fc.getSelectedFile()); + try (ObjectOutputStream oos = new ObjectOutputStream(fout)) { + oos.writeObject(p); + oos.close(); + } + } catch (Exception ex) { + Debug.stacktrace(ex); + JOptionPane.showInternalMessageDialog(this, + "Error saving file.\n\n" + ex.getMessage()); + } + } + }//GEN-LAST:event_savePluginActionPerformed + + private void openIconBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openIconBtnActionPerformed + fc.setFileFilter(new FileNameExtensionFilter( + "Image (jpeg,jpg,gif,png,bmp)", + "jpeg", "jpg", "gif", "png", "bmp")); + int result = fc.showDialog(this, "Select Icon"); + if (result == JFileChooser.APPROVE_OPTION) { + try { + icon = new ImageIcon(ImageIO.read(fc.getSelectedFile())); + iconPreview.setIcon(icon); + } catch (Exception ex) { + Debug.stacktrace(ex); + JOptionPane.showInternalMessageDialog(this, + "Error opening image.\n\n" + ex.getMessage()); + } + } + }//GEN-LAST:event_openIconBtnActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField author; + private javax.swing.JTextArea codeBox; + private javax.swing.JLabel iconPreview; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTabbedPane jTabbedPane1; + private javax.swing.JComboBox langSelect; + private javax.swing.JTextArea longDesc; + private javax.swing.JButton openIconBtn; + private javax.swing.JTextField packageID; + private javax.swing.JTextField pluginName; + private javax.swing.JButton savePlugin; + private javax.swing.JTextField shortDesc; + private javax.swing.JTextField version; + private javax.swing.JTextField website; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/plugin/LoadPlugin.java b/src/net/apocalypselabs/symat/plugin/LoadPlugin.java new file mode 100644 index 0000000..d859577 --- /dev/null +++ b/src/net/apocalypselabs/symat/plugin/LoadPlugin.java @@ -0,0 +1,79 @@ +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * 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 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * 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 Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat.plugin; + +import java.io.File; +import java.io.FileInputStream; +import java.io.ObjectInputStream; +import net.apocalypselabs.symat.CodeRunner; +import net.apocalypselabs.symat.Debug; + +/** + * + * @author Skylar + */ +public class LoadPlugin { + + private Plugin p = new Plugin(); + + public LoadPlugin(String path) { + try { + File f = new File(path); + FileInputStream fin = new FileInputStream(f); + ObjectInputStream ois = new ObjectInputStream(fin); + p = (Plugin) ois.readObject(); + ois.close(); + } catch (Exception ex) { + Debug.stacktrace(ex); + } + } + + public void exec() { + CodeRunner cr = new CodeRunner(p.getLang()); + cr.evalString(p.getScript()); + } + +} diff --git a/src/net/apocalypselabs/symat/plugin/Plugin.java b/src/net/apocalypselabs/symat/plugin/Plugin.java index b84eb8f..1a8606b 100644 --- a/src/net/apocalypselabs/symat/plugin/Plugin.java +++ b/src/net/apocalypselabs/symat/plugin/Plugin.java @@ -4,8 +4,8 @@ */ package net.apocalypselabs.symat.plugin; -import java.awt.image.BufferedImage; import java.io.Serializable; +import javax.swing.ImageIcon; /** * Plugin container class. @@ -15,7 +15,7 @@ public class Plugin implements Serializable { public final int LANG_JS = 0; public final int LANG_PY = 1; - private BufferedImage icon; + private ImageIcon icon; private String packageName = ""; private String script = ""; private String title = ""; @@ -24,12 +24,29 @@ public class Plugin implements Serializable { private String author = ""; private String website = ""; private String other = ""; + private String version = ""; private int lang = LANG_JS; public Plugin() { } + /** + * Get plugin version. + * @return + */ + public String getVersion() { + return version; + } + + /** + * Set plugin version. + * @param v + */ + public void setVersion(String v) { + version = v; + } + /** * Get the plugin package name. * @return @@ -98,7 +115,7 @@ public class Plugin implements Serializable { * Get the plugin icon. * @return */ - public BufferedImage getIcon() { + public ImageIcon getIcon() { return icon; } @@ -106,7 +123,7 @@ public class Plugin implements Serializable { * Set the plugin icon. * @param i */ - public void setIcon(BufferedImage i) { + public void setIcon(ImageIcon i) { icon = i; }