essential-actions

Clone or download

[Text Block Action] Cleanup, Refactored, Updated to work with new Action API

Modified Files

--- '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 @@
<groupId>com.stream-pi</groupId>
<artifactId>textblockaction</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1</version>
<build>
<plugins>
@@ -40,14 +40,9 @@
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
- <JavaFXVersion>16-ea+4</JavaFXVersion>
-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
-
- <IkonliVersion>11.5.0</IkonliVersion>
- <IkonliFA5PackVersion>11.5.0</IkonliFA5PackVersion>
</properties>
<dependencies>
@@ -62,17 +57,5 @@
<artifactId>action-api</artifactId>
<version>${ActionAPIVersion}</version>
</dependency>
-
- <dependency>
- <groupId>org.kordamp.ikonli</groupId>
- <artifactId>ikonli-fontawesome5-pack</artifactId>
- <version>${IkonliFA5PackVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>org.kordamp.ikonli</groupId>
- <artifactId>ikonli-javafx</artifactId>
- <version>${IkonliVersion}</version>
- </dependency>
</dependencies>
</project>
\ 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