essential-actions

Clone or download

Cleanup, work, add new action "Run Executable Action"

Modified Files

M Makefile
+3 −0
--- 'a/Makefile'
+++ b/Makefile
@@ -30,3 +30,6 @@ website:
openfile:
./build.sh openfileaction
+
+runexecutable:
+ ./build.sh runexecutableaction
M build.bat
+10 −12
--- 'a/build.bat'
+++ b/build.bat
@@ -18,6 +18,7 @@ if "%1%"=="twitch-talk" (goto twitch)
if "%1%"=="twitter" (goto twitteraction)
if "%1%"=="website" (goto websiteaction)
if "%1%"=="openfile" (goto openfileaction)
+if "%1%"=="runexecutable" (goto runexecutableaction)
if NOT "%1%"=="" (
echo Invalid argument %1%
@@ -26,17 +27,6 @@ if NOT "%1%"=="" (
set quit=false
-goto hotkeyaction
-goto mediakeyaction
-goto obssuite
-goto playaudioclipaction
-goto runcommandaction
-goto textblockaction
-goto twitch
-goto twitteraction
-goto websiteaction
-goto openfileaction
-
:hotkeyaction
pushd %CD%
cd hotkeyaction
@@ -207,4 +197,12 @@ cd openfileaction
call mvn clean -Dmaven.test.skip package
move target\openfileaction-*.jar ..\%FOLD%\openfileaction.jar
popd
-if "%quit%" == "true" (EXIT /B 0)
\ No newline at end of file
+if "%quit%" == "true" (EXIT /B 0)
+
+:runexecutableaction
+pushd %CD%
+cd runexecutableaction
+call mvn clean -Dmaven.test.skip package
+move target\runexecutableaction-*.jar ..\%FOLD%\runexecutableaction.jar
+popd
+if "%quit%" == "true" (EXIT /B 0)
M build.sh
+14 −0
--- 'a/build.sh'
+++ b/build.sh
@@ -143,6 +143,13 @@ openfileaction() {
popd || exit
}
+runexecutableaction() {
+ pushd . || exit
+ cd runexecutableaction && mvn clean -Dmaven.test.skip package
+ mv target/runexecutableaction-*.jar ../$FOLD/runexecutableaction.jar
+ popd || exit
+}
+
mkdir -p $FOLD
rm -rf "${FOLD:?}/"*
cp $DEPS/* $FOLD/
@@ -175,6 +182,12 @@ twitteraction)
websiteaction)
websiteaction
;;
+openfileaction)
+ openfileaction
+ ;;
+runexecutableaction)
+ runexecutableaction
+ ;;
*)
# build all actions as default
hotkeyaction
@@ -187,5 +200,6 @@ websiteaction)
twitteraction
websiteaction
openfileaction
+ runexecutableaction
;;
esac
--- 'a/hotkeyaction/src/main/java/com/stream_pi/hotkeyaction/HotkeyAction.java'
+++ b/hotkeyaction/src/main/java/com/stream_pi/hotkeyaction/HotkeyAction.java
@@ -27,7 +27,7 @@ public class HotkeyAction extends Normal
}
@Override
- public void initProperties()
+ public void initProperties() throws MinorException
{
Property keyCombination = new Property("key_comb", Type.STRING);
keyCombination.setDisplayName("Key combination (Separate using comma)");
--- 'a/runcommandaction/src/main/java/com/stream_pi/runcommandaction/RunCommandAction.java'
+++ b/runcommandaction/src/main/java/com/stream_pi/runcommandaction/RunCommandAction.java
@@ -22,7 +22,7 @@ public class RunCommandAction extends No
}
@Override
- public void initProperties()
+ public void initProperties() throws MinorException
{
Property commandProperty = new Property("command", Type.STRING);
commandProperty.setDisplayName("Command");
--- /dev/null
+++ b/runexecutableaction/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.stream-pi</groupId>
+ <artifactId>runexecutableaction</artifactId>
+ <version>1.0.0</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>test-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <release>11</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.stream-pi</groupId>
+ <artifactId>action-api</artifactId>
+ <version>${ActionAPIVersion}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+++ b/runexecutableaction/src/main/java/com/stream_pi/runexecutableaction/RunExecutableAction.java
@@ -0,0 +1,67 @@
+package com.stream_pi.runexecutableaction;
+
+import com.stream_pi.action_api.actionproperty.property.*;
+import com.stream_pi.action_api.externalplugin.NormalAction;
+import com.stream_pi.util.exception.MinorException;
+import com.stream_pi.util.version.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+public class RunExecutableAction extends NormalAction
+{
+
+ public RunExecutableAction()
+ {
+ setName("Run Executable");
+ setCategory("Essentials");
+ setAuthor("rnayabed");
+ setServerButtonGraphic("far-file-code");
+ setVersion(new Version(1,0,0));
+ }
+
+ @Override
+ public void initProperties() throws MinorException
+ {
+ StringProperty executablePathProperty = new StringProperty("executable_location");
+ executablePathProperty.setDisplayName("Executable Location");
+ executablePathProperty.setControlType(ControlType.FILE_PATH);
+ executablePathProperty.setExtensionFilters(
+ new FileExtensionFilter("Executable", "*.*")
+ );
+
+ addClientProperties(executablePathProperty);
+ }
+
+ @Override
+ public void onActionClicked() throws MinorException
+ {
+ String executableLocation = getClientProperties().getSingleProperty("executable_location").getStringValue();
+
+ if(executableLocation.isBlank())
+ {
+ throw new MinorException("Executable File location is empty");
+ }
+
+
+ File executableFile = new File(executableLocation);
+
+ if(!executableFile.exists())
+ {
+ throw new MinorException("The File at given path '"+executableLocation+"' does not exist.");
+ }
+
+ try
+ {
+ ProcessBuilder processBuilder = new ProcessBuilder();
+ processBuilder.directory(executableFile.getParentFile());
+ processBuilder.command(executableLocation);
+ processBuilder.start();
+ }
+ catch (IOException e)
+ {
+ throw new MinorException(e.getMessage());
+ }
+ }
+}
--- /dev/null
+++ b/runexecutableaction/src/main/java/module-info.java
@@ -0,0 +1,10 @@
+module com.stream_pi.runexecutableaction
+{
+ requires com.stream_pi.action_api;
+ requires com.stream_pi.util;
+
+ requires org.kordamp.ikonli.javafx;
+ requires org.kordamp.ikonli.fontawesome5;
+
+ provides com.stream_pi.action_api.externalplugin.ExternalPlugin with com.stream_pi.runexecutableaction.RunExecutableAction;
+}
\ No newline at end of file