From: Debayan Sutradhar Date: Tue, 01 Jun 2021 00:18:12 +0530 Subject: [Run Command Action] Updated to work with new Action API, Cleanup --- [Run Command Action] Updated to work with new Action API, Cleanup --- --- 'a/runcommandaction/.gitignore' +++ b/runcommandaction/.gitignore @@ -1,6 +1,6 @@ .idea/ target/ -WebsiteAction.iml +*.iml .classpath .factorypath .project --- 'a/runcommandaction/pom.xml' +++ b/runcommandaction/pom.xml @@ -6,7 +6,7 @@ com.stream-pi runcommandaction - 1.1.0 + 1.1.1 @@ -43,9 +43,6 @@ UTF-8 11 11 - - 11.5.0 - 11.5.0 @@ -60,17 +57,5 @@ action-api ${ActionAPIVersion} - - - org.kordamp.ikonli - ikonli-fontawesome5-pack - ${IkonliFA5PackVersion} - - - - org.kordamp.ikonli - ikonli-javafx - ${IkonliVersion} - \ No newline at end of file --- 'a/runcommandaction/src/main/java/com/stream_pi/runcommandaction/RunCommandAction.java' +++ b/runcommandaction/src/main/java/com/stream_pi/runcommandaction/RunCommandAction.java @@ -3,10 +3,13 @@ package com.stream_pi.runcommandaction; import com.stream_pi.action_api.actionproperty.property.Property; import com.stream_pi.action_api.actionproperty.property.Type; 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.IOException; -public class RunCommandAction extends NormalAction { +public class RunCommandAction extends NormalAction +{ public RunCommandAction() { @@ -19,7 +22,8 @@ public class RunCommandAction extends No } @Override - public void initProperties() throws Exception { + public void initProperties() + { Property commandProperty = new Property("command", Type.STRING); commandProperty.setDisplayName("Command"); @@ -27,24 +31,22 @@ public class RunCommandAction extends No } @Override - public void initAction() throws Exception { - - - } - - @Override - public void onActionClicked() throws Exception + public void onActionClicked() throws MinorException { - runCommand(getClientProperties().getSingleProperty("command").getStringValue()); - } - - @Override - public void onShutDown() throws Exception { - // TODO Auto-generated method stub + String command = getClientProperties().getSingleProperty("command").getStringValue(); + try + { + runCommand(command); + } + catch (IOException e) + { + e.printStackTrace(); + throw new MinorException("Unable to run command \n\n"+command+"\n\n.Reason:\n"+e.getMessage()); + } } - private void runCommand(String command) throws Exception + private void runCommand(String command) throws IOException { Runtime rt = Runtime.getRuntime(); rt.exec(command); --- 'a/runcommandaction/src/main/java/module-info.java' +++ b/runcommandaction/src/main/java/module-info.java @@ -1,4 +1,3 @@ - module com.stream_pi.runcommandaction { requires com.stream_pi.action_api; @@ -8,5 +7,4 @@ module com.stream_pi.runcommandaction requires org.kordamp.ikonli.fontawesome5; provides com.stream_pi.action_api.externalplugin.ExternalPlugin with com.stream_pi.runcommandaction.RunCommandAction; - } \ No newline at end of file