Rework ThingActions (#8755)

* Remove duplication by making use of default Java generated exceptions
* Make ThingActions labels/descriptions more consistent

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2020-10-15 10:53:53 +02:00
committed by GitHub
parent aef1d10f40
commit 978e122e00
40 changed files with 305 additions and 785 deletions

View File

@@ -281,83 +281,43 @@ public class LGWebOSActions implements ThingActions {
// delegation methods for "legacy" rule support
public static void showToast(@Nullable ThingActions actions, String text) throws IOException {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).showToast(text);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void showToast(ThingActions actions, String text) throws IOException {
((LGWebOSActions) actions).showToast(text);
}
public static void showToast(@Nullable ThingActions actions, String icon, String text) throws IOException {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).showToast(icon, text);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void showToast(ThingActions actions, String icon, String text) throws IOException {
((LGWebOSActions) actions).showToast(icon, text);
}
public static void launchBrowser(@Nullable ThingActions actions, String url) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).launchBrowser(url);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void launchBrowser(ThingActions actions, String url) {
((LGWebOSActions) actions).launchBrowser(url);
}
public static void launchApplication(@Nullable ThingActions actions, String appId) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).launchApplication(appId);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void launchApplication(ThingActions actions, String appId) {
((LGWebOSActions) actions).launchApplication(appId);
}
public static void launchApplication(@Nullable ThingActions actions, String appId, String param) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).launchApplication(appId, param);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void launchApplication(ThingActions actions, String appId, String param) {
((LGWebOSActions) actions).launchApplication(appId, param);
}
public static void sendText(@Nullable ThingActions actions, String text) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).sendText(text);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void sendText(ThingActions actions, String text) {
((LGWebOSActions) actions).sendText(text);
}
public static void sendButton(@Nullable ThingActions actions, String button) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).sendButton(button);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void sendButton(ThingActions actions, String button) {
((LGWebOSActions) actions).sendButton(button);
}
public static void increaseChannel(@Nullable ThingActions actions) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).increaseChannel();
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void increaseChannel(ThingActions actions) {
((LGWebOSActions) actions).increaseChannel();
}
public static void decreaseChannel(@Nullable ThingActions actions) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).decreaseChannel();
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void decreaseChannel(ThingActions actions) {
((LGWebOSActions) actions).decreaseChannel();
}
public static void sendRCButton(@Nullable ThingActions actions, String rcButton) {
if (actions instanceof LGWebOSActions) {
((LGWebOSActions) actions).sendRCButton(rcButton);
} else {
throw new IllegalArgumentException("Actions is not an instance of LGWebOSActions");
}
public static void sendRCButton(ThingActions actions, String rcButton) {
((LGWebOSActions) actions).sendRCButton(rcButton);
}
}

View File

@@ -1,45 +1,45 @@
actionShowToastLabel=Show Toast
actionShowToastLabel=show a toast message
actionShowToastDesc=Sends a toast message to a WebOS device with openHAB icon.
actionShowToastInputTextLabel=Text
actionShowToastInputTextDesc=The text to display
actionShowToastWithIconLabel=Show Toast with Icon
actionShowToastWithIconLabel=show a toast message with icon
actionShowToastWithIconLabel=Sends a toast message to a WebOS device with custom icon.
actionShowToastInputIconLabel=Icon
actionShowToastInputIconDesc=The URL to the icon to display
actionLaunchBrowserLabel=Launch Browser
actionLaunchBrowserLabel=launch the browser
actionLaunchBrowserDesc=Opens the given URL in the TV's browser application.
actionLaunchBrowserInputUrlLabel=URL
actionLaunchBrowserInputUrlDesc=The URL to open
actionLaunchApplicationLabel=Launch Application
actionLaunchApplicationLabel=launch an application
actionLaunchApplicationDesc=Opens the application with given Application ID.
actionLaunchApplicationInputAppIDLabel=Application ID
actionLaunchApplicationInputAppIDDesc=The Application ID
actionLaunchApplicationWithParamsLabel=Launch Application with Parameters
actionLaunchApplicationWithParamsLabel=launch an application with parameters
actionLaunchApplicationWithParamsDesc=Opens the application with given Application ID and passes additional parameters.
actionLaunchApplicationInputParamsLabel=JSON Parameters
actionLaunchApplicationInputParamsDesc=The parameters to hand over to the application in JSON format
actionSendTextLabel=Send Text
actionSendTextLabel=send a text input
actionSendTextDesc=Sends a text input to a WebOS device.
actionSendTextInputTextLabel=Text
actionSendTextInputTextDesc=The text to input
actionSendButtonLabel=Send Button
actionSendButtonLabel=send a button press
actionSendButtonDesc=Sends a button press event to a WebOS device.
actionSendButtonInputButtonLabel=Button
actionSendButtonInputButtonDesc=Can be one of UP, DOWN, LEFT, RIGHT, BACK, DELETE, ENTER, HOME, or OK
actionIncreaseChannelLabel=Channel Up
actionIncreaseChannelLabel=switch one channel up
actionIncreaseChannelDesc=TV will switch one channel up in the current channel list.
actionDecreaseChannelLabel=Channel Down
actionDecreaseChannelLabel=switch one channel down
actionDecreaseChannelDesc=TV will switch one channel down in the current channel list.
actionSendRCButtonLabel=Remote Control button press
actionSendRCButtonLabel=simulate remote control button press
actionSendRCButtonDesc=Simulates pressing of a Remote Control Button.
actionSendRCButtonInputTextLabel=Remote Control button name
actionSendRCButtonInputTextDesc=The Remote Control button name to send to the WebOS device.