Skip to content

Commit

Permalink
Merge pull request #82 from Gaming32/groovy-scripting
Browse files Browse the repository at this point in the history
here we go
  • Loading branch information
EmeraldBlock committed Apr 4, 2022
2 parents 8e50158 + bd9ee6b commit 57bb8e3
Show file tree
Hide file tree
Showing 53 changed files with 1,954 additions and 2,465 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ network_*.svg
sorting_networks
/stats-config.txt
dependency-reduced-pom.xml
/scripts
40 changes: 0 additions & 40 deletions monthly-scripts/Apr2021sorts.txt

This file was deleted.

27 changes: 0 additions & 27 deletions monthly-scripts/Feb2021sorts.txt

This file was deleted.

21 changes: 0 additions & 21 deletions monthly-scripts/Jan2021sorts.txt

This file was deleted.

61 changes: 0 additions & 61 deletions monthly-scripts/Mar2021sorts.txt

This file was deleted.

55 changes: 0 additions & 55 deletions monthly-scripts/May2021sorts.txt

This file was deleted.

31 changes: 31 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<artifactId>classgraph</artifactId>
<version>4.8.139</version>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>

<licenses>
Expand Down Expand Up @@ -95,6 +100,32 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<sourceFileIncludes>
<include>io/github/arrayv/groovyapi/**/*.java</include>
<include>io/github/arrayv/main/**/*.java</include>
<include>io/github/arrayv/sortdata/**/*.java</include>
<include>io/github/arrayv/sorts/templates/Sort.java</include>
<include>io/github/arrayv/utils/**/*.java</include>
</sourceFileIncludes>
<links>
<link>https://javadoc.io/doc/io.github.classgraph/classgraph/4.8.139</link>
<link>https://docs.groovy-lang.org/4.0.0/html/api</link>
</links>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/github/arrayv/dialogs/RunScriptDialog.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.arrayv.dialogs;

import javax.swing.filechooser.FileNameExtensionFilter;

/*
MIT License
Expand Down Expand Up @@ -29,6 +31,9 @@ public RunScriptDialog() {
super();

fileDialog.setDialogTitle("Choose a script file...");
FileNameExtensionFilter groovyFiles = new FileNameExtensionFilter("Groovy Script Files (.groovy)", "groovy");
this.removeAllFilesOption();
fileDialog.addChoosableFileFilter(groovyFiles);

fileDialog.showDialog(null, "Select");
this.file = fileDialog.getSelectedFile();
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/io/github/arrayv/frames/ArrayFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public ArrayFrame(int[] array, ArrayVisualizer arrayVisualizer) {

setUndecorated(true);
initComponents();
setLocation(Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), frame.getX() + frame.getWidth()), frame.getY() + 29);
setBounds(
Math.min((int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth(), frame.getX() + frame.getWidth()),
frame.getY() + 29,
getWidth(),
arrayVisualizer.getUtilFrame().getHeight()
);
setAlwaysOnTop(false);
setVisible(true);
}
Expand Down
43 changes: 32 additions & 11 deletions src/main/java/io/github/arrayv/frames/UtilFrame.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package io.github.arrayv.frames;

import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import io.github.arrayv.dialogs.RunScriptDialog;
import io.github.arrayv.main.ArrayManager;
import io.github.arrayv.main.ArrayVisualizer;
import io.github.arrayv.panes.JErrorPane;
import io.github.arrayv.prompts.ShufflePrompt;
import io.github.arrayv.prompts.SortPrompt;
import io.github.arrayv.prompts.ViewPrompt;
Expand Down Expand Up @@ -50,14 +55,15 @@ public final class UtilFrame extends javax.swing.JFrame {

private int[] array;

private ArrayManager arrayManager;
private ArrayVisualizer arrayVisualizer;
private Delays Delays;
private final ArrayManager arrayManager;
private final ArrayVisualizer arrayVisualizer;
private final Delays Delays;
private final Highlights Highlights;
private final JFrame frame;
private final Timer Timer;
private final Sounds Sounds;

private AppFrame abstractFrame;
private Highlights Highlights;
private JFrame frame;
private Timer Timer;
private Sounds Sounds;

public UtilFrame(int[] array, ArrayVisualizer arrayVisualizer) {
this.array = array;
Expand Down Expand Up @@ -266,6 +272,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1.removeItem("Stability Check");
}

JButton runScriptButton = new JButton("Run Script");
runScriptButton.addActionListener(e -> {
File scriptFile = new RunScriptDialog().getFile();
if (scriptFile == null) return;
try {
arrayVisualizer.getScriptManager().runInThread(scriptFile);
} catch (IOException e1) {
JErrorPane.invokeErrorMessage(e1, "Run Script");
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
Expand Down Expand Up @@ -293,8 +310,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(this.jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(this.jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(this.jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(runScriptButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(this.jComboBox1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
.addGap(0, 10, Short.MAX_VALUE))
.addGap(0, 10, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, true)
Expand Down Expand Up @@ -333,7 +351,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(this.jButton5)
.addGap(5, 5, 5)
.addComponent(this.jCheckBox6)
.addComponent(this.jCheckBox4))
.addComponent(this.jCheckBox4)
.addGap(5, 5, 5)
.addComponent(runScriptButton)
.addGap(8, 8, 8))
);

pack();
Expand Down Expand Up @@ -453,9 +474,9 @@ private void jButton5ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerforme

private void jCheckBox5ActionPerformed() {//GEN-FIRST:event_jButton4ActionPerformed
if (jCheckBox5.isSelected()) {
Sounds.toggleSofterSounds(true);
Sounds.setSofterSounds(true);
} else {
Sounds.toggleSofterSounds(false);
Sounds.setSofterSounds(false);
}
}//GEN-LAST:event_jCheckBox5ActionPerformed

Expand Down
Loading

0 comments on commit 57bb8e3

Please sign in to comment.