client

Clone or download

Refactor, Cleanup

Modified Files

package com.stream_pi.client.window;
package com.stream_pi.client.window;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ScreenSaver;
import com.stream_pi.client.controller.ScreenSaver;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import java.io.File;
import java.io.File;
import java.util.Objects;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Executors;
import java.util.logging.Logger;
import java.util.logging.Logger;
import com.stream_pi.client.Main;
import com.stream_pi.client.Main;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.profile.ClientProfiles;
import com.stream_pi.client.profile.ClientProfiles;
import com.stream_pi.client.window.dashboard.DashboardBase;
import com.stream_pi.client.window.dashboard.DashboardBase;
import com.stream_pi.client.window.firsttimeuse.FirstTimeUse;
import com.stream_pi.client.window.firsttimeuse.FirstTimeUse;
import com.stream_pi.client.window.settings.SettingsBase;
import com.stream_pi.client.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.combobox.StreamPiComboBox;
import com.stream_pi.util.combobox.StreamPiComboBox;
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.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.geometry.Insets;
import javafx.geometry.Insets;
import javafx.scene.Cursor;
import javafx.scene.Cursor;
import javafx.scene.image.Image;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.scene.text.Font;
import javafx.stage.Screen;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.Stage;
public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener
public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener
{
{
private final ExecutorService executor = Executors.newCachedThreadPool();
private final ExecutorService executor = Executors.newCachedThreadPool();
private Config config;
private Config config;
private ClientProfiles clientProfiles;
private ClientProfiles clientProfiles;
private ClientInfo clientInfo;
private ClientInfo clientInfo;
private Stage stage;
private Stage stage;
public Stage getStage()
public Stage getStage()
{
{
return stage;
return stage;
}
}
public Logger getLogger()
public Logger getLogger()
{
{
return logger;
return logger;
}
}
private DashboardBase dashboardBase;
private DashboardBase dashboardBase;
private SettingsBase settingsBase;
private SettingsBase settingsBase;
private FirstTimeUse firstTimeUse;
private FirstTimeUse firstTimeUse;
public FirstTimeUse getFirstTimeUse() {
return firstTimeUse;
}
private StackPane alertStackPane;
private StackPane alertStackPane;
@Override
@Override
public ClientProfiles getClientProfiles() {
public ClientProfiles getClientProfiles() {
return clientProfiles;
return clientProfiles;
}
}
public void setClientProfiles(ClientProfiles clientProfiles) {
public void setClientProfiles(ClientProfiles clientProfiles) {
this.clientProfiles = clientProfiles;
this.clientProfiles = clientProfiles;
}
}
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()
public void initLogger()
{
{
try
try
{
{
if(logFileHandler != null)
if(logFileHandler != null)
return;
return;
closeLogger();
closeLogger();
logger = Logger.getLogger("");
logger = Logger.getLogger("");
if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite())
if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite())
{
{
String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log";
String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log";
Platform platform = getClientInfo().getPlatform();
Platform platform = getClientInfo().getPlatform();
if(platform == Platform.ANDROID ||
if(platform == Platform.ANDROID ||
platform == Platform.IOS)
platform == Platform.IOS)
path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log";
path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.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();
}
}
private HostServices hostServices;
private HostServices hostServices;
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;
}
}
public void initBase() throws SevereException
public void initBase() throws SevereException
{
{
stage = (Stage) getScene().getWindow();
stage = (Stage) getScene().getWindow();
getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))));
getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))));
clientInfo = ClientInfo.getInstance();
clientInfo = ClientInfo.getInstance();
dashboardBase = new DashboardBase(this, this);
dashboardBase = new DashboardBase(this, this);
dashboardBase.prefWidthProperty().bind(widthProperty());
dashboardBase.prefWidthProperty().bind(widthProperty());
dashboardBase.prefHeightProperty().bind(heightProperty());
dashboardBase.prefHeightProperty().bind(heightProperty());
settingsBase = new SettingsBase(getHostServices(), this, this);
settingsBase = new SettingsBase(getHostServices(), this, this);
alertStackPane = new StackPane();
alertStackPane = new StackPane();
alertStackPane.setPadding(new Insets(10));
alertStackPane.setPadding(new Insets(10));
alertStackPane.setVisible(false);
alertStackPane.setVisible(false);
StreamPiAlert.setParent(alertStackPane);
StreamPiAlert.setParent(alertStackPane);
StreamPiComboBox.setParent(alertStackPane);
StreamPiComboBox.setParent(alertStackPane);
firstTimeUse = new FirstTimeUse(this, this);
getChildren().clear();
getChildren().clear();
getChildren().addAll(alertStackPane);
getChildren().addAll(alertStackPane);
if(getClientInfo().isPhone())
if(getClientInfo().isPhone())
{
{
dashboardBase.setPadding(new Insets(10));
dashboardBase.setPadding(new Insets(10));
settingsBase.setPadding(new Insets(10));
settingsBase.setPadding(new Insets(10));
}
}
initLogger();
initLogger();
checkPrePathDirectory();
checkPrePathDirectory();
getChildren().addAll(settingsBase, dashboardBase);
getChildren().addAll(settingsBase, dashboardBase);
setStyle(null);
setStyle(null);
config = Config.getInstance();
config = Config.getInstance();
initThemes();
if(config.isFirstTimeUse())
if(config.isFirstTimeUse())
{
{
clearStylesheets();
applyDefaultStylesheet();
firstTimeUse = new FirstTimeUse(this, this);
applyDefaultIconsStylesheet();
getChildren().add(firstTimeUse);
getChildren().add(firstTimeUse);
if(getClientInfo().isPhone())
if(getClientInfo().isPhone())
{
{
firstTimeUse.setPadding(new Insets(10));
firstTimeUse.setPadding(new Insets(10));
}
}
firstTimeUse.toFront();
firstTimeUse.toFront();
//resolution check
//resolution check
resizeAccordingToResolution();
resizeAccordingToResolution();
}
}
else
else
{
{
dashboardBase.toFront();
dashboardBase.toFront();
}
}
initThemes();
}
}
private void resizeAccordingToResolution()
private void resizeAccordingToResolution()
{
{
if(!getClientInfo().isPhone())
if(!getClientInfo().isPhone())
{
{
double height = getScreenHeight();
double height = getScreenHeight();
double width = getScreenWidth();
double width = getScreenWidth();
if(height < 500)
if(height < 500)
setPrefHeight(320);
setPrefHeight(320);
if(width < 500)
if(width < 500)
setPrefWidth(240);
setPrefWidth(240);
}
}
}
}
@Override
@Override
public ExecutorService getExecutor()
public ExecutorService getExecutor()
{
{
return executor;
return executor;
}
}
@Override
@Override
public double getStageWidth()
public double getStageWidth()
{
{
if(getClientInfo().isPhone())
if(getClientInfo().isPhone())
{
{
return getScreenWidth();
return getScreenWidth();
}
}
else
else
{
{
return getStage().getWidth();
return getStage().getWidth();
}
}
}
}
public double getScreenWidth()
public double getScreenWidth()
{
{
return Screen.getPrimary().getBounds().getWidth();
return Screen.getPrimary().getBounds().getWidth();
}
}
@Override
@Override
public double getStageHeight()
public double getStageHeight()
{
{
if(ClientInfo.getInstance().getPlatform() == Platform.ANDROID)
if(ClientInfo.getInstance().getPlatform() == Platform.ANDROID)
{
{
return getScreenHeight();
return getScreenHeight();
}
}
else
else
{
{
return getStage().getHeight();
return getStage().getHeight();
}
}
}
}
public double getScreenHeight()
public double getScreenHeight()
{
{
return Screen.getPrimary().getBounds().getHeight();
return Screen.getPrimary().getBounds().getHeight();
}
}
private void checkPrePathDirectory() throws SevereException
private void checkPrePathDirectory() throws SevereException
{
{
try
try
{
{
String path = getClientInfo().getPrePath();
String path = getClientInfo().getPrePath();
if(path == null)
if(path == null)
{
{
throwStoragePermErrorAlert("Unable to access file system!");
throwStoragePermErrorAlert("Unable to access file system!");
return;
return;
}
}
File file = new File(path);
File file = new File(path);
if(!file.exists())
if(!file.exists())
{
{
boolean result = file.mkdirs();
boolean result = file.mkdirs();
if(result)
if(result)
{
{
Config.unzipToDefaultPrePath();
Config.unzipToDefaultPrePath();
ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+
ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+
Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath());
Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath());
int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4);
int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4);
int rows,cols;
int rows,cols;
if (StartupFlags.IS_X_MODE || StartupFlags.DEFAULT_FULLSCREEN_MODE)
if (StartupFlags.IS_X_MODE || StartupFlags.DEFAULT_FULLSCREEN_MODE)
{
{
setupFlags();
setupFlags();
getStage().show();
getStage().show();
rows = (int) (getStageHeight()/pre);
rows = (int) (getStageHeight()/pre);
cols = (int) (getStageWidth()/pre);
cols = (int) (getStageWidth()/pre);
}
}
else
else
{
{
rows = (int) (Config.getInstance().getStartupWindowHeight()/pre);
rows = (int) (Config.getInstance().getStartupWindowHeight()/pre);
cols = (int) (Config.getInstance().getStartupWindowWidth()/pre);
cols = (int) (Config.getInstance().getStartupWindowWidth()/pre);
}
}
clientProfile.setCols(cols);
clientProfile.setCols(cols);
clientProfile.setRows(rows);
clientProfile.setRows(rows);
clientProfile.saveProfileDetails();
clientProfile.saveProfileDetails();
initLogger();
initLogger();
}
}
else
else
{
{
throwStoragePermErrorAlert("No storage permission. Give it!");
throwStoragePermErrorAlert("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());
}
}
}
}
private void throwStoragePermErrorAlert(String msg) throws SevereException
private void throwStoragePermErrorAlert(String msg) throws SevereException
{
{
resizeAccordingToResolution();
resizeAccordingToResolution();
clearStylesheets();
clearStylesheets();
applyDefaultStylesheet();
applyDefaultStylesheet();
applyDefaultIconsStylesheet();
applyDefaultIconsStylesheet();
getStage().show();
getStage().show();
throw new SevereException(msg);
throw new SevereException(msg);
}
}
public void setupFlags() throws SevereException
public void setupFlags() throws SevereException
{
{
//Full Screen
//Full Screen
if(Config.getInstance().getIsFullScreenMode())
if(Config.getInstance().getIsFullScreenMode())
{
{
getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
getStage().setFullScreen(true);
getStage().setFullScreen(true);
}
}
else
else
{
{
getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC"));
getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC"));
getStage().setFullScreen(false);
getStage().setFullScreen(false);
}
}
//Cursor
//Cursor
if(Config.getInstance().isShowCursor())
if(Config.getInstance().isShowCursor())
{
{
setCursor(Cursor.DEFAULT);
setCursor(Cursor.DEFAULT);
}
}
else
else
{
{
setCursor(Cursor.NONE);
setCursor(Cursor.NONE);
}
}
}
}
public SettingsBase getSettingsPane() {
public SettingsBase getSettingsPane() {
return settingsBase;
return settingsBase;
}
}
public DashboardBase getDashboardPane() {
public DashboardBase getDashboardPane() {
return dashboardBase;
return dashboardBase;
}
}
public void renderRootDefaultProfile()
public void renderRootDefaultProfile()
{
{
getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(
getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(
getConfig().getStartupProfileID()
getConfig().getStartupProfileID()
), true);
), true);
}
}
public void clearStylesheets()
public void clearStylesheets()
{
{
getStylesheets().clear();
getStylesheets().clear();
}
}
public void applyDefaultStylesheet()
public void applyDefaultStylesheet()
{
{
if(clientInfo.getPlatform() != Platform.IOS)
if(clientInfo.getPlatform() != Platform.IOS)
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());
}
}
public void applyDefaultIconsStylesheet()
public void applyDefaultIconsStylesheet()
{
{
getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm());
getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm());
}
}
public Config getConfig()
public Config getConfig()
{
{
return config;
return config;
}
}
public ClientInfo getClientInfo()
public ClientInfo getClientInfo()
{
{
return clientInfo;
return clientInfo;
}
}
private Theme currentTheme;
private Theme currentTheme;
@Override
@Override
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;
clearStylesheets();
clearStylesheets();
applyDefaultStylesheet();
applyDefaultStylesheet();
getStylesheets().addAll(t.getStylesheets());
getStylesheets().addAll(t.getStylesheets());
applyDefaultIconsStylesheet();
applyDefaultIconsStylesheet();
logger.info("... Done!");
logger.info("... Done!");
}
}
Themes themes;
Themes themes;
public void initThemes() throws SevereException
public void initThemes() throws SevereException
{
{
logger.info("Loading themes ...");
logger.info("Loading themes ...");
themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion());
themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.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!");
}
}
@Override
@Override
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);
}
}
}
}
}
}
@Override
@Override
public String getDefaultThemeFullName()
public String getDefaultThemeFullName()
{
{
return config.getCurrentThemeFullName();
return config.getCurrentThemeFullName();
}
}
}
}
package com.stream_pi.client.window.firsttimeuse;
package com.stream_pi.client.window.firsttimeuse;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.Platform;
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.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class FinalConfigPane extends VBox
public class FinalConfigPane extends VBox
{
{
private TextField clientNicknameTextField;
private TextField clientNicknameTextField;
private TextField serverIPHostNameTextField;
private TextField serverIPHostNameTextField;
private TextField serverPortTextField;
private TextField serverPortTextField;
private Button nextButton;
private Button nextButton;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ClientListener clientListener;
private ClientListener clientListener;
public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener,
public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener,
Button nextButton)
Button nextButton)
{
{
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.clientListener = clientListener;
this.clientListener = clientListener;
this.nextButton = nextButton;
this.nextButton = nextButton;
getStyleClass().add("first_time_use_pane_final_config");
getStyleClass().add("first_time_use_pane_final_config");
Label label = new Label("Thats it. Now just a little bit and then you're set!");
Label label = new Label("Thats it. Now just a little bit and then you're set!");
label.setWrapText(true);
label.setWrapText(true);
VBox.setVgrow(label, Priority.ALWAYS);
VBox.setVgrow(label, Priority.ALWAYS);
label.getStyleClass().add("first_time_use_pane_final_config_label");
label.getStyleClass().add("first_time_use_pane_final_config_label");
clientNicknameTextField = new TextField();
clientNicknameTextField = new TextField();
serverIPHostNameTextField = new TextField();
serverIPHostNameTextField = new TextField();
serverPortTextField = new TextField();
serverPortTextField = new TextField();
HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField);
HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField);
HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField);
HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField);
HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField);
HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField);
Platform platform = ClientInfo.getInstance().getPlatform();
getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox);
VBox v = new VBox(clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox);
v.setSpacing(10.0);
ScrollPane scrollPane = new ScrollPane(v);
scrollPane.getStyleClass().add("first_time_use_final_config_pane_scroll_pane");
v.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
getChildren().addAll(label, scrollPane);
setSpacing(10.0);
setSpacing(10.0);
setVisible(false);
setVisible(false);
}
}
public void makeChangesToNextButton()
public void makeChangesToNextButton()
{
{
nextButton.setText("Confirm");
nextButton.setText("Confirm");
nextButton.setOnAction(event -> onConfirmButtonClicked());
nextButton.setOnAction(event -> onConfirmButtonClicked());
}
}
private void onConfirmButtonClicked()
private void onConfirmButtonClicked()
{
{
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
if(clientNicknameTextField.getText().isBlank())
if(clientNicknameTextField.getText().isBlank())
{
{
errors.append("* Nick name cannot be blank.\n");
errors.append("* Nick name cannot be blank.\n");
}
}
if(serverIPHostNameTextField.getText().isBlank())
if(serverIPHostNameTextField.getText().isBlank())
{
{
errors.append("* Server IP cannot be empty.\n");
errors.append("* Server IP cannot be empty.\n");
}
}
int port = -1;
int port = -1;
try
try
{
{
port = Integer.parseInt(serverPortTextField.getText());
port = Integer.parseInt(serverPortTextField.getText());
if(port < 1024)
if(port < 1024)
errors.append("* Server Port should be above 1024.\n");
errors.append("* Server Port should be above 1024.\n");
else if(port > 65535)
else if(port > 65535)
errors.append("* Server Port must be lesser than 65535\n");
errors.append("* Server Port must be lesser than 65535\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Server Port should be a number.\n");
errors.append("* Server Port should be a number.\n");
}
}
if(errors.toString().isEmpty())
if(errors.toString().isEmpty())
{
{
try
try
{
{
Config.getInstance().setNickName(clientNicknameTextField.getText());
Config.getInstance().setNickName(clientNicknameTextField.getText());
Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText());
Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText());
Config.getInstance().setServerPort(port);
Config.getInstance().setServerPort(port);
Config.getInstance().setFirstTimeUse(false);
Config.getInstance().setFirstTimeUse(false);
Config.getInstance().save();
Config.getInstance().save();
clientListener.init();
clientListener.init();
clientListener.setupClientConnection();
clientListener.setupClientConnection();
}
}
catch(SevereException e)
catch(SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
}
}
else
else
{
{
new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors.toString(), StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors.toString(), StreamPiAlertType.ERROR).show();
}
}
}
}
}
}
PKRIcons/PKR Profiles/PK'cJRLV&1Profiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlU EJĞl,U $bG!}__BQN=>õlc`O'T9՜Z=:﷮:s 8o -]LChF#,Ii1fzEHgaBfyfjU@7u-;LIٌ5nb_Q/PKRThemes/PKR!Themes/com.stream_pi.defaultdark/PKR%Themes/com.stream_pi.defaultdark/res/PKʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssTMo0GT+JOV[XudL߁Rrxf<c"D<$!?>~h-)䮷]f{guT+#¡p z8Xl70Hjڤږ:}P*-X֫q&^3 U.ρɥqe6cj OLas+tk
PKRIcons/PKR Profiles/PK'cJRLV&1Profiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlU EJĞl,U $bG!}__BQN=>õlc`O'T9՜Z=:﷮:s 8o -]LChF#,Ii1fzEHgaBfyfjU@7u-;LIٌ5nb_Q/PKRThemes/PKR!Themes/com.stream_pi.defaultdark/PKR%Themes/com.stream_pi.defaultdark/res/PKʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssTMo0GT+JOV[XudL߁Rrxf<c"D<$!?>~h-)䮷]f{guT+#¡p z8Xl70Hjڤږ:}P*-X֫q&^3 U.ρɥqe6cj OLas+tk
_!7lYИ 9%+Ȇ !ղJγ]\oNapfk4ވg}rOT
_!7lYИ 9%+Ȇ !ղJγ]\oNapfk4ވg}rOT
4%JLFYFԐeBC7c0HݦFG-]bݑ8ʍm5QFY7?d-<ء|(W-4]8^a<$/y GMq?dVI]hM (b SrnV߮&qc樵LqM129w~<ĦUUqiu$P|a\!X8#g PK,R}*Themes/com.stream_pi.defaultdark/theme.xmluP MNi ]89>/VZݽ˽cK FpnL; )ÑU|cr&+|a1
4%JLFYFԐeBC7c0HݦFG-]bݑ8ʍm5QFY7?d-<ء|(W-4]8^a<$/y GMq?dVI]hM (b SrnV߮&qc樵LqM129w~<ĦUUqiu$P|a\!X8#g PK,R}*Themes/com.stream_pi.defaultdark/theme.xmluP MNi ]89>/VZݽ˽cK FpnL; )ÑU|cr&+|a1
/U$aaDd]o'Z(5H1MD.&pn ZF#H6)MO2yxtY9F&^Ot]PKR"Themes/com.stream_pi.defaultlight/PKR&Themes/com.stream_pi.defaultlight/res/PKRx~/Themes/com.stream_pi.defaultlight/res/style.cssTN0G?XHT\``f#gC&hwwv==
/U$aaDd]o'Z(5H1MD.&pn ZF#H6)MO2yxtY9F&^Ot]PKR"Themes/com.stream_pi.defaultlight/PKR&Themes/com.stream_pi.defaultlight/res/PKRx~/Themes/com.stream_pi.defaultlight/res/style.cssTN0G?XHT\``f#gC&hwwv==
F+Yg {isI!!vjVCs(p.١̋ϕ$ ^ߣR; N/=^"7aЍ^#){oa2W!97m٨ U} JǓ&aCCmd!w7T79d2/֢| ~`Ph!癷aJh1dB$)|&<qGɟa3~[T*5#FbL]԰Z+nq]K]nSwRNyd-VnmY}?[`+<$c$5}ϨКH;Jzg^+8Kd6^@Q\4=GGE
F+Yg {isI!!vjVCs(p.١̋ϕ$ ^ߣR; N/=^"7aЍ^#){oa2W!97m٨ U} JǓ&aCCmd!w7T79d2/֢| ~`Ph!癷aJh1dB$)|&<qGɟa3~[T*5#FbL]԰Z+nq]K]nSwRNyd-VnmY}?[`+<$c$5}ϨКH;Jzg^+8Kd6^@Q\4=GGE
}Ahy>DgcҙÚ k+;CpYVPK,R|+Themes/com.stream_pi.defaultlight/theme.xmluPA0{)L0)ă/@hM{(3kSFIf ]FLη+-Ñ ~k[MV{1Hli0+8~oҭ ȲXZ Ni@rQ]ELz\X-gyDMu ΢WP8ztǖ5,b"+-PKR)Themes/com.stream_pi.defaulthighcontrast/PKR-Themes/com.stream_pi.defaulthighcontrast/res/PK)RG6Themes/com.stream_pi.defaulthighcontrast/res/style.cssUMo0#|^vz\eO-A: 2IU@@06<7oL~0 x 0`IBa=O!wtNu.J22*, ל,``Z@[I/ N-uhU*Z\A>=G1g\^kI]0xa\[ ϘqZ RU٧&I1zf wȍjF]LΒ344Z6QyVҺw<::u"-3-rOL`LlI6c22lZ|_pv7]2u EtXYYeuHֻ@<<Qմu{F(;άRK=Mt,c 8r8l#GftKon-<w%sjLD)lZ@Qw ׳Y4[{x}{V*%Ĉwu%B]R!VI7*DBsJi;Wi`7PK,RGzK2Themes/com.stream_pi.defaulthighcontrast/theme.xmluP10 ܑC 40 x)n&(qR|w>O]n輶,chJ{֦.Ŋ3V,t;  #x4S+IFm*Pm%u6֐OlwJs)x RD |" >9H}H>(ЋK0:ҟPKdR;f
}Ahy>DgcҙÚ k+;CpYVPK,R|+Themes/com.stream_pi.defaultlight/theme.xmluPA0{)L0)ă/@hM{(3kSFIf ]FLη+-Ñ ~k[MV{1Hli0+8~oҭ ȲXZ Ni@rQ]ELz\X-gyDMu ΢WP8ztǖ5,b"+-PKR)Themes/com.stream_pi.defaulthighcontrast/PKR-Themes/com.stream_pi.defaulthighcontrast/res/PK)RG6Themes/com.stream_pi.defaulthighcontrast/res/style.cssUMo0#|^vz\eO-A: 2IU@@06<7oL~0 x 0`IBa=O!wtNu.J22*, ל,``Z@[I/ N-uhU*Z\A>=G1g\^kI]0xa\[ ϘqZ RU٧&I1zf wȍjF]LΒ344Z6QyVҺw<::u"-3-rOL`LlI6c22lZ|_pv7]2u EtXYYeuHֻ@<<Qմu{F(;άRK=Mt,c 8r8l#GftKon-<w%sjLD)lZ@Qw ׳Y4[{x}{V*%Ĉwu%B]R!VI7*DBsJi;Wi`7PK,RGzK2Themes/com.stream_pi.defaulthighcontrast/theme.xmluP10 ܑC 40 x)n&(qR|w>O]n輶,chJ{֦.Ŋ3V,t;  #x4S+IFm*Pm%u6֐OlwJs)x RD |" >9H}H>(ЋK0:ҟPKdR;f
config.xmlTn0 ?+qG t,T In}([
config.xmlTn0 ?+qG t,T In}([
v)WON9O"Hl9o3iF`kUg[R+0~iwkG=py 5Mz&TtcСnS52VUm*ӫRPoPN֏CSY%dUU`-W5(9'(yQ ,z;LAS~džGiiBs`CèL \:tN(c ='i+а.isטjA%wߌ,c@zr7t`$&uf*ȸ$poG*ӳ;FI|k +i%k>
v)WON9O"Hl9o3iF`kUg[R+0~iwkG=py 5Mz&TtcСnS52VUm*ӫRPoPN֏CSY%dUU`-W5(9'(yQ ,z;LAS~džGiiBs`CèL \:tN(c ='i+а.isטjA%wߌ,c@zr7t`$&uf*ȸ$poG*ӳ;FI|k +i%k>
!>cB"|rNZ9'pdL/$<@4Cɘsu$APK?RAIcons/PK?R A$Profiles/PK?'cJRLV&1KProfiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlPK?RA7Themes/PK?R!A\Themes/com.stream_pi.defaultdark/PK?R%AThemes/com.stream_pi.defaultdark/res/PK?ʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssPK?,R}*5Themes/com.stream_pi.defaultdark/theme.xmlPK?R"A>Themes/com.stream_pi.defaultlight/PK?R&A~Themes/com.stream_pi.defaultlight/res/PK?Rx~/Themes/com.stream_pi.defaultlight/res/style.cssPK?,R|+Themes/com.stream_pi.defaultlight/theme.xmlPK?R)AThemes/com.stream_pi.defaulthighcontrast/PK?R-A, Themes/com.stream_pi.defaulthighcontrast/res/PK?)RG6w Themes/com.stream_pi.defaulthighcontrast/res/style.cssPK?,RGzK2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlPK?dR;f
!>cB"|rNZ9'pdL/$<@4Cɘsu$APK?RAIcons/PK?R A$Profiles/PK?'cJRLV&1KProfiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlPK?RA7Themes/PK?R!A\Themes/com.stream_pi.defaultdark/PK?R%AThemes/com.stream_pi.defaultdark/res/PK?ʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssPK?,R}*5Themes/com.stream_pi.defaultdark/theme.xmlPK?R"A>Themes/com.stream_pi.defaultlight/PK?R&A~Themes/com.stream_pi.defaultlight/res/PK?Rx~/Themes/com.stream_pi.defaultlight/res/style.cssPK?,R|+Themes/com.stream_pi.defaultlight/theme.xmlPK?R)AThemes/com.stream_pi.defaulthighcontrast/PK?R-A, Themes/com.stream_pi.defaulthighcontrast/res/PK?)RG6w Themes/com.stream_pi.defaulthighcontrast/res/style.cssPK?,RGzK2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlPK?dR;f
config.xmlPK]
config.xmlPK]
.root {
.root {
-fx-font-family : 'Roboto';
-fx-font-family : 'Roboto';
}
}
.action_box
.action_box
{
{
-fx-border-width: 1px;
-fx-border-width: 1px;
-fx-border-color : grey;
-fx-border-color : grey;
}
}
.action_box_icon_present
.action_box_icon_present
{
{
}
}
.action_box_icon_not_present
.action_box_icon_not_present
{
{
}
}
.action_box_onclick
.action_box_onclick
{
{
}
}
.settings_heading_label
.settings_heading_label
{
{
-fx-font-size: 20;
-fx-font-size: 20;
}
}
.alert_header
.alert_header
{
{
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_pane
.alert_pane
{
{
-fx-border-width : 5;
-fx-border-width : 5;
-fx-border-radius : 5;
-fx-border-radius : 5;
-fx-background-radius : 5;
-fx-background-radius : 5;
-fx-max-width : 400;
-fx-max-width : 400;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
}
}
.alert_header_icon
.alert_header_icon
{
{
-fx-icon-size : 30;
-fx-icon-size : 30;
}
}
.alert_content_pane
.alert_content_pane
{
{
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_pane_parent, .combobox_pane_parent
.alert_pane_parent, .combobox_pane_parent
{
{
-fx-background-color : rgba(0,0,0,0.5);
-fx-background-color : rgba(0,0,0,0.5);
}
}
.alert_pane_header_text
.alert_pane_header_text
{
{
-fx-font-size: 18;
-fx-font-size: 18;
}
}
.alert_button_bar
.alert_button_bar
{
{
-fx-alignment: CENTER_RIGHT;
-fx-alignment: CENTER_RIGHT;
-fx-spacing: 5;
-fx-spacing: 5;
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_scroll_pane {
.alert_scroll_pane {
-fx-max-height : 300;
-fx-max-height : 300;
/*-fx-focus-color: #FFFFFF;
/*-fx-focus-color: #FFFFFF;
-fx-faint-focus-color:#FFFFFF;*/
-fx-faint-focus-color:#FFFFFF;*/
}
}
.combo_box
.combo_box
{
{
-fx-alignment:CENTER_LEFT;
-fx-alignment:CENTER_LEFT;
-fx-pref-width:200;
-fx-pref-width:200;
-fx-padding: 5;
-fx-padding: 5;
-fx-border-width : 1;
-fx-border-width : 1;
-fx-border-color : grey;
-fx-border-color : grey;
-fx-border-radius : 3;
-fx-border-radius : 3;
}
}
.combo_box_popup
.combo_box_popup
{
{
-fx-border-width : 5;
-fx-border-width : 5;
-fx-border-radius : 5;
-fx-border-radius : 5;
-fx-background-radius : 5;
-fx-background-radius : 5;
-fx-max-height : 300;
-fx-max-height : 300;
-fx-max-width : 410;
-fx-max-width : 410;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 );
}
}
.combo_box_popup_vbox
.combo_box_popup_vbox
{
{
-fx-padding: 5 5 0 5;
-fx-padding: 5 5 0 5;
-fx-spacing:5;
-fx-spacing:5;
}
}
.combo_box_drop_down_icon
.combo_box_drop_down_icon
{
{
-fx-icon-code: fas-caret-down;
-fx-icon-code: fas-caret-down;
-fx-icon-size: 14;
-fx-icon-size: 14;
}
}
.action_grid_pane_parent
.action_grid_pane_parent
{
{
-fx-background-color:transparent;
-fx-background-color:transparent;
}
}
.first_time_use_pane_heading_label
.first_time_use_pane_heading_label
{
{
-fx-font-size: 20;
-fx-font-size: 20;
}
}
.first_time_use_final_config_pane_scroll_pane
{
-fx-background-color:transparent;
}
.first_time_use_pane_stackpane
.first_time_use_pane_stackpane
{
{
}
}
.first_time_use_pane_welcome
.first_time_use_pane_welcome
{
{
}
}
.first_time_use_pane_license
.first_time_use_pane_license
{
{
-fx-spacing : 10;
-fx-spacing : 10;
}
}
.first_time_use_pane_final_config
.first_time_use_pane_final_config
{
{
}
}
.first_time_use_pane_final_config_label
.first_time_use_pane_final_config_label
{
{
}
}
.first_time_use_welcome_pane_welcome_label
.first_time_use_welcome_pane_welcome_label
{
{
-fx-font-size: 30;
-fx-font-size: 30;
}
}
.first_time_use_welcome_pane_next_to_continue_label
.first_time_use_welcome_pane_next_to_continue_label
{
{
-fx-font-size: 15;
-fx-font-size: 15;
}
}
.scroll-pane
.scroll-pane
{
{
-fx-focus-color:transparent;
-fx-focus-color:transparent;
-fx-faint-focus-color:transparent;
-fx-faint-focus-color:transparent;
}
}
/*Alert Classes added to default stylesheet to show init error, if occurs */
/*Alert Classes added to default stylesheet to show init error, if occurs */
.action_box_display_text_label
.action_box_display_text_label
{
{
-fx-font-size : 16;
-fx-font-size : 16;
-fx-background-color : transparent;
-fx-background-color : transparent;
}
}
.alert_pane
.alert_pane
{
{
-fx-background-color : white;
-fx-background-color : white;
-fx-border-color : white;
-fx-border-color : white;
}
}
.alert_content_pane
.alert_content_pane
{
{
-fx-background-color: white;
-fx-background-color: white;
-fx-padding: 5;
-fx-padding: 5;
}
}
.alert_scroll_pane
.alert_scroll_pane
{
{
-fx-background: white;
-fx-background: white;
-fx-border-color:white;
-fx-border-color:white;
}
}
.alert_button_bar
.alert_button_bar
{
{
-fx-background-color:white;
-fx-background-color:white;
}
}
.about_donate_hyperlink
.about_donate_hyperlink
{
{
-fx-padding : 10 0 0 0;
-fx-padding : 10 0 0 0;
-fx-font-size : 25;
-fx-font-size : 25;
}
}
.screensaver
.screensaver
{
{
-fx-background-color: black;
-fx-background-color: black;
}
}