All Projects → ChristopheCVB → TouchPortalPluginSDK

ChristopheCVB / TouchPortalPluginSDK

Licence: GPL-3.0 license
This Project is an SDK to create a Touch Portal Plugin using Java or Kotlin and Gradle

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
kotlin
9241 projects

Projects that are alternatives of or similar to TouchPortalPluginSDK

AnnotationProcessorStarter
Project to set up basics of a Java annotation processor
Stars: ✭ 19 (-40.62%)
Mutual labels:  annotations, annotations-processor
serde with
This crate provides custom de/serialization helpers to use in combination with serde's `with`-annotation and with the improved `serde_as`-annotation.
Stars: ✭ 392 (+1125%)
Mutual labels:  annotations
Labelimg
🖍️ LabelImg is a graphical image annotation tool and label object bounding boxes in images
Stars: ✭ 16,088 (+50175%)
Mutual labels:  annotations
Scan2cad
[CVPR'19] Dataset and code used in the research project Scan2CAD: Learning CAD Model Alignment in RGB-D Scans
Stars: ✭ 249 (+678.13%)
Mutual labels:  annotations
Koro1fileheader
VSCode插件:自动生成,自动更新VSCode文件头部注释, 自动生成函数注释并支持提取函数参数,支持所有主流语言,文档齐全,使用简单,配置灵活方便,持续维护多年。
Stars: ✭ 3,137 (+9703.13%)
Mutual labels:  annotations
Yolo-to-COCO-format-converter
Yolo to COCO annotation format converter
Stars: ✭ 176 (+450%)
Mutual labels:  annotations
Convalida
A simple, lightweight and powerful field validation library for Android.
Stars: ✭ 201 (+528.13%)
Mutual labels:  annotations
GEAN
This toolkit deals with GEnomic sequence and genome structure ANnotation files between inbreeding lines and species.
Stars: ✭ 36 (+12.5%)
Mutual labels:  annotations
attributes
PHP Attributes Reader. Subtree split of the Spiral Attributes component (see spiral/framework)
Stars: ✭ 22 (-31.25%)
Mutual labels:  annotations
Cocostuff10k
The official homepage of the (outdated) COCO-Stuff 10K dataset.
Stars: ✭ 248 (+675%)
Mutual labels:  annotations
Annotation tools
Visipedia Annotation Tools
Stars: ✭ 245 (+665.63%)
Mutual labels:  annotations
React Tater
A React component to add annotations to any element on a page 🥔
Stars: ✭ 235 (+634.38%)
Mutual labels:  annotations
controller-logger
AOP based API logging for Spring Boot
Stars: ✭ 57 (+78.13%)
Mutual labels:  annotations
Awesome Data Annotation
A list of tools for annotating data, managing annotations, etc.
Stars: ✭ 204 (+537.5%)
Mutual labels:  annotations
Library-Spring
The library web application where you can borrow books. It's Spring MVC and Hibernate project.
Stars: ✭ 73 (+128.13%)
Mutual labels:  annotations
React Image Annotation
An infinitely customizable image annotation library built on React
Stars: ✭ 203 (+534.38%)
Mutual labels:  annotations
Each
A macro library that converts native imperative syntax to scalaz's monadic expressions
Stars: ✭ 245 (+665.63%)
Mutual labels:  annotations
stylelint-problem-matcher
A GitHub Action that registers a problem matcher for Stylelint's report format
Stars: ✭ 18 (-43.75%)
Mutual labels:  annotations
obsidian-hypothesis-plugin
An Obsidian.md plugin that syncs highlights from Hypothesis.
Stars: ✭ 164 (+412.5%)
Mutual labels:  annotations
boost-reflection
This library provides Java-like Reflection API to C++ language.
Stars: ✭ 16 (-50%)
Mutual labels:  annotations

Touch Portal Plugin SDK

Touch Portal Plugin SDK

Build, Coverage and Publish Release Build and Publish Snapshot Code Coverage Language gradle: Java

This Project is an SDK to create a Touch Portal Plugin using Java or Kotlin and Gradle. This SDK is a complete solution which will not only help you connect to communicate with TouchPortal through Actions, Events, States, Settings and Connectors, but it will also help you with the hassle of packaging it

For further reference, the Touch Portal Plugin documentation can be found here

Documentation

Once you have cloned this project, you can run the gradlew javaDoc and browse the document in the build/docs/javadoc of each module

Releases

Latest is 8.0.0

Go to releases

Maven Central

Latest version is 8.0.0

Prior versions were not published to Maven Central

Gradle

plugins {
  id 'com.christophecvb.touchportal.plugin-packager' version '8.0.0'
}

dependencies {
  implementation 'com.christophecvb.touchportal:plugin-sdk:8.0.0'
  annotationProcessor 'com.christophecvb.touchportal:plugin-sdk-annotations-processor:8.0.0'
}

Get Started

  • Create a new Gradle Java Project
  • Copy the build.gradle from the SampleJava or SampleKotlin module to your new module
    • Edit the properties mainClassPackage and mainClassSimpleName
    • Replace versionName by your plugin version ('1.0.0' for example)
    • Replace the dependencies to get the latest Maven Central ones
  • Create a class (mainClassSimpleName's value), in the package you chose (mainClassPackage's value), extending TouchPortalPlugin and implementing TouchPortalPlugin.TouchPortalPluginListener (i.e. MyTouchPortalPlugin extends TouchPortalPlugin implements TouchPortalPlugin.TouchPortalPluginListener) like the example below:
public class MyTouchPortalPlugin extends TouchPortalPlugin implements TouchPortalPlugin.TouchPortalPluginListener {
    /**
     * Logger
     */
    private final static Logger LOGGER = Logger.getLogger(TouchPortalPlugin.class.getName());
    
    /**
     * Constructor calling super
     */
    public MyTouchPortalPlugin() {
        super(true);// true is for paralleling Actions executions
    }

    public static void main(String... args) {
        if (args != null && args.length == 1) {
            if (PluginHelper.COMMAND_START.equals(args[0])) {
                // Initialize your Plugin
                MyTouchPortalPlugin myTouchPortalPlugin = new MyTouchPortalPlugin();
                // Initiate the connection with the Touch Portal Plugin System (will trigger an onInfo message with a confirmation from TouchPortal and the initial settings)
                boolean connectedPairedAndListening = myTouchPortalPlugin.connectThenPairAndListen(myTouchPortalPlugin);
            }
        }
    }

    /**
     * Called when the Socket connection is lost or the plugin has received the close Message
     */
    public void onDisconnected(Exception exception) {  }

    /**
     * Called when receiving a message from the Touch Portal Plugin System
     */
    public void onReceived(JsonObject jsonMessage) { }

    /**
     * Called when the Info Message is received when Touch Portal confirms our initial connection is successful
     */
    public void onInfo(TPInfoMessage tpInfoMessage) { }

    /**
     * Called when a List Change Message is received
     */
    public void onListChanged(TPListChangeMessage tpListChangeMessage) { }

    /**
     * Called when a Broadcast Message is received
     */
    public void onBroadcast(TPBroadcastMessage tpBroadcastMessage) { }

    /**
     * Called when a Settings Message is received
     */
    public void onSettings(TPSettingsMessage tpSettingsMessage) { }

  /**
   * Called when a Notification Option Clicked Message is received
   */
  public void onNotificationOptionClicked(TPNotificationOptionClickedMessage tpNotificationOptionClickedMessage) {}
}

Development and Interaction

  • The SDK will automatically callback your action methods if they only contain @Data annotated parameters
public class MyTouchPortalPlugin extends TouchPortalPlugin implements TouchPortalPlugin.TouchPortalPluginListener {
    // ...

    /**
     * Action example with a Data Text parameter
     *
     * @param text String
     */
    @Action(description = "Long Description of Dummy Action with Data Text", format = "Set text to {$text$}", categoryId = "BaseCategory")
    private void actionWithText(@Data String text) {
        TouchPortalSamplePlugin.LOGGER.log(Level.INFO, "Action actionWithText received: " + text);
    }
    
    // ...
}
  • Otherwise, call your actions manually in the onReceived(JsonObject jsonMessage) method
public class MyTouchPortalPlugin extends TouchPortalPlugin implements TouchPortalPlugin.TouchPortalPluginListener {
    // ...
  
    public void onReceived(JsonObject jsonMessage) {
        // Check if ReceiveMessage is an Action
        if (ReceivedMessageHelper.isTypeAction(jsonMessage)) {
            // Get the Action ID
            String receivedActionId = ReceivedMessageHelper.getActionId(jsonMessage);
            if (receivedActionId != null) {
                // Manually call the action methods which not all parameters are annotated with @Data
                switch (receivedActionId) {
                    // case ...:
                    // break;
                }
            }
        }
    }
    
    //...
}
  • Don't forget to initialize all your services once you receive the onInfo event. The TPInfoMessage will also contain the initial values of your settings.
public class MyTouchPortalPlugin extends TouchPortalPlugin implements TouchPortalPlugin.TouchPortalPluginListener {
    // ...
  
    public void onInfo(TPInfoMessage tpInfoMessage) {
        // TPInfoMessage will contain the initial settings stored by TP
        // -> Note that your annotated Settings fields will be up to date at this point
      
        // continue plugin initialization
    }
    
    // ...
}
  • Finally, send messages back to TouchPortal when you want to update your states
public class MyTouchPortalPlugin extends TouchPortalPlugin implements TouchPortalPlugin.TouchPortalPluginListener {
    // ...
  
    @State(defaultValue = "Default Value", categoryId = "SecondCategory")
    private String customStateText;
  
    @Action(description = "Long Description of Dummy Action with Data Text", format = "Set text to {$text$}", categoryId = "BaseCategory")
    private void actionWithText(@Data String text) {
      // ... do something then update state
      this.customStateText = "new state value";
      this.sendStateUpdate(MyTouchPortalPluginConstants.BaseCategory.States.CustomStateText.ID, this.customStateText, true);
    }
    
    // ...
}

Use Annotations to describe your plugin and package it

  • The provided Annotations help you in the automatic generation of the entry.tp file (necessary for packaging and deployment of your plugin)
  • Current supported annotations include: Plugin, Category, Action, Data, State, Event and Setting
  • More examples can be found in the sample modules
// ...

@Plugin(version = BuildConfig.VERSION_CODE, colorDark = "#203060", colorLight = "#4070F0", name = "My Touch Portal Plugin")
public class MyTouchPortalPlugin extends TouchPortalPlugin {
    //...

    /**
     * Action example that contains a dynamic data text
     *
     * @param text String
     */
    @Action(description = "Long Description of Dummy Action with Data", format = "Set text to {$text$}", categoryId = "BaseCategory")
    private void dummyWithData(@Data String text) {
        LOGGER.log(Level.Info, "Action dummyWithData received: " + text);
    }

    /**
     * State and Event definition example
     */
    @State(defaultValue = "1", categoryId = "BaseCategory")
    @Event(valueChoices = {"1", "2"}, format = "When customStateWithEvent becomes $val")
    private String customStateWithEvent;

    private enum Categories {
        /**
         * Category definition example
         */
        @Category(name = "My Touch Portal Plugin", imagePath = "images/icon-24.png")
        BaseCategory
    }

    //...
}

Prepackaging

  • Add the Plugin icon and extra resources into the src/main/resources/ directory of your module

Build

  • Use the common gradlew clean task to clean your build directories.
  • Use the common gradlew build task to build your project with the Annotations.
  • Use the gradlew packagePlugin task to pack your plugin into a .tpp file. Output files will be in your module build/plugin directory.

Debugging tips

  • A clean Touch Portal installation won't accept plugin connections by default. You need to install your plugin first on TouchPortal to 'jumpstart' the Plugin listening service and then restart Touch Portal.
  • Using IntelliJ, you can also create a Configuration to start and debug the plugin right from the IDE
    • Run > Edit Configurations
    • Add New Configuration (+)
    • Select Application
      • Name: TPP Start
      • Module: Java 8 (1.8)
      • ClassPath Module (-cp): YourModule.main
      • Main Class: your.package.YourTouchPortalPlugin
      • Arguments: start
      • Working Directory: YourModule/build/plugin/YourTouchPortalPlugin Touch Portal Plugin SDK Gradle Application Configuration

ROADMAP

The roadmap can be found here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].