server
Clone or download
Modified Files
/*
/*
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad
Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)
This program is free software: you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
Written by : Debayan Sutradhar (rnayabed)
Written by : Debayan Sutradhar (rnayabed)
*/
*/
package com.stream_pi.server;
package com.stream_pi.server;
import com.stream_pi.server.controller.Controller;
import com.stream_pi.server.controller.Controller;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.StartupFlags;
import javafx.application.Application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.Stage;
public class Main extends Application {
public class Main extends Application {
/**
/**
* First method to be called
* First method to be called
* This method first parses all the available command line arguments passed.
* This method first parses all the available command line arguments passed.
* Then a new instance of controller is created, and then initialised.
* Then a new instance of controller is created, and then initialised.
*/
*/
public void start(Stage stage) {
public void start(Stage stage) {
for(String eachArg : getParameters().getRaw())
for(String eachArg : getParameters().getRaw())
{
{
if(!eachArg.startsWith("-DStream-Pi"))
if(!eachArg.startsWith("-DStream-Pi"))
continue;
continue;
String[] r = eachArg.split("=");
String[] r = eachArg.split("=");
String arg = r[0];
String arg = r[0];
String val = r[1];
String val = r[1];
if(arg.equals("-DStream-Pi.startupRunnerFileName"))
if(arg.equals("-DStream-Pi.startupRunnerFileName"))
ServerInfo.getInstance().setRunnerFileName(val);
StartupFlags.RUNNER_FILE_NAME = val;
else if(arg.equals("-DStream-Pi.startupMode"))
else if(arg.equals("-DStream-Pi.startupMode"))
ServerInfo.getInstance().setStartMinimised(val.equals("min"));
StartupFlags.START_MINIMISED = val.equals("min");
}
}
Controller d = new Controller();
Controller d = new Controller();
Scene s = new Scene(d);
Scene s = new Scene(d);
stage.setScene(s);
stage.setScene(s);
d.setHostServices(getHostServices());
d.setHostServices(getHostServices());
d.init();
d.init();
}
}
/**
/**
* This is a fallback. Called in some JVMs.
* This is a fallback. Called in some JVMs.
* This method just sends the command line arguments to JavaFX Application
* This method just sends the command line arguments to JavaFX Application
*/
*/
public static void main(String[] args)
public static void main(String[] args)
{
{
launch(args);
launch(args);
}
}
}
}
package com.stream_pi.server.controller;
package com.stream_pi.server.controller;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.PropertySaver;
import com.stream_pi.action_api.action.PropertySaver;
import com.stream_pi.action_api.action.ServerConnection;
import com.stream_pi.action_api.action.ServerConnection;
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.action_api.externalplugin.ToggleAction;
import com.stream_pi.action_api.externalplugin.ToggleAction;
import com.stream_pi.action_api.externalplugin.ToggleExtras;
import com.stream_pi.action_api.externalplugin.ToggleExtras;
import com.stream_pi.server.Main;
import com.stream_pi.server.Main;
import com.stream_pi.server.action.ExternalPlugins;
import com.stream_pi.server.action.ExternalPlugins;
import com.stream_pi.server.client.Client;
import com.stream_pi.server.client.Client;
import com.stream_pi.server.client.ClientProfile;
import com.stream_pi.server.client.ClientProfile;
import com.stream_pi.server.connection.ClientConnection;
import com.stream_pi.server.connection.ClientConnection;
import com.stream_pi.server.connection.ClientConnections;
import com.stream_pi.server.connection.ClientConnections;
import com.stream_pi.server.connection.MainServer;
import com.stream_pi.server.connection.MainServer;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.StartupFlags;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.window.Base;
import com.stream_pi.server.window.Base;
import com.stream_pi.server.window.dashboard.DashboardBase;
import com.stream_pi.server.window.dashboard.DashboardBase;
import com.stream_pi.server.window.dashboard.DonatePopupContent;
import com.stream_pi.server.window.dashboard.DonatePopupContent;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.server.window.firsttimeuse.FirstTimeUse;
import com.stream_pi.server.window.firsttimeuse.FirstTimeUse;
import com.stream_pi.server.window.settings.SettingsBase;
import com.stream_pi.server.window.settings.SettingsBase;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertListener;
import com.stream_pi.util.alert.StreamPiAlertListener;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.exception.*;
import com.stream_pi.util.exception.*;
import javafx.animation.Animation;
import javafx.animation.Animation;
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.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.stage.WindowEvent;
import javafx.util.Duration;
import javafx.util.Duration;
import java.awt.MenuItem;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.TrayIcon;
import java.net.SocketAddress;
import java.net.SocketAddress;
import java.util.Objects;
import java.util.Objects;
import java.util.Random;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Level;
public class Controller extends Base implements PropertySaver, ServerConnection, ToggleExtras
public class Controller extends Base implements PropertySaver, ServerConnection, ToggleExtras
{
{
private ExecutorService executor = Executors.newCachedThreadPool();
private ExecutorService executor = Executors.newCachedThreadPool();
private MainServer mainServer;
private MainServer mainServer;
private Animation openSettingsAnimation;
private Animation openSettingsAnimation;
private Animation closeSettingsAnimation;
private Animation closeSettingsAnimation;
public Controller(){
public Controller(){
mainServer = null;
mainServer = null;
}
}
public void setupDashWindow() throws SevereException
public void setupDashWindow() throws SevereException
{
{
try
try
{
{
getStage().setOnCloseRequest(this::onCloseRequest);
getStage().setOnCloseRequest(this::onCloseRequest);
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException(e.getMessage());
throw new SevereException(e.getMessage());
}
}
}
}
@Override
@Override
public void init()
public void init()
{
{
try
try
{
{
initBase();
initBase();
setupDashWindow();
setupDashWindow();
setupSettingsWindowsAnimations();
setupSettingsWindowsAnimations();
ExternalPlugins.getInstance().setPropertySaver(this);
ExternalPlugins.getInstance().setPropertySaver(this);
ExternalPlugins.getInstance().setToggleExtras(this);
ExternalPlugins.getInstance().setToggleExtras(this);
ExternalPlugins.getInstance().setServerConnection(this);
ExternalPlugins.getInstance().setServerConnection(this);
getDashboardBase().getPluginsPane().getSettingsButton().setOnAction(event -> {
getDashboardBase().getPluginsPane().getSettingsButton().setOnAction(event -> {
openSettingsAnimation.play();
openSettingsAnimation.play();
});
});
getSettingsBase().getCloseButton().setOnAction(event -> {
getSettingsBase().getCloseButton().setOnAction(event -> {
closeSettingsAnimation.play();
closeSettingsAnimation.play();
});
});
getSettingsBase().getThemesSettings().setController(this);
getSettingsBase().getThemesSettings().setController(this);
mainServer = new MainServer(this, this);
mainServer = new MainServer(this, this);
if(getConfig().isFirstTimeUse())
if(getConfig().isFirstTimeUse())
{
{
Stage stage = new Stage();
Stage stage = new Stage();
Scene s = new Scene(new FirstTimeUse(this, this),
Scene s = new Scene(new FirstTimeUse(this, this),
getConfig().getStartupWindowWidth(), getConfig().getStartupWindowHeight());
getConfig().getStartupWindowWidth(), getConfig().getStartupWindowHeight());
stage.setScene(s);
stage.setScene(s);
stage.setMinHeight(500);
stage.setMinHeight(500);
stage.setMinWidth(700);
stage.setMinWidth(700);
stage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))));
stage.getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))));
stage.setTitle("Stream-Pi Server Setup");
stage.setTitle("Stream-Pi Server Setup");
stage.initModality(Modality.APPLICATION_MODAL);
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOnCloseRequest(event->Platform.exit());
stage.setOnCloseRequest(event->Platform.exit());
stage.show();
stage.show();
}
}
else
else
{
{
if(getConfig().isAllowDonatePopup())
if(getConfig().isAllowDonatePopup())
{
{
if(new Random().nextInt(5) == 3)
if(new Random().nextInt(5) == 3)
new DonatePopupContent(getHostServices(), this).show();
new DonatePopupContent(getHostServices(), this).show();
}
}
othInit();
othInit();
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
}
}
@Override
@Override
public void othInit()
public void othInit()
{
{
try
try
{
{
if(ServerInfo.getInstance().isStartMinimised() && SystemTray.isSupported())
if(StartupFlags.START_MINIMISED && SystemTray.isSupported())
minimiseApp();
minimiseApp();
else
else
getStage().show();
getStage().show();
}
}
catch(MinorException e)
catch(MinorException e)
{
{
handleMinorException(e);
handleMinorException(e);
}
}
executor.execute(new Task<Void>() {
executor.execute(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try
try
{
{
getSettingsBase().getGeneralSettings().loadDataFromConfig();
getSettingsBase().getGeneralSettings().loadDataFromConfig();
//themes
//themes
getSettingsBase().getThemesSettings().setThemes(getThemes());
getSettingsBase().getThemesSettings().setThemes(getThemes());
getSettingsBase().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsBase().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsBase().getThemesSettings().loadThemes();
getSettingsBase().getThemesSettings().loadThemes();
//clients
//clients
getSettingsBase().getClientsSettings().loadData();
getSettingsBase().getClientsSettings().loadData();
try
try
{
{
//Plugins
//Plugins
Platform.runLater(()->{
Platform.runLater(()->{
getDashboardBase().getPluginsPane().clearData();
getDashboardBase().getPluginsPane().clearData();
getDashboardBase().getPluginsPane().loadOtherActions();
getDashboardBase().getPluginsPane().loadOtherActions();
});
});
ExternalPlugins.setPluginsLocation(getConfig().getPluginsPath());
ExternalPlugins.setPluginsLocation(getConfig().getPluginsPath());
ExternalPlugins.getInstance().init();
ExternalPlugins.getInstance().init();
Platform.runLater(()->getDashboardBase().getPluginsPane().loadData());
Platform.runLater(()->getDashboardBase().getPluginsPane().loadData());
getSettingsBase().getPluginsSettings().loadPlugins();
getSettingsBase().getPluginsSettings().loadPlugins();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
getSettingsBase().getPluginsSettings().showPluginInitError();
getSettingsBase().getPluginsSettings().showPluginInitError();
handleMinorException(e);
handleMinorException(e);
}
}
//Server
//Server
mainServer.setPort(getConfig().getPort());
mainServer.setPort(getConfig().getPort());
mainServer.start();
mainServer.start();
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
return null;
return null;
}
}
});
});
}
}
private void setupSettingsWindowsAnimations()
private void setupSettingsWindowsAnimations()
{
{
Node settingsNode = getSettingsBase();
Node settingsNode = getSettingsBase();
Node dashboardNode = getDashboardBase();
Node dashboardNode = getDashboardBase();
openSettingsAnimation = createOpenSettingsAnimation(settingsNode, dashboardNode);
openSettingsAnimation = createOpenSettingsAnimation(settingsNode, dashboardNode);
closeSettingsAnimation = createCloseSettingsAnimation(settingsNode, dashboardNode);
closeSettingsAnimation = createCloseSettingsAnimation(settingsNode, dashboardNode);
}
}
public void onCloseRequest(WindowEvent event)
public void onCloseRequest(WindowEvent event)
{
{
try
try
{
{
if(Config.getInstance().getMinimiseToSystemTrayOnClose() &&
if(Config.getInstance().getMinimiseToSystemTrayOnClose() &&
SystemTray.isSupported())
SystemTray.isSupported())
{
{
minimiseApp();
minimiseApp();
event.consume();
event.consume();
return;
return;
}
}
onQuitApp();
onQuitApp();
ExternalPlugins.getInstance().shutDownActions();
ExternalPlugins.getInstance().shutDownActions();
Platform.exit();
Platform.exit();
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
handleMinorException(e);
handleMinorException(e);
}
}
}
}
public void onQuitApp()
public void onQuitApp()
{
{
try
try
{
{
if(getConfig() != null)
if(getConfig() != null)
{
{
getConfig().setStartupWindowSize(getWidth(), getHeight());
getConfig().setStartupWindowSize(getWidth(), getHeight());
getConfig().setRightDividerPositions(getDashboardBase().getDividerPositions());
getConfig().setRightDividerPositions(getDashboardBase().getDividerPositions());
getConfig().setLeftDividerPositions(getDashboardBase().getLeftSplitPane().getDividerPositions());
getConfig().setLeftDividerPositions(getDashboardBase().getLeftSplitPane().getDividerPositions());
getConfig().save();
getConfig().save();
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
stopServerAndAllConnections();
stopServerAndAllConnections();
executor.shutdown();
executor.shutdown();
getLogger().info("Shutting down ...");
getLogger().info("Shutting down ...");
closeLogger();
closeLogger();
}
}
private void stopServerAndAllConnections()
private void stopServerAndAllConnections()
{
{
if(mainServer!=null)
if(mainServer!=null)
mainServer.stopListeningForConnections();
mainServer.stopListeningForConnections();
ClientConnections.getInstance().disconnectAll();
ClientConnections.getInstance().disconnectAll();
}
}
@Override
@Override
public void restart()
public void restart()
{
{
getLogger().info("Restarting ...");
getLogger().info("Restarting ...");
stopServerAndAllConnections();
stopServerAndAllConnections();
Platform.runLater(this::init);
Platform.runLater(this::init);
}
}
public void minimiseApp() throws MinorException
public void minimiseApp() throws MinorException
{
{
try
try
{
{
SystemTray systemTray = SystemTray.getSystemTray();
SystemTray systemTray = SystemTray.getSystemTray();
if(getTrayIcon() == null)
if(getTrayIcon() == null)
initIconTray(systemTray);
initIconTray(systemTray);
systemTray.add(getTrayIcon());
systemTray.add(getTrayIcon());
getStage().hide();
getStage().hide();
getStage().setOnShown(windowEvent -> {
getStage().setOnShown(windowEvent -> {
systemTray.remove(getTrayIcon());
systemTray.remove(getTrayIcon());
});
});
}
}
catch(Exception e)
catch(Exception e)
{
{
throw new MinorException(e.getMessage());
throw new MinorException(e.getMessage());
}
}
}
}
public void initIconTray(SystemTray systemTray)
public void initIconTray(SystemTray systemTray)
{
{
Platform.setImplicitExit(false);
Platform.setImplicitExit(false);
PopupMenu popup = new PopupMenu();
PopupMenu popup = new PopupMenu();
MenuItem exitItem = new MenuItem("Exit");
MenuItem exitItem = new MenuItem("Exit");
exitItem.addActionListener(l->{
exitItem.addActionListener(l->{
systemTray.remove(getTrayIcon());
systemTray.remove(getTrayIcon());
onQuitApp();
onQuitApp();
Platform.exit();
Platform.exit();
});
});
popup.add(exitItem);
popup.add(exitItem);
TrayIcon trayIcon = new TrayIcon(
TrayIcon trayIcon = new TrayIcon(
Toolkit.getDefaultToolkit().getImage(Main.class.getResource("app_icon.png")),
Toolkit.getDefaultToolkit().getImage(Main.class.getResource("app_icon.png")),
"Stream-Pi Server",
"Stream-Pi Server",
popup
popup
);
);
trayIcon.addActionListener(l-> Platform.runLater(()-> {
trayIcon.addActionListener(l-> Platform.runLater(()-> {
getStage().show();
getStage().show();
getStage().setAlwaysOnTop(true);
getStage().setAlwaysOnTop(true);
getStage().setAlwaysOnTop(false);
getStage().setAlwaysOnTop(false);
}));
}));
trayIcon.setImageAutoSize(true);
trayIcon.setImageAutoSize(true);
this.trayIcon = trayIcon;
this.trayIcon = trayIcon;
}
}
private TrayIcon trayIcon = null;
private TrayIcon trayIcon = null;
public TrayIcon getTrayIcon()
public TrayIcon getTrayIcon()
{
{
return trayIcon;
return trayIcon;
}
}
@Override
@Override
public void handleMinorException(MinorException e)
public void handleMinorException(MinorException e)
{
{
getLogger().log(Level.SEVERE, e.getShortMessage(), e);
getLogger().log(Level.SEVERE, e.getShortMessage(), e);
e.printStackTrace();
e.printStackTrace();
Platform.runLater(()-> new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show());
Platform.runLater(()-> new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show());
}
}
@Override
@Override
public void handleSevereException(SevereException e) {
public void handleSevereException(SevereException e) {
getLogger().log(Level.SEVERE, e.getShortMessage(), e);
getLogger().log(Level.SEVERE, e.getShortMessage(), e);
e.printStackTrace();
e.printStackTrace();
Platform.runLater(()->{
Platform.runLater(()->{
StreamPiAlert alert = new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.ERROR);
StreamPiAlert alert = new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.ERROR);
alert.setOnClicked(new StreamPiAlertListener()
alert.setOnClicked(new StreamPiAlertListener()
{
{
@Override
@Override
public void onClick(String txt)
public void onClick(String txt)
{
{
onQuitApp();
onQuitApp();
Platform.exit();
Platform.exit();
}
}
});
});
alert.show();
alert.show();
});
});
}
}
@Override
@Override
public synchronized void onNormalActionClicked(NormalAction action, String profileID, SocketAddress socketAddress)
public synchronized void onNormalActionClicked(NormalAction action, String profileID, SocketAddress socketAddress)
{
{
try
try
{
{
action.onActionClicked();
action.onActionClicked();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
sendActionFailed(e, socketAddress, profileID, action.getID());
sendActionFailed(e, socketAddress, profileID, action.getID());
}
}
}
}
@Override
@Override
public synchronized void onToggleActionClicked(ToggleAction action, boolean toggle, String profileID, SocketAddress socketAddress)
public synchronized void onToggleActionClicked(ToggleAction action, boolean toggle, String profileID, SocketAddress socketAddress)
{
{
try
try
{
{
if(toggle)
if(toggle)
{
{
action.onToggleOn();
action.onToggleOn();
}
}
else
else
{
{
action.onToggleOff();
action.onToggleOff();
}
}
}
}
catch (MinorException e)
catch (MinorException e)
{
{
sendActionFailed(e, socketAddress, profileID, action.getID());
sendActionFailed(e, socketAddress, profileID, action.getID());
}
}
}
}
@Override
@Override
public void clearTemp() {
public void clearTemp() {
Platform.runLater(() -> {
Platform.runLater(() -> {
getDashboardBase().getClientAndProfileSelectorPane().refresh();
getDashboardBase().getClientAndProfileSelectorPane().refresh();
getDashboardBase().getActionGridPane().clear();
getDashboardBase().getActionGridPane().clear();
getDashboardBase().getActionGridPane().setFreshRender(true);
getDashboardBase().getActionGridPane().setFreshRender(true);
getDashboardBase().getActionDetailsPane().clear();
getDashboardBase().getActionDetailsPane().clear();
getSettingsBase().getClientsSettings().loadData();
getSettingsBase().getClientsSettings().loadData();
});
});
}
}
@Override
@Override
public void saveServerProperties()
public void saveServerProperties()
{
{
try
try
{
{
ExternalPlugins.getInstance().saveServerSettings();
ExternalPlugins.getInstance().saveServerSettings();
getSettingsBase().getPluginsSettings().loadPlugins();
getSettingsBase().getPluginsSettings().loadPlugins();
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
handleMinorException(e);
handleMinorException(e);
}
}
}
}
private void saveClientActionMain(String profileID, String actionID, SocketAddress socketAddress, boolean sendIcons)
private void saveClientActionMain(String profileID, String actionID, SocketAddress socketAddress, boolean sendIcons)
{
{
try {
try {
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress);
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress);
ClientProfile clientProfile = clientConnection.getClient().getProfileByID(profileID);
ClientProfile clientProfile = clientConnection.getClient().getProfileByID(profileID);
Action action = clientProfile.getActionByID(actionID);
Action action = clientProfile.getActionByID(actionID);
clientConnection.saveActionDetails(profileID, action);
clientConnection.saveActionDetails(profileID, action);
if(sendIcons && action.isHasIcon())
if(sendIcons && action.isHasIcon())
{
{
saveAllIcons(profileID, actionID, socketAddress, false);
saveAllIcons(profileID, actionID, socketAddress, false);
}
}
Platform.runLater(()->{
Platform.runLater(()->{
try {
try {
ActionBox actionBox = getDashboardBase().getActionGridPane().getActionBoxByIDAndProfileID(
ActionBox actionBox = getDashboardBase().getActionGridPane().getActionBoxByIDAndProfileID(
action.getID(),
action.getID(),
profileID
profileID
);
);
if(actionBox != null)
if(actionBox != null)
{
{
Platform.runLater(actionBox::init);
Platform.runLater(actionBox::init);
}
}
if(getDashboardBase().getActionDetailsPane().getAction() != null)
if(getDashboardBase().getActionDetailsPane().getAction() != null)
{
{
// This block is executed when no Action is selected.
// This block is executed when no Action is selected.
if(getDashboardBase().getActionDetailsPane().getAction().getID().equals(actionID))
if(getDashboardBase().getActionDetailsPane().getAction().getID().equals(actionID))
{
{
getDashboardBase().getActionDetailsPane().setAction(action);
getDashboardBase().getActionDetailsPane().setAction(action);
getDashboardBase().getActionDetailsPane().refresh();
getDashboardBase().getActionDetailsPane().refresh();
}
}
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
});
});
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
}
}
@Override
@Override
public void saveClientAction(String profileID, String actionID, SocketAddress socketAddress, boolean sendIcons, boolean runAsync)
public void saveClientAction(String profileID, String actionID, SocketAddress socketAddress, boolean sendIcons, boolean runAsync)
{
{
if(runAsync)
if(runAsync)
{
{
executor.execute(new Task<Void>() {
executor.execute(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
saveClientActionMain(profileID, actionID, socketAddress, sendIcons);
saveClientActionMain(profileID, actionID, socketAddress, sendIcons);
return null;
return null;
}
}
});
});
}
}
else
else
{
{
saveClientActionMain(profileID, actionID, socketAddress, sendIcons);
saveClientActionMain(profileID, actionID, socketAddress, sendIcons);
}
}
}
}
@Override
@Override
public void saveAllIcons(String profileID, String actionID, SocketAddress socketAddress)
public void saveAllIcons(String profileID, String actionID, SocketAddress socketAddress)
{
{
saveAllIcons(profileID, actionID, socketAddress, true);
saveAllIcons(profileID, actionID, socketAddress, true);
}
}
public void saveAllIcons(String profileID, String actionID, SocketAddress socketAddress, boolean async)
public void saveAllIcons(String profileID, String actionID, SocketAddress socketAddress, boolean async)
{
{
if(async)
if(async)
{
{
executor.execute(new Task<Void>() {
executor.execute(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
saveAllIconsMain(profileID, actionID, socketAddress);
saveAllIconsMain(profileID, actionID, socketAddress);
return null;
return null;
}
}
});
});
}
}
else
else
{
{
saveAllIconsMain(profileID, actionID, socketAddress);
saveAllIconsMain(profileID, actionID, socketAddress);
}
}
}
}
private void saveAllIconsMain(String profileID, String actionID, SocketAddress socketAddress)
private void saveAllIconsMain(String profileID, String actionID, SocketAddress socketAddress)
{
{
try {
try {
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress);
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress);
ClientProfile clientProfile = clientConnection.getClient().getProfileByID(profileID);
ClientProfile clientProfile = clientConnection.getClient().getProfileByID(profileID);
Action action = clientProfile.getActionByID(actionID);
Action action = clientProfile.getActionByID(actionID);
for(String eachState : action.getIcons().keySet())
for(String eachState : action.getIcons().keySet())
{
{
clientConnection.sendIcon(profileID, actionID, eachState,
clientConnection.sendIcon(profileID, actionID, eachState,
action.getIcon(eachState));
action.getIcon(eachState));
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
}
}
@Override
@Override
public void saveIcon(String state, String profileID, String actionID, SocketAddress socketAddress) {
public void saveIcon(String state, String profileID, String actionID, SocketAddress socketAddress) {
executor.execute(new Task<Void>() {
executor.execute(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try {
try {
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress);
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress);
ClientProfile clientProfile = clientConnection.getClient().getProfileByID(profileID);
ClientProfile clientProfile = clientConnection.getClient().getProfileByID(profileID);
Action action = clientProfile.getActionByID(actionID);
Action action = clientProfile.getActionByID(actionID);
clientConnection.sendIcon(profileID, actionID, state, action.getIcon(state));
clientConnection.sendIcon(profileID, actionID, state, action.getIcon(state));
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
return null;
return null;
}
}
});
});
}
}
@Override
@Override
public com.stream_pi.util.platform.Platform getPlatform() {
public com.stream_pi.util.platform.Platform getPlatform() {
return ServerInfo.getInstance().getPlatform();
return ServerInfo.getInstance().getPlatform();
}
}
@Override
@Override
public void sendActionFailed(MinorException exception, SocketAddress socketAddress, String profileID, String actionID)
public void sendActionFailed(MinorException exception, SocketAddress socketAddress, String profileID, String actionID)
{
{
if(exception.getTitle() != null)
if(exception.getTitle() != null)
{
{
exception.setShortMessage(exception.getTitle()+"\n"+exception.getShortMessage());
exception.setShortMessage(exception.getTitle()+"\n"+exception.getShortMessage());
}
}
exception.setTitle("Error while running action");
exception.setTitle("Error while running action");
handleMinorException(exception);
handleMinorException(exception);
executor.execute(new Task<Void>() {
executor.execute(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try {
try {
ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress)
ClientConnections.getInstance().getClientConnectionBySocketAddress(socketAddress)
.sendActionFailed(profileID, actionID);
.sendActionFailed(profileID, actionID);
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
return null;
return null;
}
}
});
});
}
}
private Animation createOpenSettingsAnimation(Node settingsNode, Node dashboardNode) {
private Animation createOpenSettingsAnimation(Node settingsNode, Node dashboardNode) {
Timeline openSettingsTimeline = new Timeline();
Timeline openSettingsTimeline = new Timeline();
openSettingsTimeline.setCycleCount(1);
openSettingsTimeline.setCycleCount(1);
openSettingsTimeline.getKeyFrames().addAll(
openSettingsTimeline.getKeyFrames().addAll(
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
0.0D, Interpolator.EASE_IN),
0.0D, Interpolator.EASE_IN),
new KeyValue(settingsNode.scaleXProperty(),
new KeyValue(settingsNode.scaleXProperty(),
1.1D, Interpolator.EASE_IN),
1.1D, Interpolator.EASE_IN),
new KeyValue(settingsNode.scaleYProperty(),
new KeyValue(settingsNode.scaleYProperty(),
1.1D, Interpolator.EASE_IN),
1.1D, Interpolator.EASE_IN),
new KeyValue(settingsNode.scaleZProperty(),
new KeyValue(settingsNode.scaleZProperty(),
1.1D, Interpolator.EASE_IN)),
1.1D, Interpolator.EASE_IN)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleXProperty(),
new KeyValue(settingsNode.scaleXProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleYProperty(),
new KeyValue(settingsNode.scaleYProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleZProperty(),
new KeyValue(settingsNode.scaleZProperty(),
1.0D, Interpolator.LINEAR)),
1.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleXProperty(),
new KeyValue(dashboardNode.scaleXProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleYProperty(),
new KeyValue(dashboardNode.scaleYProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleZProperty(),
new KeyValue(dashboardNode.scaleZProperty(),
1.0D, Interpolator.LINEAR)),
1.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
0.0D, Interpolator.LINEAR),
0.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleXProperty(),
new KeyValue(dashboardNode.scaleXProperty(),
0.9D, Interpolator.LINEAR),
0.9D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleYProperty(),
new KeyValue(dashboardNode.scaleYProperty(),
0.9D, Interpolator.LINEAR),
0.9D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleZProperty(),
new KeyValue(dashboardNode.scaleZProperty(),
0.9D, Interpolator.LINEAR))
0.9D, Interpolator.LINEAR))
);
);
openSettingsTimeline.setOnFinished(e -> settingsNode.toFront());
openSettingsTimeline.setOnFinished(e -> settingsNode.toFront());
return openSettingsTimeline;
return openSettingsTimeline;
}
}
private Animation createCloseSettingsAnimation(Node settingsNode, Node dashboardNode) {
private Animation createCloseSettingsAnimation(Node settingsNode, Node dashboardNode) {
Timeline closeSettingsTimeline = new Timeline();
Timeline closeSettingsTimeline = new Timeline();
closeSettingsTimeline.setCycleCount(1);
closeSettingsTimeline.setCycleCount(1);
closeSettingsTimeline.getKeyFrames().addAll(
closeSettingsTimeline.getKeyFrames().addAll(
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleXProperty(),
new KeyValue(settingsNode.scaleXProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleYProperty(),
new KeyValue(settingsNode.scaleYProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleZProperty(),
new KeyValue(settingsNode.scaleZProperty(),
1.0D, Interpolator.LINEAR)),
1.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
0.0D, Interpolator.LINEAR),
0.0D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleXProperty(),
new KeyValue(settingsNode.scaleXProperty(),
1.1D, Interpolator.LINEAR),
1.1D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleYProperty(),
new KeyValue(settingsNode.scaleYProperty(),
1.1D, Interpolator.LINEAR),
1.1D, Interpolator.LINEAR),
new KeyValue(settingsNode.scaleZProperty(),
new KeyValue(settingsNode.scaleZProperty(),
1.1D, Interpolator.LINEAR)),
1.1D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
0.0D, Interpolator.LINEAR),
0.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleXProperty(),
new KeyValue(dashboardNode.scaleXProperty(),
0.9D, Interpolator.LINEAR),
0.9D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleYProperty(),
new KeyValue(dashboardNode.scaleYProperty(),
0.9D, Interpolator.LINEAR),
0.9D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleZProperty(),
new KeyValue(dashboardNode.scaleZProperty(),
0.9D, Interpolator.LINEAR)),
0.9D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleXProperty(),
new KeyValue(dashboardNode.scaleXProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleYProperty(),
new KeyValue(dashboardNode.scaleYProperty(),
1.0D, Interpolator.LINEAR),
1.0D, Interpolator.LINEAR),
new KeyValue(dashboardNode.scaleZProperty(),
new KeyValue(dashboardNode.scaleZProperty(),
1.0D, Interpolator.LINEAR))
1.0D, Interpolator.LINEAR))
);
);
closeSettingsTimeline.setOnFinished(event1 -> {
closeSettingsTimeline.setOnFinished(event1 -> {
dashboardNode.toFront();
dashboardNode.toFront();
executor.execute(new Task<Void>() {
executor.execute(new Task<Void>() {
@Override
@Override
protected Void call() {
protected Void call() {
try {
try {
getSettingsBase().getClientsSettings().loadData();
getSettingsBase().getClientsSettings().loadData();
getSettingsBase().getGeneralSettings().loadDataFromConfig();
getSettingsBase().getGeneralSettings().loadDataFromConfig();
getSettingsBase().getPluginsSettings().loadPlugins();
getSettingsBase().getPluginsSettings().loadPlugins();
getSettingsBase().getThemesSettings().setThemes(getThemes());
getSettingsBase().getThemesSettings().setThemes(getThemes());
getSettingsBase().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsBase().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsBase().getThemesSettings().loadThemes();
getSettingsBase().getThemesSettings().loadThemes();
getSettingsBase().setDefaultTabToGeneral();
getSettingsBase().setDefaultTabToGeneral();
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
handleMinorException(e);
handleMinorException(e);
}
}
return null;
return null;
}
}
});
});
});
});
return closeSettingsTimeline;
return closeSettingsTimeline;
}
}
@Override
@Override
public void setToggleStatus(boolean currentStatus, String profileID, String actionID, SocketAddress clientSocketAddress)
public void setToggleStatus(boolean currentStatus, String profileID, String actionID, SocketAddress clientSocketAddress)
throws MinorException
throws MinorException
{
{
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(
ClientConnection clientConnection = ClientConnections.getInstance().getClientConnectionBySocketAddress(
clientSocketAddress
clientSocketAddress
);
);
if(clientConnection == null)
if(clientConnection == null)
throw new ClientNotFoundException("setToggleStatus failed because no client found with given socket address");
throw new ClientNotFoundException("setToggleStatus failed because no client found with given socket address");
new Thread(new Task<Void>() {
new Thread(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try
try
{
{
clientConnection.setToggleStatus(currentStatus, profileID, actionID);
clientConnection.setToggleStatus(currentStatus, profileID, actionID);
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
return null;
return null;
}
}
}).start();
}).start();
}
}
}
}
/*
/*
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 platform;
private final Platform platform;
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 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 = System.getProperty("user.home")+"/Stream-Pi/Server/";
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"))
platform = Platform.WINDOWS;
platform = Platform.WINDOWS;
else if (osName.contains("linux"))
else if (osName.contains("linux"))
platform = Platform.LINUX;
platform = Platform.LINUX;
else if (osName.contains("mac"))
else if (osName.contains("mac"))
platform = Platform.MAC;
platform = Platform.MAC;
else
else
platform = Platform.UNKNOWN;
platform = Platform.UNKNOWN;
}
}
public String getPrePath() {
public String getPrePath() {
return prePath;
return prePath;
}
}
public void setStartMinimised(boolean startMinimised)
{
this.startMinimised = startMinimised;
}
public boolean isStartMinimised()
{
return startMinimised;
}
public void setRunnerFileName(String runnerFileName)
{
this.runnerFileName = runnerFileName;
}
public String getRunnerFileName()
{
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 getPlatform()
public Platform getPlatform()
{
{
return platform;
return platform;
}
}
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;
}
}
}
}
package com.stream_pi.server.info;
public class StartupFlags
{
public static String RUNNER_FILE_NAME = null;
public static boolean START_MINIMISED = false;
}
package com.stream_pi.server.window.settings.About;
package com.stream_pi.server.window.settings.About;
import com.stream_pi.util.contactlinks.ContactLinks;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class ContactTab extends ScrollPane
public class ContactTab extends ScrollPane
{
{
private final HostServices hostServices;
private final HostServices hostServices;
public ContactTab(HostServices hostServices)
public ContactTab(HostServices hostServices)
{
{
this.hostServices = hostServices;
this.hostServices = hostServices;
getStyleClass().add("about_contact_tab_scroll_pane");
getStyleClass().add("about_contact_tab_scroll_pane");
Hyperlink github = new Hyperlink("GitHub");
Hyperlink github = new Hyperlink("GitHub");
github.setOnAction(event -> openWebpage("https://github.com/Stream-Pi"));
github.setOnAction(event -> openWebpage(ContactLinks.getGitHub()));
Hyperlink discord = new Hyperlink("Discord");
Hyperlink discord = new Hyperlink("Discord");
discord.setOnAction(event -> openWebpage("https://discord.gg/BExqGmk"));
discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord()));
Hyperlink website = new Hyperlink("Website");
Hyperlink website = new Hyperlink("Website");
website.setOnAction(event -> openWebpage("https://stream-pi.com"));
website.setOnAction(event -> openWebpage(ContactLinks.getWebsite()));
Hyperlink twitter = new Hyperlink("Twitter");
Hyperlink twitter = new Hyperlink("Twitter");
twitter.setOnAction(event -> openWebpage("https://twitter.com/Stream_Pi"));
twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter()));
Hyperlink matrix = new Hyperlink("Matrix");
Hyperlink matrix = new Hyperlink("Matrix");
matrix.setOnAction(event -> openWebpage("https://matrix.to/#/#stream-pi_general:matrix.org"));
matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix()));
VBox vBox = new VBox(github, discord, website, twitter, matrix);
VBox vBox = new VBox(github, discord, website, twitter, matrix);
vBox.setSpacing(10.0);
vBox.setSpacing(10.0);
setContent(vBox);
setContent(vBox);
}
}
public void openWebpage(String url)
public void openWebpage(String url)
{
{
hostServices.showDocument(url);
hostServices.showDocument(url);
}
}
}
}
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.info.StartupFlags;
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.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.alert.StreamPiAlertListener;
import com.stream_pi.util.alert.StreamPiAlertListener;
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.checkforupdates.UpdateHyperlinkOnClick;
import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick;
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.uihelper.HBoxWithSpaceBetween;
import com.stream_pi.util.uihelper.HBoxWithSpaceBetween;
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.event.ActionEvent;
import javafx.event.ActionEvent;
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.controlsfx.control.ToggleSwitch;
import org.controlsfx.control.ToggleSwitch;
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 ToggleSwitch startOnBootToggleSwitch;
private final ToggleSwitch startOnBootToggleSwitch;
private final HBoxWithSpaceBetween startOnBootHBox;
private final HBoxWithSpaceBetween startOnBootHBox;
private final ToggleSwitch minimizeToSystemTrayOnCloseToggleSwitch;
private final ToggleSwitch minimizeToSystemTrayOnCloseToggleSwitch;
private final HBoxWithSpaceBetween minimizeToSystemTrayOnCloseHBox;
private final HBoxWithSpaceBetween minimizeToSystemTrayOnCloseHBox;
private final ToggleSwitch showAlertsPopupToggleSwitch;
private final ToggleSwitch showAlertsPopupToggleSwitch;
private final HBoxWithSpaceBetween showAlertsPopupHBox;
private final HBoxWithSpaceBetween showAlertsPopupHBox;
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();
startOnBootToggleSwitch = new ToggleSwitch();
startOnBootToggleSwitch = new ToggleSwitch();
startOnBootHBox = new HBoxWithSpaceBetween("Start on Boot", startOnBootToggleSwitch);
startOnBootHBox = new HBoxWithSpaceBetween("Start on Boot", startOnBootToggleSwitch);
startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty());
startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty());
minimizeToSystemTrayOnCloseToggleSwitch = new ToggleSwitch();
minimizeToSystemTrayOnCloseToggleSwitch = new ToggleSwitch();
minimizeToSystemTrayOnCloseHBox = new HBoxWithSpaceBetween("Minimise To Tray On Close", minimizeToSystemTrayOnCloseToggleSwitch);
minimizeToSystemTrayOnCloseHBox = new HBoxWithSpaceBetween("Minimise To Tray On Close", minimizeToSystemTrayOnCloseToggleSwitch);
showAlertsPopupToggleSwitch = new ToggleSwitch();
showAlertsPopupToggleSwitch = new ToggleSwitch();
showAlertsPopupHBox = new HBoxWithSpaceBetween("Show Popup On Alert", showAlertsPopupToggleSwitch);
showAlertsPopupHBox = new HBoxWithSpaceBetween("Show Popup On Alert", showAlertsPopupToggleSwitch);
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),
minimizeToSystemTrayOnCloseHBox,
minimizeToSystemTrayOnCloseHBox,
startOnBootHBox,
startOnBootHBox,
showAlertsPopupHBox
showAlertsPopupHBox
);
);
serverNameTextField.setPrefWidth(200);
serverNameTextField.setPrefWidth(200);
saveButton = new Button("Save");
saveButton = new Button("Save");
saveButton.setOnAction(event->save());
saveButton.setOnAction(event->save());
getChildren().addAll(checkForUpdatesButton, saveButton);
getChildren().addAll(checkForUpdatesButton, saveButton);
setPadding(new Insets(10));
setPadding(new Insets(10));
}
}
private void checkForUpdates()
private void checkForUpdates()
{
{
new CheckForUpdates(checkForUpdatesButton,
new CheckForUpdates(checkForUpdatesButton,
PlatformType.SERVER, ServerInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() {
PlatformType.SERVER, ServerInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() {
@Override
@Override
public void handle(ActionEvent actionEvent) {
public void handle(ActionEvent actionEvent) {
hostServices.showDocument(getURL());
hostServices.showDocument(getURL());
}
}
});
});
}
}
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()+"");
minimizeToSystemTrayOnCloseToggleSwitch.setSelected(config.getMinimiseToSystemTrayOnClose());
minimizeToSystemTrayOnCloseToggleSwitch.setSelected(config.getMinimiseToSystemTrayOnClose());
showAlertsPopupToggleSwitch.setSelected(config.isShowAlertsPopup());
showAlertsPopupToggleSwitch.setSelected(config.isShowAlertsPopup());
startOnBootToggleSwitch.setSelected(config.getStartOnBoot());
startOnBootToggleSwitch.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);
});
});
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 = minimizeToSystemTrayOnCloseToggleSwitch.isSelected();
boolean minimizeToSystemTrayOnClose = minimizeToSystemTrayOnCloseToggleSwitch.isSelected();
boolean showAlertsPopup = showAlertsPopupToggleSwitch.isSelected();
boolean showAlertsPopup = showAlertsPopupToggleSwitch.isSelected();
boolean startOnBoot = startOnBootToggleSwitch.isSelected();
boolean startOnBoot = startOnBootToggleSwitch.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\n");
errors.append("* Server Port must be more than 1024\n");
else if(serverPort > 65535)
else if(serverPort > 65535)
errors.append("* Server Port must be lesser than 65535\n");
errors.append("* Server Port must be lesser than 65535\n");
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("Uh Oh!", "Please rectify the following errors and try again :\n"+errors.toString());
throw new MinorException("Uh Oh!", "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(StartupFlags.RUNNER_FILE_NAME == 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().getPlatform());
StartAtBoot startAtBoot = new StartAtBoot(PlatformType.SERVER, ServerInfo.getInstance().getPlatform());
if(startOnBoot)
if(startOnBoot)
{
{
startAtBoot.create(new File(ServerInfo.getInstance().getRunnerFileName()));
startAtBoot.create(new File(StartupFlags.RUNNER_FILE_NAME));
}
}
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 = false;
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);
StreamPiAlert.setIsShowPopup(showAlertsPopup);
StreamPiAlert.setIsShowPopup(showAlertsPopup);
config.setShowAlertsPopup(showAlertsPopup);
config.setShowAlertsPopup(showAlertsPopup);
config.setStartupOnBoot(startOnBoot);
config.setStartupOnBoot(startOnBoot);
config.save();
config.save();
loadDataFromConfig();
loadDataFromConfig();
if(toBeReloaded)
if(toBeReloaded)
{
{
StreamPiAlert restartPrompt = new StreamPiAlert(
StreamPiAlert restartPrompt = new StreamPiAlert(
"Warning",
"Warning",
"Stream-Pi Server needs to be restarted for these changes to take effect. Restart?\n" +
"Stream-Pi Server needs to be restarted for these changes to take effect. Restart?\n" +
"All your current connections will be disconnected.",
"All your current connections will be disconnected.",
StreamPiAlertType.WARNING
StreamPiAlertType.WARNING
);
);
String yesOption = "Yes";
String yesOption = "Yes";
String noOption = "No";
String noOption = "No";
restartPrompt.setButtons(yesOption, noOption);
restartPrompt.setButtons(yesOption, noOption);
restartPrompt.setOnClicked(new StreamPiAlertListener() {
restartPrompt.setOnClicked(new StreamPiAlertListener() {
@Override
@Override
public void onClick(String s) {
public void onClick(String s) {
if(s.equals(yesOption))
if(s.equals(yesOption))
{
{
serverListener.restart();
serverListener.restart();
}
}
}
}
});
});
restartPrompt.show();
restartPrompt.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);
});
});
}
}
return null;
return null;
}
}
}).start();
}).start();
}
}
}
}