diff --git a/gui/ASL GUI.exe b/gui/ASL GUI.exe
new file mode 100644
index 0000000..86823c7
Binary files /dev/null and b/gui/ASL GUI.exe differ
diff --git a/gui/README.md b/gui/README.md
index 0eea8ae..56f79d2 100644
--- a/gui/README.md
+++ b/gui/README.md
@@ -1,4 +1,4 @@
-ASL GUI
+ASL GUI
===========
An optional Java interface to make the compile procces of ASL faster and more user-friendly. It's released under the MIT licence just like the core project.
diff --git a/gui/src/asl/gui/DlgError.java b/gui/src/asl/gui/DlgError.java
new file mode 100644
index 0000000..52f6299
--- /dev/null
+++ b/gui/src/asl/gui/DlgError.java
@@ -0,0 +1,83 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2015 Ozan Egitmen.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package asl.gui;
+
+public class DlgError extends javax.swing.JDialog {
+
+ boolean isAbort = true;
+
+ public DlgError(java.awt.Frame parent, boolean modal, String errorMessage) {
+ super(parent, modal);
+ initComponents();
+ lblError.setText(errorMessage);
+ }
+
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblError = new javax.swing.JLabel();
+ lblTitle = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("ERROR");
+ setIconImage(null);
+ setMinimumSize(new java.awt.Dimension(380, 150));
+ setResizable(false);
+ setType(java.awt.Window.Type.POPUP);
+
+ lblError.setFont(new java.awt.Font("Segoe UI Light", 0, 16)); // NOI18N
+ lblError.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ lblError.setText("Some error");
+
+ lblTitle.setFont(new java.awt.Font("Segoe UI Light", 0, 16)); // NOI18N
+ lblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ lblTitle.setText("asl.exe has encountered an error:");
+ lblTitle.setToolTipText("");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(lblTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
+ .addComponent(lblError, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(lblTitle)
+ .addGap(18, 18, 18)
+ .addComponent(lblError)
+ .addGap(27, 27, 27))
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel lblError;
+ private javax.swing.JLabel lblTitle;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/gui/src/asl/gui/Main.java b/gui/src/asl/gui/Main.java
index bee0e78..78c2f95 100644
--- a/gui/src/asl/gui/Main.java
+++ b/gui/src/asl/gui/Main.java
@@ -24,7 +24,13 @@
package asl.gui;
import java.awt.Color;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
@@ -41,7 +47,7 @@ import javax.swing.plaf.ColorUIResource;
public class Main extends javax.swing.JFrame {
Preferences prefs = Preferences.userRoot().node(this.getClass().getName());
- boolean outputFixDir = false;
+ boolean aslFix, outputDirFix, gaveError = false;
public Main() {
initComponents();
@@ -76,6 +82,7 @@ public class Main extends javax.swing.JFrame {
}
@SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
private void initComponents() {
lblInput = new javax.swing.JLabel();
@@ -100,23 +107,22 @@ public class Main extends javax.swing.JFrame {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("ASL GUI");
- setMinimumSize(new java.awt.Dimension(410, 429));
setResizable(false);
- lblInput.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
+ lblInput.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16)); // NOI18N
lblInput.setText("Input Directory:");
lblInput.setOpaque(true);
- txtInputDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
+ txtInputDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16)); // NOI18N
- lblOutput.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
+ lblOutput.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16)); // NOI18N
lblOutput.setText("Output Directory:");
lblOutput.setOpaque(true);
- txtOutputDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
+ txtOutputDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16)); // NOI18N
btnInput.setText("...");
- btnInput.setToolTipText("Opens a dialog to select input file or directory");
+ btnInput.setToolTipText("Opens a dialog to select input file");
btnInput.setFocusable(false);
btnInput.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
@@ -133,11 +139,11 @@ public class Main extends javax.swing.JFrame {
}
});
- lblASL.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
+ lblASL.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16)); // NOI18N
lblASL.setText("ASL Compiler Directory");
lblASL.setOpaque(true);
- txtASLDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16));
+ txtASLDir.setFont(new java.awt.Font("Segoe UI Light", 0, 16)); // NOI18N
btnASL.setText("...");
btnASL.setToolTipText("Opens a dialog to select the compiler location");
@@ -150,20 +156,20 @@ public class Main extends javax.swing.JFrame {
jSeparator.setToolTipText("");
- lblASLSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
+ lblASLSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10)); // NOI18N
lblASLSmall.setText("Location of the asl.exe file.");
lblASLSmall.setOpaque(true);
- lblInputSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
- lblInputSmall.setText("Script that should be compiled in to the output directory.");
+ lblInputSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10)); // NOI18N
+ lblInputSmall.setText("Directory of scripts that will be compiled in to the output directory.");
lblInputSmall.setOpaque(true);
- lblOutputSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
+ lblOutputSmall.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10)); // NOI18N
lblOutputSmall.setText("Directory that the compiled .sqf script(s) will be saved in.");
lblOutputSmall.setOpaque(true);
- cbCompileAll.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 11));
- cbCompileAll.setText("Compile all scripts (Directory of the selected script will be used).");
+ cbCompileAll.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 11)); // NOI18N
+ cbCompileAll.setText("Compile all scripts including sub folders.");
cbCompileAll.setFocusable(false);
cbCompileAll.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
@@ -171,7 +177,7 @@ public class Main extends javax.swing.JFrame {
}
});
- cbPrettyPrinting.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 11));
+ cbPrettyPrinting.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 11)); // NOI18N
cbPrettyPrinting.setText("Activate pretty printing.");
cbPrettyPrinting.setFocusable(false);
cbPrettyPrinting.addChangeListener(new javax.swing.event.ChangeListener() {
@@ -180,7 +186,7 @@ public class Main extends javax.swing.JFrame {
}
});
- btnCompile.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16));
+ btnCompile.setFont(new java.awt.Font("Microsoft JhengHei UI Light", 0, 16)); // NOI18N
btnCompile.setText("Compile");
btnCompile.setToolTipText("Opens a dialog to select output directory");
btnCompile.setFocusable(false);
@@ -190,15 +196,20 @@ public class Main extends javax.swing.JFrame {
}
});
- lblASLError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
+ lblASLError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10)); // NOI18N
lblASLError.setForeground(java.awt.Color.red);
lblASLError.setText("Some error");
+ lblASLError.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mouseClicked(java.awt.event.MouseEvent evt) {
+ lblASLErrorMouseClicked(evt);
+ }
+ });
- lblInputError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
+ lblInputError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10)); // NOI18N
lblInputError.setForeground(java.awt.Color.red);
lblInputError.setText("Some error");
- lblOutputError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10));
+ lblOutputError.setFont(new java.awt.Font("Microsoft YaHei UI", 0, 10)); // NOI18N
lblOutputError.setForeground(java.awt.Color.red);
lblOutputError.setText("Some error");
lblOutputError.addMouseListener(new java.awt.event.MouseAdapter() {
@@ -235,14 +246,14 @@ public class Main extends javax.swing.JFrame {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnOutput))
.addComponent(lblOutputSmall)
- .addComponent(cbPrettyPrinting)
- .addComponent(cbCompileAll)
.addComponent(lblInput)
.addGroup(layout.createSequentialGroup()
.addComponent(txtInputDir, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnInput))
- .addComponent(lblInputSmall))
+ .addComponent(lblInputSmall)
+ .addComponent(cbCompileAll)
+ .addComponent(cbPrettyPrinting))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(24, 24, 24))
.addGroup(layout.createSequentialGroup()
@@ -288,41 +299,41 @@ public class Main extends javax.swing.JFrame {
.addComponent(cbCompileAll)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(cbPrettyPrinting)
- .addGap(18, 18, 18)
+ .addGap(11, 11, 11)
.addComponent(btnCompile, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(11, 11, 11))
);
pack();
setLocationRelativeTo(null);
- }
+ }// //GEN-END:initComponents
- private void btnInputMouseClicked(java.awt.event.MouseEvent evt) {
+ private void btnInputMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnInputMouseClicked
if (SwingUtilities.isLeftMouseButton(evt)) {
- String path = fileChooser("Select asl script location", new FileNameExtensionFilter("Arma Scripting Language File", "asl"));
+ String path = fileChooser("Select input directory", null);
File inputDir = new File(path);
if (inputDir.exists()) {
prefs.put("inputDir", path);
txtInputDir.setText(path);
}
}
- }
+ }//GEN-LAST:event_btnInputMouseClicked
- private void btnOutputMouseClicked(java.awt.event.MouseEvent evt) {
+ private void btnOutputMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnOutputMouseClicked
if (SwingUtilities.isLeftMouseButton(evt)) {
- String path = fileChooser("Select output location", null);
+ String path = fileChooser("Select output directory", null);
File outputDir = new File(path);
if (outputDir.exists() && outputDir.isDirectory()) {
prefs.put("outputDir", path);
txtOutputDir.setText(path);
} else if (!outputDir.exists()) {
- lblOutputError.setText("Folder doesn't exsist! Click this message to create it.");
- outputFixDir = true;
+ lblOutputError.setText("Output folder doesn't exsist! Click this message to create it.");
+ outputDirFix = true;
}
}
- }
+ }//GEN-LAST:event_btnOutputMouseClicked
- private void btnASLMouseClicked(java.awt.event.MouseEvent evt) {
+ private void btnASLMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnASLMouseClicked
if (SwingUtilities.isLeftMouseButton(evt)) {
String path = fileChooser("Select 'asl.exe' location", new FileNameExtensionFilter("Executable", "exe"));
File asl = new File(path);
@@ -331,46 +342,116 @@ public class Main extends javax.swing.JFrame {
txtASLDir.setText(path);
}
}
- }
+ }//GEN-LAST:event_btnASLMouseClicked
- private void btnCompileMouseClicked(java.awt.event.MouseEvent evt) {
+ private void btnCompileMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCompileMouseClicked
if (SwingUtilities.isLeftMouseButton(evt)) {
+ String sumthin = new File(txtASLDir.getText()).getParent() + "\\asl.exe";
+ if (!new File(sumthin).exists()) {
+ lblASLError.setText("asl.exe isn't in this location! You can click this message to download it.");
+ }
JTextField[] dirFields = {txtASLDir, txtInputDir, txtOutputDir};
for (byte i = 0; i < 3; i++) {
File bleh = new File(dirFields[i].getText());
if (!bleh.exists()) {
+ gaveError = true;
switch (i) {
case 0:
lblASLError.setText("asl.exe isn't in this location! You can click this message to download it.");
+ aslFix = true;
break;
case 1:
- lblInputError.setText("Script doesn't exist!");
+ lblInputError.setText("This folder doesn't exist!");
break;
case 2:
- lblOutputError.setText("This Folder doesn't exsist! Click this message to create it.");
- outputFixDir = true;
+ lblOutputError.setText("Output folder doesn't exsist! Click this message to create it.");
+ outputDirFix = true;
+ break;
+ }
+ return;
+ }
+ if (bleh.exists() && gaveError) {
+ switch (i) {
+ case 0:
+ lblASLError.setText(" ");
+ break;
+ case 1:
+ lblInputError.setText(" ");
+ break;
+ case 2:
+ lblOutputError.setText(" ");
+ outputDirFix = true;
break;
}
}
-
+ }
+ if (gaveError) {
+ return;
+ }
+ String compileAll = "", prettyPrinting = "";
+ if (cbCompileAll.isSelected()) {
+ compileAll = "-r";
+ }
+ if (cbPrettyPrinting.isSelected()) {
+ prettyPrinting = "-pretty";
+ }
+ String asl = txtASLDir.getText();
+ String input = txtInputDir.getText();
+ String output = txtOutputDir.getText();
+ String aslError = " ";
+ try {
+ Process aslProcess = new ProcessBuilder(asl, compileAll, prettyPrinting, input, output).start();
+ InputStream is = aslProcess.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr);
+ String line;
+ while ((line = br.readLine()) != null) {
+ if (line.contains("Error")) {
+ aslError = line;
+ }
+ }
+ aslProcess.waitFor();
+ if (!aslError.equals(" ")) {
+ DlgError error = new DlgError(this, true, aslError);
+ error.setLocationRelativeTo(this);
+ error.setVisible(true);
+ }
+ //Runtime.getRuntime().exec("cmd /c start \"" + asl + "\" " + compileAll + prettyPrinting + "\"" + input + "\" \"" + output + "\"");
+ //TODO: Start app in command line with parameters
+ } catch (IOException | InterruptedException ex) {
+ Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
- }
+ }//GEN-LAST:event_btnCompileMouseClicked
- private void cbCompileAllStateChanged(javax.swing.event.ChangeEvent evt) {
+ private void cbCompileAllStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbCompileAllStateChanged
prefs.putBoolean("compileAll", cbCompileAll.isSelected());
- }
+ }//GEN-LAST:event_cbCompileAllStateChanged
- private void cbPrettyPrintingStateChanged(javax.swing.event.ChangeEvent evt) {
+ private void cbPrettyPrintingStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbPrettyPrintingStateChanged
prefs.putBoolean("prettyPrinting", cbPrettyPrinting.isSelected());
- }
+ }//GEN-LAST:event_cbPrettyPrintingStateChanged
- private void lblOutputErrorMouseClicked(java.awt.event.MouseEvent evt) {
- if (SwingUtilities.isLeftMouseButton(evt) && outputFixDir) {
+ private void lblOutputErrorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblOutputErrorMouseClicked
+ if (SwingUtilities.isLeftMouseButton(evt) && outputDirFix) {
new File(txtOutputDir.getText()).mkdirs();
- outputFixDir = false;
+ outputDirFix = false;
+ lblOutputError.setText(" ");
}
- }
+ }//GEN-LAST:event_lblOutputErrorMouseClicked
+
+ private void lblASLErrorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblASLErrorMouseClicked
+ if (SwingUtilities.isLeftMouseButton(evt) && aslFix) {
+ try {
+ URI github = new URI("https://github.com/DeKugelschieber/asl/releases");
+ java.awt.Desktop.getDesktop().browse(github);
+ } catch (URISyntaxException | IOException ex) {
+ Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ aslFix = false;
+ lblASLError.setText(" ");
+ }
+ }//GEN-LAST:event_lblASLErrorMouseClicked
public static void main(String args[]) {
try {
@@ -389,6 +470,7 @@ public class Main extends javax.swing.JFrame {
});
}
+ // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnASL;
private javax.swing.JButton btnCompile;
private javax.swing.JButton btnInput;
@@ -408,4 +490,5 @@ public class Main extends javax.swing.JFrame {
private javax.swing.JTextField txtASLDir;
private javax.swing.JTextField txtInputDir;
private javax.swing.JTextField txtOutputDir;
+ // End of variables declaration//GEN-END:variables
}