From: Debayan Sutradhar Date: Tue, 01 Jun 2021 00:30:30 +0530 Subject: [Twitter Action] - Cleanup, Updated to work with new Action API --- [Twitter Action] - Cleanup, Updated to work with new Action API --- --- 'a/twitteraction/pom.xml' +++ b/twitteraction/pom.xml @@ -6,7 +6,7 @@ com.stream-pi twitteraction - 1.0.1 + 1.0.2 @@ -40,27 +40,17 @@ 1.0.0-SNAPSHOT 1.0.0-SNAPSHOT - 16-ea+5 - + 4.0.7 UTF-8 11 11 - - 11.5.0 - 11.5.0 org.twitter4j twitter4j-core - 4.0.7 - - - - org.openjfx - javafx-controls - ${JavaFXVersion} + ${Twitter4JVersion} @@ -74,17 +64,5 @@ action-api ${ActionAPIVersion} - - - org.kordamp.ikonli - ikonli-fontawesome5-pack - ${IkonliFA5PackVersion} - - - - org.kordamp.ikonli - ikonli-javafx - ${IkonliVersion} - \ No newline at end of file --- 'a/twitteraction/src/main/java/com/stream_pi/twitteraction/TwitterAction.java' +++ b/twitteraction/src/main/java/com/stream_pi/twitteraction/TwitterAction.java @@ -7,6 +7,7 @@ import com.stream_pi.action_api.external import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertListener; import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.uihelper.HBoxInputBox; import com.stream_pi.util.version.Version; import javafx.application.Platform; @@ -18,12 +19,15 @@ import javafx.scene.control.TextField; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import twitter4j.Twitter; +import twitter4j.TwitterException; import twitter4j.TwitterFactory; import twitter4j.auth.AccessToken; import twitter4j.auth.RequestToken; import twitter4j.conf.ConfigurationBuilder; -public class TwitterAction extends NormalAction { + +public class TwitterAction extends NormalAction +{ Button loginAsNewUserButton, logoutButton; @@ -34,7 +38,7 @@ public class TwitterAction extends Norma setAuthor("rnayabed"); setServerButtonGraphic("fab-twitter"); setHelpLink("https://github.com/stream-pi/essentialactions"); - setVersion(new Version(1,0,1)); + setVersion(new Version(1,0,2)); loginAsNewUserButton = new Button("Login as new user"); @@ -98,7 +102,7 @@ public class TwitterAction extends Norma } @Override - public void initProperties() throws Exception + public void initProperties() throws MinorException { Property oAuthConsumerKey = new Property("consumer_key", Type.STRING); oAuthConsumerKey.setDisplayName("API Key"); @@ -234,9 +238,8 @@ public class TwitterAction extends Norma TwitterFactory tf; @Override - public void initAction() throws Exception { - //System.setProperty("twitter4j.http.useSSL", "true"); - + public void initAction() throws MinorException + { setNewTwitterConfig( getServerProperties().getSingleProperty("consumer_key").getStringValue(), getServerProperties().getSingleProperty("consumer_key_secret").getStringValue(), @@ -259,20 +262,25 @@ public class TwitterAction extends Norma } @Override - public void onActionClicked() throws Exception { + public void onActionClicked() throws MinorException + { Twitter twitter = tf.getInstance(); - twitter.updateStatus(getClientProperties().getSingleProperty("tweet").getStringValue()); + try + { + twitter.updateStatus( + getClientProperties().getSingleProperty("tweet").getStringValue() + ); + } catch (TwitterException e) + { + e.printStackTrace(); + throw new MinorException("Unable to update Twitter : "+e.getMessage()); + } } - /*public String addRandomBlank(String value) + /* + TOP SECRET - If you found this then congrats :D (you probably know why) + public String getRandomBlanks() { - return value+("⠀".repeat(new Random().nextInt(100))); + return "⠀".repeat(new Random().nextInt(100)); }*/ - - @Override - public void onShutDown() throws Exception { - // TODO Auto-generated method stub - - } - } --- 'a/twitteraction/src/main/java/module-info.java' +++ b/twitteraction/src/main/java/module-info.java @@ -1,4 +1,5 @@ -module com.stream_pi.twitteraction { +module com.stream_pi.twitteraction +{ requires com.stream_pi.action_api; requires com.stream_pi.util;