diff --git a/src/net/apocalypselabs/symat/CodeEditor.form b/src/net/apocalypselabs/symat/CodeEditor.form index 99fb83d..9f5a418 100644 --- a/src/net/apocalypselabs/symat/CodeEditor.form +++ b/src/net/apocalypselabs/symat/CodeEditor.form @@ -130,7 +130,7 @@ - + @@ -138,7 +138,7 @@ - + diff --git a/src/net/apocalypselabs/symat/CodeEditor.java b/src/net/apocalypselabs/symat/CodeEditor.java index 2aa6409..37b8a3c 100644 --- a/src/net/apocalypselabs/symat/CodeEditor.java +++ b/src/net/apocalypselabs/symat/CodeEditor.java @@ -159,7 +159,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { javascriptOption = new javax.swing.JRadioButtonMenuItem(); pythonOption = new javax.swing.JRadioButtonMenuItem(); runMenu = new javax.swing.JMenu(); - jMenuItem5 = new javax.swing.JMenuItem(); + runCodeBtn = new javax.swing.JMenuItem(); jMenuItem4.setText("jMenuItem4"); @@ -297,14 +297,14 @@ public class CodeEditor extends javax.swing.JInternalFrame { } }); - jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0)); - jMenuItem5.setText("Run code"); - jMenuItem5.addActionListener(new java.awt.event.ActionListener() { + runCodeBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0)); + runCodeBtn.setText("Run code"); + runCodeBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem5ActionPerformed(evt); + runCodeBtnActionPerformed(evt); } }); - runMenu.add(jMenuItem5); + runMenu.add(runCodeBtn); jMenuBar1.add(runMenu); @@ -399,13 +399,27 @@ public class CodeEditor extends javax.swing.JInternalFrame { }//GEN-LAST:event_runMenuActionPerformed - private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed + private void runCodeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runCodeBtnActionPerformed if (javascriptOption.isSelected()) { - execCode("javascript"); + new RunThread("javascript").start(); } else if (pythonOption.isSelected()) { - execCode("python"); + new RunThread("python").start(); } - }//GEN-LAST:event_jMenuItem5ActionPerformed + }//GEN-LAST:event_runCodeBtnActionPerformed + + private class RunThread extends Thread { + + String lang = ""; + + public RunThread(String codelang) { + lang = codelang; + } + + @Override + public void run() { + execCode(lang); + } + } private void execCode(String lang) { CodeRunner cr = new CodeRunner(lang); @@ -477,7 +491,6 @@ public class CodeEditor extends javax.swing.JInternalFrame { private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuBar jMenuBar2; private javax.swing.JMenuItem jMenuItem4; - private javax.swing.JMenuItem jMenuItem5; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; @@ -487,6 +500,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { private javax.swing.JMenuItem openMenu; private javax.swing.JTextArea outputBox; private javax.swing.JRadioButtonMenuItem pythonOption; + private javax.swing.JMenuItem runCodeBtn; private javax.swing.JMenu runMenu; private javax.swing.JMenuItem saveAsMenu; private javax.swing.JMenuItem saveMenu; diff --git a/src/net/apocalypselabs/symat/CodeExport.java b/src/net/apocalypselabs/symat/CodeExport.java index 414f1aa..143f56b 100644 --- a/src/net/apocalypselabs/symat/CodeExport.java +++ b/src/net/apocalypselabs/symat/CodeExport.java @@ -1,7 +1,7 @@ -/* +/* * Apocalypse Laboratories * Open Source License - * + * * Source code can be used for any purpose, as long as: * - Compiled binaries are rebranded and trademarks are not * visible by the end user at any time, except to give @@ -14,7 +14,7 @@ * - and you provide your modified source code for download, * under the terms of the GNU LGPL v3 or a comparable * license. - * + * * Compiled binaries cannot be redistributed or mirrored, * unless: * - You have written permission from Apocalypse Laboratories; @@ -22,7 +22,7 @@ * not even behind a paywall or other blocking mechanism; * - or you have received a multi-computer license, in which * case you should take measures to prevent unauthorized - * downloads, such as preventing download access from the + * downloads, such as preventing download access from the * Internet. */ package net.apocalypselabs.symat; @@ -75,10 +75,10 @@ public class CodeExport extends javax.swing.JInternalFrame { previewPane.setText(html); previewPane.setCaretPosition(0); } - + /** * Create CodeExport window with a set language for syntax highlighting. - * + * * @param code The code. * @param lang Options are "js" or "python". */ @@ -351,6 +351,7 @@ public class CodeExport extends javax.swing.JInternalFrame { htmlWorker.setStyleSheet(styles); htmlWorker.parse(new StringReader(k)); document.close(); + savedMsg(); } } catch (IOException | DocumentException e) { JOptionPane.showInternalMessageDialog(this, "Error saving: " + e.getMessage()); @@ -361,11 +362,16 @@ public class CodeExport extends javax.swing.JInternalFrame { try { PrintStream out = new PrintStream(new FileOutputStream(path)); out.print(content); + savedMsg(); } catch (Exception ex) { JOptionPane.showInternalMessageDialog(this, "Error saving: " + ex.getMessage()); } } + private void savedMsg() { + JOptionPane.showInternalMessageDialog(this, "Export complete!"); + } + private String addSaveExt(String path, String format) { if (!path.matches(".*\\.(" + format + ")")) { path += "." + format;