Functional plugin system complete

master
skylarmt 9 years ago
parent 552a3162a5
commit 98b147dfea

@ -90,17 +90,33 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveAsMenuActionPerformed"/>
</Events> </Events>
</MenuItem> </MenuItem>
<Menu class="javax.swing.JMenu" name="jMenu1">
<Properties>
<Property name="text" type="java.lang.String" value="Publish"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="exportMenu"> <MenuItem class="javax.swing.JMenuItem" name="exportMenu">
<Properties> <Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor"> <Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+E"/> <KeyStroke key="Ctrl+E"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Export..."/> <Property name="text" type="java.lang.String" value="Export Code"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportMenuActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportMenuActionPerformed"/>
</Events> </Events>
</MenuItem> </MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="packPluginMenu">
<Properties>
<Property name="text" type="java.lang.String" value="Package Plugin..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="packPluginMenuActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<MenuItem class="javax.swing.JMenuItem" name="shareMenu"> <MenuItem class="javax.swing.JMenuItem" name="shareMenu">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Share..."/> <Property name="text" type="java.lang.String" value="Share..."/>

@ -90,14 +90,10 @@ public class Editor extends javax.swing.JInternalFrame {
public Editor(boolean python) { public Editor(boolean python) {
initComponents(); initComponents();
FileFilter filter = new FileNameExtensionFilter("SyMAT JavaScript (.syjs)", "syjs"); FileFilter filter = new FileNameExtensionFilter("JavaScript (syjs, js)", "syjs", "js");
fc.setFileFilter(filter); fc.setFileFilter(filter);
fc.addChoosableFileFilter(filter); fc.addChoosableFileFilter(filter);
filter = new FileNameExtensionFilter("SyMAT Python (.sypy)", "sypy"); filter = new FileNameExtensionFilter("Python (sypy, py)", "sypy", "py");
fc.addChoosableFileFilter(filter);
filter = new FileNameExtensionFilter("JavaScript file (.js)", "js");
fc.addChoosableFileFilter(filter);
filter = new FileNameExtensionFilter("Python script (.py)", "py");
fc.addChoosableFileFilter(filter); fc.addChoosableFileFilter(filter);
int font_size = 12; int font_size = 12;
@ -183,6 +179,7 @@ public class Editor extends javax.swing.JInternalFrame {
/** /**
* Show open dialog. * Show open dialog.
*
* @param openfile Nothing to see here, move along. * @param openfile Nothing to see here, move along.
*/ */
public Editor(int openfile) { public Editor(int openfile) {
@ -236,7 +233,9 @@ public class Editor extends javax.swing.JInternalFrame {
sampleGraph = new javax.swing.JMenuItem(); sampleGraph = new javax.swing.JMenuItem();
saveMenu = new javax.swing.JMenuItem(); saveMenu = new javax.swing.JMenuItem();
saveAsMenu = new javax.swing.JMenuItem(); saveAsMenu = new javax.swing.JMenuItem();
jMenu1 = new javax.swing.JMenu();
exportMenu = new javax.swing.JMenuItem(); exportMenu = new javax.swing.JMenuItem();
packPluginMenu = new javax.swing.JMenuItem();
shareMenu = new javax.swing.JMenuItem(); shareMenu = new javax.swing.JMenuItem();
shareAsMenu = new javax.swing.JMenuItem(); shareAsMenu = new javax.swing.JMenuItem();
editMenu = new javax.swing.JMenu(); editMenu = new javax.swing.JMenu();
@ -385,14 +384,27 @@ public class Editor extends javax.swing.JInternalFrame {
}); });
fileMenu.add(saveAsMenu); fileMenu.add(saveAsMenu);
jMenu1.setText("Publish");
jMenu1.setToolTipText("");
exportMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK)); exportMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
exportMenu.setText("Export..."); exportMenu.setText("Export Code");
exportMenu.addActionListener(new java.awt.event.ActionListener() { exportMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
exportMenuActionPerformed(evt); exportMenuActionPerformed(evt);
} }
}); });
fileMenu.add(exportMenu); jMenu1.add(exportMenu);
packPluginMenu.setText("Package Plugin...");
packPluginMenu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
packPluginMenuActionPerformed(evt);
}
});
jMenu1.add(packPluginMenu);
fileMenu.add(jMenu1);
shareMenu.setText("Share..."); shareMenu.setText("Share...");
shareMenu.addActionListener(new java.awt.event.ActionListener() { shareMenu.addActionListener(new java.awt.event.ActionListener() {
@ -759,10 +771,7 @@ public class Editor extends javax.swing.JInternalFrame {
} }
private void exportMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuActionPerformed private void exportMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuActionPerformed
String lang = "js"; String lang = pythonOption.isSelected() ? "python" : "js";
if (pythonOption.isSelected()) {
lang = "python";
}
Main.loadFrame(new CodeExport(codeBox.getText(), lang)); Main.loadFrame(new CodeExport(codeBox.getText(), lang));
}//GEN-LAST:event_exportMenuActionPerformed }//GEN-LAST:event_exportMenuActionPerformed
@ -833,6 +842,12 @@ public class Editor extends javax.swing.JInternalFrame {
} }
}//GEN-LAST:event_shareAsMenuActionPerformed }//GEN-LAST:event_shareAsMenuActionPerformed
private void packPluginMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_packPluginMenuActionPerformed
Main.loadFrame(new PackagePlugin(codeBox.getText(),
javascriptOption.isSelected() ? 0 : 1
));
}//GEN-LAST:event_packPluginMenuActionPerformed
private void createShared(String id) { private void createShared(String id) {
try { try {
String padid = Pads.genPad(id, codeBox.getText()); String padid = Pads.genPad(id, codeBox.getText());
@ -912,6 +927,7 @@ public class Editor extends javax.swing.JInternalFrame {
private javax.swing.JMenuItem exportMenu; private javax.swing.JMenuItem exportMenu;
private javax.swing.JMenu fileMenu; private javax.swing.JMenu fileMenu;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4; private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuBar jMenuBar1;
@ -927,6 +943,7 @@ public class Editor extends javax.swing.JInternalFrame {
private javax.swing.JMenu openSampleBtn; private javax.swing.JMenu openSampleBtn;
private javax.swing.JTextArea outputBox; private javax.swing.JTextArea outputBox;
private javax.swing.JPanel outputPanel; private javax.swing.JPanel outputPanel;
private javax.swing.JMenuItem packPluginMenu;
private javax.swing.JMenuItem pasteBtn; private javax.swing.JMenuItem pasteBtn;
private javax.swing.JRadioButtonMenuItem pythonOption; private javax.swing.JRadioButtonMenuItem pythonOption;
private javax.swing.JMenuItem redoBtn; private javax.swing.JMenuItem redoBtn;

@ -58,6 +58,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -77,6 +78,7 @@ import javax.swing.ListModel;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.filechooser.FileNameExtensionFilter;
import net.apocalypselabs.symat.plugin.LoadPlugin;
import org.pushingpixels.flamingo.api.ribbon.*; import org.pushingpixels.flamingo.api.ribbon.*;
import org.pushingpixels.flamingo.api.ribbon.resize.*; import org.pushingpixels.flamingo.api.ribbon.resize.*;
import org.pushingpixels.flamingo.api.common.*; import org.pushingpixels.flamingo.api.common.*;
@ -145,6 +147,8 @@ public class Main extends JRibbonFrame {
public static Main maingui; public static Main maingui;
JRibbonBand pluginband = new JRibbonBand("Plugins", null);
/** /**
* Creates the main app window and does some quick things that aren't * Creates the main app window and does some quick things that aren't
* threaded in SplashScreen. * threaded in SplashScreen.
@ -265,6 +269,26 @@ public class Main extends JRibbonFrame {
} }
} }
/**
* Load plugins from disk.
*/
public void loadPlugins() {
File dir = new File(System.getProperty("user.home") + "\\.symat\\plugins");
dir.mkdirs();
File[] files = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".sypl");
}
});
for (File pl : files) {
pluginband.addCommandButton(
(new LoadPlugin(pl)).getRibbonBtn(),
RibbonElementPriority.MEDIUM);
}
}
/** /**
* Load the ribbon in all its glory. * Load the ribbon in all its glory.
*/ */
@ -277,6 +301,7 @@ public class Main extends JRibbonFrame {
JRibbonBand appsband = new JRibbonBand("Apps", null); JRibbonBand appsband = new JRibbonBand("Apps", null);
JRibbonBand webband = new JRibbonBand("Community", null); JRibbonBand webband = new JRibbonBand("Community", null);
JRibbonBand collabband = new JRibbonBand("Team", null); JRibbonBand collabband = new JRibbonBand("Team", null);
loadPlugins();
shellbtn.addActionListener(new ActionListener() { shellbtn.addActionListener(new ActionListener() {
@Override @Override
@ -372,14 +397,19 @@ public class Main extends JRibbonFrame {
collabband.setResizePolicies((List) Arrays.asList( collabband.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.None(appsband.getControlPanel()), new CoreRibbonResizePolicies.None(appsband.getControlPanel()),
new IconRibbonBandResizePolicy(appsband.getControlPanel()))); new IconRibbonBandResizePolicy(appsband.getControlPanel())));
pluginband.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.None(appsband.getControlPanel()),
new IconRibbonBandResizePolicy(appsband.getControlPanel())));
RibbonTask hometask = new RibbonTask("Home", coreband, appsband); RibbonTask hometask = new RibbonTask("Home", coreband, appsband);
RibbonTask webtask = new RibbonTask("Tools", webband, collabband); RibbonTask webtask = new RibbonTask("Tools", webband, collabband);
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);
} }
public static ResizableIcon getRibbonIcon(String name) { public static ResizableIcon getRibbonIcon(String name) {
@ -505,8 +535,8 @@ public class Main extends JRibbonFrame {
= new FileNameExtensionFilter("SyMAT File" = new FileNameExtensionFilter("SyMAT File"
+ "(syjs, sypy, js, py, sytt)", + "(syjs, sypy, js, py, sytt)",
"syjs", "sypy", "js", "py", "sytt"); "syjs", "sypy", "js", "py", "sytt");
FileFilter tasklist = FileFilter tasklist
new FileNameExtensionFilter("Task List (sytt)", = new FileNameExtensionFilter("Task List (sytt)",
"sytt"); "sytt");
fc.setFileFilter(all); fc.setFileFilter(all);
fc.addChoosableFileFilter(script); fc.addChoosableFileFilter(script);

@ -4,8 +4,6 @@
<Properties> <Properties>
<Property name="closable" type="boolean" value="true"/> <Property name="closable" type="boolean" value="true"/>
<Property name="iconifiable" type="boolean" value="true"/> <Property name="iconifiable" type="boolean" value="true"/>
<Property name="maximizable" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="true"/>
<Property name="title" type="java.lang.String" value="Package Plugin"/> <Property name="title" type="java.lang.String" value="Package Plugin"/>
</Properties> </Properties>
<SyntheticProperties> <SyntheticProperties>
@ -56,7 +54,7 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" pref="393" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
@ -66,19 +64,19 @@
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="website" max="32767" attributes="0"/> <Component id="website" pref="129" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/> <Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="version" min="-2" pref="73" max="-2" attributes="0"/> <Component id="version" pref="129" max="32767" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="pluginName" min="-2" pref="127" max="-2" attributes="0"/> <Component id="pluginName" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/> <Component id="jLabel4" min="-2" pref="39" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="author" min="-2" pref="133" max="-2" attributes="0"/> <Component id="author" max="32767" attributes="0"/>
</Group> </Group>
<Component id="packageID" max="32767" attributes="0"/> <Component id="packageID" max="32767" attributes="0"/>
<Component id="shortDesc" max="32767" attributes="0"/> <Component id="shortDesc" max="32767" attributes="0"/>
@ -209,13 +207,16 @@
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="iconPreview" min="-2" pref="100" max="-2" attributes="0"/> <Component id="iconPreview" min="-2" pref="115" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="openIconBtn" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="openIconBtn" max="32767" attributes="0"/>
<Component id="defaultIconBtn" max="32767" attributes="0"/>
</Group>
</Group> </Group>
<Component id="jLabel9" min="-2" max="-2" attributes="0"/> <Component id="jLabel9" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="0" pref="194" max="32767" attributes="0"/> <EmptySpace min="0" pref="181" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -229,10 +230,14 @@
<Component id="jLabel9" min="-2" max="-2" attributes="0"/> <Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="openIconBtn" min="-2" max="-2" attributes="0"/> <Component id="openIconBtn" min="-2" max="-2" attributes="0"/>
<Component id="iconPreview" min="-2" pref="76" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="defaultIconBtn" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="iconPreview" min="-2" pref="83" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel10" pref="122" max="32767" attributes="0"/> <Component id="jLabel10" pref="122" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -247,6 +252,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="iconPreview"> <Component class="javax.swing.JLabel" name="iconPreview">
<Properties> <Properties>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder/> <LineBorder/>
@ -256,7 +262,7 @@
</Component> </Component>
<Component class="javax.swing.JButton" name="openIconBtn"> <Component class="javax.swing.JButton" name="openIconBtn">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Open Icon..."/> <Property name="text" type="java.lang.String" value="Open icon..."/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openIconBtnActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openIconBtnActionPerformed"/>
@ -268,6 +274,14 @@
<Property name="verticalAlignment" type="int" value="1"/> <Property name="verticalAlignment" type="int" value="1"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JButton" name="defaultIconBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Use default"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="defaultIconBtnActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="jPanel2"> <Container class="javax.swing.JPanel" name="jPanel2">

@ -45,9 +45,11 @@
*/ */
package net.apocalypselabs.symat; package net.apocalypselabs.symat;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
@ -61,17 +63,35 @@ import net.apocalypselabs.symat.plugin.Plugin;
*/ */
public class PackagePlugin extends javax.swing.JInternalFrame { public class PackagePlugin extends javax.swing.JInternalFrame {
private JFileChooser fc = new JFileChooser(); private final JFileChooser fcimg = new JFileChooser();
private final JFileChooser fcexp = new JFileChooser();
private ImageIcon icon; private ImageIcon icon;
public PackagePlugin(String code, int lang) {
this();
try {
icon = new ImageIcon(
ImageIO.read(PackagePlugin.class.getResource("images/plugin.png")));
} catch (IOException ex) {
Debug.stacktrace(ex);
}
langSelect.setSelectedIndex(lang);
codeBox.setText(code);
iconPreview.setIcon(icon);
}
/** /**
* Creates new form PackagePlugin * Creates new form PackagePlugin
*/ */
public PackagePlugin() { public PackagePlugin() {
fc.setFileFilter(new FileNameExtensionFilter( fcimg.setFileFilter(new FileNameExtensionFilter(
"Image (jpeg,jpg,gif,png,bmp)", "Image (jpeg,jpg,gif,png,bmp)",
"jpeg", "jpg", "gif", "png", "bmp")); "jpeg", "jpg", "gif", "png", "bmp"));
fcexp.setFileFilter(new FileNameExtensionFilter(
"Plugin (sypl)",
"sypl"));
initComponents(); initComponents();
author.setText(PrefStorage.getSetting("author"));
} }
/** /**
@ -105,6 +125,7 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
iconPreview = new javax.swing.JLabel(); iconPreview = new javax.swing.JLabel();
openIconBtn = new javax.swing.JButton(); openIconBtn = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel();
defaultIconBtn = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel();
langSelect = new javax.swing.JComboBox(); langSelect = new javax.swing.JComboBox();
@ -115,8 +136,6 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
setClosable(true); setClosable(true);
setIconifiable(true); setIconifiable(true);
setMaximizable(true);
setResizable(true);
setTitle("Package Plugin"); setTitle("Package Plugin");
jLabel1.setText("Plugin Name:"); jLabel1.setText("Plugin Name:");
@ -145,7 +164,7 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
.addContainerGap() .addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel7) .addComponent(jLabel7)
.addComponent(jScrollPane1) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1) .addComponent(jLabel1)
@ -154,18 +173,18 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(website) .addComponent(website, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel5) .addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(version, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(version, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(pluginName, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pluginName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel4) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(author, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(author))
.addComponent(packageID) .addComponent(packageID)
.addComponent(shortDesc)))) .addComponent(shortDesc))))
.addContainerGap()) .addContainerGap())
@ -204,9 +223,10 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
jLabel9.setText("Icon:"); jLabel9.setText("Icon:");
iconPreview.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
iconPreview.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); iconPreview.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
openIconBtn.setText("Open Icon..."); openIconBtn.setText("Open icon...");
openIconBtn.addActionListener(new java.awt.event.ActionListener() { openIconBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
openIconBtnActionPerformed(evt); openIconBtnActionPerformed(evt);
@ -216,6 +236,13 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
jLabel10.setText("Recommended icon size is 100x76."); jLabel10.setText("Recommended icon size is 100x76.");
jLabel10.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLabel10.setVerticalAlignment(javax.swing.SwingConstants.TOP);
defaultIconBtn.setText("Use default");
defaultIconBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
defaultIconBtnActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout); jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup( jPanel4Layout.setHorizontalGroup(
@ -227,11 +254,13 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
.addGroup(jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup() .addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(openIconBtn)) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(openIconBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(defaultIconBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(jLabel9)) .addComponent(jLabel9))
.addGap(0, 194, Short.MAX_VALUE))) .addGap(0, 181, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
jPanel4Layout.setVerticalGroup( jPanel4Layout.setVerticalGroup(
@ -241,9 +270,12 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
.addComponent(jLabel9) .addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(openIconBtn) .addComponent(openIconBtn)
.addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18) .addGap(18, 18, 18)
.addComponent(defaultIconBtn))
.addComponent(iconPreview, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE) .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
.addContainerGap()) .addContainerGap())
); );
@ -340,23 +372,32 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
p.setLang(langSelect.getSelectedIndex()); p.setLang(langSelect.getSelectedIndex());
p.setScript(codeBox.getText()); p.setScript(codeBox.getText());
p.setIcon(icon); p.setIcon(icon);
if (p.getTitle().equals("")
|| p.getAuthor().equals("")
|| p.getLongTitle().equals("")
|| p.getDesc().equals("")
|| p.getPackage().equals("")
|| p.getVersion().equals("")
|| p.getScript().equals("")
|| p.getIcon() == null) {
throw new Exception("One or more required fields are empty.");
}
} catch (Exception ex) { } catch (Exception ex) {
Debug.stacktrace(ex); Debug.stacktrace(ex);
JOptionPane.showInternalMessageDialog(this, JOptionPane.showInternalMessageDialog(this,
"Error. Please check your data.\n\n" + ex.getMessage()); "Error. Please check your data.\n\n" + ex.getMessage());
return; return;
} }
fc.setFileFilter(new FileNameExtensionFilter( int result = fcexp.showDialog(this, "Publish");
"Plugin (sypl)",
"sypl"));
int result = fc.showDialog(this, "Publish");
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
try { try {
FileOutputStream fout = new FileOutputStream(fc.getSelectedFile()); FileOutputStream fout = new FileOutputStream(FileUtils.getFileWithExtension(fcexp));
try (ObjectOutputStream oos = new ObjectOutputStream(fout)) { try (ObjectOutputStream oos = new ObjectOutputStream(fout)) {
oos.writeObject(p); oos.writeObject(p);
oos.close(); oos.close();
} }
JOptionPane.showInternalMessageDialog(this,
"Publish complete!");
} catch (Exception ex) { } catch (Exception ex) {
Debug.stacktrace(ex); Debug.stacktrace(ex);
JOptionPane.showInternalMessageDialog(this, JOptionPane.showInternalMessageDialog(this,
@ -366,13 +407,10 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
}//GEN-LAST:event_savePluginActionPerformed }//GEN-LAST:event_savePluginActionPerformed
private void openIconBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openIconBtnActionPerformed private void openIconBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openIconBtnActionPerformed
fc.setFileFilter(new FileNameExtensionFilter( int result = fcimg.showDialog(this, "Select Icon");
"Image (jpeg,jpg,gif,png,bmp)",
"jpeg", "jpg", "gif", "png", "bmp"));
int result = fc.showDialog(this, "Select Icon");
if (result == JFileChooser.APPROVE_OPTION) { if (result == JFileChooser.APPROVE_OPTION) {
try { try {
icon = new ImageIcon(ImageIO.read(fc.getSelectedFile())); icon = new ImageIcon(ImageIO.read(fcimg.getSelectedFile()));
iconPreview.setIcon(icon); iconPreview.setIcon(icon);
} catch (Exception ex) { } catch (Exception ex) {
Debug.stacktrace(ex); Debug.stacktrace(ex);
@ -382,10 +420,23 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
} }
}//GEN-LAST:event_openIconBtnActionPerformed }//GEN-LAST:event_openIconBtnActionPerformed
private void defaultIconBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultIconBtnActionPerformed
try {
icon = new ImageIcon(
ImageIO.read(PackagePlugin.class.getResource("images/plugin.png")));
iconPreview.setIcon(icon);
} catch (IOException ex) {
Debug.stacktrace(ex);
JOptionPane.showInternalMessageDialog(this,
"Error opening default icon.\n\n" + ex.getMessage());
}
}//GEN-LAST:event_defaultIconBtnActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField author; private javax.swing.JTextField author;
private javax.swing.JTextArea codeBox; private javax.swing.JTextArea codeBox;
private javax.swing.JButton defaultIconBtn;
private javax.swing.JLabel iconPreview; private javax.swing.JLabel iconPreview;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel10;

@ -12,6 +12,9 @@ import java.util.ArrayList;
* @author Skylar * @author Skylar
*/ */
public class TaskList implements Serializable { public class TaskList implements Serializable {
private static final long serialVersionUID = 13370L;
private final ArrayList<SingleTask> tasks = new ArrayList<>(); private final ArrayList<SingleTask> tasks = new ArrayList<>();
private String title = "Untitled"; private String title = "Untitled";

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

@ -45,23 +45,29 @@
*/ */
package net.apocalypselabs.symat.plugin; package net.apocalypselabs.symat.plugin;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import net.apocalypselabs.symat.CodeRunner; import net.apocalypselabs.symat.CodeRunner;
import net.apocalypselabs.symat.Debug; import net.apocalypselabs.symat.Debug;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.RichTooltip;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon;
/** /**
* * Plugin loader class.
* @author Skylar * @author Skylar
*/ */
public class LoadPlugin { public class LoadPlugin {
private Plugin p = new Plugin(); private Plugin p = new Plugin();
public LoadPlugin(String path) { public LoadPlugin(File f) {
try { try {
File f = new File(path);
FileInputStream fin = new FileInputStream(f); FileInputStream fin = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fin); ObjectInputStream ois = new ObjectInputStream(fin);
p = (Plugin) ois.readObject(); p = (Plugin) ois.readObject();
@ -71,6 +77,29 @@ public class LoadPlugin {
} }
} }
public LoadPlugin(String path) {
this(new File(path));
}
private ResizableIcon getRibbonIcon() {
return ImageWrapperResizableIcon.getIcon(
p.getIcon().getImage(),
new Dimension(100, 76));
}
public JCommandButton getRibbonBtn() {
JCommandButton b = new JCommandButton(p.getTitle(), getRibbonIcon());
b.setActionRichTooltip(new RichTooltip(p.getLongTitle(),
p.getDesc()));
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
exec();
}
});
return b;
}
public void exec() { public void exec() {
CodeRunner cr = new CodeRunner(p.getLang()); CodeRunner cr = new CodeRunner(p.getLang());
cr.evalString(p.getScript()); cr.evalString(p.getScript());

@ -12,6 +12,8 @@ import javax.swing.ImageIcon;
*/ */
public class Plugin implements Serializable { public class Plugin implements Serializable {
private static final long serialVersionUID = 13371L;
public final int LANG_JS = 0; public final int LANG_JS = 0;
public final int LANG_PY = 1; public final int LANG_PY = 1;

Loading…
Cancel
Save