essential-actions

Clone or download

[OBS] [SetCurrentProfile] - Cleanup, updated to use new action api

Modified Files

.idea/
.idea/
target/
target/
*.iml
.classpath
.classpath
.factorypath
.factorypath
.project
.project
.settings/
.settings/
<?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>obssuite_setcurrentprofileaction</artifactId>
<artifactId>obssuite_setcurrentprofileaction</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.0</version>
<executions>
<executions>
<execution>
<execution>
<id>test-jar</id>
<id>test-jar</id>
<phase>package</phase>
<phase>package</phase>
<goals>
<goals>
<goal>test-jar</goal>
<goal>test-jar</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-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.8.1</version>
<configuration>
<configuration>
<release>11</release>
<release>11</release>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
<properties>
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
<OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<OBSSuiteMotherVersion>2.0.1</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
<artifactId>util</artifactId>
<version>${UtilVersion}</version>
<version>${UtilVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>action-api</artifactId>
<artifactId>action-api</artifactId>
<version>${ActionAPIVersion}</version>
<version>${ActionAPIVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_motheraction</artifactId>
<artifactId>obssuite_motheraction</artifactId>
<version>${OBSSuiteMotherVersion}</version>
<version>${OBSSuiteMotherVersion}</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
package setcurrentprofile;
package setcurrentprofile;
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.action_api.externalplugin.NormalAction;
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import mother.motherconnection.MotherConnection;
import mother.motherconnection.MotherConnection;
public class SetCurrentProfile extends NormalAction
public class SetCurrentProfile extends NormalAction
{
{
public SetCurrentProfile() {
public SetCurrentProfile()
{
setName("Set Current Profile");
setName("Set Current Profile");
setCategory("OBS");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
setAuthor("rnayabed");
setVersion(MotherConnection.VERSION);
setVersion(MotherConnection.VERSION);
}
}
@Override
@Override
public void initProperties() throws Exception
public void initProperties() throws MinorException
{
{
Property currentProfileProperty = new Property("profile", Type.STRING);
Property currentProfileProperty = new Property("profile", Type.STRING);
currentProfileProperty.setDisplayName("Profile Name");
currentProfileProperty.setDisplayName("Profile Name");
Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
autoConnectProperty.setDefaultValueBoolean(true);
autoConnectProperty.setDefaultValueBoolean(true);
autoConnectProperty.setDisplayName("Auto Connect if not connected");
autoConnectProperty.setDisplayName("Auto Connect if not connected");
addClientProperties(currentProfileProperty, autoConnectProperty);
addClientProperties(currentProfileProperty, autoConnectProperty);
}
}
@Override
@Override
public void onActionClicked() throws Exception
public void onActionClicked() throws MinorException
{
{
String profile = getClientProperties().getSingleProperty("profile").getStringValue();
String profile = getClientProperties().getSingleProperty("profile").getStringValue();
if(profile.isBlank())
if(profile.isBlank())
{
{
throw new MinorException("Blank Profile Name","No Profile Name specified");
throw new MinorException("Blank Profile Name","No Profile Name specified");
}
}
if (MotherConnection.getRemoteController() == null)
if (MotherConnection.getRemoteController() == null)
{
{
boolean autoConnect = getClientProperties().getSingleProperty(
boolean autoConnect = getClientProperties().getSingleProperty(
"auto_connect"
"auto_connect"
).getBoolValue();
).getBoolValue();
if(autoConnect)
if(autoConnect)
{
{
MotherConnection.connect(()->setProfile(profile));
MotherConnection.connect(()->setProfile(profile));
}
}
else
else
{
{
MotherConnection.showOBSNotRunningError();
MotherConnection.showOBSNotRunningError();
}
}
}
}
else
else
{
{
setProfile(profile);
setProfile(profile);
}
}
}
}
public void setProfile(String profile)
public void setProfile(String profile)
{
{
MotherConnection.getRemoteController().setCurrentProfile(profile, setCurrentProfileResponse -> {
MotherConnection.getRemoteController().setCurrentProfile(profile, setCurrentProfileResponse -> {
String status = setCurrentProfileResponse.getStatus();
String status = setCurrentProfileResponse.getStatus();
String error = setCurrentProfileResponse.getError();
String error = setCurrentProfileResponse.getError();
if(status.equals("error"))
if(status.equals("error"))
{
{
String content;
String content;
if(error.equals("profile does not exist"))
if(error.equals("profile does not exist"))
{
{
content = "Profile "+profile+" does not exist.";
content = "Profile "+profile+" does not exist.";
}
}
else
else
{
{
content = error;
content = error;
}
}
new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
}
}
});
});
}
}
}
}