server

Clone or download

EXE/DEB support

Modified Files

/*
/*
ServerInfo.java
ServerInfo.java
Stores basic information about the server - name, platform type
Stores basic information about the server - name, platform type
Contributors: Debayan Sutradhar (@dubbadhar)
Contributors: Debayan Sutradhar (@dubbadhar)
*/
*/
package com.stream_pi.server.info;
package com.stream_pi.server.info;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.ReleaseStatus;
import com.stream_pi.util.platform.ReleaseStatus;
import com.stream_pi.util.version.Version;
import com.stream_pi.util.version.Version;
public class ServerInfo {
public class ServerInfo {
private Version version;
private Version version;
private final ReleaseStatus releaseStatus;
private final ReleaseStatus releaseStatus;
private final Platform platformType;
private final Platform platformType;
private String prePath;
private String prePath;
private Version minThemeSupportVersion;
private Version minThemeSupportVersion;
private Version minPluginSupportVersion;
private Version minPluginSupportVersion;
private Version commStandardVersion;
private Version commStandardVersion;
private static ServerInfo instance = null;
private static ServerInfo instance = null;
private String runnerFileName = null;
private String runnerFileName = null;
private boolean startMinimised = false;
private boolean startMinimised = false;
private ServerInfo()
private ServerInfo()
{
{
version = new Version(1,0,0);
version = new Version(1,0,0);
minThemeSupportVersion = new Version(1,0,0);
minThemeSupportVersion = new Version(1,0,0);
minPluginSupportVersion = new Version(1,0,0);
minPluginSupportVersion = new Version(1,0,0);
commStandardVersion = new Version(1,0,0);
commStandardVersion = new Version(1,0,0);
releaseStatus = ReleaseStatus.EA;
releaseStatus = ReleaseStatus.EA;
prePath = "data/";
prePath = System.getProperty("user.home")+"/Stream-Pi/Server/";
String osName = System.getProperty("os.name").toLowerCase();
String osName = System.getProperty("os.name").toLowerCase();
if(osName.contains("windows"))
if(osName.contains("windows"))
platformType = Platform.WINDOWS;
platformType = Platform.WINDOWS;
else if (osName.contains("linux"))
else if (osName.contains("linux"))
platformType = Platform.LINUX;
platformType = Platform.LINUX;
else if (osName.contains("mac"))
else if (osName.contains("mac"))
platformType = Platform.MAC;
platformType = Platform.MAC;
else
else
platformType = Platform.UNKNOWN;
platformType = Platform.UNKNOWN;
}
}
public String getPrePath() {
public String getPrePath() {
return prePath;
return prePath;
}
}
public void setStartMinimised(boolean startMinimised)
public void setStartMinimised(boolean startMinimised)
{
{
this.startMinimised = startMinimised;
this.startMinimised = startMinimised;
}
}
public boolean isStartMinimised()
public boolean isStartMinimised()
{
{
return startMinimised;
return startMinimised;
}
}
public void setRunnerFileName(String runnerFileName)
public void setRunnerFileName(String runnerFileName)
{
{
this.runnerFileName = runnerFileName;
this.runnerFileName = runnerFileName;
}
}
public String getRunnerFileName()
public String getRunnerFileName()
{
{
return runnerFileName;
return runnerFileName;
}
}
public static synchronized ServerInfo getInstance()
public static synchronized ServerInfo getInstance()
{
{
if(instance == null)
if(instance == null)
{
{
instance = new ServerInfo();
instance = new ServerInfo();
}
}
return instance;
return instance;
}
}
public Platform getPlatformType()
public Platform getPlatformType()
{
{
return platformType;
return platformType;
}
}
public Version getVersion() {
public Version getVersion() {
return version;
return version;
}
}
public ReleaseStatus getReleaseStatus()
public ReleaseStatus getReleaseStatus()
{
{
return releaseStatus;
return releaseStatus;
}
}
public Version getMinThemeSupportVersion()
public Version getMinThemeSupportVersion()
{
{
return minThemeSupportVersion;
return minThemeSupportVersion;
}
}
public Version getMinPluginSupportVersion()
public Version getMinPluginSupportVersion()
{
{
return minPluginSupportVersion;
return minPluginSupportVersion;
}
}
public Version getCommStandardVersion()
public Version getCommStandardVersion()
{
{
return commStandardVersion;
return commStandardVersion;
}
}
}
}
/*
/*
Config.java
Config.java
Contributor(s) : Debayan Sutradhar (@rnayabed)
Contributor(s) : Debayan Sutradhar (@rnayabed)
handler for config.xml
handler for config.xml
*/
*/
package com.stream_pi.server.io;
package com.stream_pi.server.io;
import java.io.File;
import java.io.File;
import java.util.logging.Logger;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamResult;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.xmlconfighelper.XMLConfigHelper;
import com.stream_pi.util.xmlconfighelper.XMLConfigHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Element;
public class Config
public class Config
{
{
private static Config instance = null;
private static Config instance = null;
private final File configFile;
private final File configFile;
private Document document;
private Document document;
private Config() throws SevereException {
private Config() throws SevereException {
try {
try {
configFile = new File(ServerInfo.getInstance().getPrePath()+"config.xml");
configFile = new File(ServerInfo.getInstance().getPrePath()+"config.xml");
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
document = docBuilder.parse(configFile);
document = docBuilder.parse(configFile);
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
throw new SevereException("Config", "unable to read config.xml");
throw new SevereException("Config", "unable to read config.xml");
}
}
}
}
public static synchronized Config getInstance() throws SevereException
public static synchronized Config getInstance() throws SevereException
{
{
if(instance == null)
if(instance == null)
instance = new Config();
instance = new Config();
return instance;
return instance;
}
}
Logger logger = Logger.getLogger(Config.class.getName());
Logger logger = Logger.getLogger(Config.class.getName());
public void save() throws SevereException {
public void save() throws SevereException {
try {
try {
logger.info("Saving config ...");
logger.info("Saving config ...");
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(configFile);
Result output = new StreamResult(configFile);
Source input = new DOMSource(document);
Source input = new DOMSource(document);
transformer.transform(input, output);
transformer.transform(input, output);
logger.info("... Done!");
logger.info("... Done!");
} catch (Exception e) {
} catch (Exception e) {
throw new SevereException("Config", "unable to save config.xml");
throw new SevereException("Config", "unable to save config.xml");
}
}
}
}
//Getters
//Getters
//comms
//comms
private Element getCommsElement()
private Element getCommsElement()
{
{
return (Element) document.getElementsByTagName("comms").item(0);
return (Element) document.getElementsByTagName("comms").item(0);
}
}
public String getServerName()
public String getServerName()
{
{
return XMLConfigHelper.getStringProperty(getCommsElement(), "name",
return XMLConfigHelper.getStringProperty(getCommsElement(), "name",
getDefaultServerName(), false, true, document, configFile);
getDefaultServerName(), false, true, document, configFile);
}
}
public int getPort()
public int getPort()
{
{
return XMLConfigHelper.getIntProperty(getCommsElement(), "port",
return XMLConfigHelper.getIntProperty(getCommsElement(), "port",
getDefaultPort(), false, true, document, configFile);
getDefaultPort(), false, true, document, configFile);
}
}
//default getters
//default getters
public String getDefaultServerName()
public String getDefaultServerName()
{
{
return "Stream-Pi Server";
return "Stream-Pi Server";
}
}
public int getDefaultPort()
public int getDefaultPort()
{
{
return 2004;
return 2004;
}
}
private Element getServerElement()
private Element getServerElement()
{
{
return (Element) document.getElementsByTagName("server").item(0);
return (Element) document.getElementsByTagName("server").item(0);
}
}
//server
//server
private Element getActionGridElement()
private Element getActionGridElement()
{
{
return (Element) getServerElement().getElementsByTagName("action-grid").item(0);
return (Element) getServerElement().getElementsByTagName("action-grid").item(0);
}
}
public int getActionGridActionGap()
public int getActionGridActionGap()
{
{
return XMLConfigHelper.getIntProperty(getActionGridElement(), "gap",
return XMLConfigHelper.getIntProperty(getActionGridElement(), "gap",
getDefaultActionGridActionGap(), false, true, document, configFile);
getDefaultActionGridActionGap(), false, true, document, configFile);
}
}
public int getActionGridActionSize()
public int getActionGridActionSize()
{
{
return XMLConfigHelper.getIntProperty(getActionGridElement(), "size",
return XMLConfigHelper.getIntProperty(getActionGridElement(), "size",
getDefaultActionGridSize(), false, true, document, configFile);
getDefaultActionGridSize(), false, true, document, configFile);
}
}
public String getCurrentThemeFullName()
public String getCurrentThemeFullName()
{
{
return XMLConfigHelper.getStringProperty(getServerElement(), "current-theme-full-name",
return XMLConfigHelper.getStringProperty(getServerElement(), "current-theme-full-name",
getDefaultCurrentThemeFullName(), false, true, document, configFile);
getDefaultCurrentThemeFullName(), false, true, document, configFile);
}
}
public String getThemesPath()
public String getThemesPath()
{
{
return XMLConfigHelper.getStringProperty(getServerElement(), "themes-path",
return XMLConfigHelper.getStringProperty(getServerElement(), "themes-path",
getDefaultThemesPath(), false, true, document, configFile);
getDefaultThemesPath(), false, true, document, configFile);
}
}
public String getPluginsPath()
public String getPluginsPath()
{
{
return XMLConfigHelper.getStringProperty(getServerElement(), "plugins-path",
return XMLConfigHelper.getStringProperty(getServerElement(), "plugins-path",
getDefaultPluginsPath(), false, true, document, configFile);
getDefaultPluginsPath(), false, true, document, configFile);
}
}
//default getters
//default getters
public String getDefaultCurrentThemeFullName()
public String getDefaultCurrentThemeFullName()
{
{
return "com.stream_pi.defaultlight";
return "com.stream_pi.defaultlight";
}
}
public String getDefaultThemesPath()
public String getDefaultThemesPath()
{
{
return "Themes/";
return ServerInfo.getInstance().getPrePath()+"Themes/";
}
}
public String getDefaultPluginsPath()
public String getDefaultPluginsPath()
{
{
return "Plugins/";
return ServerInfo.getInstance().getPrePath()+"Plugins/";
}
}
//server > startup-window-size
//server > startup-window-size
private Element getStartupWindowSizeElement()
private Element getStartupWindowSizeElement()
{
{
return (Element) getServerElement().getElementsByTagName("startup-window-size").item(0);
return (Element) getServerElement().getElementsByTagName("startup-window-size").item(0);
}
}
public double getStartupWindowWidth()
public double getStartupWindowWidth()
{
{
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width",
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width",
getDefaultStartupWindowWidth(), false, true, document, configFile);
getDefaultStartupWindowWidth(), false, true, document, configFile);
}
}
public double getStartupWindowHeight()
public double getStartupWindowHeight()
{
{
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height",
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height",
getDefaultStartupWindowHeight(), false, true, document, configFile);
getDefaultStartupWindowHeight(), false, true, document, configFile);
}
}
//default getters
//default getters
public int getDefaultStartupWindowWidth()
public int getDefaultStartupWindowWidth()
{
{
return 1024;
return 1024;
}
}
public int getDefaultStartupWindowHeight()
public int getDefaultStartupWindowHeight()
{
{
return 768;
return 768;
}
}
//others
//others
private Element getOthersElement()
private Element getOthersElement()
{
{
return (Element) document.getElementsByTagName("others").item(0);
return (Element) document.getElementsByTagName("others").item(0);
}
}
public boolean getStartOnBoot()
public boolean getStartOnBoot()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot",
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot",
getDefaultStartOnBoot(), false, true, document, configFile);
getDefaultStartOnBoot(), false, true, document, configFile);
}
}
public boolean getMinimiseToSystemTrayOnClose()
public boolean getMinimiseToSystemTrayOnClose()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "minimize-to-tray-on-close",
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "minimize-to-tray-on-close",
getDefaultMinimiseToSystemTrayOnClose(), false, true, document, configFile);
getDefaultMinimiseToSystemTrayOnClose(), false, true, document, configFile);
}
}
public boolean isFirstTimeUse()
public boolean isFirstTimeUse()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile);
}
}
public boolean isAllowDonatePopup()
public boolean isAllowDonatePopup()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "allow-donate-popup", true, false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "allow-donate-popup", true, false, true, document, configFile);
}
}
//default getters
//default getters
public boolean getDefaultStartOnBoot()
public boolean getDefaultStartOnBoot()
{
{
return false;
return false;
}
}
public boolean getDefaultMinimiseToSystemTrayOnClose()
public boolean getDefaultMinimiseToSystemTrayOnClose()
{
{
return true;
return true;
}
}
//Setters
//Setters
//comms
//comms
public void setServerName(String name)
public void setServerName(String name)
{
{
getCommsElement().getElementsByTagName("name").item(0).setTextContent(name);
getCommsElement().getElementsByTagName("name").item(0).setTextContent(name);
}
}
public void setServerPort(int port)
public void setServerPort(int port)
{
{
getCommsElement().getElementsByTagName("port").item(0).setTextContent(port+"");
getCommsElement().getElementsByTagName("port").item(0).setTextContent(port+"");
}
}
//server
//server
public int getDefaultActionGridActionGap()
public int getDefaultActionGridActionGap()
{
{
return 5;
return 5;
}
}
public int getDefaultActionGridSize()
public int getDefaultActionGridSize()
{
{
return 100;
return 100;
}
}
public void setActionGridSize(int size)
public void setActionGridSize(int size)
{
{
getActionGridElement().getElementsByTagName("size").item(0).setTextContent(size+"");
getActionGridElement().getElementsByTagName("size").item(0).setTextContent(size+"");
}
}
public void setActionGridGap(int size)
public void setActionGridGap(int size)
{
{
getActionGridElement().getElementsByTagName("gap").item(0).setTextContent(size+"");
getActionGridElement().getElementsByTagName("gap").item(0).setTextContent(size+"");
}
}
public void setPluginsPath(String path)
public void setPluginsPath(String path)
{
{
getServerElement().getElementsByTagName("plugins-path").item(0).setTextContent(path);
getServerElement().getElementsByTagName("plugins-path").item(0).setTextContent(path);
}
}
public void setThemesPath(String path)
public void setThemesPath(String path)
{
{
getServerElement().getElementsByTagName("themes-path").item(0).setTextContent(path);
getServerElement().getElementsByTagName("themes-path").item(0).setTextContent(path);
}
}
public void setCurrentThemeFullName(String themeName)
public void setCurrentThemeFullName(String themeName)
{
{
getServerElement().getElementsByTagName("current-theme-full-name").item(0).setTextContent(themeName);
getServerElement().getElementsByTagName("current-theme-full-name").item(0).setTextContent(themeName);
}
}
//server > startup-window-size
//server > startup-window-size
public void setStartupWindowSize(double width, double height)
public void setStartupWindowSize(double width, double height)
{
{
setStartupWindowWidth(width);
setStartupWindowWidth(width);
setStartupWindowHeight(height);
setStartupWindowHeight(height);
}
}
public void setStartupWindowWidth(double width)
public void setStartupWindowWidth(double width)
{
{
getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+"");
getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+"");
}
}
public void setStartupWindowHeight(double height)
public void setStartupWindowHeight(double height)
{
{
getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+"");
getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+"");
}
}
//others
//others
public void setStartupOnBoot(boolean value)
public void setStartupOnBoot(boolean value)
{
{
getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+"");
}
}
public void setMinimiseToSystemTrayOnClose(boolean value)
public void setMinimiseToSystemTrayOnClose(boolean value)
{
{
getOthersElement().getElementsByTagName("minimize-to-tray-on-close").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("minimize-to-tray-on-close").item(0).setTextContent(value+"");
}
}
public void setFirstTimeUse(boolean value)
public void setFirstTimeUse(boolean value)
{
{
getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+"");
}
}
public void setAllowDonatePopup(boolean value)
public void setAllowDonatePopup(boolean value)
{
{
getOthersElement().getElementsByTagName("allow-donate-popup").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("allow-donate-popup").item(0).setTextContent(value+"");
}
}
}
}
package com.stream_pi.server.window;
package com.stream_pi.server.window;
import com.stream_pi.server.connection.ServerListener;
import com.stream_pi.server.connection.ServerListener;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.Main;
import com.stream_pi.server.Main;
import com.stream_pi.server.window.dashboard.DashboardBase;
import com.stream_pi.server.window.dashboard.DashboardBase;
import com.stream_pi.server.window.settings.SettingsBase;
import com.stream_pi.server.window.settings.SettingsBase;
import com.stream_pi.theme_api.Theme;
import com.stream_pi.theme_api.Theme;
import com.stream_pi.theme_api.Themes;
import com.stream_pi.theme_api.Themes;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
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.iohelper.IOHelper;
import com.stream_pi.util.iohelper.IOHelper;
import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler;
import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler;
import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler;
import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.Platform;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.scene.image.Image;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.Stage;
import java.awt.*;
import java.io.File;
import java.io.File;
import java.util.logging.Logger;
import java.util.logging.Logger;
public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ServerListener {
public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ServerListener {
private Config config;
private Config config;
private ServerInfo serverInfo;
private ServerInfo serverInfo;
private Stage stage;
private Stage stage;
private HostServices hostServices;
private HostServices hostServices;
public Logger getLogger(){
public Logger getLogger(){
return logger;
return logger;
}
}
private SettingsBase settingsBase;
private SettingsBase settingsBase;
private DashboardBase dashboardBase;
private DashboardBase dashboardBase;
private StackPane alertStackPane;
private StackPane alertStackPane;
public void setHostServices(HostServices hostServices)
public void setHostServices(HostServices hostServices)
{
{
this.hostServices = hostServices;
this.hostServices = hostServices;
}
}
public HostServices getHostServices()
public HostServices getHostServices()
{
{
return hostServices;
return hostServices;
}
}
private Logger logger = null;
private Logger logger = null;
private StreamPiLogFileHandler logFileHandler = null;
private StreamPiLogFileHandler logFileHandler = null;
private StreamPiLogFallbackHandler logFallbackHandler = null;
private StreamPiLogFallbackHandler logFallbackHandler = null;
@Override
@Override
public void initLogger() throws SevereException
public void initLogger() throws SevereException
{
{
try
try
{
{
if(logger != null || logFileHandler != null)
if(logger != null || logFileHandler != null)
return;
return;
closeLogger();
closeLogger();
logger = Logger.getLogger("");
logger = Logger.getLogger("");
if(new File(ServerInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite())
if(new File(ServerInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite())
{
{
String path = ServerInfo.getInstance().getPrePath()+"../streampi.log";
String path = ServerInfo.getInstance().getPrePath()+"../streampi.log";
if(ServerInfo.getInstance().getPlatformType() == Platform.ANDROID)
if(ServerInfo.getInstance().getPlatformType() == Platform.ANDROID)
path = ServerInfo.getInstance().getPrePath()+"streampi.log";
path = ServerInfo.getInstance().getPrePath()+"streampi.log";
logFileHandler = new StreamPiLogFileHandler(path);
logFileHandler = new StreamPiLogFileHandler(path);
logger.addHandler(logFileHandler);
logger.addHandler(logFileHandler);
}
}
else
else
{
{
logFallbackHandler = new StreamPiLogFallbackHandler();
logFallbackHandler = new StreamPiLogFallbackHandler();
logger.addHandler(logFallbackHandler);
logger.addHandler(logFallbackHandler);
}
}
}
}
catch(Exception e)
catch(Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
logFallbackHandler = new StreamPiLogFallbackHandler();
logFallbackHandler = new StreamPiLogFallbackHandler();
logger.addHandler(logFallbackHandler);
logger.addHandler(logFallbackHandler);
}
}
}
}
public void closeLogger()
public void closeLogger()
{
{
if(logFileHandler != null)
if(logFileHandler != null)
logFileHandler.close();
logFileHandler.close();
else if(logFallbackHandler != null)
else if(logFallbackHandler != null)
logFallbackHandler.close();
logFallbackHandler.close();
}
}
public void initBase() throws SevereException
public void initBase() throws SevereException
{
{
stage = (Stage) getScene().getWindow();
stage = (Stage) getScene().getWindow();
getStage().getIcons().add(new Image(Main.class.getResourceAsStream("app_icon.png")));
getStage().getIcons().add(new Image(Main.class.getResourceAsStream("app_icon.png")));
getStage().setMinWidth(500);
getStage().setMinWidth(500);
getStage().setMinHeight(500);
getStage().setMinHeight(500);
serverInfo = ServerInfo.getInstance();
serverInfo = ServerInfo.getInstance();
settingsBase = new SettingsBase(getHostServices(), this, this);
settingsBase = new SettingsBase(getHostServices(), this, this);
settingsBase.prefWidthProperty().bind(widthProperty());
settingsBase.prefWidthProperty().bind(widthProperty());
settingsBase.prefHeightProperty().bind(heightProperty());
settingsBase.prefHeightProperty().bind(heightProperty());
dashboardBase = new DashboardBase(this, getHostServices());
dashboardBase = new DashboardBase(this, getHostServices());
dashboardBase.prefWidthProperty().bind(widthProperty());
dashboardBase.prefWidthProperty().bind(widthProperty());
dashboardBase.prefHeightProperty().bind(heightProperty());
dashboardBase.prefHeightProperty().bind(heightProperty());
alertStackPane = new StackPane();
alertStackPane = new StackPane();
alertStackPane.setVisible(false);
alertStackPane.setVisible(false);
StreamPiAlert.setParent(alertStackPane);
StreamPiAlert.setParent(alertStackPane);
getChildren().clear();
getChildren().clear();
getChildren().addAll(alertStackPane);
getChildren().addAll(alertStackPane);
initLogger();
initLogger();
checkPrePathDirectory();
checkPrePathDirectory();
getChildren().addAll(settingsBase, dashboardBase);
getChildren().addAll(settingsBase, dashboardBase);
config = Config.getInstance();
config = Config.getInstance();
initThemes();
initThemes();
stage.setWidth(config.getStartupWindowWidth());
stage.setWidth(config.getStartupWindowWidth());
stage.setHeight(config.getStartupWindowHeight());
stage.setHeight(config.getStartupWindowHeight());
stage.centerOnScreen();
stage.centerOnScreen();
dashboardBase.toFront();
dashboardBase.toFront();
}
}
private void checkPrePathDirectory() throws SevereException
private void checkPrePathDirectory() throws SevereException
{
{
try
try
{
{
File filex = new File(ServerInfo.getInstance().getPrePath());
File filex = new File(ServerInfo.getInstance().getPrePath());
if(filex.getAbsoluteFile().getParentFile().canWrite())
if(!filex.exists())
{
{
if(!filex.exists())
boolean result = filex.mkdirs();
if(result)
{
{
filex.mkdirs();
IOHelper.unzip(Main.class.getResourceAsStream("Default.obj"), ServerInfo.getInstance().getPrePath());
IOHelper.unzip(Main.class.getResourceAsStream("Default.obj"), ServerInfo.getInstance().getPrePath());
Config.getInstance().setThemesPath(ServerInfo.getInstance().getPrePath()+"Themes/");
Config.getInstance().setPluginsPath(ServerInfo.getInstance().getPrePath()+"Plugins/");
if(SystemTray.isSupported())
{
Config.getInstance().setMinimiseToSystemTrayOnClose(true);
}
Config.getInstance().save();
}
else
{
setPrefSize(300,300);
clearStylesheets();
applyDefaultStylesheet();
applyDefaultIconsStylesheet();
getStage().show();
throw new SevereException("No storage permission. Give it!");
}
}
}
else
{
setPrefSize(300,300);
clearStylesheets();
applyDefaultStylesheet();
applyDefaultIconsStylesheet();
getStage().show();
throw new SevereException("No storage permission. Give it!");
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException(e.getMessage());
throw new SevereException(e.getMessage());
}
}
}
}
public void initThemes() throws SevereException {
public void initThemes() throws SevereException {
clearStylesheets();
clearStylesheets();
registerThemes();
registerThemes();
applyDefaultStylesheet();
applyDefaultStylesheet();
applyDefaultTheme();
applyDefaultTheme();
applyDefaultIconsStylesheet();
applyDefaultIconsStylesheet();
}
}
public Stage getStage()
public Stage getStage()
{
{
return stage;
return stage;
}
}
public void applyDefaultStylesheet()
public void applyDefaultStylesheet()
{
{
logger.info("Applying default stylesheet ...");
logger.info("Applying default stylesheet ...");
Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13);
Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13);
getStylesheets().add(Main.class.getResource("style.css").toExternalForm());
getStylesheets().add(Main.class.getResource("style.css").toExternalForm());
logger.info("... Done!");
logger.info("... Done!");
}
}
public void applyDefaultIconsStylesheet()
public void applyDefaultIconsStylesheet()
{
{
Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13);
Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13);
getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm());
getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm());
}
}
public DashboardBase getDashboardPane()
public DashboardBase getDashboardPane()
{
{
return dashboardBase;
return dashboardBase;
}
}
public SettingsBase getSettingsPane()
public SettingsBase getSettingsPane()
{
{
return settingsBase;
return settingsBase;
}
}
public Config getConfig()
public Config getConfig()
{
{
return config;
return config;
}
}
public ServerInfo getServerInfo()
public ServerInfo getServerInfo()
{
{
return serverInfo;
return serverInfo;
}
}
private Theme currentTheme;
private Theme currentTheme;
public Theme getCurrentTheme()
public Theme getCurrentTheme()
{
{
return currentTheme;
return currentTheme;
}
}
public void applyTheme(Theme t)
public void applyTheme(Theme t)
{
{
logger.info("Applying theme '"+t.getFullName()+"' ...");
logger.info("Applying theme '"+t.getFullName()+"' ...");
if(t.getFonts() != null)
if(t.getFonts() != null)
{
{
for(String fontFile : t.getFonts())
for(String fontFile : t.getFonts())
{
{
Font.loadFont(fontFile.replace("%20",""), 13);
Font.loadFont(fontFile.replace("%20",""), 13);
}
}
}
}
currentTheme = t;
currentTheme = t;
getStylesheets().addAll(t.getStylesheets());
getStylesheets().addAll(t.getStylesheets());
logger.info("... Done!");
logger.info("... Done!");
}
}
public void clearStylesheets()
public void clearStylesheets()
{
{
getStylesheets().clear();
getStylesheets().clear();
}
}
Themes themes;
Themes themes;
public void registerThemes() throws SevereException
public void registerThemes() throws SevereException
{
{
logger.info("Loading themes ...");
logger.info("Loading themes ...");
themes = new Themes(getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), serverInfo.getMinThemeSupportVersion());
themes = new Themes(getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), serverInfo.getMinThemeSupportVersion());
if(themes.getErrors().size()>0)
if(themes.getErrors().size()>0)
{
{
StringBuilder themeErrors = new StringBuilder();
StringBuilder themeErrors = new StringBuilder();
for(MinorException eachException : themes.getErrors())
for(MinorException eachException : themes.getErrors())
{
{
themeErrors.append("\n * ").append(eachException.getShortMessage());
themeErrors.append("\n * ").append(eachException.getShortMessage());
}
}
if(themes.getIsBadThemeTheCurrentOne())
if(themes.getIsBadThemeTheCurrentOne())
{
{
themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")");
themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")");
getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName());
getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName());
getConfig().save();
getConfig().save();
}
}
handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString()));
handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString()));
}
}
logger.info("... Done!");
logger.info("... Done!");
}
}
public Themes getThemes()
public Themes getThemes()
{
{
return themes;
return themes;
}
}
public void applyDefaultTheme()
public void applyDefaultTheme()
{
{
logger.info("Applying default theme ...");
logger.info("Applying default theme ...");
boolean foundTheme = false;
boolean foundTheme = false;
for(Theme t: themes.getThemeList())
for(Theme t: themes.getThemeList())
{
{
if(t.getFullName().equals(config.getCurrentThemeFullName()))
if(t.getFullName().equals(config.getCurrentThemeFullName()))
{
{
foundTheme = true;
foundTheme = true;
applyTheme(t);
applyTheme(t);
break;
break;
}
}
}
}
if(foundTheme)
if(foundTheme)
logger.info("... Done!");
logger.info("... Done!");
else
else
{
{
logger.info("Theme not found. reverting to light theme ...");
logger.info("Theme not found. reverting to light theme ...");
try {
try {
Config.getInstance().setCurrentThemeFullName("com.streampi.DefaultLight");
Config.getInstance().setCurrentThemeFullName("com.streampi.DefaultLight");
Config.getInstance().save();
Config.getInstance().save();
applyDefaultTheme();
applyDefaultTheme();
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
}
}
}
}
}
}
package com.stream_pi.server.window.settings;
package com.stream_pi.server.window.settings;
import com.stream_pi.server.connection.ServerListener;
import com.stream_pi.server.connection.ServerListener;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.ServerInfo;
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.checkforupdates.CheckForUpdates;
import com.stream_pi.util.checkforupdates.CheckForUpdates;
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.platform.PlatformType;
import com.stream_pi.util.platform.PlatformType;
import com.stream_pi.util.startatboot.StartAtBoot;
import com.stream_pi.util.startatboot.StartAtBoot;
import com.stream_pi.util.version.Version;
import com.stream_pi.util.version.Version;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.control.TextField;
import javafx.scene.layout.*;
import javafx.scene.layout.*;
import javafx.stage.DirectoryChooser;
import javafx.stage.DirectoryChooser;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.awt.SystemTray;
import java.awt.SystemTray;
import java.io.BufferedReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.File;
import java.io.InputStreamReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URL;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class GeneralSettings extends VBox {
public class GeneralSettings extends VBox {
private final TextField serverNameTextField;
private final TextField serverNameTextField;
private final TextField portTextField;
private final TextField portTextField;
private final TextField pluginsPathTextField;
private final TextField pluginsPathTextField;
private final TextField themesPathTextField;
private final TextField themesPathTextField;
private final TextField actionGridPaneActionBoxSize;
private final TextField actionGridPaneActionBoxSize;
private final TextField actionGridPaneActionBoxGap;
private final TextField actionGridPaneActionBoxGap;
private final ToggleButton startOnBootToggleButton;
private final ToggleButton startOnBootToggleButton;
private final ToggleButton minimizeToSystemTrayOnCloseToggleButton;
private final ToggleButton minimizeToSystemTrayOnCloseToggleButton;
private final Button saveButton;
private final Button saveButton;
private final Button checkForUpdatesButton;
private final Button checkForUpdatesButton;
private Logger logger;
private Logger logger;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ServerListener serverListener;
private ServerListener serverListener;
private HostServices hostServices;
private HostServices hostServices;
public GeneralSettings(ExceptionAndAlertHandler exceptionAndAlertHandler, ServerListener serverListener, HostServices hostServices)
public GeneralSettings(ExceptionAndAlertHandler exceptionAndAlertHandler, ServerListener serverListener, HostServices hostServices)
{
{
this.hostServices = hostServices;
this.hostServices = hostServices;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.serverListener = serverListener;
this.serverListener = serverListener;
logger = Logger.getLogger(GeneralSettings.class.getName());
logger = Logger.getLogger(GeneralSettings.class.getName());
serverNameTextField = new TextField();
serverNameTextField = new TextField();
portTextField = new TextField();
portTextField = new TextField();
pluginsPathTextField = new TextField();
pluginsPathTextField = new TextField();
themesPathTextField = new TextField();
themesPathTextField = new TextField();
actionGridPaneActionBoxSize = new TextField();
actionGridPaneActionBoxSize = new TextField();
actionGridPaneActionBoxGap = new TextField();
actionGridPaneActionBoxGap = new TextField();
startOnBootToggleButton = new ToggleButton("Start on Boot");
startOnBootToggleButton = new ToggleButton("Start on Boot");
minimizeToSystemTrayOnCloseToggleButton = new ToggleButton("Minimise To Tray On Close");
minimizeToSystemTrayOnCloseToggleButton = new ToggleButton("Minimise To Tray On Close");
checkForUpdatesButton = new Button("Check for updates");
checkForUpdatesButton = new Button("Check for updates");
checkForUpdatesButton.setOnAction(event->checkForUpdates());
checkForUpdatesButton.setOnAction(event->checkForUpdates());
getStyleClass().add("general_settings");
getStyleClass().add("general_settings");
prefWidthProperty().bind(widthProperty());
prefWidthProperty().bind(widthProperty());
setAlignment(Pos.CENTER);
setAlignment(Pos.CENTER);
setSpacing(5);
setSpacing(5);
getChildren().addAll(
getChildren().addAll(
getUIInputBox("Server Name", serverNameTextField),
getUIInputBox("Server Name", serverNameTextField),
getUIInputBox("Port", portTextField),
getUIInputBox("Port", portTextField),
getUIInputBox("Grid Pane - Box Size", actionGridPaneActionBoxSize),
getUIInputBox("Grid Pane - Box Size", actionGridPaneActionBoxSize),
getUIInputBox("Grid Pane - Box Gap", actionGridPaneActionBoxGap),
getUIInputBox("Grid Pane - Box Gap", actionGridPaneActionBoxGap),
getUIInputBoxWithDirectoryChooser("Plugins Path", pluginsPathTextField),
getUIInputBoxWithDirectoryChooser("Plugins Path", pluginsPathTextField),
getUIInputBoxWithDirectoryChooser("Themes Path", themesPathTextField)
getUIInputBoxWithDirectoryChooser("Themes Path", themesPathTextField)
);
);
serverNameTextField.setPrefWidth(200);
serverNameTextField.setPrefWidth(200);
HBox toggleButtons = new HBox(minimizeToSystemTrayOnCloseToggleButton, startOnBootToggleButton);
HBox toggleButtons = new HBox(minimizeToSystemTrayOnCloseToggleButton, startOnBootToggleButton);
toggleButtons.setSpacing(10.0);
toggleButtons.setSpacing(10.0);
VBox.setMargin(toggleButtons, new Insets(30, 0 , 0,0));
VBox.setMargin(toggleButtons, new Insets(30, 0 , 0,0));
toggleButtons.setAlignment(Pos.CENTER);
toggleButtons.setAlignment(Pos.CENTER);
saveButton = new Button("Save");
saveButton = new Button("Save");
saveButton.setOnAction(event->save());
saveButton.setOnAction(event->save());
getChildren().addAll(toggleButtons, checkForUpdatesButton, saveButton);
getChildren().addAll(toggleButtons, checkForUpdatesButton, saveButton);
setPadding(new Insets(10));
setPadding(new Insets(10));
}
}
private void checkForUpdates()
private void checkForUpdates()
{
{
new CheckForUpdates(checkForUpdatesButton, hostServices,
new CheckForUpdates(checkForUpdatesButton, hostServices,
PlatformType.SERVER, ServerInfo.getInstance().getVersion());
PlatformType.SERVER, ServerInfo.getInstance().getVersion());
}
}
private HBox getUIInputBoxWithDirectoryChooser(String labelText, TextField textField)
private HBox getUIInputBoxWithDirectoryChooser(String labelText, TextField textField)
{
{
HBox hBox = getUIInputBox(labelText, textField);
HBox hBox = getUIInputBox(labelText, textField);
hBox.setSpacing(5.0);
hBox.setSpacing(5.0);
TextField tf = (TextField) hBox.getChildren().get(2);
TextField tf = (TextField) hBox.getChildren().get(2);
tf.setPrefWidth(300);
tf.setPrefWidth(300);
tf.setDisable(true);
tf.setDisable(true);
Button button = new Button();
Button button = new Button();
FontIcon fontIcon = new FontIcon("far-folder");
FontIcon fontIcon = new FontIcon("far-folder");
button.setGraphic(fontIcon);
button.setGraphic(fontIcon);
button.setOnAction(event -> {
button.setOnAction(event -> {
DirectoryChooser directoryChooser = new DirectoryChooser();
DirectoryChooser directoryChooser = new DirectoryChooser();
try {
try {
File selectedDirectory = directoryChooser.showDialog(getScene().getWindow());
File selectedDirectory = directoryChooser.showDialog(getScene().getWindow());
textField.setText(selectedDirectory.getAbsolutePath());
textField.setText(selectedDirectory.getAbsolutePath());
}
}
catch (NullPointerException e)
catch (NullPointerException e)
{
{
logger.info("No folder selected");
logger.info("No folder selected");
}
}
});
});
hBox.getChildren().add(button);
hBox.getChildren().add(button);
return hBox;
return hBox;
}
}
private HBox getUIInputBox(String labelText, TextField textField)
private HBox getUIInputBox(String labelText, TextField textField)
{
{
textField.setPrefWidth(100);
textField.setPrefWidth(100);
Label label = new Label(labelText);
Label label = new Label(labelText);
Region region = new Region();
Region region = new Region();
HBox.setHgrow(region, Priority.ALWAYS);
HBox.setHgrow(region, Priority.ALWAYS);
return new HBox(label, region, textField);
return new HBox(label, region, textField);
}
}
public void loadDataFromConfig() throws SevereException {
public void loadDataFromConfig() throws SevereException {
Config config = Config.getInstance();
Config config = Config.getInstance();
Platform.runLater(()->
Platform.runLater(()->
{
{
serverNameTextField.setText(config.getServerName());
serverNameTextField.setText(config.getServerName());
portTextField.setText(config.getPort()+"");
portTextField.setText(config.getPort()+"");
pluginsPathTextField.setText(config.getPluginsPath());
pluginsPathTextField.setText(config.getPluginsPath());
themesPathTextField.setText(config.getThemesPath());
themesPathTextField.setText(config.getThemesPath());
actionGridPaneActionBoxSize.setText(config.getActionGridActionSize()+"");
actionGridPaneActionBoxSize.setText(config.getActionGridActionSize()+"");
actionGridPaneActionBoxGap.setText(config.getActionGridActionGap()+"");
actionGridPaneActionBoxGap.setText(config.getActionGridActionGap()+"");
minimizeToSystemTrayOnCloseToggleButton.setSelected(config.getMinimiseToSystemTrayOnClose());
minimizeToSystemTrayOnCloseToggleButton.setSelected(config.getMinimiseToSystemTrayOnClose());
startOnBootToggleButton.setSelected(config.getStartOnBoot());
startOnBootToggleButton.setSelected(config.getStartOnBoot());
});
});
}
}
public void save()
public void save()
{
{
new Thread(new Task<Void>() {
new Thread(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try {
try {
boolean toBeReloaded = false;
boolean toBeReloaded = false;
boolean dashToBeReRendered = false;
boolean dashToBeReRendered = false;
Platform.runLater(()->{
Platform.runLater(()->{
saveButton.setDisable(true);
saveButton.setDisable(true);
serverNameTextField.setDisable(true);
serverNameTextField.setDisable(true);
portTextField.setDisable(true);
portTextField.setDisable(true);
minimizeToSystemTrayOnCloseToggleButton.setDisable(true);
minimizeToSystemTrayOnCloseToggleButton.setDisable(true);
startOnBootToggleButton.setDisable(true);
startOnBootToggleButton.setDisable(true);
});
});
String serverNameStr = serverNameTextField.getText();
String serverNameStr = serverNameTextField.getText();
String serverPortStr = portTextField.getText();
String serverPortStr = portTextField.getText();
String pluginsPathStr = pluginsPathTextField.getText();
String pluginsPathStr = pluginsPathTextField.getText();
String themesPathStr = themesPathTextField.getText();
String themesPathStr = themesPathTextField.getText();
String actionGridActionBoxSize = actionGridPaneActionBoxSize.getText();
String actionGridActionBoxSize = actionGridPaneActionBoxSize.getText();
String actionGridActionBoxGap = actionGridPaneActionBoxGap.getText();
String actionGridActionBoxGap = actionGridPaneActionBoxGap.getText();
boolean minimizeToSystemTrayOnClose = minimizeToSystemTrayOnCloseToggleButton.isSelected();
boolean minimizeToSystemTrayOnClose = minimizeToSystemTrayOnCloseToggleButton.isSelected();
boolean startOnBoot = startOnBootToggleButton.isSelected();
boolean startOnBoot = startOnBootToggleButton.isSelected();
Config config = Config.getInstance();
Config config = Config.getInstance();
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
if(serverNameStr.isBlank())
if(serverNameStr.isBlank())
{
{
errors.append("* Server Name cannot be blank.\n");
errors.append("* Server Name cannot be blank.\n");
}
}
else
else
{
{
if(!config.getServerName().equals(serverNameStr))
if(!config.getServerName().equals(serverNameStr))
{
{
toBeReloaded = true;
toBeReloaded = true;
}
}
}
}
int serverPort=-1;
int serverPort=-1;
try {
try {
serverPort = Integer.parseInt(serverPortStr);
serverPort = Integer.parseInt(serverPortStr);
if (serverPort < 1024)
if (serverPort < 1024)
errors.append("* Server Port must be more than 1024");
errors.append("* Server Port must be more than 1024");
if(config.getPort()!=serverPort)
if(config.getPort()!=serverPort)
{
{
toBeReloaded = true;
toBeReloaded = true;
}
}
}
}
catch (NumberFormatException e)
catch (NumberFormatException e)
{
{
errors.append("* Server Port must be integer.\n");
errors.append("* Server Port must be integer.\n");
}
}
int actionSize=-1;
int actionSize=-1;
try {
try {
actionSize = Integer.parseInt(actionGridActionBoxSize);
actionSize = Integer.parseInt(actionGridActionBoxSize);
if(config.getActionGridActionSize() != actionSize)
if(config.getActionGridActionSize() != actionSize)
{
{
dashToBeReRendered = true;
dashToBeReRendered = true;
}
}
}
}
catch (NumberFormatException e)
catch (NumberFormatException e)
{
{
errors.append("* action Size must be integer.\n");
errors.append("* action Size must be integer.\n");
}
}
int actionGap=-1;
int actionGap=-1;
try {
try {
actionGap = Integer.parseInt(actionGridActionBoxGap);
actionGap = Integer.parseInt(actionGridActionBoxGap);
if(config.getActionGridActionGap() != actionGap)
if(config.getActionGridActionGap() != actionGap)
{
{
dashToBeReRendered = true;
dashToBeReRendered = true;
}
}
}
}
catch (NumberFormatException e)
catch (NumberFormatException e)
{
{
errors.append("* action Gap must be integer.\n");
errors.append("* action Gap must be integer.\n");
}
}
if(pluginsPathStr.isBlank())
if(pluginsPathStr.isBlank())
{
{
errors.append("* Plugins Path must not be blank.\n");
errors.append("* Plugins Path must not be blank.\n");
}
}
else
else
{
{
if(!config.getPluginsPath().equals(pluginsPathStr))
if(!config.getPluginsPath().equals(pluginsPathStr))
{
{
toBeReloaded = true;
toBeReloaded = true;
}
}
}
}
if(themesPathStr.isBlank())
if(themesPathStr.isBlank())
{
{
errors.append("* Themes Path must not be blank.\n");
errors.append("* Themes Path must not be blank.\n");
}
}
else
else
{
{
if(!config.getThemesPath().equals(themesPathStr))
if(!config.getThemesPath().equals(themesPathStr))
{
{
toBeReloaded = true;
toBeReloaded = true;
}
}
}
}
if(!errors.toString().isEmpty())
if(!errors.toString().isEmpty())
{
{
throw new MinorException("settings", "Please rectify the following errors and try again :\n"+errors.toString());
throw new MinorException("settings", "Please rectify the following errors and try again :\n"+errors.toString());
}
}
if(config.getStartOnBoot() != startOnBoot)
if(config.getStartOnBoot() != startOnBoot)
{
{
if(ServerInfo.getInstance().getRunnerFileName() == null)
if(ServerInfo.getInstance().getRunnerFileName() == null)
{
{
new StreamPiAlert("Uh Oh", "No Runner File Name Specified as startup arguments. Cant set run at boot.", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh", "No Runner File Name Specified as startup arguments. Cant set run at boot.", StreamPiAlertType.ERROR).show();
startOnBoot = false;
startOnBoot = false;
}
}
else
else
{
{
StartAtBoot startAtBoot = new StartAtBoot(PlatformType.SERVER, ServerInfo.getInstance().getPlatformType());
StartAtBoot startAtBoot = new StartAtBoot(PlatformType.SERVER, ServerInfo.getInstance().getPlatformType());
if(startOnBoot)
if(startOnBoot)
{
{
startAtBoot.create(new File(ServerInfo.getInstance().getRunnerFileName()));
startAtBoot.create(new File(ServerInfo.getInstance().getRunnerFileName()));
}
}
else
else
{
{
boolean result = startAtBoot.delete();
boolean result = startAtBoot.delete();
if(!result)
if(!result)
new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show();
}
}
}
}
}
}
if(!minimizeToSystemTrayOnClose)
if(minimizeToSystemTrayOnClose)
{
{
if(!SystemTray.isSupported())
if(!SystemTray.isSupported())
{
{
StreamPiAlert alert = new StreamPiAlert("Not Supported", "Tray System not supported on this platform ", StreamPiAlertType.ERROR);
StreamPiAlert alert = new StreamPiAlert("Not Supported", "Tray System not supported on this platform ", StreamPiAlertType.ERROR);
alert.show();
alert.show();
minimizeToSystemTrayOnClose = true;
minimizeToSystemTrayOnClose = false;
}
}
}
}
config.setServerName(serverNameStr);
config.setServerName(serverNameStr);
config.setServerPort(serverPort);
config.setServerPort(serverPort);
config.setActionGridGap(actionGap);
config.setActionGridGap(actionGap);
config.setActionGridSize(actionSize);
config.setActionGridSize(actionSize);
config.setPluginsPath(pluginsPathStr);
config.setPluginsPath(pluginsPathStr);
config.setThemesPath(themesPathStr);
config.setThemesPath(themesPathStr);
config.setMinimiseToSystemTrayOnClose(minimizeToSystemTrayOnClose);
config.setMinimiseToSystemTrayOnClose(minimizeToSystemTrayOnClose);
config.setStartupOnBoot(startOnBoot);
config.setStartupOnBoot(startOnBoot);
config.save();
config.save();
loadDataFromConfig();
loadDataFromConfig();
if(toBeReloaded)
if(toBeReloaded)
{
{
new StreamPiAlert("Restart","Restart to see changes", StreamPiAlertType.INFORMATION).show();
new StreamPiAlert("Restart","Restart to see changes", StreamPiAlertType.INFORMATION).show();
}
}
if(dashToBeReRendered)
if(dashToBeReRendered)
{
{
serverListener.clearTemp();
serverListener.clearTemp();
}
}
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
catch (SevereException e)
catch (SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
finally {
finally {
Platform.runLater(()->{
Platform.runLater(()->{
saveButton.setDisable(false);
saveButton.setDisable(false);
serverNameTextField.setDisable(false);
serverNameTextField.setDisable(false);
portTextField.setDisable(false);
portTextField.setDisable(false);
minimizeToSystemTrayOnCloseToggleButton.setDisable(false);
minimizeToSystemTrayOnCloseToggleButton.setDisable(false);
startOnBootToggleButton.setDisable(false);
startOnBootToggleButton.setDisable(false);
});
});
}
}
return null;
return null;
}
}
}).start();
}).start();
}
}
}
}
PK3ZR
PK3ZR
config.xmlUT *9`,9`*9`ux uRn0+w$vp[ϑ+M^_Dx0o?ޅҚC6u%Lk4~<
config.xmlUT *9`,9`*9`ux uRn0+w$vp[ϑ+M^_Dx0o?ޅҚC6u%Lk4~<
Δ5P[醴tu`ô$Mp>}ᘀc֪KcqEOe<B ^3EQ%/K]<̤M Q~R(wbې䖋%oxJ"UnFWɡȮ A O;b8|6Ҏ eXZ!Eg#*>6_ i1NM)X[â@κ&?D6~PK[-]PK霟Q Plugins/UT _9`9`ux PK霟Qm Plugins/config.xmlUT _9`9`ux Q(K-*ϳU23PRHKOKU
Δ5P[醴tu`ô$Mp>}ᘀc֪KcqEOe<B ^3EQ%/K]<̤M Q~R(wbې䖋%oxJ"UnFWɡȮ A O;b8|6Ҏ eXZ!Eg#*>6_ i1NM)X[â@κ&?D6~PK[-]PK霟Q Plugins/UT _9`9`ux PK霟Qm Plugins/config.xmlUT _9`9`ux Q(K-*ϳU23PRHKOKU
qӵPR(.IKIKUWIKL/-J,jRPIL1la,.}4ePKTXmPKPR Themes/UT +`9`9`ux PKDR! Themes/com.stream_pi.defaultdark/UT k`9`9`ux PKDR% Themes/com.stream_pi.defaultdark/res/UT 2`9`9`ux PKDR . Themes/com.stream_pi.defaultdark/res/style.cssUT 2`9`9`ux Vێ0}G,*[u/,9BF$r<|eV
qӵPR(.IKIKUWIKL/-J,jRPIL1la,.}4ePKTXmPKPR Themes/UT +`9`9`ux PKDR! Themes/com.stream_pi.defaultdark/UT k`9`9`ux PKDR% Themes/com.stream_pi.defaultdark/res/UT 2`9`9`ux PKDR . Themes/com.stream_pi.defaultdark/res/style.cssUT 2`9`9`ux Vێ0}G,*[u/,9BF$r<|eV
Z` ao~ٿ>'ݏZjnjN9E :j0*wxΩzD,v@/./!,mkkkO" NQEJB)t3( taiN%쒋]Cy{Mi[\Xxgh_76~n>MPelZvp:UHiz8K<i*@6r'\d 6]S M\(aYwZe!^4L԰ᒣANآn:k{.H۬ 9 E Ñ!rz7Ͱ=JpK 6|Et~gXm9K,m~`F:P= F%y)j`1wi4 8߰NXn󙅎EE{3SV^E%w)ta g>Տ L-aVῷ.PKЛE$ PKDR* Themes/com.stream_pi.defaultdark/theme.xmlUT k`9`9`ux uP MNi ]89>/VZݽ˽cK FpnL; )ÑU|cr&+|a1
Z` ao~ٿ>'ݏZjnjN9E :j0*wxΩzD,v@/./!,mkkkO" NQEJB)t3( taiN%쒋]Cy{Mi[\Xxgh_76~n>MPelZvp:UHiz8K<i*@6r'\d 6]S M\(aYwZe!^4L԰ᒣANآn:k{.H۬ 9 E Ñ!rz7Ͱ=JpK 6|Et~gXm9K,m~`F:P= F%y)j`1wi4 8߰NXn󙅎EE{3SV^E%w)ta g>Տ L-aVῷ.PKЛE$ PKDR* Themes/com.stream_pi.defaultdark/theme.xmlUT k`9`9`ux uP MNi ]89>/VZݽ˽cK FpnL; )ÑU|cr&+|a1
/U$aaDd]o'Z(5H1MD.&pn ZF#H6)MO2yxtY9F&^Ot]PK}PKDR" Themes/com.stream_pi.defaultlight/UT k`9`9`ux PKDR+ Themes/com.stream_pi.defaultlight/theme.xmlUT k`9`9`ux uPA0{)L0)ă/@hM{(3kSFIf ]FLη+-Ñ ~k[MV{1Hli0+8~oҭ ȲXZ Ni@rQ]ELz\X-gyDMu ΢WP8ztǖ5,b"+-PK|PK#DR& Themes/com.stream_pi.defaultlight/res/UT ;1`9`9`ux PK#DR / Themes/com.stream_pi.defaultlight/res/style.cssUT ;1`9`9`ux VM G@꭪^{NAK &bmժ}#IxTh@R|jYZ_~AmDm;Yx"AeIaVXpaoG()PQPg?ﺊ/W<-\.( ڞg%N57XcB"WJ6ImC7qkzBU%-xz$_C tS3&ZaxRBi'geJ472,Ǹ0a%I]Hk.H+mN(GLm5p]3LW3bYOlܲ.wOqMj8p/ưi:kG.ZrLlp٘94#>A6ê1R] l,IVbsXYhmnpK
/U$aaDd]o'Z(5H1MD.&pn ZF#H6)MO2yxtY9F&^Ot]PK}PKDR" Themes/com.stream_pi.defaultlight/UT k`9`9`ux PKDR+ Themes/com.stream_pi.defaultlight/theme.xmlUT k`9`9`ux uPA0{)L0)ă/@hM{(3kSFIf ]FLη+-Ñ ~k[MV{1Hli0+8~oҭ ȲXZ Ni@rQ]ELz\X-gyDMu ΢WP8ztǖ5,b"+-PK|PK#DR& Themes/com.stream_pi.defaultlight/res/UT ;1`9`9`ux PK#DR / Themes/com.stream_pi.defaultlight/res/style.cssUT ;1`9`9`ux VM G@꭪^{NAK &bmժ}#IxTh@R|jYZ_~AmDm;Yx"AeIaVXpaoG()PQPg?ﺊ/W<-\.( ڞg%N57XcB"WJ6ImC7qkzBU%-xz$_C tS3&ZaxRBi'geJ472,Ǹ0a%I]Hk.H+mN(GLm5p]3LW3bYOlܲ.wOqMj8p/ưi:kG.ZrLlp٘94#>A6ê1R] l,IVbsXYhmnpK
&᪂mS^
&᪂mS^
ްNoHBǢ,ܽNˌ{%)Qxewza7.Í T;a]鿷>PKF; PKͺDR) Themes/com.stream_pi.defaulthighcontrast/UT Z4`9`9`ux PKѸDR- Themes/com.stream_pi.defaulthighcontrast/res/UT 0`9`9`ux PKѸDR" 6 Themes/com.stream_pi.defaulthighcontrast/res/style.cssUT 0`9`9`ux UK0 .`ƹB 8BѐIA^ſHYN,D톅N;=B͖L5/ '/^σnDIvv3=&`k6E="%GT];xUP
ްNoHBǢ,ܽNˌ{%)Qxewza7.Í T;a]鿷>PKF; PKͺDR) Themes/com.stream_pi.defaulthighcontrast/UT Z4`9`9`ux PKѸDR- Themes/com.stream_pi.defaulthighcontrast/res/UT 0`9`9`ux PKѸDR" 6 Themes/com.stream_pi.defaulthighcontrast/res/style.cssUT 0`9`9`ux UK0 .`ƹB 8BѐIA^ſHYN,D톅N;=B͖L5/ '/^σnDIvv3=&`k6E="%GT];xUP
RPEHL\{윞2^3NΚt/9A7dnlWF8Xfƞ*5V.aZ",(B2V(tFχy|Qg(QLZAN;+z%*'MHk a*5<w'Z!nO걘k( k~":yڡԏ<ވ"6 \`:lB޼н/އuDLNy-+RMmBq;mM< KlYA\A0`b<RGnl.K#wb?p__]vDaeΙ/C[ ؅hPK" PKͺDR2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlUT Z4`9`9`ux uP10 ܑC 40 x)n&(qR|w>O]n輶,chJ{֦.Ŋ3V,t;  #x4S+IFm*Pm%u6֐OlwJs)x RD |" >9H}H>(ЋK0:ҟPKGzKPK3ZR[-]
RPEHL\{윞2^3NΚt/9A7dnlWF8Xfƞ*5V.aZ",(B2V(tFχy|Qg(QLZAN;+z%*'MHk a*5<w'Z!nO걘k( k~":yڡԏ<ވ"6 \`:lB޼н/އuDLNy-+RMmBq;mM< KlYA\A0`b<RGnl.K#wb?p__]vDaeΙ/C[ ؅hPK" PKͺDR2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlUT Z4`9`9`ux uP10 ܑC 40 x)n&(qR|w>O]n輶,chJ{֦.Ŋ3V,t;  #x4S+IFm*Pm%u6֐OlwJs)x RD |" >9H}H>(ЋK0:ҟPKGzKPK3ZR[-]
config.xmlUT *9`,9`*9`ux PK霟Q APlugins/UT _9`9`ux PK霟QTXm Plugins/config.xmlUT _9`9`ux PKPR AThemes/UT +`9`9`ux PKDR! AThemes/com.stream_pi.defaultdark/UT k`9`9`ux PKDR% AWThemes/com.stream_pi.defaultdark/res/UT 2`9`9`ux PKDRЛE$ . Themes/com.stream_pi.defaultdark/res/style.cssUT 2`9`9`ux PKDR}* ZThemes/com.stream_pi.defaultdark/theme.xmlUT k`9`9`ux PKDR" AThemes/com.stream_pi.defaultlight/UT k`9`9`ux PKDR|+ Themes/com.stream_pi.defaultlight/theme.xmlUT k`9`9`ux PK#DR& A/ Themes/com.stream_pi.defaultlight/res/UT ;1`9`9`ux PK#DRF; / Themes/com.stream_pi.defaultlight/res/style.cssUT ;1`9`9`ux PKͺDR) A/ Themes/com.stream_pi.defaulthighcontrast/UT Z4`9`9`ux PKѸDR- A Themes/com.stream_pi.defaulthighcontrast/res/UT 0`9`9`ux PKѸDR" 6  Themes/com.stream_pi.defaulthighcontrast/res/style.cssUT 0`9`9`ux PKͺDRGzK2 sThemes/com.stream_pi.defaulthighcontrast/theme.xmlUT Z4`9`9`ux PK 
config.xmlUT *9`,9`*9`ux PK霟Q APlugins/UT _9`9`ux PK霟QTXm Plugins/config.xmlUT _9`9`ux PKPR AThemes/UT +`9`9`ux PKDR! AThemes/com.stream_pi.defaultdark/UT k`9`9`ux PKDR% AWThemes/com.stream_pi.defaultdark/res/UT 2`9`9`ux PKDRЛE$ . Themes/com.stream_pi.defaultdark/res/style.cssUT 2`9`9`ux PKDR}* ZThemes/com.stream_pi.defaultdark/theme.xmlUT k`9`9`ux PKDR" AThemes/com.stream_pi.defaultlight/UT k`9`9`ux PKDR|+ Themes/com.stream_pi.defaultlight/theme.xmlUT k`9`9`ux PK#DR& A/ Themes/com.stream_pi.defaultlight/res/UT ;1`9`9`ux PK#DRF; / Themes/com.stream_pi.defaultlight/res/style.cssUT ;1`9`9`ux PKͺDR) A/ Themes/com.stream_pi.defaulthighcontrast/UT Z4`9`9`ux PKѸDR- A Themes/com.stream_pi.defaulthighcontrast/res/UT 0`9`9`ux PKѸDR" 6  Themes/com.stream_pi.defaulthighcontrast/res/style.cssUT 0`9`9`ux PKͺDRGzK2 sThemes/com.stream_pi.defaulthighcontrast/theme.xmlUT Z4`9`9`ux PK