From: Debayan Sutradhar Date: Tue, 01 Jun 2021 00:24:18 +0530 Subject: [Text Block Action] Cleanup, Refactored, Updated to work with new Action API --- [Text Block Action] Cleanup, Refactored, Updated to work with new Action API --- --- 'a/textblockaction/.gitignore' +++ b/textblockaction/.gitignore @@ -1,5 +1,5 @@ .idea/ -HotkeyAction.iml +*.iml target/ --- 'a/textblockaction/pom.xml' +++ b/textblockaction/pom.xml @@ -6,7 +6,7 @@ com.stream-pi textblockaction - 1.0.0 + 1.0.1 @@ -40,14 +40,9 @@ 1.0.0-SNAPSHOT 1.0.0-SNAPSHOT - 16-ea+4 - UTF-8 11 11 - - 11.5.0 - 11.5.0 @@ -62,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/textblockaction/src/main/java/com/stream_pi/textblockaction/TextBlockAction.java' +++ b/textblockaction/src/main/java/com/stream_pi/textblockaction/TextBlockAction.java @@ -3,13 +3,14 @@ package com.stream_pi.textblockaction; 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 static java.awt.event.KeyEvent.*; import java.awt.*; -public class TextBlockAction extends NormalAction { - +public class TextBlockAction extends NormalAction +{ public TextBlockAction() { setName("Text Block"); @@ -17,11 +18,12 @@ public class TextBlockAction extends Nor setAuthor("rnayabed"); setServerButtonGraphic("fas-keyboard"); setHelpLink("https://github.com/stream-pi/essentialactions"); - setVersion(new Version(1,0,0)); + setVersion(new Version(1,0,1)); } @Override - public void initProperties() throws Exception { + public void initProperties() throws MinorException + { Property textBlockProperty = new Property("text_block", Type.STRING); textBlockProperty.setDisplayName("Text"); textBlockProperty.setDefaultValueStr("Stream-Pi FTW"); @@ -34,19 +36,28 @@ public class TextBlockAction extends Nor private Robot robot; @Override - public void initAction() throws Exception { - robot = new Robot(); + public void initAction() throws MinorException + { + try + { + robot = new Robot(); + } + catch (AWTException e) + { + e.printStackTrace(); + throw new MinorException("Unable to start AWT Robot"); + } } @Override - public void onActionClicked() throws Exception + public void onActionClicked() throws MinorException { Property textBlockProperty = getClientProperties().getSingleProperty("text_block"); type(textBlockProperty.getStringValue()); } - public void type(String toType) throws Exception + public void type(String toType) { release(VK_CAPS_LOCK); release(VK_SHIFT); @@ -66,7 +77,7 @@ public class TextBlockAction extends Nor } private boolean isShiftOn = false; - public void pressAndReleaseKey(char c) throws Exception + public void pressAndReleaseKey(char c) { if(Character.isUpperCase(c)) { @@ -189,11 +200,5 @@ public class TextBlockAction extends Nor { robot.keyRelease(keyCode); } - - @Override - public void onShutDown() throws Exception { - // TODO Auto-generated method stub - - } } --- 'a/textblockaction/src/main/java/module-info.java' +++ b/textblockaction/src/main/java/module-info.java @@ -1,6 +1,5 @@ -import com.stream_pi.textblockaction.TextBlockAction; - -module com.stream_pi.textblockaction { +module com.stream_pi.textblockaction +{ requires com.stream_pi.action_api; requires com.stream_pi.util; @@ -9,6 +8,5 @@ module com.stream_pi.textblockaction { requires java.desktop; - provides com.stream_pi.action_api.externalplugin.ExternalPlugin with TextBlockAction; - + provides com.stream_pi.action_api.externalplugin.ExternalPlugin with com.stream_pi.textblockaction.TextBlockAction; } \ No newline at end of file