client
Clone or download
Modified Files
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>client</artifactId>
<artifactId>client</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<url>https://stream-pi.com/</url>
<url>https://stream-pi.com/</url>
<properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>17-ea+8</javafx.version>
<javafx.version>17-ea+8</javafx.version>
<javafx.scope>compile</javafx.scope>
<javafx.scope>compile</javafx.scope>
<javafx.systemPath>/opt/javafx-17-sdk/lib</javafx.systemPath>
<javafx.systemPath>/opt/javafx-17-sdk/lib</javafx.systemPath>
<javafx.drm.egl.lib.path>/home/rnayabed/openjfx/javafx-sdk-17/lib/libgluon_drm-1.1.3.so</javafx.drm.egl.lib.path>
<javafx.drm.egl.lib.path>/home/rnayabed/openjfx/javafx-sdk-17/lib/libgluon_drm-1.1.3.so</javafx.drm.egl.lib.path>
<javafx.drm.display.card>/dev/dri/card0</javafx.drm.display.card>
<javafx.drm.display.card>/dev/dri/card0</javafx.drm.display.card>
<client.plugin.version>0.1.40-SNAPSHOT</client.plugin.version>
<client.plugin.version>0.1.40-SNAPSHOT</client.plugin.version>
<ikonli.version>11.5.0</ikonli.version>
<ikonli.version>11.5.0</ikonli.version>
<action.api.version>1.0.0-SNAPSHOT</action.api.version>
<action.api.version>1.0.0-SNAPSHOT</action.api.version>
<util.version>1.0.0-SNAPSHOT</util.version>
<util.version>1.0.0-SNAPSHOT</util.version>
<theme.api.version>1.0.0-SNAPSHOT</theme.api.version>
<theme.api.version>1.0.0-SNAPSHOT</theme.api.version>
<attach.version>4.0.11</attach.version>
<attach.version>4.0.11</attach.version>
<main.class.name>com.stream_pi.client.Main</main.class.name>
<main.class.name>com.stream_pi.client.Main</main.class.name>
<source.plugin.version>2.2.1</source.plugin.version>
<source.plugin.version>2.2.1</source.plugin.version>
<javadoc.plugin.version>3.1.0</javadoc.plugin.version>
<javadoc.plugin.version>3.1.0</javadoc.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>org.openjfx</groupId>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
<version>${javafx.version}</version>
<!--scope>${javafx.scope}</scope>
<!--scope>${javafx.scope}</scope>
<systemPath>${javafx.systemPath}/javafx.controls.jar</systemPath-->
<systemPath>${javafx.systemPath}/javafx.controls.jar</systemPath-->
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.openjfx</groupId>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<artifactId>javafx-base</artifactId>
<version>${javafx.version}</version>
<version>${javafx.version}</version>
<!--scope>${javafx.scope}</scope>
<!--scope>${javafx.scope}</scope>
<systemPath>${javafx.systemPath}/javafx.base.jar</systemPath-->
<systemPath>${javafx.systemPath}/javafx.base.jar</systemPath-->
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.openjfx</groupId>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
<version>${javafx.version}</version>
<!--scope>${javafx.scope}</scope>
<!--scope>${javafx.scope}</scope>
<systemPath>${javafx.systemPath}/javafx.graphics.jar</systemPath-->
<systemPath>${javafx.systemPath}/javafx.graphics.jar</systemPath-->
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-fontawesome5-pack</artifactId>
<artifactId>ikonli-fontawesome5-pack</artifactId>
<version>${ikonli.version}</version>
<version>${ikonli.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<artifactId>ikonli-javafx</artifactId>
<version>${ikonli.version}</version>
<version>${ikonli.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>action-api</artifactId>
<artifactId>action-api</artifactId>
<version>${action.api.version}</version>
<version>${action.api.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>theme-api</artifactId>
<artifactId>theme-api</artifactId>
<version>${theme.api.version}</version>
<version>${theme.api.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
<artifactId>util</artifactId>
<version>${util.version}</version>
<version>${util.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
<version>${attach.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<groupId>com.gluonhq.attach</groupId>
<artifactId>util</artifactId>
<artifactId>util</artifactId>
<version>${attach.version}</version>
<version>${attach.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<groupId>com.gluonhq.attach</groupId>
<artifactId>orientation</artifactId>
<artifactId>orientation</artifactId>
<version>${attach.version}</version>
<version>${attach.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
<version>${attach.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<groupId>com.gluonhq.attach</groupId>
<artifactId>browser</artifactId>
<artifactId>browser</artifactId>
<version>${attach.version}</version>
<version>${attach.version}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<groupId>com.gluonhq.attach</groupId>
<artifactId>vibration</artifactId>
<artifactId>vibration</artifactId>
<version>${attach.version}</version>
<version>${attach.version}</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
<repositories>
<repositories>
<repository>
<repository>
<id>gluon-releases</id>
<id>gluon-releases</id>
<url>http://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
<url>http://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
</repository>
</repository>
<repository>
<repository>
<id>sonatype-snapshot</id>
<id>sonatype-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repository>
</repositories>
</repositories>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.8.1</version>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.openjfx</groupId>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.5</version>
<version>0.0.5</version>
<configuration>
<configuration>
<commandlineArgs>-DStream-Pi.defaultFullScreenMode=true</commandlineArgs>
<commandlineArgs>-DStream-Pi.defaultFullScreenMode=false</commandlineArgs>
<options>
<options>
<option>-Dglass.gtk.uiScale=1.0</option>
<option>-Dglass.gtk.uiScale=1.0</option>
<option>-Dprism.verbose=true</option>
<option>-Dprism.verbose=true</option>
<option>-Djavafx.verbose=true</option>
<option>-Djavafx.verbose=true</option>
<option>-Dprism.forceGPU=true</option>
<option>-Dprism.forceGPU=true</option>
</options>
</options>
<stripDebug>true</stripDebug>
<stripDebug>true</stripDebug>
<compress>2</compress>
<compress>2</compress>
<noHeaderFiles>true</noHeaderFiles>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
<noManPages>true</noManPages>
<mainClass>${main.class.name}</mainClass>
<mainClass>${main.class.name}</mainClass>
<!--options>${additional.javafx.plugin.options}</options-->
<!--options>${additional.javafx.plugin.options}</options-->
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<groupId>com.gluonhq</groupId>
<artifactId>client-maven-plugin</artifactId>
<artifactId>client-maven-plugin</artifactId>
<version>${client.plugin.version}</version>
<version>${client.plugin.version}</version>
<configuration>
<configuration>
<target>${client.target}</target>
<target>${client.target}</target>
<verbose>true</verbose>
<verbose>true</verbose>
<nativeImageArgs>
<nativeImageArgs>
<list>--initialize-at-build-time=com.sun.org.apache.xml.internal.serializer.ToXMLStream</list>
<list>--initialize-at-build-time=com.sun.org.apache.xml.internal.serializer.ToXMLStream</list>
<list>${additional.native.client.args}</list>
<list>${additional.native.client.args}</list>
</nativeImageArgs>
</nativeImageArgs>
<bundlesList>
<bundlesList>
<list>com.sun.org.apache.xerces.internal.impl.msg.XMLMessages</list>
<list>com.sun.org.apache.xerces.internal.impl.msg.XMLMessages</list>
</bundlesList>
</bundlesList>
<attachList>
<attachList>
<list>lifecycle</list>
<list>lifecycle</list>
<list>storage</list>
<list>storage</list>
<list>browser</list>
<list>browser</list>
<list>vibration</list>
<list>vibration</list>
<list>orientation</list>
<list>orientation</list>
</attachList>
</attachList>
<reflectionList>
<reflectionList>
<list>java.util.logging.FileHandler</list>
<list>java.util.logging.FileHandler</list>
<list>com.stream_pi.client.window.settings.About.Contributor</list>
<list>com.stream_pi.client.window.settings.About.Contributor</list>
<list>javafx.scene.control.TableColumnBase</list>
<list>javafx.scene.control.TableColumnBase</list>
</reflectionList>
</reflectionList>
<mainClass>${main.class.name}</mainClass>
<mainClass>${main.class.name}</mainClass>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.0</version>
<configuration>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>
</plugins>
</build>
</build>
<pluginRepositories>
<pluginRepositories>
<pluginRepository>
<pluginRepository>
<id>gluon-releases</id>
<id>gluon-releases</id>
<url>http://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
<url>http://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
</pluginRepository>
</pluginRepository>
<pluginRepository>
<pluginRepository>
<id>gluon-snapshots</id>
<id>gluon-snapshots</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/public-snapshots</url>
<url>https://nexus.gluonhq.com/nexus/content/repositories/public-snapshots</url>
</pluginRepository>
</pluginRepository>
<pluginRepository>
<pluginRepository>
<id>Sonatype</id>
<id>Sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepository>
</pluginRepositories>
</pluginRepositories>
<profiles>
<profiles>
<profile>
<profile>
<id>android</id>
<id>android</id>
<properties>
<properties>
<client.target>android</client.target>
<client.target>android</client.target>
<additional.native.client.args>-Dsvm.targetName=android</additional.native.client.args>
<additional.native.client.args>-Dsvm.targetName=android</additional.native.client.args>
</properties>
</properties>
</profile>
</profile>
<profile>
<profile>
<id>ios</id>
<id>ios</id>
<properties>
<properties>
<client.target>ios</client.target>
<client.target>ios</client.target>
<additional.native.client.args>-Dsvm.targetName=iOS</additional.native.client.args>
<additional.native.client.args>-Dsvm.targetName=iOS</additional.native.client.args>
</properties>
</properties>
</profile>
</profile>
<profile>
<profile>
<id>linux-aarch64</id>
<id>linux-aarch64</id>
<properties>
<properties>
<client.target>linux-aarch64</client.target>
<client.target>linux-aarch64</client.target>
<additional.native.client.args>-Dsvm.targetName=Linux</additional.native.client.args>
<additional.native.client.args>-Dsvm.targetName=Linux</additional.native.client.args>
</properties>
</properties>
</profile>
</profile>
<profile>
<profile>
<id>linux-x86_64</id>
<id>linux-x86_64</id>
<properties>
<properties>
<client.target>host</client.target>
<client.target>host</client.target>
<additional.native.client.args>-Dsvm.targetName=Linux</additional.native.client.args>
<additional.native.client.args>-Dsvm.targetName=Linux</additional.native.client.args>
</properties>
</properties>
</profile>
</profile>
<profile>
<profile>
<id>windows-x86_64</id>
<id>windows-x86_64</id>
<properties>
<properties>
<client.target>host</client.target>
<client.target>host</client.target>
<additional.native.client.args>-Dsvm.targetName=Linux</additional.native.client.args>
<additional.native.client.args>-Dsvm.targetName=Linux</additional.native.client.args>
</properties>
</properties>
</profile>
</profile>
<!--profile>
<!--profile>
<id>ARM-DRM</id>
<id>ARM-DRM</id>
<properties>
<properties>
<additional.javafx.plugin.options>
<additional.javafx.plugin.options>
<option>-Dmonocle.platform=EGL</option>
<option>-Dmonocle.platform=EGL</option>
<option>-Dembedded=monocle</option>
<option>-Dembedded=monocle</option>
<option>-Dglass.platform=Monocle</option>
<option>-Dglass.platform=Monocle</option>
<option>-Degl.displayid=${javafx.drm.display.card}</option>
<option>-Degl.displayid=${javafx.drm.display.card}</option>
<option>-Dmonocle.egl.lib=${javafx.drm.egl.lib.path}</option>
<option>-Dmonocle.egl.lib=${javafx.drm.egl.lib.path}</option>
<option>-Dprism.verbose=true</option>
<option>-Dprism.verbose=true</option>
</additional.javafx.plugin.options>
</additional.javafx.plugin.options>
</properties>
</properties>
</profile-->
</profile-->
<profile>
<profile>
<id>release</id>
<id>release</id>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<version>2.2.1</version>
<executions>
<executions>
<execution>
<execution>
<id>attach-sources</id>
<id>attach-sources</id>
<goals>
<goals>
<goal>jar-no-fork</goal>
<goal>jar-no-fork</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<version>${javadoc.plugin.version}</version>
<executions>
<executions>
<execution>
<execution>
<id>attach-javadocs</id>
<id>attach-javadocs</id>
<goals>
<goals>
<goal>jar</goal>
<goal>jar</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
<configuration>
<configuration>
<source>8</source>
<source>8</source>
</configuration>
</configuration>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${gpg.plugin.version}</version>
<version>${gpg.plugin.version}</version>
<executions>
<executions>
<execution>
<execution>
<id>sign-artifacts</id>
<id>sign-artifacts</id>
<phase>verify</phase>
<phase>verify</phase>
<goals>
<goals>
<goal>sign</goal>
<goal>sign</goal>
</goals>
</goals>
<configuration>
<configuration>
<gpgArguments>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
<arg>loopback</arg>
</gpgArguments>
</gpgArguments>
</configuration>
</configuration>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
</profile>
</profile>
</profiles>
</profiles>
<organization>
<organization>
<name>Stream Pi</name>
<name>Stream Pi</name>
<url>https://www.stream-pi.com</url>
<url>https://www.stream-pi.com</url>
</organization>
</organization>
<issueManagement>
<issueManagement>
<system>GitHub</system>
<system>GitHub</system>
<url>https://github.com/Stream-Pi/client/issues</url>
<url>https://github.com/Stream-Pi/client/issues</url>
</issueManagement>
</issueManagement>
<licenses>
<licenses>
<license>
<license>
<name>GPL-3.0 License</name>
<name>GPL-3.0 License</name>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
<distribution>repo</distribution>
<distribution>repo</distribution>
</license>
</license>
</licenses>
</licenses>
<developers>
<developers>
<developer>
<developer>
<name>Debayan Sutradhar</name>
<name>Debayan Sutradhar</name>
<email>debayansutradhar3@gmail.com</email>
<email>debayansutradhar3@gmail.com</email>
<organization>Stream-Pi</organization>
<organization>Stream-Pi</organization>
<organizationUrl>https://www.stream-pi.com</organizationUrl>
<organizationUrl>https://www.stream-pi.com</organizationUrl>
</developer>
</developer>
<developer>
<developer>
<name>Abhinay Agarwal</name>
<name>Abhinay Agarwal</name>
<email>abhinay_agarwal@live.com</email>
<email>abhinay_agarwal@live.com</email>
<organization>Stream-Pi</organization>
<organization>Stream-Pi</organization>
<organizationUrl>https://www.stream-pi.com</organizationUrl>
<organizationUrl>https://www.stream-pi.com</organizationUrl>
</developer>
</developer>
</developers>
</developers>
<scm>
<scm>
<url>https://github.com/stream-pi/client</url>
<url>https://github.com/stream-pi/client</url>
<connection>scm:git:git://github.com/stream-pi/client.git</connection>
<connection>scm:git:git://github.com/stream-pi/client.git</connection>
<developerConnection>scm:git:ssh://git@github.com:stream-pi/client.git</developerConnection>
<developerConnection>scm:git:ssh://git@github.com:stream-pi/client.git</developerConnection>
</scm>
</scm>
<distributionManagement>
<distributionManagement>
<snapshotRepository>
<snapshotRepository>
<id>ossrh</id>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</snapshotRepository>
<repository>
<repository>
<id>ossrh</id>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</repository>
</distributionManagement>
</distributionManagement>
</project>
</project>
package com.stream_pi.client.connection;
package com.stream_pi.client.connection;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.actionproperty.ClientProperties;
import com.stream_pi.action_api.actionproperty.ClientProperties;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.theme_api.Theme;
import com.stream_pi.theme_api.Theme;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.comms.Message;
import com.stream_pi.util.comms.Message;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.version.Version;
import com.stream_pi.util.version.Version;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import java.io.*;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class Client extends Thread
public class Client extends Thread
{
{
private Socket socket;
private Socket socket;
private ObjectOutputStream oos;
private ObjectOutputStream oos;
private ObjectInputStream ois;
private ObjectInputStream ois;
private AtomicBoolean stop = new AtomicBoolean(false);
private AtomicBoolean stop = new AtomicBoolean(false);
private ClientListener clientListener;
private ClientListener clientListener;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ClientInfo clientInfo;
private ClientInfo clientInfo;
private String serverIP;
private String serverIP;
private int serverPort;
private int serverPort;
private Logger logger;
private Logger logger;
private Runnable onConnectAndSetupToBeRun;
private Runnable onConnectAndSetupToBeRun;
public Client(String serverIP, int serverPort, ClientListener clientListener,
public Client(String serverIP, int serverPort, ClientListener clientListener,
ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun)
ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun)
{
{
this.serverIP = serverIP;
this.serverIP = serverIP;
this.serverPort = serverPort;
this.serverPort = serverPort;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.clientInfo = ClientInfo.getInstance();
this.clientInfo = ClientInfo.getInstance();
this.clientListener = clientListener;
this.clientListener = clientListener;
this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun;
this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun;
logger = Logger.getLogger(Client.class.getName());
logger = Logger.getLogger(Client.class.getName());
new Thread(new Task<Void>() {
new Thread(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try
try
{
{
try
try
{
{
logger.info("Trying to connect to server at "+serverIP+":"+serverPort);
logger.info("Trying to connect to server at "+serverIP+":"+serverPort);
socket = new Socket();
socket = new Socket();
socket.connect(new InetSocketAddress(serverIP, serverPort), 5000);
socket.connect(new InetSocketAddress(serverIP, serverPort), 5000);
clientListener.setConnected(true);
clientListener.setConnected(true);
clientListener.updateSettingsConnectDisconnectButton();
clientListener.updateSettingsConnectDisconnectButton();
logger.info("Connected to "+socket.getRemoteSocketAddress()+" !");
logger.info("Connected to "+socket.getRemoteSocketAddress()+" !");
}
}
catch (IOException e)
catch (IOException e)
{
{
e.printStackTrace();
e.printStackTrace();
clientListener.setConnected(false);
clientListener.setConnected(false);
clientListener.updateSettingsConnectDisconnectButton();
clientListener.updateSettingsConnectDisconnectButton();
throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again.");
throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again.");
}
}
try
try
{
{
oos = new ObjectOutputStream(socket.getOutputStream());
oos = new ObjectOutputStream(socket.getOutputStream());
ois = new ObjectInputStream(socket.getInputStream());
ois = new ObjectInputStream(socket.getInputStream());
}
}
catch (IOException e)
catch (IOException e)
{
{
logger.severe(e.getMessage());
logger.severe(e.getMessage());
e.printStackTrace();
e.printStackTrace();
throw new MinorException("Unable to set up io Streams to server. Check connection and try again.");
throw new MinorException("Unable to set up io Streams to server. Check connection and try again.");
}
}
start();
start();
} catch (MinorException e)
} catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
return null;
return null;
}
}
}).start();
}).start();
}
}
public synchronized void exit()
public synchronized void exit()
{
{
if(stop.get())
if(stop.get())
return;
return;
logger.info("Stopping ...");
logger.info("Stopping ...");
try
try
{
{
if(socket!=null)
if(socket!=null)
{
{
disconnect();
disconnect();
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
logger.severe(e.getMessage());
logger.severe(e.getMessage());
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public synchronized void sendMessage(Message message) throws SevereException
public synchronized void sendMessage(Message message) throws SevereException
{
{
try
try
{
{
oos.writeObject(message);
oos.writeObject(message);
oos.flush();
oos.flush();
}
}
catch (IOException e)
catch (IOException e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException("Unable to write to io Stream!");
throw new SevereException("Unable to write to io Stream!");
}
}
}
}
@Override
@Override
public void run() {
public void run() {
try
try
{
{
while(!stop.get())
while(!stop.get())
{
{
try
try
{
{
Message message = (Message) ois.readObject();
Message message = (Message) ois.readObject();
String header = message.getHeader();
String header = message.getHeader();
logger.info("Message Received. Heading : "+header);
logger.info("Message Received. Heading : "+header);
switch (header)
switch (header)
{
{
case "ready" : onServerReady();
case "ready" : onServerReady();
break;
break;
case "action_icon" : onActionIconReceived(message);
case "action_icon" : onActionIconReceived(message);
break;
break;
case "disconnect" : serverDisconnected(message);
case "disconnect" : serverDisconnected(message);
break;
break;
case "get_client_details" : sendClientDetails();
case "get_client_details" : sendClientDetails();
break;
break;
case "get_client_screen_details" : sendClientScreenDetails();
case "get_client_screen_details" : sendClientScreenDetails();
break;
break;
case "get_profiles" : sendProfileNamesToServer();
case "get_profiles" : sendProfileNamesToServer();
break;
break;
case "get_profile_details": sendProfileDetailsToServer(message);
case "get_profile_details": sendProfileDetailsToServer(message);
break;
break;
case "save_action_details": saveActionDetails(message);
case "save_action_details": saveActionDetails(message);
break;
break;
case "delete_action": deleteAction(message);
case "delete_action": deleteAction(message);
break;
break;
case "get_themes": sendThemesToServer();
case "get_themes": sendThemesToServer();
break;
break;
case "save_client_details": saveClientDetails(message);
case "save_client_details": saveClientDetails(message);
break;
break;
case "save_client_profile": saveProfileDetails(message);
case "save_client_profile": saveProfileDetails(message);
break;
break;
case "delete_profile": deleteProfile(message);
case "delete_profile": deleteProfile(message);
break;
break;
case "action_failed": actionFailed(message);
case "action_failed": actionFailed(message);
break;
break;
case "set_toggle_status": onSetToggleStatus(message);
case "set_toggle_status": onSetToggleStatus(message);
break;
break;
default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal.");
default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal.");
}
}
}
}
catch (IOException | ClassNotFoundException e)
catch (IOException | ClassNotFoundException e)
{
{
logger.severe(e.getMessage());
logger.severe(e.getMessage());
e.printStackTrace();
e.printStackTrace();
clientListener.setConnected(false);
clientListener.setConnected(false);
clientListener.updateSettingsConnectDisconnectButton();
clientListener.updateSettingsConnectDisconnectButton();
clientListener.onDisconnect();
clientListener.onDisconnect();
if(!stop.get())
if(!stop.get())
{
{
//isDisconnect.set(true); //Prevent running disconnect
//isDisconnect.set(true); //Prevent running disconnect
throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)");
throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)");
}
}
exit();
exit();
return;
return;
}
}
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
logger.severe(e.getMessage());
logger.severe(e.getMessage());
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
logger.severe(e.getMessage());
logger.severe(e.getMessage());
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
private void onSetToggleStatus(Message message)
private void onSetToggleStatus(Message message)
{
{
String[] arr = message.getStringArrValue();
String[] arr = message.getStringArrValue();
String profileID = arr[0];
String profileID = arr[0];
String actionID = arr[1];
String actionID = arr[1];
boolean newStatus = arr[2].equals("true");
boolean newStatus = arr[2].equals("true");
boolean currentStatus = clientListener.getToggleStatus(profileID,actionID);
boolean currentStatus = clientListener.getToggleStatus(profileID,actionID);
if(currentStatus == newStatus)
if(currentStatus == newStatus)
{
{
return;
return;
}
}
ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID);
ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID);
if(actionBox!=null)
if(actionBox!=null)
{
{
actionBox.setCurrentToggleStatus(newStatus);
actionBox.setCurrentToggleStatus(newStatus);
Platform.runLater(()-> actionBox.toggle(newStatus));
Platform.runLater(()-> actionBox.toggle(newStatus));
}
}
}
}
private void onActionIconReceived(Message message) throws MinorException
private void onActionIconReceived(Message message) throws MinorException
{
{
String profileID = message.getStringArrValue()[0];
String profileID = message.getStringArrValue()[0];
String actionID = message.getStringArrValue()[1];
String actionID = message.getStringArrValue()[1];
String state = message.getStringArrValue()[2];
String state = message.getStringArrValue()[2];
clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon(
clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon(
actionID,
actionID,
message.getByteArrValue(),
message.getByteArrValue(),
state
state
);
);
Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID);
Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID);
clientListener.renderAction(profileID, a);
clientListener.renderAction(profileID, a);
}
}
//commands
//commands
public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException
public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException
{
{
try
try
{
{
Thread.sleep(50);
Thread.sleep(50);
}
}
catch (InterruptedException e)
catch (InterruptedException e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
Message message = new Message("action_icon");
Message message = new Message("action_icon");
message.setStringArrValue(profileID, actionID, state);
message.setStringArrValue(profileID, actionID, state);
message.setByteArrValue(icon);
message.setByteArrValue(icon);
sendMessage(message);
sendMessage(message);
}
}
public void disconnect() throws SevereException
public void disconnect() throws SevereException
{
{
disconnect("");
disconnect("");
}
}
public void disconnect(String message) throws SevereException
public void disconnect(String message) throws SevereException
{
{
if(stop.get())
if(stop.get())
return;
return;
stop.set(true);
stop.set(true);
logger.info("Sending server disconnect message ...");
logger.info("Sending server disconnect message ...");
Message m = new Message("disconnect");
Message m = new Message("disconnect");
m.setStringValue(message);
m.setStringValue(message);
sendMessage(m);
sendMessage(m);
try
try
{
{
if(!socket.isClosed())
if(!socket.isClosed())
socket.close();
socket.close();
clientListener.setConnected(false);
clientListener.setConnected(false);
clientListener.updateSettingsConnectDisconnectButton();
clientListener.updateSettingsConnectDisconnectButton();
}
}
catch (IOException e)
catch (IOException e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException("Unable to close socket");
throw new SevereException("Unable to close socket");
}
}
}
}
public void onServerReady()
public void onServerReady()
{
{
if(onConnectAndSetupToBeRun!=null)
if(onConnectAndSetupToBeRun!=null)
{
{
onConnectAndSetupToBeRun.run();
onConnectAndSetupToBeRun.run();
onConnectAndSetupToBeRun = null;
onConnectAndSetupToBeRun = null;
}
}
}
}
public void sendThemesToServer() throws SevereException
public void sendThemesToServer() throws SevereException
{
{
Message message = new Message("themes");
Message message = new Message("themes");
String[] arr = new String[clientListener.getThemes().getThemeList().size()*4];
String[] arr = new String[clientListener.getThemes().getThemeList().size()*4];
int x = 0;
int x = 0;
for(int i = 0;i<clientListener.getThemes().getThemeList().size();i++)
for(int i = 0;i<clientListener.getThemes().getThemeList().size();i++)
{
{
Theme theme = clientListener.getThemes().getThemeList().get(i);
Theme theme = clientListener.getThemes().getThemeList().get(i);
arr[x] = theme.getFullName();
arr[x] = theme.getFullName();
arr[x+1] = theme.getShortName();
arr[x+1] = theme.getShortName();
arr[x+2] = theme.getAuthor();
arr[x+2] = theme.getAuthor();
arr[x+3] = theme.getVersion().getText();
arr[x+3] = theme.getVersion().getText();
x+=4;
x+=4;
}
}
message.setStringArrValue(arr);
message.setStringArrValue(arr);
sendMessage(message);
sendMessage(message);
}
}
public void sendActionIcon(String clientProfileID, String actionID, String state) throws SevereException
public void sendActionIcon(String clientProfileID, String actionID, String state) throws SevereException
{
{
sendIcon(clientProfileID,
sendIcon(clientProfileID,
actionID,
actionID,
state,
state,
clientListener.getClientProfiles()
clientListener.getClientProfiles()
.getProfileFromID(clientProfileID)
.getProfileFromID(clientProfileID)
.getActionFromID(actionID).getIcon(state));
.getActionFromID(actionID).getIcon(state));
}
}
public void serverDisconnected(Message message)
public void serverDisconnected(Message message)
{
{
stop.set(true);
stop.set(true);
String txt = "Disconnected!";
String txt = "Disconnected!";
String m = message.getStringValue();
String m = message.getStringValue();
if(!m.isBlank())
if(!m.isBlank())
txt = "Message : "+m;
txt = "Message : "+m;
exceptionAndAlertHandler.onAlert("Disconnected from Server", txt, StreamPiAlertType.WARNING);
exceptionAndAlertHandler.onAlert("Disconnected from Server", txt, StreamPiAlertType.WARNING);
if(!socket.isClosed()) {
if(!socket.isClosed()) {
try {
try {
socket.close();
socket.close();
} catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
clientListener.setConnected(false);
clientListener.setConnected(false);
clientListener.onDisconnect();
clientListener.onDisconnect();
clientListener.updateSettingsConnectDisconnectButton();
clientListener.updateSettingsConnectDisconnectButton();
}
}
public void sendClientScreenDetails() throws SevereException
public void sendClientScreenDetails() throws SevereException
{
{
Message toBeSent = new Message("client_screen_details");
Message toBeSent = new Message("client_screen_details");
toBeSent.setDoubleArrValue(
toBeSent.setDoubleArrValue(
clientListener.getStageWidth(),
clientListener.getStageWidth(),
clientListener.getStageHeight()
clientListener.getStageHeight()
);
);
sendMessage(toBeSent);
sendMessage(toBeSent);
}
}
public void sendClientDetails() throws SevereException
public void sendClientDetails() throws SevereException
{
{
sendClientDetails("register_client_details");
sendClientDetails("register_client_details");
}
}
public void updateClientDetails() throws SevereException
public void updateClientDetails() throws SevereException
{
{
sendClientDetails("update_client_details");
sendClientDetails("update_client_details");
}
}
public void sendClientDetails(String header) throws SevereException
public void sendClientDetails(String header) throws SevereException
{
{
String clientVersion = clientInfo.getVersion().getText();
String clientVersion = clientInfo.getVersion().getText();
String releaseStatus = clientInfo.getReleaseStatus().toString();
String releaseStatus = clientInfo.getReleaseStatus().toString();
String clientCommStandard = clientInfo.getCommStandardVersion().getText();
String clientCommStandard = clientInfo.getCommStandardVersion().getText();
String clientMinThemeStandard = clientInfo.getMinThemeSupportVersion().getText();
String clientMinThemeStandard = clientInfo.getMinThemeSupportVersion().getText();
String clientNickname = Config.getInstance().getClientNickName();
String clientNickname = Config.getInstance().getClientNickName();
String screenWidth = clientListener.getStageWidth()+"";
String screenWidth = clientListener.getStageWidth()+"";
String screenHeight = clientListener.getStageHeight()+"";
String screenHeight = clientListener.getStageHeight()+"";
String OS = clientInfo.getPlatform()+"";
String OS = clientInfo.getPlatform()+"";
String defaultProfileID = Config.getInstance().getStartupProfileID();
String defaultProfileID = Config.getInstance().getStartupProfileID();
Message toBeSent = new Message(header);
Message toBeSent = new Message(header);
toBeSent.setStringArrValue(
toBeSent.setStringArrValue(
clientVersion,
clientVersion,
releaseStatus,
releaseStatus,
clientCommStandard,
clientCommStandard,
clientMinThemeStandard,
clientMinThemeStandard,
clientNickname,
clientNickname,
screenWidth,
screenWidth,
screenHeight,
screenHeight,
OS,
OS,
defaultProfileID,
defaultProfileID,
clientListener.getDefaultThemeFullName()
clientListener.getDefaultThemeFullName()
);
);
sendMessage(toBeSent);
sendMessage(toBeSent);
}
}
public void sendProfileNamesToServer() throws SevereException
public void sendProfileNamesToServer() throws SevereException
{
{
Message message = new Message("profiles");
Message message = new Message("profiles");
String[] arr = new String[clientListener.getClientProfiles().getClientProfiles().size()];
String[] arr = new String[clientListener.getClientProfiles().getClientProfiles().size()];
int totalActions = 0;
int totalActions = 0;
for(int i = 0;i<arr.length;i++)
for(int i = 0;i<arr.length;i++)
{
{
ClientProfile clientProfile = clientListener.getClientProfiles().getClientProfiles().get(i);
ClientProfile clientProfile = clientListener.getClientProfiles().getClientProfiles().get(i);
totalActions += clientProfile.getActions().size();
totalActions += clientProfile.getActions().size();
arr[i] = clientProfile.getID();
arr[i] = clientProfile.getID();
}
}
message.setStringArrValue(arr);
message.setStringArrValue(arr);
message.setIntValue(totalActions);
message.setIntValue(totalActions);
sendMessage(message);
sendMessage(message);
}
}
public void sendProfileDetailsToServer(Message message) throws SevereException
public void sendProfileDetailsToServer(Message message) throws SevereException
{
{
String ID = message.getStringValue();
String ID = message.getStringValue();
Message tbs1 = new Message("profile_details");
Message tbs1 = new Message("profile_details");
ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(ID);
ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(ID);
String[] arr = new String[]{
String[] arr = new String[]{
ID,
ID,
clientProfile.getName(),
clientProfile.getName(),
clientProfile.getRows()+"",
clientProfile.getRows()+"",
clientProfile.getCols()+"",
clientProfile.getCols()+"",
clientProfile.getActionSize()+"",
clientProfile.getActionSize()+"",
clientProfile.getActionGap()+""
clientProfile.getActionGap()+""
};
};
tbs1.setStringArrValue(arr);
tbs1.setStringArrValue(arr);
sendMessage(tbs1);
sendMessage(tbs1);
for(Action action : clientProfile.getActions())
for(Action action : clientProfile.getActions())
{
{
sendActionDetails(clientProfile.getID(), action);
sendActionDetails(clientProfile.getID(), action);
}
}
for(Action action : clientProfile.getActions())
for(Action action : clientProfile.getActions())
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
for(String key : action.getIcons().keySet())
for(String key : action.getIcons().keySet())
{
{
sendActionIcon(clientProfile.getID(), action.getID(), key);
sendActionIcon(clientProfile.getID(), action.getID(), key);
}
}
}
}
}
}
}
}
public void sendActionDetails(String profileID, Action action) throws SevereException {
public void sendActionDetails(String profileID, Action action) throws SevereException
{
if(action == null)
if(action == null)
{
{
logger.info("NO SUCH ACTION");
logger.info("NO SUCH ACTION");
return;
return;
}
}
ArrayList<String> a = new ArrayList<>();
ArrayList<String> a = new ArrayList<>();
a.add(profileID);
a.add(profileID);
a.add(action.getID());
a.add(action.getID());
a.add(action.getActionType()+"");
a.add(action.getActionType()+"");
if(action.getActionType() == ActionType.NORMAL ||
if(action.getActionType() == ActionType.NORMAL ||
action.getActionType() == ActionType.TOGGLE) {
action.getActionType() == ActionType.TOGGLE) {
a.add(action.getVersion().getText());
a.add(action.getVersion().getText());
}
}
else
else
{
{
a.add("no");
a.add("no");
}
}
if(action.getActionType() ==ActionType.NORMAL ||
if(action.getActionType() ==ActionType.NORMAL ||
action.getActionType() == ActionType.TOGGLE)
action.getActionType() == ActionType.TOGGLE)
{
{
a.add(action.getModuleName());
a.add(action.getModuleName());
}
}
else
else
{
{
a.add("nut");
a.add("nut");
}
}
//display
//display
a.add(action.getBgColourHex());
a.add(action.getBgColourHex());
//icon
//icon
StringBuilder allIconStatesNames = new StringBuilder();
StringBuilder allIconStatesNames = new StringBuilder();
for(String eachState : action.getIcons().keySet())
for(String eachState : action.getIcons().keySet())
{
{
allIconStatesNames.append(eachState).append("::");
allIconStatesNames.append(eachState).append("::");
}
}
a.add(allIconStatesNames.toString());
a.add(allIconStatesNames.toString());
a.add(action.getCurrentIconState()+"");
a.add(action.getCurrentIconState()+"");
logger.info("CuRrent ICON state asdasd : "+action.getCurrentIconState());
//text
//text
a.add(action.isShowDisplayText()+"");
a.add(action.isShowDisplayText()+"");
a.add(action.getDisplayTextFontColourHex());
a.add(action.getDisplayTextFontColourHex());
a.add(action.getDisplayText());
a.add(action.getDisplayText());
a.add(action.getDisplayTextAlignment()+"");
a.add(action.getDisplayTextAlignment()+"");
//location
//location
if(action.getLocation() == null)
if(action.getLocation() == null)
{
{
a.add("-1");
a.add("-1");
a.add("-1");
a.add("-1");
}
}
else
else
{
{
a.add(action.getLocation().getRow()+"");
a.add(action.getLocation().getRow()+"");
a.add(action.getLocation().getCol()+"");
a.add(action.getLocation().getCol()+"");
}
}
a.add(action.getParent());
a.add(action.getParent());
a.add(action.getDelayBeforeExecuting()+"");
a.add(action.getDelayBeforeExecuting()+"");
//client properties
//client properties
ClientProperties clientProperties = action.getClientProperties();
ClientProperties clientProperties = action.getClientProperties();
a.add(clientProperties.getSize()+"");
a.add(clientProperties.getSize()+"");
for(Property property : clientProperties.get())
for(Property property : clientProperties.get())
{
{
a.add(property.getName());
a.add(property.getName());
a.add(property.getRawValue());
a.add(property.getRawValue());
}
}
Message message = new Message("action_details");
Message message = new Message("action_details");
String[] x = new String[a.size()];
String[] x = new String[a.size()];
x = a.toArray(x);
x = a.toArray(x);
message.setStringArrValue(x);
message.setStringArrValue(x);
sendMessage(message);
sendMessage(message);
}
}
public void saveActionDetails(Message message)
public void saveActionDetails(Message message)
{
{
String[] r = message.getStringArrValue();
String[] r = message.getStringArrValue();
String profileID = r[0];
String profileID = r[0];
String actionID = r[1];
String actionID = r[1];
ActionType actionType = ActionType.valueOf(r[2]);
ActionType actionType = ActionType.valueOf(r[2]);
//3 - Version
//3 - Version
//4 - ModuleName
//4 - ModuleName
//display
//display
String bgColorHex = r[5];
String bgColorHex = r[5];
String[] iconStates = r[6].split("::");
String[] iconStates = r[6].split("::");
String currentIconState = r[7];
String currentIconState = r[7];
//text
//text
boolean isShowDisplayText = r[8].equals("true");
boolean isShowDisplayText = r[8].equals("true");
String displayFontColor = r[9];
String displayFontColor = r[9];
String displayText = r[10];
String displayText = r[10];
DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[11]);
DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[11]);
//location
//location
String row = r[12];
String row = r[12];
String col = r[13];
String col = r[13];
Location location = new Location(Integer.parseInt(row), Integer.parseInt(col));
Location location = new Location(Integer.parseInt(row), Integer.parseInt(col));
Action action = new Action(actionID, actionType);
Action action = new Action(actionID, actionType);
if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE)
if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE)
{
{
try
try
{
{
action.setVersion(new Version(r[3]));
action.setVersion(new Version(r[3]));
action.setModuleName(r[4]);
action.setModuleName(r[4]);
}
}
catch (Exception e)
catch (Exception e)
{
{
logger.severe(e.getMessage());
logger.severe(e.getMessage());
e.printStackTrace();
e.printStackTrace();
}
}
}
}
action.setBgColourHex(bgColorHex);
action.setBgColourHex(bgColorHex);
action.setShowDisplayText(isShowDisplayText);
action.setShowDisplayText(isShowDisplayText);
action.setDisplayTextFontColourHex(displayFontColor);
action.setDisplayTextFontColourHex(displayFontColor);
action.setDisplayText(displayText);
action.setDisplayText(displayText);
action.setDisplayTextAlignment(displayTextAlignment);
action.setDisplayTextAlignment(displayTextAlignment);
action.setCurrentIconState(currentIconState);
action.setCurrentIconState(currentIconState);
action.setLocation(location);
action.setLocation(location);
String parent = r[14];
String parent = r[14];
action.setParent(parent);
action.setParent(parent);
//client properties
//client properties
action.setDelayBeforeExecuting(Integer.parseInt(r[15]));
action.setDelayBeforeExecuting(Integer.parseInt(r[15]));
int clientPropertiesSize = Integer.parseInt(r[16]);
int clientPropertiesSize = Integer.parseInt(r[16]);
ClientProperties clientProperties = new ClientProperties();
ClientProperties clientProperties = new ClientProperties();
if(actionType == ActionType.FOLDER)
if(actionType == ActionType.FOLDER)
clientProperties.setDuplicatePropertyAllowed(true);
clientProperties.setDuplicatePropertyAllowed(true);
for(int i = 17;i<((clientPropertiesSize*2) + 17); i+=2)
for(int i = 17;i<((clientPropertiesSize*2) + 17); i+=2)
{
{
Property property = new Property(r[i], Type.STRING);
Property property = new Property(r[i], Type.STRING);
property.setRawValue(r[i+1]);
property.setRawValue(r[i+1]);
clientProperties.addProperty(property);
clientProperties.addProperty(property);
}
}
action.setClientProperties(clientProperties);
action.setClientProperties(clientProperties);
for(String state : iconStates)
{
action.addIcon(state, null);
}
try
try
{
{
Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID());
Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID());
if(old != null)
if(old != null)
{
{
for(String oldState : old.getIcons().keySet())
for(String oldState : old.getIcons().keySet())
{
{
boolean isPresent = false;
boolean isPresent = false;
for(String state : iconStates)
for(String state : iconStates)
{
{
if(state.equals(oldState))
if(state.equals(oldState))
{
{
isPresent = true;
isPresent = true;
action.addIcon(state, old.getIcon(state));
break;
break;
}
}
}
}
if(!isPresent)
if(!isPresent)
{
{
// State no longer exists. Delete.
// State no longer exists. Delete.
new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete();
new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete();
}
}
}
}
}
}
clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action);
clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action);
clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action);
clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action);
clientListener.renderAction(profileID, action);
clientListener.renderAction(profileID, action);
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
}
}
}
}
public void deleteAction(Message message)
public void deleteAction(Message message)
{
{
try
try
{
{
String[] arr = message.getStringArrValue();
String[] arr = message.getStringArrValue();
String profileID = arr[0];
String profileID = arr[0];
String actionID = arr[1];
String actionID = arr[1];
Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID);
Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID);
if(acc == null)
if(acc == null)
{
{
exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist."));
exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist."));
return;
return;
}
}
if(acc.getActionType() == ActionType.FOLDER)
if(acc.getActionType() == ActionType.FOLDER)
{
{
ArrayList<String> idsToBeRemoved = new ArrayList<>();
ArrayList<String> idsToBeRemoved = new ArrayList<>();
ArrayList<String> folders = new ArrayList<>();
ArrayList<String> folders = new ArrayList<>();
String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID();
String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID();
folders.add(folderToBeDeletedID);
folders.add(folderToBeDeletedID);
boolean startOver = true;
boolean startOver = true;
while(startOver)
while(startOver)
{
{
startOver = false;
startOver = false;
for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions())
for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions())
{
{
if(folders.contains(action.getParent()))
if(folders.contains(action.getParent()))
{
{
if(!idsToBeRemoved.contains(action.getID()))
if(!idsToBeRemoved.contains(action.getID()))
{
{
idsToBeRemoved.add(action.getID());
idsToBeRemoved.add(action.getID());
if(action.getActionType() == ActionType.FOLDER)
if(action.getActionType() == ActionType.FOLDER)
{
{
folders.add(action.getID());
folders.add(action.getID());
startOver = true;
startOver = true;
}
}
}
}
}
}
}
}
}
}
for(String ids : idsToBeRemoved)
for(String ids : idsToBeRemoved)
{
{
clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids);
clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids);
}
}
Platform.runLater(clientListener::renderRootDefaultProfile);
Platform.runLater(clientListener::renderRootDefaultProfile);
}
}
else if (acc.getActionType() == ActionType.COMBINE)
else if (acc.getActionType() == ActionType.COMBINE)
{
{
for(Property property : acc.getClientProperties().get())
for(Property property : acc.getClientProperties().get())
{
{
clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue());
clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue());
}
}
}
}
clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID());
clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID());
clientListener.getClientProfiles().getProfileFromID(profileID).saveActions();
clientListener.getClientProfiles().getProfileFromID(profileID).saveActions();
if(acc.getLocation().getCol()!=-1)
if(acc.getLocation().getCol()!=-1)
{
{
Platform.runLater(()-> {
Platform.runLater(()-> {
if (clientListener.getCurrentProfile().getID().equals(profileID)
if (clientListener.getCurrentProfile().getID().equals(profileID)
&& clientListener.getCurrentParent().equals(acc.getParent()))
&& clientListener.getCurrentParent().equals(acc.getParent()))
{
{
clientListener.clearActionBox(
clientListener.clearActionBox(
acc.getLocation().getCol(),
acc.getLocation().getCol(),
acc.getLocation().getRow()
acc.getLocation().getRow()
);
);
}
}
});
});
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
}
}
}
}
public void saveClientDetails(Message message)
public void saveClientDetails(Message message)
{
{
try
try
{
{
boolean reInit = false;
boolean reInit = false;
String[] sep = message.getStringArrValue();
String[] sep = message.getStringArrValue();
Config.getInstance().setNickName(sep[0]);
Config.getInstance().setNickName(sep[0]);
Config.getInstance().setStartupProfileID(sep[1]);
Config.getInstance().setStartupProfileID(sep[1]);
String oldThemeFullName = Config.getInstance().getCurrentThemeFullName();
String oldThemeFullName = Config.getInstance().getCurrentThemeFullName();
String newThemeFullName = sep[2];
String newThemeFullName = sep[2];
if(!oldThemeFullName.equals(newThemeFullName))
if(!oldThemeFullName.equals(newThemeFullName))
{
{
reInit = true;
reInit = true;
}
}
Config.getInstance().setCurrentThemeFullName(sep[2]);
Config.getInstance().setCurrentThemeFullName(sep[2]);
Config.getInstance().save();
Config.getInstance().save();
if(reInit)
if(reInit)
{
{
Platform.runLater(clientListener::init);
Platform.runLater(clientListener::init);
}
}
else
else
{
{
Platform.runLater(clientListener::loadSettings);
Platform.runLater(clientListener::loadSettings);
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
}
}
public void saveProfileDetails(Message message) throws SevereException, MinorException
public void saveProfileDetails(Message message) throws SevereException, MinorException
{
{
String[] sep = message.getStringArrValue();
String[] sep = message.getStringArrValue();
ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]);
ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]);
if(clientProfile == null)
if(clientProfile == null)
{
{
clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"),
clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"),
Config.getInstance().getIconsPath());
Config.getInstance().getIconsPath());
}
}
clientProfile.setName(sep[1]);
clientProfile.setName(sep[1]);
clientProfile.setRows(Integer.parseInt(sep[2]));
clientProfile.setRows(Integer.parseInt(sep[2]));
clientProfile.setCols(Integer.parseInt(sep[3]));
clientProfile.setCols(Integer.parseInt(sep[3]));
clientProfile.setActionSize(Integer.parseInt(sep[4]));
clientProfile.setActionSize(Integer.parseInt(sep[4]));
clientProfile.setActionGap(Integer.parseInt(sep[5]));
clientProfile.setActionGap(Integer.parseInt(sep[5]));
try
try
{
{
clientListener.getClientProfiles().addProfile(clientProfile);
clientListener.getClientProfiles().addProfile(clientProfile);
clientProfile.saveProfileDetails();
clientProfile.saveProfileDetails();
clientListener.refreshGridIfCurrentProfile(sep[0]);
clientListener.refreshGridIfCurrentProfile(sep[0]);
Platform.runLater(clientListener::loadSettings);
Platform.runLater(clientListener::loadSettings);
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException(e.getMessage());
throw new SevereException(e.getMessage());
}
}
}
}
public void deleteProfile(Message message)
public void deleteProfile(Message message)
{
{
clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID(
clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID(
message.getStringValue()
message.getStringValue()
));
));
if(clientListener.getCurrentProfile().getID().equals(message.getStringValue()))
if(clientListener.getCurrentProfile().getID().equals(message.getStringValue()))
{
{
Platform.runLater(clientListener::renderRootDefaultProfile);
Platform.runLater(clientListener::renderRootDefaultProfile);
}
}
}
}
public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException
public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException
{
{
Message m = new Message("action_clicked");
Message m = new Message("action_clicked");
m.setStringArrValue(profileID, actionID, toggleState+"");
m.setStringArrValue(profileID, actionID, toggleState+"");
sendMessage(m);
sendMessage(m);
}
}
public void actionFailed(Message message)
public void actionFailed(Message message)
{
{
String[] r = message.getStringArrValue();
String[] r = message.getStringArrValue();
String profileID = r[0];
String profileID = r[0];
String actionID = r[1];
String actionID = r[1];
clientListener.onActionFailed(profileID, actionID);
clientListener.onActionFailed(profileID, actionID);
}
}
}
}
package com.stream_pi.client.window.dashboard.actiongridpane;
package com.stream_pi.client.window.dashboard.actiongridpane;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import javafx.animation.Interpolator;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.animation.Timeline;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundImage;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundPosition;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.TextAlignment;
import javafx.scene.text.TextAlignment;
import javafx.util.Duration;
import javafx.util.Duration;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectInputStream;
import java.nio.ByteBuffer;
import java.nio.ByteBuffer;
import java.util.logging.Logger;
public class ActionBox extends StackPane
public class ActionBox extends StackPane
{
{
private Label displayTextLabel;
private Label displayTextLabel;
private int row;
private int row;
private int col;
private int col;
public int getRow() {
public int getRow() {
return row;
return row;
}
}
public int getCol() {
public int getCol() {
return col;
return col;
}
}
private Logger logger;
public void clear()
public void clear()
{
{
setStyle(null);
setStyle(null);
setAction(null);
setAction(null);
setCurrentToggleStatus(false);
setCurrentToggleStatus(false);
getStyleClass().clear();
getStyleClass().clear();
setBackground(Background.EMPTY);
setBackground(Background.EMPTY);
removeFontIcon();
removeFontIcon();
getChildren().clear();
getChildren().clear();
baseInit();
baseInit();
}
}
private FontIcon statusIcon;
private FontIcon statusIcon;
public void baseInit()
public void baseInit()
{
{
displayTextLabel = new Label();
displayTextLabel = new Label();
displayTextLabel.setWrapText(true);
displayTextLabel.setWrapText(true);
displayTextLabel.setTextAlignment(TextAlignment.CENTER);
displayTextLabel.setTextAlignment(TextAlignment.CENTER);
displayTextLabel.getStyleClass().add("action_box_display_text_label");
displayTextLabel.getStyleClass().add("action_box_display_text_label");
displayTextLabel.prefHeightProperty().bind(heightProperty());
displayTextLabel.prefHeightProperty().bind(heightProperty());
displayTextLabel.prefWidthProperty().bind(widthProperty());
displayTextLabel.prefWidthProperty().bind(widthProperty());
statusIcon = new FontIcon("fas-exclamation-triangle");
statusIcon = new FontIcon("fas-exclamation-triangle");
statusIcon.getStyleClass().add("action_box_error_icon");
statusIcon.getStyleClass().add("action_box_error_icon");
statusIcon.setOpacity(0);
statusIcon.setOpacity(0);
statusIcon.setCache(true);
statusIcon.setCache(true);
statusIcon.setCacheHint(CacheHint.SPEED);
statusIcon.setCacheHint(CacheHint.SPEED);
statusIcon.setIconSize(size - 30);
statusIcon.setIconSize(size - 30);
getChildren().addAll(statusIcon, displayTextLabel);
getChildren().addAll(statusIcon, displayTextLabel);
setMinSize(size, size);
setMinSize(size, size);
setMaxSize(size, size);
setMaxSize(size, size);
getStyleClass().clear();
getStyleClass().clear();
getStyleClass().add("action_box");
getStyleClass().add("action_box");
getStyleClass().add("action_box_"+row+"_"+col);
getStyleClass().add("action_box_"+row+"_"+col);
setIcon(null);
setIcon(null);
setOnMouseClicked(touchEvent -> actionClicked());
setOnMouseClicked(touchEvent -> actionClicked());
setOnMousePressed(TouchEvent -> {
setOnMousePressed(TouchEvent -> {
if(action != null)
if(action != null)
{
{
getStyleClass().add("action_box_onclick");
getStyleClass().add("action_box_onclick");
}
}
});
});
setOnMouseReleased(TouchEvent ->{
setOnMouseReleased(TouchEvent ->{
if(action != null)
if(action != null)
{
{
getStyleClass().remove("action_box_onclick");
getStyleClass().remove("action_box_onclick");
}
}
});
});
statusIconAnimation = new Timeline(
statusIconAnimation = new Timeline(
new KeyFrame(
new KeyFrame(
Duration.millis(0.0D),
Duration.millis(0.0D),
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)),
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)),
new KeyFrame(
new KeyFrame(
Duration.millis(100.0D),
Duration.millis(100.0D),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)),
new KeyFrame(
new KeyFrame(
Duration.millis(600.0D),
Duration.millis(600.0D),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)),
new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)),
new KeyFrame(
new KeyFrame(
Duration.millis(700.0D),
Duration.millis(700.0D),
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT))
new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT))
);
);
statusIconAnimation.setOnFinished(event -> {
statusIconAnimation.setOnFinished(event -> {
statusIcon.toBack();
statusIcon.toBack();
});
});
setCache(true);
setCache(true);
setCacheHint(CacheHint.QUALITY);
setCacheHint(CacheHint.QUALITY);
}
}
public void actionClicked()
public void actionClicked()
{
{
if(action!=null)
if(action!=null)
{
{
if(!getActionGridPaneListener().isConnected())
if(!getActionGridPaneListener().isConnected())
{
{
try
try
{
{
if(Config.getInstance().isTryConnectingWhenActionClicked())
if(Config.getInstance().isTryConnectingWhenActionClicked())
{
{
clientListener.setupClientConnection(this::actionClicked);
clientListener.setupClientConnection(this::actionClicked);
}
}
else
else
{
{
exceptionAndAlertHandler.onAlert("Not Connected", "Not Connected to any Server", StreamPiAlertType.ERROR);
exceptionAndAlertHandler.onAlert("Not Connected", "Not Connected to any Server", StreamPiAlertType.ERROR);
}
}
return;
return;
}
}
catch (SevereException e)
catch (SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
}
}
if(action.getActionType() == ActionType.FOLDER)
if(action.getActionType() == ActionType.FOLDER)
{
{
getActionGridPaneListener().renderFolder(action.getID());
getActionGridPaneListener().renderFolder(action.getID());
}
}
else
else
{
{
if(action.getActionType() == ActionType.COMBINE)
if(action.getActionType() == ActionType.COMBINE)
{
{
getActionGridPaneListener().combineActionClicked(action.getID());
getActionGridPaneListener().combineActionClicked(action.getID());
}
}
else if(action.getActionType() == ActionType.NORMAL)
else if(action.getActionType() == ActionType.NORMAL)
{
{
getActionGridPaneListener().normalActionClicked(action.getID());
getActionGridPaneListener().normalActionClicked(action.getID());
}
}
else if(action.getActionType() == ActionType.TOGGLE)
else if(action.getActionType() == ActionType.TOGGLE)
{
{
toggle();
toggle();
getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus());
getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus());
}
}
}
}
}
}
}
}
private Timeline statusIconAnimation;
private Timeline statusIconAnimation;
public Timeline getStatusIconAnimation() {
public Timeline getStatusIconAnimation() {
return statusIconAnimation;
return statusIconAnimation;
}
}
public ActionGridPaneListener getActionGridPaneListener() {
public ActionGridPaneListener getActionGridPaneListener() {
return actionGridPaneListener;
return actionGridPaneListener;
}
}
private int size;
private int size;
private ActionGridPaneListener actionGridPaneListener;
private ActionGridPaneListener actionGridPaneListener;
private ClientListener clientListener;
private ClientListener clientListener;
public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler,
public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler,
ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col)
ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col)
{
{
this.actionGridPaneListener = actionGridPaneListener;
this.actionGridPaneListener = actionGridPaneListener;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.size = size;
this.size = size;
this.row = row;
this.row = row;
this.col = col;
this.col = col;
this.clientListener = clientListener;
this.clientListener = clientListener;
this.logger = Logger.getLogger("");
baseInit();
baseInit();
}
}
public Logger getLogger()
{
return logger;
}
public static Action deserialize(ByteBuffer buffer) {
public static Action deserialize(ByteBuffer buffer) {
try {
try {
ByteArrayInputStream is = new ByteArrayInputStream(buffer.array());
ByteArrayInputStream is = new ByteArrayInputStream(buffer.array());
ObjectInputStream ois = new ObjectInputStream(is);
ObjectInputStream ois = new ObjectInputStream(is);
return (Action) ois.readObject();
return (Action) ois.readObject();
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
throw new RuntimeException(e);
throw new RuntimeException(e);
}
}
}
}
public void setIcon(byte[] iconByteArray)
public void setIcon(byte[] iconByteArray)
{
{
removeFontIcon();
removeFontIcon();
if(iconByteArray == null)
if(iconByteArray == null)
{
{
getStyleClass().remove("action_box_icon_present");
getStyleClass().remove("action_box_icon_present");
getStyleClass().add("action_box_icon_not_present");
getStyleClass().add("action_box_icon_not_present");
setBackground(null);
setBackground(null);
}
}
else
else
{
{
getStyleClass().add("action_box_icon_present");
getStyleClass().add("action_box_icon_present");
getStyleClass().remove("action_box_icon_not_present");
getStyleClass().remove("action_box_icon_not_present");
setBackground(
setBackground(
new Background(
new Background(
new BackgroundImage(new Image(
new BackgroundImage(new Image(
new ByteArrayInputStream(iconByteArray), size, size, false, true
new ByteArrayInputStream(iconByteArray), size, size, false, true
), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
new BackgroundSize(100, 100, true, true, true, false))
new BackgroundSize(100, 100, true, true, true, false))
)
)
);
);
}
}
}
}
private Action action = null;
private Action action = null;
public Action getAction() {
public Action getAction() {
return action;
return action;
}
}
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private String parent;
private String parent;
public String getStreamPiParent() {
public String getStreamPiParent() {
return parent;
return parent;
}
}
public void setStreamPiParent(String parent) {
public void setStreamPiParent(String parent) {
this.parent = parent;
this.parent = parent;
}
}
/*
public ActionBox(int size, Action action, ExceptionAndAlertHandler exceptionAndAlertHandler,
ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col)
{
this.actionGridPaneListener = actionGridPaneListener;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.action = action;
this.size = size;
this.row = row;
this.col = col;
baseInit();
init();
}*/
public void setAction(Action action)
public void setAction(Action action)
{
{
this.action = action;
this.action = action;
}
}
public void init()
public void init()
{
{
setDisplayTextFontColour(action.getDisplayTextFontColourHex());
setDisplayTextFontColour(action.getDisplayTextFontColourHex());
if(action.isShowDisplayText())
if(action.isShowDisplayText())
setDisplayTextLabel(action.getDisplayText());
setDisplayTextLabel(action.getDisplayText());
else
else
setDisplayTextLabel("");
setDisplayTextLabel("");
setDisplayTextAlignment(action.getDisplayTextAlignment());
setDisplayTextAlignment(action.getDisplayTextAlignment());
setBackgroundColour(action.getBgColourHex());
setBackgroundColour(action.getBgColourHex());
try
try
{
{
if(action.getActionType() == ActionType.TOGGLE)
if(action.getActionType() == ActionType.TOGGLE)
{
{
toggle(getCurrentToggleStatus());
toggle(getCurrentToggleStatus());
}
}
else
else
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
if(!action.getCurrentIconState().isBlank())
if(!action.getCurrentIconState().isBlank())
{
{
setIcon(action.getCurrentIcon());
setIcon(action.getCurrentIcon());
}
}
}
}
else
else
{
{
setIcon(null);
setIcon(null);
}
}
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public void setCurrentToggleStatus(boolean currentToggleStatus)
public void setCurrentToggleStatus(boolean currentToggleStatus)
{
{
if(getAction() != null)
if(getAction() != null)
getAction().setCurrentToggleStatus(currentToggleStatus);
getAction().setCurrentToggleStatus(currentToggleStatus);
}
}
public boolean getCurrentToggleStatus()
public boolean getCurrentToggleStatus()
{
{
if(getAction() == null)
if(getAction() == null)
return false;
return false;
return getAction().getCurrentToggleStatus();
return getAction().getCurrentToggleStatus();
}
}
public void toggle()
public void toggle()
{
{
setCurrentToggleStatus(!getCurrentToggleStatus());
setCurrentToggleStatus(!getCurrentToggleStatus());
toggle(getCurrentToggleStatus());
toggle(getCurrentToggleStatus());
}
}
public void toggle(boolean isON)
public void toggle(boolean isON)
{
{
String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__");
String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__");
boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true");
boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true");
boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true");
boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true");
if(isON) // ON
if(isON) // ON
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on");
boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on");
if(isToggleOnPresent)
if(isToggleOnPresent)
{
{
if(isToggleOnHidden)
if(isToggleOnHidden)
{
{
setDefaultToggleIcon(true);
setDefaultToggleIcon(true);
}
}
else
else
{
{
setIcon(action.getIcons().get("toggle_on"));
setIcon(action.getIcons().get("toggle_on"));
}
}
}
}
else
else
{
{
setDefaultToggleIcon(true);
setDefaultToggleIcon(true);
}
}
}
}
else
else
{
{
setDefaultToggleIcon(true);
setDefaultToggleIcon(true);
}
}
}
}
else // OFF
else // OFF
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off");
boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off");
if(isToggleOffPresent)
if(isToggleOffPresent)
{
{
if(isToggleOffHidden)
if(isToggleOffHidden)
{
{
setDefaultToggleIcon(false);
setDefaultToggleIcon(false);
}
}
else
else
{
{
setIcon(action.getIcons().get("toggle_off"));
setIcon(action.getIcons().get("toggle_off"));
}
}
}
}
else
else
{
{
setDefaultToggleIcon(false);
setDefaultToggleIcon(false);
}
}
}
}
else
else
{
{
setDefaultToggleIcon(false);
setDefaultToggleIcon(false);
}
}
}
}
}
}
public void setDefaultToggleIcon(boolean isToggleOn)
public void setDefaultToggleIcon(boolean isToggleOn)
{
{
String styleClass;
String styleClass;
if(isToggleOn)
if(isToggleOn)
{
{
styleClass = "action_box_toggle_on";
styleClass = "action_box_toggle_on";
}
}
else
else
{
{
styleClass = "action_box_toggle_off";
styleClass = "action_box_toggle_off";
}
}
setBackground(null);
setBackground(null);
removeFontIcon();
removeFontIcon();
fontIcon = new FontIcon();
fontIcon = new FontIcon();
fontIcon.getStyleClass().add(styleClass);
fontIcon.getStyleClass().add(styleClass);
fontIcon.setIconSize((int) (size * 0.8));
fontIcon.setIconSize((int) (size * 0.8));
getChildren().add(fontIcon);
getChildren().add(fontIcon);
fontIcon.toBack();
fontIcon.toBack();
}
}
public void removeFontIcon()
public void removeFontIcon()
{
{
if(fontIcon!=null)
if(fontIcon!=null)
{
{
getChildren().remove(fontIcon);
getChildren().remove(fontIcon);
fontIcon = null;
fontIcon = null;
}
}
}
}
FontIcon fontIcon = null;
FontIcon fontIcon = null;
public void animateStatus()
public void animateStatus()
{
{
statusIcon.toFront();
statusIcon.toFront();
statusIconAnimation.play();
statusIconAnimation.play();
}
}
public void setDisplayTextLabel(String text)
public void setDisplayTextLabel(String text)
{
{
displayTextLabel.setText(text);
displayTextLabel.setText(text);
}
}
public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment)
public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment)
{
{
if(displayTextAlignment == DisplayTextAlignment.CENTER)
if(displayTextAlignment == DisplayTextAlignment.CENTER)
displayTextLabel.setAlignment(Pos.CENTER);
displayTextLabel.setAlignment(Pos.CENTER);
else if (displayTextAlignment == DisplayTextAlignment.BOTTOM)
else if (displayTextAlignment == DisplayTextAlignment.BOTTOM)
displayTextLabel.setAlignment(Pos.BOTTOM_CENTER);
displayTextLabel.setAlignment(Pos.BOTTOM_CENTER);
else if (displayTextAlignment == DisplayTextAlignment.TOP)
else if (displayTextAlignment == DisplayTextAlignment.TOP)
displayTextLabel.setAlignment(Pos.TOP_CENTER);
displayTextLabel.setAlignment(Pos.TOP_CENTER);
}
}
public void setDisplayTextFontColour(String colour)
public void setDisplayTextFontColour(String colour)
{
{
System.out.println("'"+colour+"'COLOR");
if(!colour.isEmpty())
if(!colour.isEmpty())
{
{
System.out.println(
"putting ..." + Thread.currentThread().getName()
);
displayTextLabel.setStyle("-fx-text-fill : "+colour+";");
displayTextLabel.setStyle("-fx-text-fill : "+colour+";");
}
}
}
}
public void setBackgroundColour(String colour)
public void setBackgroundColour(String colour)
{
{
System.out.println("COLOr : "+colour);
if(!colour.isEmpty())
if(!colour.isEmpty())
setStyle("-fx-background-color : "+colour);
setStyle("-fx-background-color : "+colour);
}
}
}
}