server
Clone or download
Modified Files
package com.stream_pi.server.controller;
package com.stream_pi.server.controller;
import com.stream_pi.action_api.action.ServerConnection;
import com.stream_pi.action_api.action.ServerConnection;
import com.stream_pi.action_api.action.PropertySaver;
import com.stream_pi.action_api.action.PropertySaver;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.server.Main;
import com.stream_pi.server.Main;
import com.stream_pi.server.action.NormalActionPlugins;
import com.stream_pi.server.action.NormalActionPlugins;
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.io.Config;
import com.stream_pi.server.io.Config;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.info.ServerInfo;
import com.stream_pi.server.window.Base;
import com.stream_pi.server.window.Base;
import com.stream_pi.server.window.dashboard.DonatePopupContent;
import com.stream_pi.server.window.dashboard.DonatePopupContent;
import com.stream_pi.server.window.firsttimeuse.FirstTimeUse;
import com.stream_pi.server.window.firsttimeuse.FirstTimeUse;
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.MinorException;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.iohelper.IOHelper;
import com.stream_pi.util.iohelper.IOHelper;
import 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.event.EventHandler;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.Scene;
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 java.awt.SystemTray;
import java.awt.SystemTray;
import javafx.util.Duration;
import javafx.util.Duration;
import java.awt.Toolkit;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.TrayIcon;
import java.awt.PopupMenu;
import java.awt.PopupMenu;
import java.awt.MenuItem;
import java.awt.MenuItem;
import java.io.File;
import java.io.File;
import java.net.Inet4Address;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.NetworkInterface;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.Enumeration;
import java.util.Random;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Level;
public class Controller extends Base implements PropertySaver, ServerConnection
public class Controller extends Base implements PropertySaver, ServerConnection
{
{
MainServer mainServer;
MainServer mainServer;
public void setupDashWindow() throws SevereException
public void setupDashWindow() throws SevereException
{
{
try
try
{
{
StringBuilder ips = new StringBuilder();
StringBuilder ips = new StringBuilder();
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
while(e.hasMoreElements())
while(e.hasMoreElements())
{
{
NetworkInterface n = e.nextElement();
NetworkInterface n = e.nextElement();
Enumeration<InetAddress> ee = n.getInetAddresses();
Enumeration<InetAddress> ee = n.getInetAddresses();
while (ee.hasMoreElements())
while (ee.hasMoreElements())
{
{
InetAddress i = ee.nextElement();
InetAddress i = ee.nextElement();
String hostAddress = i.getHostAddress();
String hostAddress = i.getHostAddress();
if(i instanceof Inet4Address)
if(i instanceof Inet4Address)
{
{
ips.append(hostAddress);
ips.append(hostAddress);
if(e.hasMoreElements())
if(e.hasMoreElements())
ips.append(" / ");
ips.append(" / ");
}
}
}
}
}
}
getStage().setTitle("Stream-Pi Server - IP(s): "+ips.toString()+" | Port: "+ Config.getInstance().getPort()); //Sets title
getStage().setTitle("Stream-Pi Server - IP(s): "+ips.toString()+" | Port: "+ Config.getInstance().getPort()); //Sets title
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();
NormalActionPlugins.getInstance().setPropertySaver(this);
NormalActionPlugins.getInstance().setPropertySaver(this);
NormalActionPlugins.getInstance().setServerConnection(this);
NormalActionPlugins.getInstance().setServerConnection(this);
getDashboardPane().getPluginsPane().getSettingsButton().setOnAction(event -> {
getDashboardPane().getPluginsPane().getSettingsButton().setOnAction(event -> {
openSettingsTimeLine.play();
openSettingsTimeLine.play();
});
});
getSettingsPane().getCloseButton().setOnAction(event -> {
getSettingsPane().getCloseButton().setOnAction(event -> {
closeSettingsTimeLine.play();
closeSettingsTimeLine.play();
});
});
getSettingsPane().getThemesSettings().setController(this);
getSettingsPane().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.setResizable(false);
stage.setResizable(false);
stage.setScene(s);
stage.setScene(s);
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(ServerInfo.getInstance().isStartMinimised() && SystemTray.isSupported())
minimiseApp();
minimiseApp();
else
else
getStage().show();
getStage().show();
}
}
catch(MinorException e)
catch(MinorException e)
{
{
handleMinorException(e);
handleMinorException(e);
}
}
new Thread(new Task<Void>() {
new Thread(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
try
try
{
{
getSettingsPane().getGeneralSettings().loadDataFromConfig();
getSettingsPane().getGeneralSettings().loadDataFromConfig();
//themes
//themes
getSettingsPane().getThemesSettings().setThemes(getThemes());
getSettingsPane().getThemesSettings().setThemes(getThemes());
getSettingsPane().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsPane().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsPane().getThemesSettings().loadThemes();
getSettingsPane().getThemesSettings().loadThemes();
//clients
//clients
getSettingsPane().getClientsSettings().loadData();
getSettingsPane().getClientsSettings().loadData();
try
try
{
{
//Plugins
//Plugins
Platform.runLater(()->{
Platform.runLater(()->{
getDashboardPane().getPluginsPane().clearData();
getDashboardPane().getPluginsPane().clearData();
getDashboardPane().getPluginsPane().loadOtherActions();
getDashboardPane().getPluginsPane().loadOtherActions();
});
});
NormalActionPlugins.setPluginsLocation(getConfig().getPluginsPath());
NormalActionPlugins.setPluginsLocation(getConfig().getPluginsPath());
NormalActionPlugins.getInstance().init();
NormalActionPlugins.getInstance().init();
Platform.runLater(()->getDashboardPane().getPluginsPane().loadData());
Platform.runLater(()->getDashboardPane().getPluginsPane().loadData());
getSettingsPane().getPluginsSettings().loadPlugins();
getSettingsPane().getPluginsSettings().loadPlugins();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
getSettingsPane().getPluginsSettings().showPluginInitError();
getSettingsPane().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;
}
}
}).start();
}).start();
}
}
private void setupSettingsWindowsAnimations()
private void setupSettingsWindowsAnimations()
{
{
Node settingsNode = getSettingsPane();
Node settingsNode = getSettingsPane();
Node dashboardNode = getDashboardPane();
Node dashboardNode = getDashboardPane();
openSettingsTimeLine = new 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(event1 -> {
openSettingsTimeLine.setOnFinished(event1 -> {
settingsNode.toFront();
settingsNode.toFront();
});
});
closeSettingsTimeLine = new 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();
new Thread(new Task<Void>() {
new Thread(new Task<Void>() {
@Override
@Override
protected Void call() {
protected Void call() {
try {
try {
getSettingsPane().getClientsSettings().loadData();
getSettingsPane().getClientsSettings().loadData();
getSettingsPane().getGeneralSettings().loadDataFromConfig();
getSettingsPane().getGeneralSettings().loadDataFromConfig();
getSettingsPane().getPluginsSettings().loadPlugins();
getSettingsPane().getPluginsSettings().loadPlugins();
getSettingsPane().getThemesSettings().setThemes(getThemes());
getSettingsPane().getThemesSettings().setThemes(getThemes());
getSettingsPane().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsPane().getThemesSettings().setCurrentThemeFullName(getCurrentTheme().getFullName());
getSettingsPane().getThemesSettings().loadThemes();
getSettingsPane().getThemesSettings().loadThemes();
getSettingsPane().setDefaultTabToGeneral();
getSettingsPane().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;
}
}
}).start();
}).start();
});
});
}
}
private Timeline openSettingsTimeLine;
private Timeline openSettingsTimeLine;
private Timeline closeSettingsTimeLine;
private Timeline closeSettingsTimeLine;
public Controller(){
public Controller(){
mainServer = null;
mainServer = null;
}
}
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;
}
}
getConfig().setStartupWindowSize(
getConfig().setStartupWindowSize(
getWidth(),
getWidth(),
getHeight()
getHeight()
);
);
getConfig().save();
getConfig().save();
onQuitApp();
onQuitApp();
NormalActionPlugins.getInstance().shutDownActions();
NormalActionPlugins.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);
}
}
finally
finally
{
{
closeLogger();
closeLogger();
}
}
}
}
public void onQuitApp()
public void onQuitApp()
{
{
if(mainServer!=null)
if(mainServer!=null)
mainServer.stopListeningForConnections();
mainServer.stopListeningForConnections();
ClientConnections.getInstance().disconnectAll();
ClientConnections.getInstance().disconnectAll();
getLogger().info("Shutting down ...");
getLogger().info("Shutting down ...");
}
}
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(()-> getStage().show()));
trayIcon.addActionListener(l-> Platform.runLater(()-> getStage().show()));
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.getMessage(), e);
getLogger().log(Level.SEVERE, e.getMessage(), e);
e.printStackTrace();
e.printStackTrace();
Platform.runLater(()->{
Platform.runLater(()->{
new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show();
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.getMessage(), e);
getLogger().log(Level.SEVERE, e.getMessage(), 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 boolean onNormalActionClicked(NormalAction action) {
public boolean onNormalActionClicked(NormalAction action) {
try{
try{
getLogger().info("action "+action.getID()+" clicked!");
getLogger().info("action "+action.getID()+" clicked!");
action.onActionClicked();
action.onActionClicked();
return true;
return true;
}
}
catch (Exception e)
catch (Exception e)
{
{
//check if its windows UAC related
//check if its windows UAC related
if(e.getMessage().contains("operation requires elevation"))
if(e.getMessage().contains("operation requires elevation"))
{
{
handleMinorException(new MinorException(
handleMinorException(new MinorException(
"Action Execution Failed!",
"Action Execution Failed!",
"Error running action at ["+action.getLocation().getRow()+","+action.getLocation().getCol()+"] ("+action.getDisplayText()+")\n"+
"Error running action at ["+action.getLocation().getRow()+","+action.getLocation().getCol()+"] ("+action.getDisplayText()+")\n"+
"This action requires higher UAC privileges. Re-launch Stream-Pi Server with 'Administrator Privileges' in order to run this command.")
"This action requires higher UAC privileges. Re-launch Stream-Pi Server with 'Administrator Privileges' in order to run this command.")
);
);
}
}
else
else
{
{
handleMinorException(new MinorException(
handleMinorException(new MinorException(
"Action Execution Failed!",
"Action Execution Failed!",
"Error running action at ["+action.getLocation().getRow()+","+action.getLocation().getCol()+"] ("+action.getDisplayText()+")\n"+
"Error running action at ["+action.getLocation().getRow()+","+action.getLocation().getCol()+"] ("+action.getDisplayText()+")\n"+
"Check stacktrace/log to know what exactly happened\n\nMessage : \n"+e.getMessage() )
"Check stacktrace/log to know what exactly happened\n\nMessage : \n"+e.getMessage() )
);
);
}
}
return false;
return false;
}
}
}
}
@Override
@Override
public void clearTemp() {
public void clearTemp() {
Platform.runLater(() -> {
Platform.runLater(() -> {
getDashboardPane().getClientDetailsPane().refresh();
getDashboardPane().getClientDetailsPane().refresh();
getDashboardPane().getActionGridPane().clear();
getDashboardPane().getActionGridPane().clear();
getDashboardPane().getActionGridPane().setFreshRender(true);
getDashboardPane().getActionGridPane().setFreshRender(true);
getDashboardPane().getActionDetailsPane().clear();
getDashboardPane().getActionDetailsPane().clear();
getSettingsPane().getClientsSettings().loadData();
getSettingsPane().getClientsSettings().loadData();
});
});
}
}
@Override
@Override
public void saveServerProperties() {
public void saveServerProperties() {
try {
try {
NormalActionPlugins.getInstance().saveServerSettings();
NormalActionPlugins.getInstance().saveServerSettings();
getSettingsPane().getPluginsSettings().loadPlugins();
getSettingsPane().getPluginsSettings().loadPlugins();
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
handleMinorException(e);
handleMinorException(e);
}
}
}
}
@Override
@Override
public com.stream_pi.util.platform.Platform getPlatform() {
public com.stream_pi.util.platform.Platform getPlatform() {
return ServerInfo.getInstance().getPlatformType();
return ServerInfo.getInstance().getPlatformType();
}
}
}
}
package com.stream_pi.server.window.dashboard;
package com.stream_pi.server.window.dashboard;
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 javafx.collections.FXCollections;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
import javafx.util.Callback;
import javafx.util.Callback;
public class ClientAndProfileSelectorPane extends HBox {
public class ClientAndProfileSelectorPane extends HBox {
private DashboardInterface dashboard;
private DashboardInterface dashboard;
public ClientAndProfileSelectorPane(DashboardInterface dashboard)
public ClientAndProfileSelectorPane(DashboardInterface dashboard)
{
{
this.dashboard = dashboard;
this.dashboard = dashboard;
VBox.setVgrow(this, Priority.NEVER);
VBox.setVgrow(this, Priority.NEVER);
getStyleClass().add("client_and_profile_selector_pane");
getStyleClass().add("client_and_profile_selector_pane");
setPadding(new Insets(10));
setPadding(new Insets(10));
setMinHeight(90);
setMinHeight(90);
setMaxHeight(90);
initUI();
initUI();
loadData();
loadData();
setCache(true);
setCache(true);
setCacheHint(CacheHint.SPEED);
setCacheHint(CacheHint.SPEED);
}
}
private ComboBox<ClientConnection> clientsComboBox;
private ComboBox<ClientConnection> clientsComboBox;
private Label noClientsConnectedLabel;
private Label noClientsConnectedLabel;
private ComboBox<ClientProfile> clientProfilesComboBox;
private ComboBox<ClientProfile> clientProfilesComboBox;
public void initUI()
public void initUI()
{
{
noClientsConnectedLabel = new Label("No Clients Connected");
noClientsConnectedLabel = new Label("No Clients Connected");
noClientsConnectedLabel.getStyleClass().add("client_and_profile_selector_pane_no_clients_connected_label");
noClientsConnectedLabel.getStyleClass().add("client_and_profile_selector_pane_no_clients_connected_label");
noClientsConnectedLabel.managedProperty().bind(noClientsConnectedLabel.visibleProperty());
noClientsConnectedLabel.managedProperty().bind(noClientsConnectedLabel.visibleProperty());
clientsComboBox = new ComboBox<>();
clientsComboBox = new ComboBox<>();
clientsComboBox.getStyleClass().add("client_and_profile_selector_pane_client_selector_combo_box");
clientsComboBox.getStyleClass().add("client_and_profile_selector_pane_client_selector_combo_box");
clientsComboBox.setPromptText("Choose client");
clientsComboBox.setPromptText("Choose client");
clientsComboBox.valueProperty().addListener((observableValue, oldVal, newVal) -> {
clientsComboBox.valueProperty().addListener((observableValue, oldVal, newVal) -> {
if(oldVal!=newVal && newVal!=null)
if(oldVal!=newVal && newVal!=null)
{
{
dashboard.newSelectedClientConnection(newVal);
dashboard.newSelectedClientConnection(newVal);
clientProfilesComboBox.setItems(FXCollections.observableArrayList(newVal.getClient().getAllClientProfiles()));
clientProfilesComboBox.setItems(FXCollections.observableArrayList(newVal.getClient().getAllClientProfiles()));
clientProfilesComboBox.setVisible(true);
clientProfilesComboBox.setVisible(true);
}
}
});
});
clientsComboBox.managedProperty().bind(clientsComboBox.visibleProperty());
clientsComboBox.managedProperty().bind(clientsComboBox.visibleProperty());
Callback<ListView<ClientConnection>, ListCell<ClientConnection>> clientsComboBoxFactory = new Callback<>() {
Callback<ListView<ClientConnection>, ListCell<ClientConnection>> clientsComboBoxFactory = new Callback<>() {
@Override
@Override
public ListCell<ClientConnection> call(ListView<ClientConnection> clientConnectionListView) {
public ListCell<ClientConnection> call(ListView<ClientConnection> clientConnectionListView) {
return new ListCell<>() {
return new ListCell<>() {
@Override
@Override
protected void updateItem(ClientConnection clientConnection, boolean b) {
protected void updateItem(ClientConnection clientConnection, boolean b) {
super.updateItem(clientConnection, b);
super.updateItem(clientConnection, b);
if(clientConnection == null)
if(clientConnection == null)
{
{
setText("Choose client");
setText("Choose client");
}
}
else
else
{
{
Client client = clientConnection.getClient();
Client client = clientConnection.getClient();
setText(client.getNickName());
setText(client.getNickName());
}
}
}
}
};
};
}
}
};
};
clientsComboBox.setCellFactory(clientsComboBoxFactory);
clientsComboBox.setCellFactory(clientsComboBoxFactory);
clientsComboBox.setButtonCell(clientsComboBoxFactory.call(null));
clientsComboBox.setButtonCell(clientsComboBoxFactory.call(null));
clientProfilesComboBox = new ComboBox<>();
clientProfilesComboBox = new ComboBox<>();
clientProfilesComboBox.getStyleClass().add("client_and_profile_selector_pane_profile_selector_combo_box");
clientProfilesComboBox.getStyleClass().add("client_and_profile_selector_pane_profile_selector_combo_box");
clientProfilesComboBox.setPromptText("Choose Profile");
clientProfilesComboBox.setPromptText("Choose Profile");
clientProfilesComboBox.valueProperty().addListener((observableValue, oldVal, newVal) -> {
clientProfilesComboBox.valueProperty().addListener((observableValue, oldVal, newVal) -> {
if(oldVal!=newVal && newVal!=null)
if(oldVal!=newVal && newVal!=null)
{
{
dashboard.newSelectedClientProfile(newVal);
dashboard.newSelectedClientProfile(newVal);
}
}
});
});
clientProfilesComboBox.managedProperty().bind(clientProfilesComboBox.visibleProperty());
clientProfilesComboBox.managedProperty().bind(clientProfilesComboBox.visibleProperty());
Callback<ListView<ClientProfile>, ListCell<ClientProfile>> clientProfilesComboBoxFactory = new Callback<ListView<ClientProfile>, ListCell<ClientProfile>>() {
Callback<ListView<ClientProfile>, ListCell<ClientProfile>> clientProfilesComboBoxFactory = new Callback<ListView<ClientProfile>, ListCell<ClientProfile>>() {
@Override
@Override
public ListCell<ClientProfile> call(ListView<ClientProfile> clientProfileListView) {
public ListCell<ClientProfile> call(ListView<ClientProfile> clientProfileListView) {
return new ListCell<>()
return new ListCell<>()
{
{
@Override
@Override
protected void updateItem(ClientProfile profile, boolean b) {
protected void updateItem(ClientProfile profile, boolean b) {
super.updateItem(profile, b);
super.updateItem(profile, b);
if(profile == null)
if(profile == null)
{
{
setText("Choose Profile");
setText("Choose Profile");
}
}
else
else
{
{
setText(profile.getName());
setText(profile.getName());
}
}
}
}
};
};
}
}
};
};
clientProfilesComboBox.setCellFactory(clientProfilesComboBoxFactory);
clientProfilesComboBox.setCellFactory(clientProfilesComboBoxFactory);
clientProfilesComboBox.setButtonCell(clientProfilesComboBoxFactory.call(null));
clientProfilesComboBox.setButtonCell(clientProfilesComboBoxFactory.call(null));
VBox stack = new VBox(noClientsConnectedLabel, clientsComboBox, clientProfilesComboBox);
VBox stack = new VBox(noClientsConnectedLabel, clientsComboBox, clientProfilesComboBox);
stack.getStyleClass().add("client_and_profile_selector_pane_stack");
stack.getStyleClass().add("client_and_profile_selector_pane_stack");
getChildren().addAll(stack);
getChildren().addAll(stack);
}
}
private void loadData()
private void loadData()
{
{
clientsComboBox.getSelectionModel().clearSelection();
clientsComboBox.getSelectionModel().clearSelection();
clientProfilesComboBox.getSelectionModel().clearSelection();
clientProfilesComboBox.getSelectionModel().clearSelection();
if(ClientConnections.getInstance().getConnections().size() == 0)
if(ClientConnections.getInstance().getConnections().size() == 0)
{
{
noClientsConnectedLabel.setVisible(true);
noClientsConnectedLabel.setVisible(true);
clientsComboBox.setVisible(false);
clientsComboBox.setVisible(false);
clientProfilesComboBox.setVisible(false);
clientProfilesComboBox.setVisible(false);
dashboard.newSelectedClientConnection(null);
dashboard.newSelectedClientConnection(null);
}
}
else
else
{
{
noClientsConnectedLabel.setVisible(false);
noClientsConnectedLabel.setVisible(false);
clientsComboBox.setVisible(true);
clientsComboBox.setVisible(true);
clientProfilesComboBox.setVisible(false);
clientProfilesComboBox.setVisible(false);
clientsComboBox.setItems(FXCollections.observableArrayList(ClientConnections.getInstance().getConnections()));
clientsComboBox.setItems(FXCollections.observableArrayList(ClientConnections.getInstance().getConnections()));
}
}
}
}
public void refresh()
public void refresh()
{
{
loadData();
loadData();
}
}
}
}
package com.stream_pi.server.window.dashboard;
package com.stream_pi.server.window.dashboard;
import java.util.logging.Logger;
import java.util.logging.Logger;
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.window.dashboard.actiongridpane.ActionGridPane;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionGridPane;
import com.stream_pi.server.window.dashboard.actiondetailpane.ActionDetailsPane;
import com.stream_pi.server.window.dashboard.actiondetailpane.ActionDetailsPane;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.geometry.Orientation;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class DashboardBase extends HBox implements DashboardInterface {
public class DashboardBase extends SplitPane implements DashboardInterface {
private final VBox leftPane;
private final SplitPane leftSplitPane;
private Logger logger;
private Logger logger;
public ClientProfile currentClientProfile;
public ClientProfile currentClientProfile;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices)
public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices)
{
{
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
logger = Logger.getLogger(DashboardBase.class.getName());
logger = Logger.getLogger(DashboardBase.class.getName());
leftPane = new VBox();
HBox.setHgrow(leftPane, Priority.ALWAYS);
leftSplitPane = new SplitPane();
getChildren().add(leftPane);
leftSplitPane.getStyleClass().add("dashboard_left_split_pane");
leftSplitPane.setOrientation(Orientation.VERTICAL);
getStyleClass().add("dashboard_right_split_pane");
getItems().add(leftSplitPane);
setPluginsPane(new PluginsPane(hostServices));
setPluginsPane(new PluginsPane(hostServices));
setClientDetailsPane(new ClientAndProfileSelectorPane(this));
setClientDetailsPane(new ClientAndProfileSelectorPane(this));
setActionGridPane(new ActionGridPane(exceptionAndAlertHandler));
setActionGridPane(new ActionGridPane(exceptionAndAlertHandler));
setActionDetailsPane(new ActionDetailsPane(exceptionAndAlertHandler, hostServices));
setActionDetailsPane(new ActionDetailsPane(exceptionAndAlertHandler, hostServices));
getActionGridPane().setActionDetailsPaneListener(getActionDetailsPane());
getActionGridPane().setActionDetailsPaneListener(getActionDetailsPane());
}
}
private PluginsPane pluginsPane;
private PluginsPane pluginsPane;
private void setPluginsPane(PluginsPane pluginsPane)
private void setPluginsPane(PluginsPane pluginsPane)
{
{
this.pluginsPane = pluginsPane;
this.pluginsPane = pluginsPane;
getChildren().add(this.pluginsPane);
getItems().add(this.pluginsPane);
}
}
public PluginsPane getPluginsPane()
public PluginsPane getPluginsPane()
{
{
return pluginsPane;
return pluginsPane;
}
}
private ClientAndProfileSelectorPane clientAndProfileSelectorPane;
private ClientAndProfileSelectorPane clientAndProfileSelectorPane;
private void setClientDetailsPane(ClientAndProfileSelectorPane clientAndProfileSelectorPane)
private void setClientDetailsPane(ClientAndProfileSelectorPane clientAndProfileSelectorPane)
{
{
this.clientAndProfileSelectorPane = clientAndProfileSelectorPane;
this.clientAndProfileSelectorPane = clientAndProfileSelectorPane;
leftPane.getChildren().add(this.clientAndProfileSelectorPane);
leftSplitPane.getItems().add(this.clientAndProfileSelectorPane);
}
}
public ClientAndProfileSelectorPane getClientDetailsPane()
public ClientAndProfileSelectorPane getClientDetailsPane()
{
{
return clientAndProfileSelectorPane;
return clientAndProfileSelectorPane;
}
}
private ActionGridPane actionGridPane;
private ActionGridPane actionGridPane;
private void setActionGridPane(ActionGridPane actionGridPane)
private void setActionGridPane(ActionGridPane actionGridPane)
{
{
this.actionGridPane = actionGridPane;
this.actionGridPane = actionGridPane;
leftPane.getChildren().add(this.actionGridPane);
leftSplitPane.getItems().add(this.actionGridPane);
}
}
public ActionGridPane getActionGridPane()
public ActionGridPane getActionGridPane()
{
{
return actionGridPane;
return actionGridPane;
}
}
private ActionDetailsPane actionDetailsPane;
private ActionDetailsPane actionDetailsPane;
private void setActionDetailsPane(ActionDetailsPane actionDetailsPane)
private void setActionDetailsPane(ActionDetailsPane actionDetailsPane)
{
{
this.actionDetailsPane = actionDetailsPane;
this.actionDetailsPane = actionDetailsPane;
leftPane.getChildren().add(this.actionDetailsPane);
leftSplitPane.getItems().add(this.actionDetailsPane);
}
}
public ActionDetailsPane getActionDetailsPane()
public ActionDetailsPane getActionDetailsPane()
{
{
return actionDetailsPane;
return actionDetailsPane;
}
}
public void newSelectedClientConnection(ClientConnection clientConnection)
public void newSelectedClientConnection(ClientConnection clientConnection)
{
{
if(clientConnection == null)
if(clientConnection == null)
{
{
logger.info("Remove action grid");
logger.info("Remove action grid");
}
}
else
else
{
{
getActionDetailsPane().setClient(clientConnection.getClient());
getActionDetailsPane().setClient(clientConnection.getClient());
getActionGridPane().setClient(clientConnection.getClient());
getActionGridPane().setClient(clientConnection.getClient());
}
}
}
}
public void newSelectedClientProfile(ClientProfile clientProfile)
public void newSelectedClientProfile(ClientProfile clientProfile)
{
{
this.currentClientProfile = clientProfile;
this.currentClientProfile = clientProfile;
getActionDetailsPane().setClientProfile(clientProfile);
getActionDetailsPane().setClientProfile(clientProfile);
drawProfile(this.currentClientProfile);
drawProfile(this.currentClientProfile);
}
}
public void drawProfile(ClientProfile clientProfile)
public void drawProfile(ClientProfile clientProfile)
{
{
logger.info("Drawing ...");
logger.info("Drawing ...");
getActionGridPane().setClientProfile(clientProfile);
getActionGridPane().setClientProfile(clientProfile);
try {
try {
getActionGridPane().renderGrid();
getActionGridPane().renderGrid();
getActionGridPane().renderActions();
getActionGridPane().renderActions();
}
}
catch (SevereException e)
catch (SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
}
}
}
}
package com.stream_pi.server.window.dashboard;
package com.stream_pi.server.window.dashboard;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.action_api.otheractions.CombineAction;
import com.stream_pi.action_api.otheractions.CombineAction;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.server.action.NormalActionPlugins;
import com.stream_pi.server.action.NormalActionPlugins;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.scene.image.ImageView;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.*;
import javafx.scene.layout.*;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
public class PluginsPane extends VBox {
public class PluginsPane extends VBox {
private Button settingsButton;
private Button settingsButton;
public PluginsPane(HostServices hostServices)
public PluginsPane(HostServices hostServices)
{
{
setMinWidth(250);
setMinWidth(250);
setMaxWidth(350);
getStyleClass().add("plugins_pane");
getStyleClass().add("plugins_pane");
setPadding(new Insets(10));
setPadding(new Insets(10));
this.hostServices = hostServices;
this.hostServices = hostServices;
initUI();
initUI();
}
}
private Accordion pluginsAccordion;
private Accordion pluginsAccordion;
public void initUI()
public void initUI()
{
{
pluginsAccordion = new Accordion();
pluginsAccordion = new Accordion();
pluginsAccordion.getStyleClass().add("plugins_pane_accordion");
pluginsAccordion.getStyleClass().add("plugins_pane_accordion");
pluginsAccordion.setCache(true);
pluginsAccordion.setCache(true);
settingsButton = new Button();
settingsButton = new Button();
settingsButton.getStyleClass().add("plugins_pane_settings_button");
settingsButton.getStyleClass().add("plugins_pane_settings_button");
FontIcon cog = new FontIcon("fas-cog");
FontIcon cog = new FontIcon("fas-cog");
settingsButton.setGraphic(cog);
settingsButton.setGraphic(cog);
HBox settingsHBox = new HBox(settingsButton);
HBox settingsHBox = new HBox(settingsButton);
settingsHBox.getStyleClass().add("plugins_pane_settings_button_parent");
settingsHBox.getStyleClass().add("plugins_pane_settings_button_parent");
settingsHBox.setAlignment(Pos.CENTER_RIGHT);
settingsHBox.setAlignment(Pos.CENTER_RIGHT);
Label pluginsLabel = new Label("Plugins");
Label pluginsLabel = new Label("Plugins");
pluginsLabel.getStyleClass().add("plugins_pane_top_label");
pluginsLabel.getStyleClass().add("plugins_pane_top_label");
getChildren().addAll(pluginsLabel, pluginsAccordion, SpaceFiller.vertical(), settingsHBox);
getChildren().addAll(pluginsLabel, pluginsAccordion, SpaceFiller.vertical(), settingsHBox);
}
}
public Button getSettingsButton()
public Button getSettingsButton()
{
{
return settingsButton;
return settingsButton;
}
}
public void clearData()
public void clearData()
{
{
pluginsAccordion.getPanes().clear();
pluginsAccordion.getPanes().clear();
}
}
public void loadData()
public void loadData()
{
{
HashMap<String, ArrayList<NormalAction>> sortedPlugins = NormalActionPlugins.getInstance().getSortedPlugins();
HashMap<String, ArrayList<NormalAction>> sortedPlugins = NormalActionPlugins.getInstance().getSortedPlugins();
for(String eachCategory : sortedPlugins.keySet())
for(String eachCategory : sortedPlugins.keySet())
{
{
VBox vBox = new VBox();
VBox vBox = new VBox();
vBox.getStyleClass().add("plugins_pane_each_plugin_box_parent");
vBox.getStyleClass().add("plugins_pane_each_plugin_box_parent");
TitledPane pane = new TitledPane(eachCategory, vBox);
TitledPane pane = new TitledPane(eachCategory, vBox);
pane.getStyleClass().add("plugins_pane_each_plugin_category_titled_pane");
pane.getStyleClass().add("plugins_pane_each_plugin_category_titled_pane");
for(NormalAction eachAction : sortedPlugins.get(eachCategory))
for(NormalAction eachAction : sortedPlugins.get(eachCategory))
{
{
if(!eachAction.isVisibleInPluginsPane())
if(!eachAction.isVisibleInPluginsPane())
continue;
continue;
Button eachNormalActionPluginButton = new Button();
Button eachNormalActionPluginButton = new Button();
eachNormalActionPluginButton.getStyleClass().add("plugins_pane_each_plugin_button");
eachNormalActionPluginButton.getStyleClass().add("plugins_pane_each_plugin_button");
HBox.setHgrow(eachNormalActionPluginButton, Priority.ALWAYS);
HBox.setHgrow(eachNormalActionPluginButton, Priority.ALWAYS);
eachNormalActionPluginButton.setMaxWidth(Double.MAX_VALUE);
eachNormalActionPluginButton.setMaxWidth(Double.MAX_VALUE);
eachNormalActionPluginButton.setAlignment(Pos.CENTER_LEFT);
eachNormalActionPluginButton.setAlignment(Pos.CENTER_LEFT);
Node graphic = eachAction.getServerButtonGraphic();
Node graphic = eachAction.getServerButtonGraphic();
if(graphic == null)
if(graphic == null)
{
{
FontIcon cogs = new FontIcon("fas-cogs");
FontIcon cogs = new FontIcon("fas-cogs");
cogs.getStyleClass().add("plugins_pane_each_plugin_button_icon");
cogs.getStyleClass().add("plugins_pane_each_plugin_button_icon");
eachNormalActionPluginButton.setGraphic(cogs);
eachNormalActionPluginButton.setGraphic(cogs);
}
}
else
else
{
{
if(graphic instanceof FontIcon)
if(graphic instanceof FontIcon)
{
{
FontIcon fi = (FontIcon) graphic;
FontIcon fi = (FontIcon) graphic;
fi.getStyleClass().add("plugins_pane_each_plugin_button_icon");
fi.getStyleClass().add("plugins_pane_each_plugin_button_icon");
eachNormalActionPluginButton.setGraphic(fi);
eachNormalActionPluginButton.setGraphic(fi);
}
}
else if(graphic instanceof ImageView)
else if(graphic instanceof ImageView)
{
{
ImageView iv = (ImageView) graphic;
ImageView iv = (ImageView) graphic;
iv.getStyleClass().add("plugins_pane_each_plugin_button_imageview");
iv.getStyleClass().add("plugins_pane_each_plugin_button_imageview");
iv.setPreserveRatio(false);
iv.setPreserveRatio(false);
eachNormalActionPluginButton.setGraphic(iv);
eachNormalActionPluginButton.setGraphic(iv);
}
}
}
}
eachNormalActionPluginButton.setText(eachAction.getName());
eachNormalActionPluginButton.setText(eachAction.getName());
eachNormalActionPluginButton.setOnDragDetected(mouseEvent -> {
eachNormalActionPluginButton.setOnDragDetected(mouseEvent -> {
Dragboard db = eachNormalActionPluginButton.startDragAndDrop(TransferMode.ANY);
Dragboard db = eachNormalActionPluginButton.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
ClipboardContent content = new ClipboardContent();
content.put(Action.getDataFormat(), createFakeAction(eachAction, "Untitled action"));
content.put(Action.getDataFormat(), createFakeAction(eachAction, "Untitled action"));
db.setContent(content);
db.setContent(content);
mouseEvent.consume();
mouseEvent.consume();
});
});
HBox hBox = new HBox(eachNormalActionPluginButton);
HBox hBox = new HBox(eachNormalActionPluginButton);
hBox.getStyleClass().add("plugins_pane_each_plugin_box");
hBox.getStyleClass().add("plugins_pane_each_plugin_box");
hBox.setAlignment(Pos.TOP_LEFT);
hBox.setAlignment(Pos.TOP_LEFT);
HBox.setHgrow(eachNormalActionPluginButton, Priority.ALWAYS);
HBox.setHgrow(eachNormalActionPluginButton, Priority.ALWAYS);
if(eachAction.getHelpLink() != null) {
if(eachAction.getHelpLink() != null) {
Button helpButton = new Button();
Button helpButton = new Button();
helpButton.getStyleClass().add("plugins_pane_each_plugin_button_help_icon");
helpButton.getStyleClass().add("plugins_pane_each_plugin_button_help_icon");
FontIcon questionIcon = new FontIcon("fas-question");
FontIcon questionIcon = new FontIcon("fas-question");
questionIcon.getStyleClass().add("plugins_pane_each_plugin_button_help_button_icon");
questionIcon.getStyleClass().add("plugins_pane_each_plugin_button_help_button_icon");
helpButton.setGraphic(questionIcon);
helpButton.setGraphic(questionIcon);
helpButton.setOnAction(event -> hostServices.showDocument(eachAction.getHelpLink()));
helpButton.setOnAction(event -> hostServices.showDocument(eachAction.getHelpLink()));
hBox.getChildren().add(helpButton);
hBox.getChildren().add(helpButton);
}
}
vBox.getChildren().add(hBox);
vBox.getChildren().add(hBox);
}
}
if(vBox.getChildren().size() > 0)
if(vBox.getChildren().size() > 0)
pluginsAccordion.getPanes().add(pane);
pluginsAccordion.getPanes().add(pane);
}
}
}
}
private HostServices hostServices;
private HostServices hostServices;
public Action createFakeAction(Action action, String displayText)
public Action createFakeAction(Action action, String displayText)
{
{
Action newAction = new Action(action.getActionType());
Action newAction = new Action(action.getActionType());
if(action.getActionType() == ActionType.NORMAL)
if(action.getActionType() == ActionType.NORMAL)
{
{
newAction.setModuleName(action.getModuleName());
newAction.setModuleName(action.getModuleName());
newAction.setVersion(action.getVersion());
newAction.setVersion(action.getVersion());
newAction.setName(action.getName());
newAction.setName(action.getName());
}
}
newAction.setClientProperties(action.getClientProperties());
newAction.setClientProperties(action.getClientProperties());
for(Property property : newAction.getClientProperties().get())
for(Property property : newAction.getClientProperties().get())
{
{
if(property.getType() == Type.STRING || property.getType() == Type.INTEGER || property.getType() == Type.DOUBLE)
if(property.getType() == Type.STRING || property.getType() == Type.INTEGER || property.getType() == Type.DOUBLE)
property.setRawValue(property.getDefaultRawValue());
property.setRawValue(property.getDefaultRawValue());
}
}
// newAction.setLocation(location);
// newAction.setLocation(location);
newAction.setIDRandom();
newAction.setIDRandom();
newAction.setShowDisplayText(true);
newAction.setShowDisplayText(true);
newAction.setDisplayText(displayText);
newAction.setDisplayText(displayText);
newAction.setDisplayTextAlignment(DisplayTextAlignment.CENTER);
newAction.setDisplayTextAlignment(DisplayTextAlignment.CENTER);
newAction.setShowIcon(false);
newAction.setShowIcon(false);
newAction.setHasIcon(false);
newAction.setHasIcon(false);
//action.setParent(root);
//action.setParent(root);
newAction.setBgColourHex("");
newAction.setBgColourHex("");
newAction.setDisplayTextFontColourHex("");
newAction.setDisplayTextFontColourHex("");
return newAction;
return newAction;
}
}
public void loadOtherActions()
public void loadOtherActions()
{
{
VBox vBox = new VBox();
VBox vBox = new VBox();
vBox.getStyleClass().add("plugins_pane_each_plugin_box_parent");
vBox.getStyleClass().add("plugins_pane_each_plugin_box_parent");
Button folderActionButton = new Button("Folder");
Button folderActionButton = new Button("Folder");
folderActionButton.getStyleClass().add("plugins_pane_each_plugin_button");
folderActionButton.getStyleClass().add("plugins_pane_each_plugin_button");
folderActionButton.setMaxWidth(Double.MAX_VALUE);
folderActionButton.setMaxWidth(Double.MAX_VALUE);
folderActionButton.setAlignment(Pos.CENTER_LEFT);
folderActionButton.setAlignment(Pos.CENTER_LEFT);
FontIcon folder = new FontIcon("fas-folder");
FontIcon folder = new FontIcon("fas-folder");
folderActionButton.setGraphic(folder);
folderActionButton.setGraphic(folder);
folderActionButton.setOnDragDetected(mouseEvent -> {
folderActionButton.setOnDragDetected(mouseEvent -> {
Dragboard db = folderActionButton.startDragAndDrop(TransferMode.ANY);
Dragboard db = folderActionButton.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
ClipboardContent content = new ClipboardContent();
content.put(Action.getDataFormat(), createFakeAction(new FolderAction(), "Untitled Folder"));
content.put(Action.getDataFormat(), createFakeAction(new FolderAction(), "Untitled Folder"));
db.setContent(content);
db.setContent(content);
mouseEvent.consume();
mouseEvent.consume();
});
});
Button combineActionButton = new Button("Combine");
Button combineActionButton = new Button("Combine");
combineActionButton.getStyleClass().add("plugins_pane_each_plugin_button");
combineActionButton.getStyleClass().add("plugins_pane_each_plugin_button");
combineActionButton.setMaxWidth(Double.MAX_VALUE);
combineActionButton.setMaxWidth(Double.MAX_VALUE);
combineActionButton.setAlignment(Pos.CENTER_LEFT);
combineActionButton.setAlignment(Pos.CENTER_LEFT);
FontIcon list = new FontIcon("fas-list");
FontIcon list = new FontIcon("fas-list");
combineActionButton.setGraphic(list);
combineActionButton.setGraphic(list);
combineActionButton.setOnDragDetected(mouseEvent -> {
combineActionButton.setOnDragDetected(mouseEvent -> {
Dragboard db = combineActionButton.startDragAndDrop(TransferMode.ANY);
Dragboard db = combineActionButton.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
ClipboardContent content = new ClipboardContent();
content.put(Action.getDataFormat(), createFakeAction(new CombineAction(), "Untitled Combine"));
content.put(Action.getDataFormat(), createFakeAction(new CombineAction(), "Untitled Combine"));
db.setContent(content);
db.setContent(content);
mouseEvent.consume();
mouseEvent.consume();
});
});
HBox.setHgrow(folderActionButton, Priority.ALWAYS);
HBox.setHgrow(folderActionButton, Priority.ALWAYS);
HBox h1 = new HBox(folderActionButton);
HBox h1 = new HBox(folderActionButton);
h1.getStyleClass().add("plugins_pane_each_plugin_box");
h1.getStyleClass().add("plugins_pane_each_plugin_box");
HBox.setHgrow(combineActionButton, Priority.ALWAYS);
HBox.setHgrow(combineActionButton, Priority.ALWAYS);
HBox h2 = new HBox(combineActionButton);
HBox h2 = new HBox(combineActionButton);
h2.getStyleClass().add("plugins_pane_each_plugin_box");
h2.getStyleClass().add("plugins_pane_each_plugin_box");
vBox.getChildren().addAll(h1, h2);
vBox.getChildren().addAll(h1, h2);
TitledPane pane = new TitledPane("StreamPi", vBox);
TitledPane pane = new TitledPane("StreamPi", vBox);
pane.getStyleClass().add("plugins_pane_each_plugin_category_titled_pane");
pane.getStyleClass().add("plugins_pane_each_plugin_category_titled_pane");
pluginsAccordion.getPanes().add(pane);
pluginsAccordion.getPanes().add(pane);
pluginsAccordion.setCache(true);
pluginsAccordion.setCache(true);
pluginsAccordion.setCacheHint(CacheHint.SPEED);
pluginsAccordion.setCacheHint(CacheHint.SPEED);
}
}
}
}
package com.stream_pi.server.window.dashboard.actiondetailpane;
package com.stream_pi.server.window.dashboard.actiondetailpane;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.DisplayTextAlignment;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.otheractions.CombineAction;
import com.stream_pi.action_api.otheractions.CombineAction;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.server.uipropertybox.UIPropertyBox;
import com.stream_pi.server.uipropertybox.UIPropertyBox;
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.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.server.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
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.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBoxWithFileChooser;
import com.stream_pi.util.uihelper.HBoxInputBoxWithFileChooser;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.collections.FXCollections;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.input.TransferMode;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.paint.Paint;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser;
import javafx.stage.Window;
import javafx.stage.Window;
import javafx.util.Callback;
import javafx.util.Callback;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.io.File;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class ActionDetailsPane extends VBox implements ActionDetailsPaneListener {
public class ActionDetailsPane extends VBox implements ActionDetailsPaneListener {
private ScrollPane scrollPane;
private ScrollPane scrollPane;
private VBox vbox;
private VBox vbox;
private VBox clientPropertiesVBox;
private VBox clientPropertiesVBox;
private Button saveButton;
private Button saveButton;
private Button deleteButton;
private Button deleteButton;
private Button openFolderButton;
private Button openFolderButton;
private HBox buttonBar;
private HBox buttonBar;
private Label actionHeadingLabel;
private Label actionHeadingLabel;
private Logger logger;
private Logger logger;
private Button returnButtonForCombineActionChild;
private Button returnButtonForCombineActionChild;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private HostServices hostServices;
private HostServices hostServices;
public ActionDetailsPane(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices) {
public ActionDetailsPane(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices) {
this.hostServices = hostServices;
this.hostServices = hostServices;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
logger = Logger.getLogger(ActionDetailsPane.class.getName());
logger = Logger.getLogger(ActionDetailsPane.class.getName());
setSpacing(10.0);
setSpacing(10.0);
clientPropertiesVBox = new VBox();
clientPropertiesVBox = new VBox();
clientPropertiesVBox.setSpacing(10.0);
clientPropertiesVBox.setSpacing(10.0);
vbox = new VBox();
vbox = new VBox();
vbox.setPadding(new Insets(0, 25, 0, 5));
vbox.setPadding(new Insets(0, 25, 0, 5));
vbox.getStyleClass().add("action_details_pane_vbox");
vbox.getStyleClass().add("action_details_pane_vbox");
vbox.setSpacing(10.0);
vbox.setSpacing(10.0);
getStyleClass().add("action_details_pane");
getStyleClass().add("action_details_pane");
scrollPane = new ScrollPane();
scrollPane = new ScrollPane();
VBox.setMargin(scrollPane, new Insets(0, 0, 0, 10));
VBox.setMargin(scrollPane, new Insets(0, 0, 0, 10));
scrollPane.getStyleClass().add("action_details_pane_scroll_pane");
scrollPane.getStyleClass().add("action_details_pane_scroll_pane");
setMinHeight(310);
setMinHeight(210);
scrollPane.setContent(vbox);
scrollPane.setContent(vbox);
vbox.prefWidthProperty().bind(scrollPane.widthProperty());
vbox.prefWidthProperty().bind(scrollPane.widthProperty());
scrollPane.prefWidthProperty().bind(widthProperty());
scrollPane.prefWidthProperty().bind(widthProperty());
VBox.setVgrow(scrollPane, Priority.ALWAYS);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
openFolderButton = new Button("Open Folder");
openFolderButton = new Button("Open Folder");
FontIcon folderOpenIcon = new FontIcon("far-folder-open");
FontIcon folderOpenIcon = new FontIcon("far-folder-open");
openFolderButton.setGraphic(folderOpenIcon);
openFolderButton.setGraphic(folderOpenIcon);
openFolderButton.setOnAction(event -> onOpenFolderButtonClicked());
openFolderButton.setOnAction(event -> onOpenFolderButtonClicked());
saveButton = new Button("Apply Changes");
saveButton = new Button("Apply Changes");
FontIcon syncIcon = new FontIcon("fas-sync-alt");
FontIcon syncIcon = new FontIcon("fas-sync-alt");
saveButton.setGraphic(syncIcon);
saveButton.setGraphic(syncIcon);
saveButton.setOnAction(event -> onSaveButtonClicked());
saveButton.setOnAction(event -> onSaveButtonClicked());
deleteButton = new Button("Delete action");
deleteButton = new Button("Delete action");
deleteButton.getStyleClass().add("action_details_pane_delete_button");
deleteButton.getStyleClass().add("action_details_pane_delete_button");
FontIcon deleteIcon = new FontIcon("fas-trash");
FontIcon deleteIcon = new FontIcon("fas-trash");
deleteIcon.getStyleClass().add("action_details_pane_delete_button_icon");
deleteIcon.getStyleClass().add("action_details_pane_delete_button_icon");
deleteButton.setGraphic(deleteIcon);
deleteButton.setGraphic(deleteIcon);
deleteButton.setOnAction(event -> onDeleteButtonClicked());
deleteButton.setOnAction(event -> onDeleteButtonClicked());
returnButtonForCombineActionChild = new Button("Return");
returnButtonForCombineActionChild = new Button("Return");
returnButtonForCombineActionChild.setGraphic(new FontIcon("fas-caret-left"));
returnButtonForCombineActionChild.setGraphic(new FontIcon("fas-caret-left"));
returnButtonForCombineActionChild.managedProperty().bind(returnButtonForCombineActionChild.visibleProperty());
returnButtonForCombineActionChild.managedProperty().bind(returnButtonForCombineActionChild.visibleProperty());
returnButtonForCombineActionChild.setOnAction(event -> {
returnButtonForCombineActionChild.setOnAction(event -> {
try {
try {
logger.info("@@## : " + action.getParent());
logger.info("@@## : " + action.getParent());
onActionClicked(getClientProfile().getActionByID(action.getParent()), getActionBox());
onActionClicked(getClientProfile().getActionByID(action.getParent()), getActionBox());
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
}
}
});
});
buttonBar = new HBox(openFolderButton, returnButtonForCombineActionChild, saveButton, deleteButton);
buttonBar = new HBox(openFolderButton, returnButtonForCombineActionChild, saveButton, deleteButton);
buttonBar.getStyleClass().add("action_details_pane_button_bar");
buttonBar.getStyleClass().add("action_details_pane_button_bar");
buttonBar.setPadding(new Insets(10, 10, 10, 0));
buttonBar.setPadding(new Insets(10, 10, 10, 0));
buttonBar.setAlignment(Pos.CENTER_RIGHT);
buttonBar.setAlignment(Pos.CENTER_RIGHT);
buttonBar.setVisible(false);
buttonBar.setVisible(false);
buttonBar.setSpacing(10.0);
buttonBar.setSpacing(10.0);
actionHeadingLabel = new Label();
actionHeadingLabel = new Label();
actionHeadingLabel.getStyleClass().add("action_details_pane_heading_label");
actionHeadingLabel.getStyleClass().add("action_details_pane_heading_label");
HBox headingHBox = new HBox(actionHeadingLabel);
HBox headingHBox = new HBox(actionHeadingLabel);
headingHBox.getStyleClass().add("action_details_pane_heading_box");
headingHBox.getStyleClass().add("action_details_pane_heading_box");
headingHBox.setPadding(new Insets(5, 10, 0, 10));
headingHBox.setPadding(new Insets(5, 10, 0, 10));
getChildren().addAll(headingHBox, scrollPane, buttonBar);
getChildren().addAll(headingHBox, scrollPane, buttonBar);
displayTextAlignmentComboBox = new ComboBox<>(FXCollections.observableArrayList(DisplayTextAlignment.TOP,
displayTextAlignmentComboBox = new ComboBox<>(FXCollections.observableArrayList(DisplayTextAlignment.TOP,
DisplayTextAlignment.CENTER, DisplayTextAlignment.BOTTOM));
DisplayTextAlignment.CENTER, DisplayTextAlignment.BOTTOM));
displayTextAlignmentComboBox.managedProperty().bind(displayTextAlignmentComboBox.visibleProperty());
displayTextAlignmentComboBox.managedProperty().bind(displayTextAlignmentComboBox.visibleProperty());
Callback<ListView<DisplayTextAlignment>, ListCell<DisplayTextAlignment>> displayTextAlignmentComboBoxFactory = new Callback<>() {
Callback<ListView<DisplayTextAlignment>, ListCell<DisplayTextAlignment>> displayTextAlignmentComboBoxFactory = new Callback<>() {
@Override
@Override
public ListCell<DisplayTextAlignment> call(ListView<DisplayTextAlignment> displayTextAlignment) {
public ListCell<DisplayTextAlignment> call(ListView<DisplayTextAlignment> displayTextAlignment) {
return new ListCell<>() {
return new ListCell<>() {
@Override
@Override
protected void updateItem(DisplayTextAlignment displayTextAlignment, boolean b) {
protected void updateItem(DisplayTextAlignment displayTextAlignment, boolean b) {
super.updateItem(displayTextAlignment, b);
super.updateItem(displayTextAlignment, b);
if (displayTextAlignment != null) {
if (displayTextAlignment != null) {
setText(displayTextAlignment.getUIName());
setText(displayTextAlignment.getUIName());
}
}
}
}
};
};
}
}
};
};
displayTextAlignmentComboBox.setCellFactory(displayTextAlignmentComboBoxFactory);
displayTextAlignmentComboBox.setCellFactory(displayTextAlignmentComboBoxFactory);
displayTextAlignmentComboBox.setButtonCell(displayTextAlignmentComboBoxFactory.call(null));
displayTextAlignmentComboBox.setButtonCell(displayTextAlignmentComboBoxFactory.call(null));
actionClientProperties = new ArrayList<>();
actionClientProperties = new ArrayList<>();
displayNameTextField = new TextField();
displayNameTextField = new TextField();
displayNameTextField.managedProperty().bind(displayNameTextField.visibleProperty());
displayNameTextField.managedProperty().bind(displayNameTextField.visibleProperty());
iconFileTextField = new TextField();
iconFileTextField = new TextField();
iconFileTextField.managedProperty().bind(iconFileTextField.visibleProperty());
iconFileTextField.managedProperty().bind(iconFileTextField.visibleProperty());
iconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
iconFileTextField.textProperty().addListener((observableValue, s, t1) -> {
try {
try {
if (!s.equals(t1) && t1.length() > 0) {
if (!s.equals(t1) && t1.length() > 0) {
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
byte[] iconFileByteArray = Files.readAllBytes(new File(t1).toPath());
hideIconCheckBox.setDisable(false);
hideIconCheckBox.setDisable(false);
hideIconCheckBox.setSelected(false);
hideIconCheckBox.setSelected(false);
clearIconButton.setDisable(false);
clearIconButton.setDisable(false);
System.out.println("ABABABABABBABABBABABABCCCCCCCCCCCCCCCCCC");
System.out.println("ABABABABABBABABBABABABCCCCCCCCCCCCCCCCCC");
action.setIcon(iconFileByteArray);
action.setIcon(iconFileByteArray);
setSendIcon(true);
setSendIcon(true);
System.out.println(action.getIconAsByteArray().length);
System.out.println(action.getIconAsByteArray().length);
}
}
} catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage()));
}
}
});
});
clearIconButton = new Button("Clear Icon");
clearIconButton = new Button("Clear Icon");
clearIconButton.managedProperty().bind(clearIconButton.visibleProperty());
clearIconButton.managedProperty().bind(clearIconButton.visibleProperty());
clearIconButton.setOnAction(event -> {
clearIconButton.setOnAction(event -> {
hideIconCheckBox.setDisable(true);
hideIconCheckBox.setDisable(true);
hideIconCheckBox.setSelected(false);
hideIconCheckBox.setSelected(false);
clearIconButton.setDisable(true);
clearIconButton.setDisable(true);
setSendIcon(false);
setSendIcon(false);
iconFileTextField.clear();
iconFileTextField.clear();
});
});
hideDisplayTextCheckBox = new CheckBox("Hide");
hideDisplayTextCheckBox = new CheckBox("Hide");
hideDisplayTextCheckBox.managedProperty().bind(hideDisplayTextCheckBox.visibleProperty());
hideDisplayTextCheckBox.managedProperty().bind(hideDisplayTextCheckBox.visibleProperty());
hideIconCheckBox = new CheckBox("Hide");
hideIconCheckBox = new CheckBox("Hide");
hideIconCheckBox.managedProperty().bind(hideIconCheckBox.visibleProperty());
hideIconCheckBox.managedProperty().bind(hideIconCheckBox.visibleProperty());
actionBackgroundColourPicker = new ColorPicker();
actionBackgroundColourPicker = new ColorPicker();
actionBackgroundColourPicker.managedProperty().bind(actionBackgroundColourPicker.visibleProperty());
actionBackgroundColourPicker.managedProperty().bind(actionBackgroundColourPicker.visibleProperty());
displayTextColourPicker = new ColorPicker();
displayTextColourPicker = new ColorPicker();
displayTextColourPicker.managedProperty().bind(displayTextColourPicker.visibleProperty());
displayTextColourPicker.managedProperty().bind(displayTextColourPicker.visibleProperty());
actionBackgroundColourTransparentCheckBox = new CheckBox("Default");
actionBackgroundColourTransparentCheckBox = new CheckBox("Default");
actionBackgroundColourPicker.disableProperty()
actionBackgroundColourPicker.disableProperty()
.bind(actionBackgroundColourTransparentCheckBox.selectedProperty());
.bind(actionBackgroundColourTransparentCheckBox.selectedProperty());
HBox.setMargin(actionBackgroundColourTransparentCheckBox, new Insets(0, 0, 0, 10));
HBox.setMargin(actionBackgroundColourTransparentCheckBox, new Insets(0, 0, 0, 10));
displayTextColourDefaultCheckBox = new CheckBox("Default");
displayTextColourDefaultCheckBox = new CheckBox("Default");
displayTextColourPicker.disableProperty()
displayTextColourPicker.disableProperty()
.bind(displayTextColourDefaultCheckBox.selectedProperty());
.bind(displayTextColourDefaultCheckBox.selectedProperty());
HBox.setMargin(displayTextColourDefaultCheckBox, new Insets(0, 0, 0, 10));
HBox.setMargin(displayTextColourDefaultCheckBox, new Insets(0, 0, 0, 10));
Region r = new Region();
Region r = new Region();
HBox.setHgrow(r, Priority.ALWAYS);
HBox.setHgrow(r, Priority.ALWAYS);
Region r1 = new Region();
Region r1 = new Region();
HBox.setHgrow(r1, Priority.ALWAYS);
HBox.setHgrow(r1, Priority.ALWAYS);
HBox displayTextColourHBox = new HBox(new Label("Display Text Colour"), r1, displayTextColourPicker,
HBox displayTextColourHBox = new HBox(new Label("Display Text Colour"), r1, displayTextColourPicker,
displayTextColourDefaultCheckBox);
displayTextColourDefaultCheckBox);
displayTextColourHBox.setAlignment(Pos.CENTER);
displayTextColourHBox.setAlignment(Pos.CENTER);
displayTextColourHBox.setSpacing(5.0);
displayTextColourHBox.setSpacing(5.0);
HBox bgColourHBox = new HBox(new Label("Background Colour"), r, actionBackgroundColourPicker,
HBox bgColourHBox = new HBox(new Label("Background Colour"), r, actionBackgroundColourPicker,
actionBackgroundColourTransparentCheckBox);
actionBackgroundColourTransparentCheckBox);
bgColourHBox.setAlignment(Pos.CENTER);
bgColourHBox.setAlignment(Pos.CENTER);
bgColourHBox.setSpacing(5.0);
bgColourHBox.setSpacing(5.0);
HBox clearIconHBox = new HBox(clearIconButton);
HBox clearIconHBox = new HBox(clearIconButton);
clearIconHBox.setAlignment(Pos.CENTER_RIGHT);
clearIconHBox.setAlignment(Pos.CENTER_RIGHT);
displayTextFieldHBox = new HBoxInputBox("Display Name", displayNameTextField, hideDisplayTextCheckBox);
displayTextFieldHBox = new HBoxInputBox("Display Name", displayNameTextField, hideDisplayTextCheckBox);
normalActionsPropsVBox = new VBox(displayTextColourHBox,
normalActionsPropsVBox = new VBox(displayTextColourHBox,
new HBox(new Label("Alignment"), SpaceFiller.horizontal(),
new HBox(new Label("Alignment"), SpaceFiller.horizontal(),
displayTextAlignmentComboBox),
displayTextAlignmentComboBox),
new HBoxInputBoxWithFileChooser("Icon", iconFileTextField, hideIconCheckBox,
new HBoxInputBoxWithFileChooser("Icon", iconFileTextField, hideIconCheckBox,
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif")),
new FileChooser.ExtensionFilter("Images", "*.jpeg", "*.jpg", "*.png", "*.gif")),
clearIconHBox, bgColourHBox);
clearIconHBox, bgColourHBox);
normalActionsPropsVBox.managedProperty().bind(normalActionsPropsVBox.visibleProperty());
normalActionsPropsVBox.managedProperty().bind(normalActionsPropsVBox.visibleProperty());
normalActionsPropsVBox.setSpacing(10.0);
normalActionsPropsVBox.setSpacing(10.0);
vbox.getChildren().addAll(displayTextFieldHBox, normalActionsPropsVBox, clientPropertiesVBox);
vbox.getChildren().addAll(displayTextFieldHBox, normalActionsPropsVBox, clientPropertiesVBox);
vbox.setVisible(false);
vbox.setVisible(false);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
setOnDragOver(dragEvent -> {
setOnDragOver(dragEvent -> {
if (dragEvent.getDragboard().hasContent(Action.getDataFormat()) && action != null) {
if (dragEvent.getDragboard().hasContent(Action.getDataFormat()) && action != null) {
if (action.getActionType() == ActionType.COMBINE) {
if (action.getActionType() == ActionType.COMBINE) {
dragEvent.acceptTransferModes(TransferMode.ANY);
dragEvent.acceptTransferModes(TransferMode.ANY);
dragEvent.consume();
dragEvent.consume();
}
}
}
}
});
});
setOnDragDropped(dragEvent -> {
setOnDragDropped(dragEvent -> {
try {
try {
Action newAction = (Action) dragEvent.getDragboard().getContent(Action.getDataFormat());
Action newAction = (Action) dragEvent.getDragboard().getContent(Action.getDataFormat());
if (newAction.getActionType() == ActionType.NORMAL) {
if (newAction.getActionType() == ActionType.NORMAL) {
newAction.setLocation(new Location(-1, -1));
newAction.setLocation(new Location(-1, -1));
newAction.setParent(this.action.getID());
newAction.setParent(this.action.getID());
combineActionPropertiesPane.getCombineAction().addChild(newAction.getID());
combineActionPropertiesPane.getCombineAction().addChild(newAction.getID());
addActionToCurrentClientProfile(newAction);
addActionToCurrentClientProfile(newAction);
ClientConnection connection = ClientConnections.getInstance()
ClientConnection connection = ClientConnections.getInstance()
.getClientConnectionBySocketAddress(getClient().getRemoteSocketAddress());
.getClientConnectionBySocketAddress(getClient().getRemoteSocketAddress());
connection.saveActionDetails(getClientProfile().getID(), newAction);
connection.saveActionDetails(getClientProfile().getID(), newAction);
combineActionPropertiesPane.renderProps();
combineActionPropertiesPane.renderProps();
saveAction();
saveAction();
}
}
} catch (MinorException e) {
} catch (MinorException e) {
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
e.printStackTrace();
e.printStackTrace();
} catch (SevereException e) {
} catch (SevereException e) {
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
e.printStackTrace();
e.printStackTrace();
} catch (CloneNotSupportedException e) {
} catch (CloneNotSupportedException e) {
e.printStackTrace();
e.printStackTrace();
}
}
});
});
}
}
private VBox normalActionsPropsVBox;
private VBox normalActionsPropsVBox;
private HBox displayTextFieldHBox;
private HBox displayTextFieldHBox;
private Client client;
private Client client;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
public void setClient(Client client) {
public void setClient(Client client) {
this.client = client;
this.client = client;
}
}
public Client getClient() {
public Client getClient() {
return client;
return client;
}
}
public void setClientProfile(ClientProfile clientProfile) {
public void setClientProfile(ClientProfile clientProfile) {
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
}
}
public ClientProfile getClientProfile() {
public ClientProfile getClientProfile() {
return clientProfile;
return clientProfile;
}
}
public void setActionHeadingLabelText(String text) {
public void setActionHeadingLabelText(String text) {
actionHeadingLabel.setText(text);
actionHeadingLabel.setText(text);
}
}
private Action action;
private Action action;
public Action getAction() {
public Action getAction() {
return action;
return action;
}
}
private ActionBox actionBox;
private ActionBox actionBox;
public ActionBox getActionBox() {
public ActionBox getActionBox() {
return actionBox;
return actionBox;
}
}
@Override
@Override
public void onActionClicked(Action action, ActionBox actionBox) throws MinorException {
public void onActionClicked(Action action, ActionBox actionBox) throws MinorException {
this.action = action;
this.action = action;
this.actionBox = actionBox;
this.actionBox = actionBox;
logger.info("action Display text : "+action.getDisplayText());
logger.info("action Display text : "+action.getDisplayText());
clear();
clear();
renderActionProperties();
renderActionProperties();
}
}
private TextField displayNameTextField;
private TextField displayNameTextField;
private CheckBox hideDisplayTextCheckBox;
private CheckBox hideDisplayTextCheckBox;
private CheckBox hideIconCheckBox;
private CheckBox hideIconCheckBox;
private TextField iconFileTextField;
private TextField iconFileTextField;
private Button clearIconButton;
private Button clearIconButton;
private ColorPicker actionBackgroundColourPicker;
private ColorPicker actionBackgroundColourPicker;
private ColorPicker displayTextColourPicker;
private ColorPicker displayTextColourPicker;
private CheckBox actionBackgroundColourTransparentCheckBox;
private CheckBox actionBackgroundColourTransparentCheckBox;
private CheckBox displayTextColourDefaultCheckBox;
private CheckBox displayTextColourDefaultCheckBox;
private ComboBox<DisplayTextAlignment> displayTextAlignmentComboBox;
private ComboBox<DisplayTextAlignment> displayTextAlignmentComboBox;
public void clear()
public void clear()
{
{
sendIcon = false;
sendIcon = false;
actionClientProperties.clear();
actionClientProperties.clear();
displayNameTextField.clear();
displayNameTextField.clear();
iconFileTextField.clear();
iconFileTextField.clear();
clientPropertiesVBox.getChildren().clear();
clientPropertiesVBox.getChildren().clear();
vbox.setVisible(false);
vbox.setVisible(false);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
buttonBar.setVisible(false);
buttonBar.setVisible(false);
setActionHeadingLabelText("");
setActionHeadingLabelText("");
actionBackgroundColourPicker.setValue(Color.WHITE);
actionBackgroundColourPicker.setValue(Color.WHITE);
displayTextColourPicker.setValue(Color.WHITE);
displayTextColourPicker.setValue(Color.WHITE);
}
}
boolean isCombineChild = false;
boolean isCombineChild = false;
public boolean isCombineChild() {
public boolean isCombineChild() {
return isCombineChild;
return isCombineChild;
}
}
public void renderActionProperties() throws MinorException
public void renderActionProperties() throws MinorException
{
{
//Combine Child action
//Combine Child action
isCombineChild = action.getLocation().getCol() == -1;
isCombineChild = action.getLocation().getCol() == -1;
displayNameTextField.setText(action.getDisplayText());
displayNameTextField.setText(action.getDisplayText());
if(isCombineChild)
if(isCombineChild)
{
{
setReturnButtonForCombineActionChildVisible(true);
setReturnButtonForCombineActionChildVisible(true);
normalActionsPropsVBox.setVisible(false);
normalActionsPropsVBox.setVisible(false);
hideDisplayTextCheckBox.setSelected(false);
hideDisplayTextCheckBox.setSelected(false);
hideDisplayTextCheckBox.setVisible(false);
hideDisplayTextCheckBox.setVisible(false);
}
}
else
else
{
{
normalActionsPropsVBox.setVisible(true);
normalActionsPropsVBox.setVisible(true);
setReturnButtonForCombineActionChildVisible(false);
setReturnButtonForCombineActionChildVisible(false);
hideDisplayTextCheckBox.setVisible(true);
hideDisplayTextCheckBox.setVisible(true);
setFolderButtonVisible(action.getActionType().equals(ActionType.FOLDER));
setFolderButtonVisible(action.getActionType().equals(ActionType.FOLDER));
displayTextAlignmentComboBox.getSelectionModel().select(action.getDisplayTextAlignment());
displayTextAlignmentComboBox.getSelectionModel().select(action.getDisplayTextAlignment());
if(!action.getBgColourHex().isEmpty())
if(!action.getBgColourHex().isEmpty())
actionBackgroundColourPicker.setValue(Color.valueOf(action.getBgColourHex()));
actionBackgroundColourPicker.setValue(Color.valueOf(action.getBgColourHex()));
else
else
actionBackgroundColourTransparentCheckBox.setSelected(true);
actionBackgroundColourTransparentCheckBox.setSelected(true);
if(!action.getDisplayTextFontColourHex().isEmpty())
if(!action.getDisplayTextFontColourHex().isEmpty())
displayTextColourPicker.setValue(Color.valueOf(action.getDisplayTextFontColourHex()));
displayTextColourPicker.setValue(Color.valueOf(action.getDisplayTextFontColourHex()));
else
else
displayTextColourDefaultCheckBox.setSelected(true);
displayTextColourDefaultCheckBox.setSelected(true);
hideDisplayTextCheckBox.setSelected(!action.isShowDisplayText());
hideDisplayTextCheckBox.setSelected(!action.isShowDisplayText());
hideIconCheckBox.setDisable(!action.isHasIcon());
hideIconCheckBox.setDisable(!action.isHasIcon());
hideIconCheckBox.setSelected(!action.isShowIcon());
hideIconCheckBox.setSelected(!action.isShowIcon());
if(!action.isHasIcon())
if(!action.isHasIcon())
{
{
hideIconCheckBox.setSelected(false);
hideIconCheckBox.setSelected(false);
}
}
clearIconButton.setDisable(!action.isHasIcon());
clearIconButton.setDisable(!action.isHasIcon());
}
}
buttonBar.setVisible(true);
buttonBar.setVisible(true);
vbox.setVisible(true);
vbox.setVisible(true);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
if(action.getActionType() == ActionType.NORMAL)
if(action.getActionType() == ActionType.NORMAL)
{
{
if(action.isInvalid())
if(action.isInvalid())
setActionHeadingLabelText("Invalid action ("+action.getModuleName()+")");
setActionHeadingLabelText("Invalid action ("+action.getModuleName()+")");
else
else
setActionHeadingLabelText(action.getName());
setActionHeadingLabelText(action.getName());
}
}
else if(action.getActionType() == ActionType.COMBINE)
else if(action.getActionType() == ActionType.COMBINE)
setActionHeadingLabelText("Combine action");
setActionHeadingLabelText("Combine action");
else if(action.getActionType() == ActionType.FOLDER)
else if(action.getActionType() == ActionType.FOLDER)
setActionHeadingLabelText("Folder action");
setActionHeadingLabelText("Folder action");
if(!action.isInvalid())
if(!action.isInvalid())
{
{
if(action.getActionType() == ActionType.NORMAL)
if(action.getActionType() == ActionType.NORMAL)
renderClientProperties();
renderClientProperties();
else if(action.getActionType() == ActionType.COMBINE)
else if(action.getActionType() == ActionType.COMBINE)
renderCombineActionProperties();
renderCombineActionProperties();
}
}
}
}
private CombineActionPropertiesPane combineActionPropertiesPane;
private CombineActionPropertiesPane combineActionPropertiesPane;
public CombineActionPropertiesPane getCombineActionPropertiesPane() {
public CombineActionPropertiesPane getCombineActionPropertiesPane() {
return combineActionPropertiesPane;
return combineActionPropertiesPane;
}
}
public void setReturnButtonForCombineActionChildVisible(boolean visible)
public void setReturnButtonForCombineActionChildVisible(boolean visible)
{
{
returnButtonForCombineActionChild.setVisible(visible);
returnButtonForCombineActionChild.setVisible(visible);
}
}
public void renderCombineActionProperties()
public void renderCombineActionProperties()
{
{
try
try
{
{
combineActionPropertiesPane = new CombineActionPropertiesPane(getActionAsCombineAction(action),
combineActionPropertiesPane = new CombineActionPropertiesPane(getActionAsCombineAction(action),
getClientProfile(),
getClientProfile(),
this
this
);
);
clientPropertiesVBox.getChildren().add(combineActionPropertiesPane);
clientPropertiesVBox.getChildren().add(combineActionPropertiesPane);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
public void setAction(Action action) {
public void setAction(Action action) {
this.action = action;
this.action = action;
}
}
public FolderAction getActionAsFolderAction(Action action)
public FolderAction getActionAsFolderAction(Action action)
{
{
FolderAction folderAction = new FolderAction();
FolderAction folderAction = new FolderAction();
folderAction.setDisplayText(action.getDisplayText());
folderAction.setDisplayText(action.getDisplayText());
folderAction.setName(action.getName());
folderAction.setName(action.getName());
folderAction.setID(action.getID());
folderAction.setID(action.getID());
folderAction.setLocation(action.getLocation());
folderAction.setLocation(action.getLocation());
folderAction.setBgColourHex(action.getBgColourHex());
folderAction.setBgColourHex(action.getBgColourHex());
folderAction.setParent(action.getParent());
folderAction.setParent(action.getParent());
folderAction.getClientProperties().set(action.getClientProperties());
folderAction.getClientProperties().set(action.getClientProperties());
folderAction.setDisplayTextAlignment(action.getDisplayTextAlignment());
folderAction.setDisplayTextAlignment(action.getDisplayTextAlignment());
folderAction.setShowIcon(action.isShowIcon());
folderAction.setShowIcon(action.isShowIcon());
folderAction.setHasIcon(action.isHasIcon());
folderAction.setHasIcon(action.isHasIcon());
if(folderAction.isHasIcon())
if(folderAction.isHasIcon())
folderAction.setIcon(action.getIconAsByteArray());
folderAction.setIcon(action.getIconAsByteArray());
folderAction.setDisplayTextFontColourHex(action.getDisplayTextFontColourHex());
folderAction.setDisplayTextFontColourHex(action.getDisplayTextFontColourHex());
return folderAction;
return folderAction;
}
}
public CombineAction getActionAsCombineAction(Action action)
public CombineAction getActionAsCombineAction(Action action)
{
{
CombineAction combineAction = new CombineAction();
CombineAction combineAction = new CombineAction();
combineAction.setDisplayText(action.getDisplayText());
combineAction.setDisplayText(action.getDisplayText());
combineAction.setName(action.getName());
combineAction.setName(action.getName());
combineAction.setID(action.getID());
combineAction.setID(action.getID());
combineAction.setLocation(action.getLocation());
combineAction.setLocation(action.getLocation());
combineAction.setBgColourHex(action.getBgColourHex());
combineAction.setBgColourHex(action.getBgColourHex());
combineAction.setParent(action.getParent());
combineAction.setParent(action.getParent());
combineAction.getClientProperties().set(action.getClientProperties());
combineAction.getClientProperties().set(action.getClientProperties());
combineAction.setDisplayTextAlignment(action.getDisplayTextAlignment());
combineAction.setDisplayTextAlignment(action.getDisplayTextAlignment());
combineAction.setShowIcon(action.isShowIcon());
combineAction.setShowIcon(action.isShowIcon());
combineAction.setHasIcon(action.isHasIcon());
combineAction.setHasIcon(action.isHasIcon());
if(combineAction.isHasIcon())
if(combineAction.isHasIcon())
combineAction.setIcon(action.getIconAsByteArray());
combineAction.setIcon(action.getIconAsByteArray());
combineAction.setDisplayTextFontColourHex(action.getDisplayTextFontColourHex());
combineAction.setDisplayTextFontColourHex(action.getDisplayTextFontColourHex());
for(Property prop : combineAction.getClientProperties().get())
for(Property prop : combineAction.getClientProperties().get())
{
{
System.out.println("PROP : "+prop.getName()+","+prop.getRawValue());
System.out.println("PROP : "+prop.getName()+","+prop.getRawValue());
}
}
return combineAction;
return combineAction;
}
}
@Override
@Override
public void onOpenFolderButtonClicked()
public void onOpenFolderButtonClicked()
{
{
FolderAction folderAction = getActionAsFolderAction(action);
FolderAction folderAction = getActionAsFolderAction(action);
actionBox.getActionGridPaneListener().renderFolder(folderAction);
actionBox.getActionGridPaneListener().renderFolder(folderAction);
clear();
clear();
}
}
@Override
@Override
public Window getCurrentWindow() {
public Window getCurrentWindow() {
return getScene().getWindow();
return getScene().getWindow();
}
}
private ArrayList<UIPropertyBox> actionClientProperties;
private ArrayList<UIPropertyBox> actionClientProperties;
public void renderClientProperties() throws MinorException
public void renderClientProperties() throws MinorException
{
{
for(int i =0;i< action.getClientProperties().getSize(); i++)
for(int i =0;i< action.getClientProperties().getSize(); i++)
{
{
Property eachProperty = action.getClientProperties().get().get(i);
Property eachProperty = action.getClientProperties().get().get(i);
if(!eachProperty.isVisible())
if(!eachProperty.isVisible())
continue;
continue;
Label label = new Label(eachProperty.getDisplayName());
Label label = new Label(eachProperty.getDisplayName());
HBox hBox = new HBox(label);
HBox hBox = new HBox(label);
hBox.setSpacing(5.0);
hBox.setSpacing(5.0);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.setAlignment(Pos.CENTER_LEFT);
Node controlNode = null;
Node controlNode = null;
if(eachProperty.getHelpLink() != null)
if(eachProperty.getHelpLink() != null)
{
{
Button helpButton = new Button();
Button helpButton = new Button();
FontIcon questionIcon = new FontIcon("fas-question");
FontIcon questionIcon = new FontIcon("fas-question");
helpButton.setGraphic(questionIcon);
helpButton.setGraphic(questionIcon);
helpButton.setOnAction(event -> {
helpButton.setOnAction(event -> {
hostServices.showDocument(eachProperty.getHelpLink());
hostServices.showDocument(eachProperty.getHelpLink());
});
});
hBox.getChildren().add(helpButton);
hBox.getChildren().add(helpButton);
}
}
hBox.getChildren().add(SpaceFiller.horizontal());
hBox.getChildren().add(SpaceFiller.horizontal());
if(eachProperty.getControlType() == ControlType.COMBO_BOX)
if(eachProperty.getControlType() == ControlType.COMBO_BOX)
{
{
ComboBox<String> comboBox = new ComboBox<>();
ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().addAll(eachProperty.getListValue());
comboBox.getItems().addAll(eachProperty.getListValue());
comboBox.getSelectionModel().select(eachProperty.getSelectedIndex());
comboBox.getSelectionModel().select(eachProperty.getSelectedIndex());
controlNode = comboBox;
controlNode = comboBox;
}
}
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD)
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD)
{
{
TextField textField = new TextField(eachProperty.getRawValue());
TextField textField = new TextField(eachProperty.getRawValue());
controlNode= textField;
controlNode= textField;
}
}
else if(eachProperty.getControlType() == ControlType.TOGGLE)
else if(eachProperty.getControlType() == ControlType.TOGGLE)
{
{
ToggleButton toggleButton = new ToggleButton();
ToggleButton toggleButton = new ToggleButton();
toggleButton.setSelected(eachProperty.getBoolValue());
toggleButton.setSelected(eachProperty.getBoolValue());
if(eachProperty.getBoolValue())
if(eachProperty.getBoolValue())
toggleButton.setText("ON");
toggleButton.setText("ON");
else
else
toggleButton.setText("OFF");
toggleButton.setText("OFF");
toggleButton.selectedProperty().addListener((observableValue, aBoolean, t1) -> {
toggleButton.selectedProperty().addListener((observableValue, aBoolean, t1) -> {
if(t1)
if(t1)
toggleButton.setText("ON");
toggleButton.setText("ON");
else
else
toggleButton.setText("OFF");
toggleButton.setText("OFF");
});
});
controlNode = toggleButton;
controlNode = toggleButton;
}
}
else if(eachProperty.getControlType() == ControlType.SLIDER_DOUBLE)
else if(eachProperty.getControlType() == ControlType.SLIDER_DOUBLE)
{
{
Slider slider = new Slider();
Slider slider = new Slider();
slider.setValue(eachProperty.getDoubleValue());
slider.setValue(eachProperty.getDoubleValue());
slider.setMax(eachProperty.getMaxDoubleValue());
slider.setMax(eachProperty.getMaxDoubleValue());
slider.setMin(eachProperty.getMinDoubleValue());
slider.setMin(eachProperty.getMinDoubleValue());
controlNode = slider;
controlNode = slider;
}
}
else if(eachProperty.getControlType() == ControlType.SLIDER_INTEGER)
else if(eachProperty.getControlType() == ControlType.SLIDER_INTEGER)
{
{
Slider slider = new Slider();
Slider slider = new Slider();
slider.setValue(eachProperty.getIntValue());
slider.setValue(eachProperty.getIntValue());
slider.setMax(eachProperty.getMaxIntValue());
slider.setMax(eachProperty.getMaxIntValue());
slider.setMin(eachProperty.getMinIntValue());
slider.setMin(eachProperty.getMinIntValue());
slider.setBlockIncrement(1.0);
slider.setBlockIncrement(1.0);
slider.setSnapToTicks(true);
slider.setSnapToTicks(true);
controlNode = slider;
controlNode = slider;
}
}
hBox.getChildren().add(controlNode);
hBox.getChildren().add(controlNode);
UIPropertyBox clientProperty = new UIPropertyBox(i, eachProperty.getDisplayName(), controlNode,
UIPropertyBox clientProperty = new UIPropertyBox(i, eachProperty.getDisplayName(), controlNode,
eachProperty.getControlType(), eachProperty.getType(), eachProperty.isCanBeBlank());
eachProperty.getControlType(), eachProperty.getType(), eachProperty.isCanBeBlank());
actionClientProperties.add(clientProperty);
actionClientProperties.add(clientProperty);
clientPropertiesVBox.getChildren().add(hBox);
clientPropertiesVBox.getChildren().add(hBox);
}
}
}
}
public void onSaveButtonClicked()
public void onSaveButtonClicked()
{
{
try {
try {
// saveButton.setDisable(true);
// saveButton.setDisable(true);
// deleteButton.setDisable(true);
// deleteButton.setDisable(true);
validateForm();
validateForm();
saveAction();
saveAction();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
private boolean sendIcon = false;
private boolean sendIcon = false;
@Override
@Override
public void setSendIcon(boolean sendIcon)
public void setSendIcon(boolean sendIcon)
{
{
this.sendIcon = sendIcon;
this.sendIcon = sendIcon;
}
}
public void addActionToCurrentClientProfile(Action newAction) throws CloneNotSupportedException {
public void addActionToCurrentClientProfile(Action newAction) throws CloneNotSupportedException {
getClientProfile().addAction(newAction);
getClientProfile().addAction(newAction);
}
}
@Override
@Override
public void saveAction(Action action, boolean runAsync)
public void saveAction(Action action, boolean runAsync)
{
{
new OnSaveActionTask(
new OnSaveActionTask(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
getClient().getRemoteSocketAddress()
getClient().getRemoteSocketAddress()
),
),
action,
action,
displayNameTextField.getText(),
displayNameTextField.getText(),
isCombineChild(),
isCombineChild(),
!hideDisplayTextCheckBox.isSelected(),
!hideDisplayTextCheckBox.isSelected(),
displayTextColourDefaultCheckBox.isSelected(),
displayTextColourDefaultCheckBox.isSelected(),
"#" + displayTextColourPicker.getValue().toString().substring(2),
"#" + displayTextColourPicker.getValue().toString().substring(2),
clearIconButton.isDisable(),
clearIconButton.isDisable(),
!hideIconCheckBox.isSelected(),
!hideIconCheckBox.isSelected(),
displayTextAlignmentComboBox.getSelectionModel().getSelectedItem(),
displayTextAlignmentComboBox.getSelectionModel().getSelectedItem(),
actionBackgroundColourTransparentCheckBox.isSelected(),
actionBackgroundColourTransparentCheckBox.isSelected(),
"#" + actionBackgroundColourPicker.getValue().toString().substring(2),
"#" + actionBackgroundColourPicker.getValue().toString().substring(2),
getCombineActionPropertiesPane(),
getCombineActionPropertiesPane(),
clientProfile, sendIcon, actionBox, actionClientProperties, exceptionAndAlertHandler,
clientProfile, sendIcon, actionBox, actionClientProperties, exceptionAndAlertHandler,
saveButton, deleteButton, runAsync
saveButton, deleteButton, runAsync
);
);
}
}
@Override
@Override
public void saveAction()
public void saveAction()
{
{
saveAction(action, true);
saveAction(action, true);
}
}
public void setFolderButtonVisible(boolean visible)
public void setFolderButtonVisible(boolean visible)
{
{
openFolderButton.setVisible(visible);
openFolderButton.setVisible(visible);
}
}
public void validateForm() throws MinorException
public void validateForm() throws MinorException
{
{
String displayNameStr = displayNameTextField.getText();
String displayNameStr = displayNameTextField.getText();
StringBuilder finalErrors = new StringBuilder();
StringBuilder finalErrors = new StringBuilder();
if(displayNameStr.isBlank())
if(displayNameStr.isBlank())
{
{
finalErrors.append(" * Display Name cannot be blank\n");
finalErrors.append(" * Display Name cannot be blank\n");
}
}
if(!isCombineChild())
if(!isCombineChild())
{
{
if(action.isHasIcon())
if(action.isHasIcon())
{
{
if(hideDisplayTextCheckBox.isSelected() && hideIconCheckBox.isSelected())
if(hideDisplayTextCheckBox.isSelected() && hideIconCheckBox.isSelected())
finalErrors.append(" * Both Icon and display text check box cannot be hidden.\n");
finalErrors.append(" * Both Icon and display text check box cannot be hidden.\n");
}
}
else
else
{
{
if(hideDisplayTextCheckBox.isSelected())
if(hideDisplayTextCheckBox.isSelected())
finalErrors.append(" * Display Text cannot be hidden, since there is also no icon.\n");
finalErrors.append(" * Display Text cannot be hidden, since there is also no icon.\n");
}
}
}
}
for (UIPropertyBox clientProperty : actionClientProperties) {
for (UIPropertyBox clientProperty : actionClientProperties) {
Node controlNode = clientProperty.getControlNode();
Node controlNode = clientProperty.getControlNode();
if (clientProperty.getControlType() == ControlType.TEXT_FIELD)
if (clientProperty.getControlType() == ControlType.TEXT_FIELD)
{
{
String value = ((TextField) controlNode).getText();
String value = ((TextField) controlNode).getText();
if(clientProperty.getType() == Type.INTEGER)
if(clientProperty.getType() == Type.INTEGER)
{
{
try
try
{
{
Integer.parseInt(value);
Integer.parseInt(value);
}
}
catch (NumberFormatException e)
catch (NumberFormatException e)
{
{
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" must be integer.\n");
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" must be integer.\n");
}
}
}
}
else
else
{
{
if(value.isBlank() && !clientProperty.isCanBeBlank())
if(value.isBlank() && !clientProperty.isCanBeBlank())
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" cannot be blank.\n");
finalErrors.append(" -> ").append(clientProperty.getDisplayName()).append(" cannot be blank.\n");
}
}
}
}
}
}
if(!finalErrors.toString().isEmpty())
if(!finalErrors.toString().isEmpty())
{
{
throw new MinorException("You made mistakes",
throw new MinorException("You made mistakes",
finalErrors.toString());
finalErrors.toString());
}
}
}
}
public void onDeleteButtonClicked()
public void onDeleteButtonClicked()
{
{
new OnDeleteActionTask(
new OnDeleteActionTask(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
ClientConnections.getInstance().getClientConnectionBySocketAddress(
getClient().getRemoteSocketAddress()
getClient().getRemoteSocketAddress()
),
),
action,
action,
isCombineChild(),
isCombineChild(),
getCombineActionPropertiesPane(),
getCombineActionPropertiesPane(),
clientProfile, actionBox, this, exceptionAndAlertHandler,
clientProfile, actionBox, this, exceptionAndAlertHandler,
!isCombineChild
!isCombineChild
);
);
}
}
}
}
package com.stream_pi.server.window.dashboard.actiongridpane;
package com.stream_pi.server.window.dashboard.actiongridpane;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.otheractions.FolderAction;
import com.stream_pi.action_api.otheractions.FolderAction;
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.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.window.dashboard.actiondetailpane.ActionDetailsPaneListener;
import com.stream_pi.server.window.dashboard.actiondetailpane.ActionDetailsPaneListener;
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 javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.*;
import javafx.scene.layout.*;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class ActionGridPane extends ScrollPane implements ActionGridPaneListener {
public class ActionGridPane extends ScrollPane implements ActionGridPaneListener {
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ActionDetailsPaneListener actionDetailsPaneListener;
private ActionDetailsPaneListener actionDetailsPaneListener;
public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler)
public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler)
{
{
logger = Logger.getLogger(ActionGridPane.class.getName());
logger = Logger.getLogger(ActionGridPane.class.getName());
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
getStyleClass().add("action_grid_pane_parent");
getStyleClass().add("action_grid_pane_parent");
VBox.setVgrow(this, Priority.ALWAYS);
actionsGridPane = new GridPane();
actionsGridPane = new GridPane();
actionsGridPane.setPadding(new Insets(5.0));
actionsGridPane.setPadding(new Insets(5.0));
actionsGridPane.getStyleClass().add("action_grid_pane");
actionsGridPane.getStyleClass().add("action_grid_pane");
actionsGridPane.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
actionsGridPane.setPrefSize(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE);
setContent(actionsGridPane);
setContent(actionsGridPane);
setCache(true);
setCache(true);
setCacheHint(CacheHint.SPEED);
setCacheHint(CacheHint.SPEED);
}
}
public void setActionDetailsPaneListener(ActionDetailsPaneListener actionDetailsPaneListener) {
public void setActionDetailsPaneListener(ActionDetailsPaneListener actionDetailsPaneListener) {
this.actionDetailsPaneListener = actionDetailsPaneListener;
this.actionDetailsPaneListener = actionDetailsPaneListener;
}
}
private String currentParent;
private String currentParent;
@Override
@Override
public void setCurrentParent(String currentParent) {
public void setCurrentParent(String currentParent) {
this.currentParent = currentParent;
this.currentParent = currentParent;
}
}
public ClientProfile getClientProfile() {
public ClientProfile getClientProfile() {
return clientProfile;
return clientProfile;
}
}
private Client client;
private Client client;
public void setClient(Client client) {
public void setClient(Client client) {
this.client = client;
this.client = client;
}
}
public Client getClient() {
public Client getClient() {
return client;
return client;
}
}
private int rows, cols;
private int rows, cols;
private GridPane actionsGridPane;
private GridPane actionsGridPane;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
public void setClientProfile(ClientProfile clientProfile)
public void setClientProfile(ClientProfile clientProfile)
{
{
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
setCurrentParent("root");
setCurrentParent("root");
setRows(clientProfile.getRows());
setRows(clientProfile.getRows());
setCols(clientProfile.getCols());
setCols(clientProfile.getCols());
}
}
@Override
@Override
public String getCurrentParent() {
public String getCurrentParent() {
return currentParent;
return currentParent;
}
}
public StackPane getFolderBackButton() throws SevereException
public StackPane getFolderBackButton() throws SevereException
{
{
StackPane stackPane = new StackPane();
StackPane stackPane = new StackPane();
stackPane.getStyleClass().add("action_box");
stackPane.getStyleClass().add("action_box");
stackPane.getStyleClass().add("action_box_valid");
stackPane.getStyleClass().add("action_box_valid");
stackPane.setPrefSize(
stackPane.setPrefSize(
Config.getInstance().getActionGridActionSize(),
Config.getInstance().getActionGridActionSize(),
Config.getInstance().getActionGridActionSize()
Config.getInstance().getActionGridActionSize()
);
);
FontIcon fontIcon = new FontIcon("fas-chevron-left");
FontIcon fontIcon = new FontIcon("fas-chevron-left");
fontIcon.getStyleClass().add("folder_action_back_button_icon");
fontIcon.getStyleClass().add("folder_action_back_button_icon");
fontIcon.setIconSize(Config.getInstance().getActionGridActionSize() - 30);
fontIcon.setIconSize(Config.getInstance().getActionGridActionSize() - 30);
stackPane.setAlignment(Pos.CENTER);
stackPane.setAlignment(Pos.CENTER);
stackPane.getChildren().add(fontIcon);
stackPane.getChildren().add(fontIcon);
stackPane.setOnMouseClicked(e->returnToPreviousParent());
stackPane.setOnMouseClicked(e->returnToPreviousParent());
return stackPane;
return stackPane;
}
}
private ActionBox[][] actionBoxes;
private ActionBox[][] actionBoxes;
private boolean isFreshRender = true;
private boolean isFreshRender = true;
private Node folderBackButton = null;
private Node folderBackButton = null;
public void renderGrid() throws SevereException
public void renderGrid() throws SevereException
{
{
actionsGridPane.setHgap(Config.getInstance().getActionGridActionGap());
actionsGridPane.setHgap(Config.getInstance().getActionGridActionGap());
actionsGridPane.setVgap(Config.getInstance().getActionGridActionGap());
actionsGridPane.setVgap(Config.getInstance().getActionGridActionGap());
if(isFreshRender)
if(isFreshRender)
{
{
clear();
clear();
actionBoxes = new ActionBox[cols][rows];
actionBoxes = new ActionBox[cols][rows];
}
}
boolean isFolder = false;
boolean isFolder = false;
if(getCurrentParent().equals("root"))
if(getCurrentParent().equals("root"))
{
{
if(folderBackButton != null)
if(folderBackButton != null)
{
{
actionsGridPane.getChildren().remove(folderBackButton);
actionsGridPane.getChildren().remove(folderBackButton);
folderBackButton = null;
folderBackButton = null;
actionBoxes[0][0] = addBlankActionBox(0,0);
actionBoxes[0][0] = addBlankActionBox(0,0);
}
}
}
}
else
else
{
{
isFolder = true;
isFolder = true;
if(folderBackButton != null)
if(folderBackButton != null)
{
{
actionsGridPane.getChildren().remove(folderBackButton);
actionsGridPane.getChildren().remove(folderBackButton);
folderBackButton = null;
folderBackButton = null;
}
}
else
else
{
{
actionsGridPane.getChildren().remove(actionBoxes[0][0]);
actionsGridPane.getChildren().remove(actionBoxes[0][0]);
}
}
folderBackButton = getFolderBackButton();
folderBackButton = getFolderBackButton();
actionsGridPane.add(folderBackButton, 0,0);
actionsGridPane.add(folderBackButton, 0,0);
}
}
for(int row = 0; row<rows; row++)
for(int row = 0; row<rows; row++)
{
{
for(int col = 0; col<cols; col++)
for(int col = 0; col<cols; col++)
{
{
if(row == 0 && col == 0 && isFolder)
if(row == 0 && col == 0 && isFolder)
continue;
continue;
if(isFreshRender)
if(isFreshRender)
{
{
actionBoxes[col][row] = addBlankActionBox(col, row);
actionBoxes[col][row] = addBlankActionBox(col, row);
}
}
else
else
{
{
if(actionBoxes[col][row].getAction() != null)
if(actionBoxes[col][row].getAction() != null)
{
{
actionBoxes[col][row].clear();
actionBoxes[col][row].clear();
}
}
}
}
}
}
}
}
isFreshRender = false;
isFreshRender = false;
}
}
public void setFreshRender(boolean freshRender)
public void setFreshRender(boolean freshRender)
{
{
isFreshRender = freshRender;
isFreshRender = freshRender;
}
}
public ActionBox addBlankActionBox(int col, int row) throws SevereException {
public ActionBox addBlankActionBox(int col, int row) throws SevereException {
ActionBox actionBox = new ActionBox(Config.getInstance().getActionGridActionSize(), actionDetailsPaneListener, this,
ActionBox actionBox = new ActionBox(Config.getInstance().getActionGridActionSize(), actionDetailsPaneListener, this,
col, row);
col, row);
actionsGridPane.add(actionBox, row, col);
actionsGridPane.add(actionBox, row, col);
return actionBox;
return actionBox;
}
}
public void renderActions()
public void renderActions()
{
{
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
for(String action1x : getClientProfile().getActionsKeySet())
for(String action1x : getClientProfile().getActionsKeySet())
{
{
Action eachAction = getClientProfile().getActionByID(action1x);
Action eachAction = getClientProfile().getActionByID(action1x);
logger.info("action ID : "+eachAction.getID()+
logger.info("action ID : "+eachAction.getID()+
"\nInvalid : "+eachAction.isInvalid());
"\nInvalid : "+eachAction.isInvalid());
try {
try {
renderAction(eachAction);
renderAction(eachAction);
}
}
catch (SevereException e)
catch (SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
errors.append("*").append(e.getShortMessage()).append("\n");
errors.append("*").append(e.getShortMessage()).append("\n");
}
}
}
}
if(!errors.toString().isEmpty())
if(!errors.toString().isEmpty())
{
{
exceptionAndAlertHandler.handleMinorException(new MinorException("Error while rendering following actions", errors.toString()));
exceptionAndAlertHandler.handleMinorException(new MinorException("Error while rendering following actions", errors.toString()));
}
}
}
}
public void clear()
public void clear()
{
{
actionsGridPane.getChildren().clear();
actionsGridPane.getChildren().clear();
}
}
private Logger logger;
private Logger logger;
public void renderAction(Action action) throws SevereException, MinorException
public void renderAction(Action action) throws SevereException, MinorException
{
{
if(!action.getParent().equals(currentParent))
if(!action.getParent().equals(currentParent))
{
{
logger.info("Skipping action "+action.getID()+", not current parent!");
logger.info("Skipping action "+action.getID()+", not current parent!");
return;
return;
}
}
if(action.getLocation().getRow()==-1)
if(action.getLocation().getRow()==-1)
{
{
logger.info("action has -1 rowIndex. Probably Combine action. Skipping ...");
logger.info("action has -1 rowIndex. Probably Combine action. Skipping ...");
return;
return;
}
}
if(action.getLocation().getRow() >= rows || action.getLocation().getCol() >= cols)
if(action.getLocation().getRow() >= rows || action.getLocation().getCol() >= cols)
{
{
throw new MinorException("action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" +
throw new MinorException("action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" +
" Consider increasing rows/cols from client settings and relocating/deleting it.");
" Consider increasing rows/cols from client settings and relocating/deleting it.");
}
}
Location location = action.getLocation();
Location location = action.getLocation();
ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()];
ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()];
actionBox.clear();
actionBox.clear();
actionBox.setAction(action);
actionBox.setAction(action);
actionBox.init();
actionBox.init();
/*ActionBox actionBox = new ActionBox(Config.getInstance().getActionGridActionSize(), action, actionDetailsPaneListener, exceptionAndAlertHandler, this);
/*ActionBox actionBox = new ActionBox(Config.getInstance().getActionGridActionSize(), action, actionDetailsPaneListener, exceptionAndAlertHandler, this);
Location location = action.getLocation();
Location location = action.getLocation();
actionBox.setStreamPiParent(currentParent);
actionBox.setStreamPiParent(currentParent);
actionBox.setRow(location.getRow());
actionBox.setRow(location.getRow());
actionBox.setCol(location.getCol());
actionBox.setCol(location.getCol());
for(Node node : actionsGridPane.getChildren())
for(Node node : actionsGridPane.getChildren())
{
{
if(GridPane.getColumnIndex(node) == location.getRow() &&
if(GridPane.getColumnIndex(node) == location.getRow() &&
GridPane.getRowIndex(node) == location.getCol())
GridPane.getRowIndex(node) == location.getCol())
{
{
actionsGridPane.getChildren().remove(node);
actionsGridPane.getChildren().remove(node);
break;
break;
}
}
}
}
System.out.println(location.getCol()+","+location.getRow());
System.out.println(location.getCol()+","+location.getRow());
actionsGridPane.add(actionBox, location.getRow(), location.getCol());*/
actionsGridPane.add(actionBox, location.getRow(), location.getCol());*/
}
}
public void setRows(int rows)
public void setRows(int rows)
{
{
this.rows = rows;
this.rows = rows;
}
}
public void setCols(int cols)
public void setCols(int cols)
{
{
this.cols = cols;
this.cols = cols;
}
}
public int getRows()
public int getRows()
{
{
return rows;
return rows;
}
}
public int getCols()
public int getCols()
{
{
return cols;
return cols;
}
}
@Override
@Override
public void addActionToCurrentClientProfile(Action newAction) {
public void addActionToCurrentClientProfile(Action newAction) {
try {
try {
getClientProfile().addAction(newAction);
getClientProfile().addAction(newAction);
} catch (CloneNotSupportedException e) {
} catch (CloneNotSupportedException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
private String previousParent;
private String previousParent;
public void setPreviousParent(String previousParent) {
public void setPreviousParent(String previousParent) {
this.previousParent = previousParent;
this.previousParent = previousParent;
}
}
public String getPreviousParent() {
public String getPreviousParent() {
return previousParent;
return previousParent;
}
}
@Override
@Override
public void renderFolder(FolderAction action) {
public void renderFolder(FolderAction action) {
setCurrentParent(action.getID());
setCurrentParent(action.getID());
setPreviousParent(action.getParent());
setPreviousParent(action.getParent());
try {
try {
renderGrid();
renderGrid();
renderActions();
renderActions();
} catch (SevereException e) {
} catch (SevereException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public void returnToPreviousParent()
public void returnToPreviousParent()
{
{
setCurrentParent(getPreviousParent());
setCurrentParent(getPreviousParent());
if(!getPreviousParent().equals("root"))
if(!getPreviousParent().equals("root"))
{
{
System.out.println("parent : "+getPreviousParent());
System.out.println("parent : "+getPreviousParent());
setPreviousParent(getClientProfile().getActionByID(
setPreviousParent(getClientProfile().getActionByID(
getPreviousParent()
getPreviousParent()
).getParent());
).getParent());
}
}
try {
try {
renderGrid();
renderGrid();
renderActions();
renderActions();
} catch (SevereException e) {
} catch (SevereException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
}
}
package com.stream_pi.server.window.settings;
package com.stream_pi.server.window.settings;
import com.stream_pi.server.uipropertybox.UIPropertyBox;
import com.stream_pi.server.uipropertybox.UIPropertyBox;
import com.stream_pi.action_api.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.action_api.normalaction.NormalAction;
import com.stream_pi.server.action.NormalActionPlugins;
import com.stream_pi.server.action.NormalActionPlugins;
import com.stream_pi.server.connection.ServerListener;
import com.stream_pi.server.connection.ServerListener;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.server.window.ExceptionAndAlertHandler;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class PluginsSettings extends VBox {
public class PluginsSettings extends VBox {
private VBox pluginsSettingsVBox;
private VBox pluginsSettingsVBox;
private ServerListener serverListener;
private ServerListener serverListener;
private Logger logger;
private Logger logger;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private HostServices hostServices;
private HostServices hostServices;
public PluginsSettings(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices)
public PluginsSettings(ExceptionAndAlertHandler exceptionAndAlertHandler, HostServices hostServices)
{
{
getStyleClass().add("plugins_settings");
getStyleClass().add("plugins_settings");
this.hostServices = hostServices;
this.hostServices = hostServices;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
pluginProperties = new ArrayList<>();
pluginProperties = new ArrayList<>();
logger = Logger.getLogger(PluginsSettings.class.getName());
logger = Logger.getLogger(PluginsSettings.class.getName());
pluginsSettingsVBox = new VBox();
pluginsSettingsVBox = new VBox();
pluginsSettingsVBox.getStyleClass().add("plugins_settings_vbox");
pluginsSettingsVBox.getStyleClass().add("plugins_settings_vbox");
pluginsSettingsVBox.setAlignment(Pos.TOP_CENTER);
pluginsSettingsVBox.setAlignment(Pos.TOP_CENTER);
ScrollPane scrollPane = new ScrollPane();
ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("plugins_settings_scroll_pane");
scrollPane.getStyleClass().add("plugins_settings_scroll_pane");
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.maxWidthProperty().bind(widthProperty().multiply(0.8));
scrollPane.maxWidthProperty().bind(widthProperty().multiply(0.8));
pluginsSettingsVBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
pluginsSettingsVBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
scrollPane.setContent(pluginsSettingsVBox);
scrollPane.setContent(pluginsSettingsVBox);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
setAlignment(Pos.TOP_CENTER);
setAlignment(Pos.TOP_CENTER);
saveButton = new Button("Save");
saveButton = new Button("Save");
saveButton.setOnAction(event -> onSaveButtonClicked());
saveButton.setOnAction(event -> onSaveButtonClicked());
HBox hBox = new HBox(saveButton);
HBox hBox = new HBox(saveButton);
hBox.setAlignment(Pos.CENTER_RIGHT);
hBox.setAlignment(Pos.CENTER_RIGHT);
getChildren().addAll(scrollPane, hBox);
getChildren().addAll(scrollPane, hBox);
}
}
private Button saveButton;
private Button saveButton;
public void onSaveButtonClicked()
public void onSaveButtonClicked()
{
{
try {
try {
//form validation
//form validation
StringBuilder finalErrors = new StringBuilder();
StringBuilder finalErrors = new StringBuilder();
for (PluginProperties p : pluginProperties)
for (PluginProperties p : pluginProperties)
{
{
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
for(int j = 0; j < p.getServerPropertyUIBox().size(); j++)
for(int j = 0; j < p.getServerPropertyUIBox().size(); j++)
{
{
UIPropertyBox serverProperty = p.getServerPropertyUIBox().get(j);
UIPropertyBox serverProperty = p.getServerPropertyUIBox().get(j);
Node controlNode = serverProperty.getControlNode();
Node controlNode = serverProperty.getControlNode();
if (serverProperty.getControlType() == ControlType.TEXT_FIELD)
if (serverProperty.getControlType() == ControlType.TEXT_FIELD)
{
{
String value = ((TextField) controlNode).getText();
String value = ((TextField) controlNode).getText();
if(serverProperty.getType() == Type.INTEGER)
if(serverProperty.getType() == Type.INTEGER)
{
{
try
try
{
{
Integer.parseInt(value);
Integer.parseInt(value);
}
}
catch (NumberFormatException e)
catch (NumberFormatException e)
{
{
errors.append(" -> ").append(serverProperty.getDisplayName()).append(" must be integer.\n");
errors.append(" -> ").append(serverProperty.getDisplayName()).append(" must be integer.\n");
}
}
}
}
else
else
{
{
if(value.isBlank() && !serverProperty.isCanBeBlank())
if(value.isBlank() && !serverProperty.isCanBeBlank())
errors.append(" -> ").append(serverProperty.getDisplayName()).append(" cannot be blank.\n");
errors.append(" -> ").append(serverProperty.getDisplayName()).append(" cannot be blank.\n");
}
}
}
}
}
}
if(!errors.toString().isBlank())
if(!errors.toString().isBlank())
{
{
finalErrors.append(" * ").append(p.getName()).append("\n").append(errors.toString()).append("\n");
finalErrors.append(" * ").append(p.getName()).append("\n").append(errors.toString()).append("\n");
}
}
}
}
if(!finalErrors.toString().isEmpty())
if(!finalErrors.toString().isEmpty())
{
{
throw new MinorException("Form Validation Errors",
throw new MinorException("Form Validation Errors",
"Please rectify the following errors and try again \n"+finalErrors.toString());
"Please rectify the following errors and try again \n"+finalErrors.toString());
}
}
//save
//save
for (PluginProperties pp : pluginProperties) {
for (PluginProperties pp : pluginProperties) {
for (int j = 0; j < pp.getServerPropertyUIBox().size(); j++) {
for (int j = 0; j < pp.getServerPropertyUIBox().size(); j++) {
UIPropertyBox serverProperty = pp.getServerPropertyUIBox().get(j);
UIPropertyBox serverProperty = pp.getServerPropertyUIBox().get(j);
String rawValue = serverProperty.getRawValue();
String rawValue = serverProperty.getRawValue();
NormalActionPlugins.getInstance().getActionFromIndex(pp.getIndex())
NormalActionPlugins.getInstance().getActionFromIndex(pp.getIndex())
.getServerProperties().get()
.getServerProperties().get()
.get(serverProperty.getIndex()).setRawValue(rawValue);
.get(serverProperty.getIndex()).setRawValue(rawValue);
}
}
}
}
NormalActionPlugins.getInstance().saveServerSettings();
NormalActionPlugins.getInstance().saveServerSettings();
NormalActionPlugins.getInstance().initPlugins();
NormalActionPlugins.getInstance().initPlugins();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
private ArrayList<PluginProperties> pluginProperties;
private ArrayList<PluginProperties> pluginProperties;
public void showPluginInitError()
public void showPluginInitError()
{
{
Platform.runLater(()->{
Platform.runLater(()->{
pluginsSettingsVBox.getChildren().add(new Label("Plugin init error. Resolve issues and restart."));
pluginsSettingsVBox.getChildren().add(new Label("Plugin init error. Resolve issues and restart."));
saveButton.setVisible(false);
saveButton.setVisible(false);
});
});
}
}
public void loadPlugins() throws MinorException {
public void loadPlugins() throws MinorException {
pluginProperties.clear();
pluginProperties.clear();
List<NormalAction> actions = NormalActionPlugins.getInstance().getPlugins();
List<NormalAction> actions = NormalActionPlugins.getInstance().getPlugins();
Platform.runLater(()-> pluginsSettingsVBox.getChildren().clear());
Platform.runLater(()-> pluginsSettingsVBox.getChildren().clear());
if(actions.size() == 0)
if(actions.size() == 0)
{
{
Platform.runLater(()->{
Platform.runLater(()->{
Label l = new Label("No Plugins Installed.");
Label l = new Label("No Plugins Installed.");
l.getStyleClass().add("plugins_pane_no_plugins_installed_label");
l.getStyleClass().add("plugins_pane_no_plugins_installed_label");
pluginsSettingsVBox.getChildren().add(l);
pluginsSettingsVBox.getChildren().add(l);
saveButton.setVisible(false);
saveButton.setVisible(false);
});
});
return;
return;
}
}
else
else
{
{
Platform.runLater(()->saveButton.setVisible(true));
Platform.runLater(()->saveButton.setVisible(true));
}
}
for(int i = 0; i<actions.size(); i++)
for(int i = 0; i<actions.size(); i++)
{
{
NormalAction action = actions.get(i);
NormalAction action = actions.get(i);
if(!action.isVisibleInServerSettingsPane())
if(!action.isVisibleInServerSettingsPane())
continue;
continue;
Label headingLabel = new Label(action.getName());
Label headingLabel = new Label(action.getName());
headingLabel.getStyleClass().add("plugins_settings_each_plugin_heading_label");
headingLabel.getStyleClass().add("plugins_settings_each_plugin_heading_label");
HBox headerHBox = new HBox(headingLabel);
HBox headerHBox = new HBox(headingLabel);
headerHBox.getStyleClass().add("plugins_settings_each_plugin_header");
headerHBox.getStyleClass().add("plugins_settings_each_plugin_header");
if (action.getHelpLink()!=null)
if (action.getHelpLink()!=null)
{
{
Button helpButton = new Button();
Button helpButton = new Button();
helpButton.getStyleClass().add("plugins_settings_each_plugin_help_button");
helpButton.getStyleClass().add("plugins_settings_each_plugin_help_button");
FontIcon questionIcon = new FontIcon("fas-question");
FontIcon questionIcon = new FontIcon("fas-question");
questionIcon.getStyleClass().add("plugins_settings_each_plugin_help_icon");
questionIcon.getStyleClass().add("plugins_settings_each_plugin_help_icon");
helpButton.setGraphic(questionIcon);
helpButton.setGraphic(questionIcon);
helpButton.setOnAction(event -> hostServices.showDocument(action.getHelpLink()));
helpButton.setOnAction(event -> hostServices.showDocument(action.getHelpLink()));
headerHBox.getChildren().addAll(SpaceFiller.horizontal() ,helpButton);
headerHBox.getChildren().addAll(SpaceFiller.horizontal() ,helpButton);
}
}
Label authorLabel = new Label(action.getAuthor());
Label authorLabel = new Label(action.getAuthor());
authorLabel.getStyleClass().add("plugins_settings_each_plugin_author_label");
authorLabel.getStyleClass().add("plugins_settings_each_plugin_author_label");
Label moduleLabel = new Label(action.getModuleName());
Label moduleLabel = new Label(action.getModuleName());
moduleLabel.getStyleClass().add("plugins_settings_each_plugin_module_label");
moduleLabel.getStyleClass().add("plugins_settings_each_plugin_module_label");
Label versionLabel = new Label("Version : "+action.getVersion().getText());
Label versionLabel = new Label("Version : "+action.getVersion().getText());
versionLabel.getStyleClass().add("plugins_settings_each_plugin_version_label");
versionLabel.getStyleClass().add("plugins_settings_each_plugin_version_label");
VBox serverPropertiesVBox = new VBox();
VBox serverPropertiesVBox = new VBox();
serverPropertiesVBox.getStyleClass().add("plugins_settings_each_plugin_server_properties_box");
serverPropertiesVBox.getStyleClass().add("plugins_settings_each_plugin_server_properties_box");
serverPropertiesVBox.setSpacing(10.0);
serverPropertiesVBox.setSpacing(10.0);
List<Property> serverProperties = action.getServerProperties().get();
List<Property> serverProperties = action.getServerProperties().get();
ArrayList<UIPropertyBox> serverPropertyArrayList = new ArrayList<>();
ArrayList<UIPropertyBox> serverPropertyArrayList = new ArrayList<>();
for(int j =0; j<serverProperties.size(); j++)
for(int j =0; j<serverProperties.size(); j++)
{
{
Property eachProperty = serverProperties.get(j);
Property eachProperty = serverProperties.get(j);
if(!eachProperty.isVisible())
if(!eachProperty.isVisible())
continue;
continue;
Label label = new Label(eachProperty.getDisplayName());
Label label = new Label(eachProperty.getDisplayName());
Region region = new Region();
Region region = new Region();
HBox.setHgrow(region, Priority.ALWAYS);
HBox.setHgrow(region, Priority.ALWAYS);
HBox hBox = new HBox(label, SpaceFiller.horizontal());
HBox hBox = new HBox(label, SpaceFiller.horizontal());
//hBox.setId(j+"");
//hBox.setId(j+"");
Node controlNode = null;
Node controlNode = null;
if(eachProperty.getControlType() == ControlType.COMBO_BOX)
if(eachProperty.getControlType() == ControlType.COMBO_BOX)
{
{
ComboBox<String> comboBox = new ComboBox<>();
ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().addAll(eachProperty.getListValue());
comboBox.getItems().addAll(eachProperty.getListValue());
comboBox.getSelectionModel().select(eachProperty.getSelectedIndex());
comboBox.getSelectionModel().select(eachProperty.getSelectedIndex());
hBox.getChildren().add(comboBox);
hBox.getChildren().add(comboBox);
controlNode = comboBox;
controlNode = comboBox;
}
}
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD)
else if(eachProperty.getControlType() == ControlType.TEXT_FIELD)
{
{
TextField textField = new TextField(eachProperty.getRawValue());
TextField textField = new TextField(eachProperty.getRawValue());
hBox.getChildren().add(textField);
hBox.getChildren().add(textField);
controlNode = textField;
controlNode = textField;
}
}
else if(eachProperty.getControlType() == ControlType.TOGGLE)
else if(eachProperty.getControlType() == ControlType.TOGGLE)
{
{
ToggleButton toggleButton = new ToggleButton();
ToggleButton toggleButton = new ToggleButton();
toggleButton.setSelected(eachProperty.getBoolValue());
toggleButton.setSelected(eachProperty.getBoolValue());
if(eachProperty.getBoolValue())
if(eachProperty.getBoolValue())
toggleButton.setText("ON");
toggleButton.setText("ON");
else
else
toggleButton.setText("OFF");
toggleButton.setText("OFF");
toggleButton.selectedProperty().addListener((observableValue, aBoolean, t1) -> {
toggleButton.selectedProperty().addListener((observableValue, aBoolean, t1) -> {
if(t1)
if(t1)
toggleButton.setText("ON");
toggleButton.setText("ON");
else
else
toggleButton.setText("OFF");
toggleButton.setText("OFF");
});
});
hBox.getChildren().add(toggleButton);
hBox.getChildren().add(toggleButton);
controlNode = toggleButton;
controlNode = toggleButton;
}
}
else if(eachProperty.getControlType() == ControlType.SLIDER_DOUBLE)
else if(eachProperty.getControlType() == ControlType.SLIDER_DOUBLE)
{
{
Slider slider = new Slider();
Slider slider = new Slider();
slider.setValue(eachProperty.getDoubleValue());
slider.setValue(eachProperty.getDoubleValue());
slider.setMax(eachProperty.getMaxDoubleValue());
slider.setMax(eachProperty.getMaxDoubleValue());
slider.setMin(eachProperty.getMinDoubleValue());
slider.setMin(eachProperty.getMinDoubleValue());
hBox.getChildren().add(slider);
hBox.getChildren().add(slider);
controlNode = slider;
controlNode = slider;
}
}
else if(eachProperty.getControlType() == ControlType.SLIDER_INTEGER)
else if(eachProperty.getControlType() == ControlType.SLIDER_INTEGER)
{
{
Slider slider = new Slider();
Slider slider = new Slider();
slider.setValue(eachProperty.getIntValue());
slider.setValue(eachProperty.getIntValue());
slider.setMax(eachProperty.getMaxIntValue());
slider.setMax(eachProperty.getMaxIntValue());
slider.setMin(eachProperty.getMinIntValue());
slider.setMin(eachProperty.getMinIntValue());
slider.setBlockIncrement(1.0);
slider.setBlockIncrement(1.0);
slider.setSnapToTicks(true);
slider.setSnapToTicks(true);
hBox.getChildren().add(slider);
hBox.getChildren().add(slider);
controlNode = slider;
controlNode = slider;
}
}
UIPropertyBox serverProperty = new UIPropertyBox(j, eachProperty.getDisplayName(), controlNode, eachProperty.getControlType(), eachProperty.getType(), eachProperty.isCanBeBlank());
UIPropertyBox serverProperty = new UIPropertyBox(j, eachProperty.getDisplayName(), controlNode, eachProperty.getControlType(), eachProperty.getType(), eachProperty.isCanBeBlank());
serverPropertyArrayList.add(serverProperty);
serverPropertyArrayList.add(serverProperty);
serverPropertiesVBox.getChildren().add(hBox);
serverPropertiesVBox.getChildren().add(hBox);
}
}
PluginProperties pp = new PluginProperties(i, serverPropertyArrayList, action.getName());
PluginProperties pp = new PluginProperties(i, serverPropertyArrayList, action.getName());
pluginProperties.add(pp);
pluginProperties.add(pp);
Platform.runLater(()->{
Platform.runLater(()->{
VBox vBox = new VBox();
VBox vBox = new VBox();
vBox.getStyleClass().add("plugins_settings_each_plugin_box");
vBox.getStyleClass().add("plugins_settings_each_plugin_box");
vBox.setSpacing(5.0);
vBox.setSpacing(5.0);
vBox.getChildren().addAll(headerHBox, authorLabel, moduleLabel, versionLabel, serverPropertiesVBox);
vBox.getChildren().addAll(headerHBox, authorLabel, moduleLabel, versionLabel, serverPropertiesVBox);
if(action.getButtonBar()!=null)
if(action.getButtonBar()!=null)
{
{
action.getButtonBar().getStyleClass().add("plugins_settings_each_plugin_button_bar");
HBox buttonBarHBox = new HBox(SpaceFiller.horizontal(), action.getButtonBar());
HBox buttonBarHBox = new HBox(SpaceFiller.horizontal(), action.getButtonBar());
buttonBarHBox.getStyleClass().add("plugins_settings_each_plugin_button_bar");
buttonBarHBox.getStyleClass().add("plugins_settings_each_plugin_button_bar_hbox");
vBox.getChildren().add(buttonBarHBox);
vBox.getChildren().add(buttonBarHBox);
}
}
pluginsSettingsVBox.getChildren().add(vBox);
pluginsSettingsVBox.getChildren().add(vBox);
});
});
}
}
}
}
public class PluginProperties
public class PluginProperties
{
{
private int index;
private int index;
private ArrayList<UIPropertyBox> serverProperty;
private ArrayList<UIPropertyBox> serverProperty;
private String name;
private String name;
public PluginProperties(int index, ArrayList<UIPropertyBox> serverProperty, String name)
public PluginProperties(int index, ArrayList<UIPropertyBox> serverProperty, String name)
{
{
this.index = index;
this.index = index;
this.serverProperty = serverProperty;
this.serverProperty = serverProperty;
this.name = name;
this.name = name;
}
}
public String getName()
public String getName()
{
{
return name;
return name;
}
}
public int getIndex() {
public int getIndex() {
return index;
return index;
}
}
public ArrayList<UIPropertyBox> getServerPropertyUIBox() {
public ArrayList<UIPropertyBox> getServerPropertyUIBox() {
return serverProperty;
return serverProperty;
}
}
}
}
}
}
PK 霟Q Plugins/UT
_9`9`ux PK 霟Q m Plugins/config.xmlUT
_9`9`ux Q(K-*ϳU23PRHKOKU
PK 霟Q Plugins/UT
_9`9`ux PK 霟Q m Plugins/config.xmlUT
_9`9`ux Q(K-*ϳU23PRHKOKU
qӵPR(.IKIKUWIKL/-J,jRPIL1la,.}4e PKTX m PK PR Themes/UT
+`9`9`ux PK DR ! Themes/com.stream_pi.defaultdark/UT
k`9`9`ux PK DR % Themes/com.stream_pi.defaultdark/res/UT
2`9`9`ux PK DR . Themes/com.stream_pi.defaultdark/res/style.cssUT
2`9`9`ux Vێ0}G,*[u/,9BF$r<|eV
qӵPR(.IKIKUWIKL/-J,jRPIL1la,.}4e PKTX m PK PR Themes/UT
+`9`9`ux PK DR ! Themes/com.stream_pi.defaultdark/UT
k`9`9`ux PK DR % Themes/com.stream_pi.defaultdark/res/UT
2`9`9`ux PK DR . Themes/com.stream_pi.defaultdark/res/style.cssUT
2`9`9`ux Vێ0}G,*[u/,9BF$r<|eV
Z` ao~ٿ>'ݏZjnjN9E :j0*wxΩzD,v@/./!,mkk kO"
NQEJB)t3( t aiN%쒋]Cy{Mi[\Xxgh_76~n>MPelZvp:UHiz8K<i*@6r'\d
6]S M\(aYwZe!^4LᒣANآn:k{.H۬9 E Ñ!rz7Ͱ=JpK6|Et~gXm9K,m ~`F:P=F%y)j`1wi4
8߰NXnEE{3SV^E%w)ta
g>ՏL-aVῷ.PKЛE$ PK DR * Themes/com.stream_pi.defaultdark/theme.xmlUT
k`9`9`ux uP MNi ]89>/VZݽ˽cK
FpnL;)ÑU|cr&+| a1
Z` ao~ٿ>'ݏZjnjN9E :j0*wxΩzD,v@/./!,mkk kO"
NQEJB)t3( t aiN%쒋]Cy{Mi[\Xxgh_76~n>MPelZvp:UHiz8K<i*@6r'\d
6]S M\(aYwZe!^4LᒣANآn:k{.H۬9 E Ñ!rz7Ͱ=JpK6|Et~gXm9K,m ~`F:P=F%y)j`1wi4
8߰NXnEE{3SV^E%w)ta
g>ՏL-aVῷ.PKЛE$ PK DR * Themes/com.stream_pi.defaultdark/theme.xmlUT
k`9`9`ux uP MNi ]89>/VZݽ˽cK
FpnL;)ÑU|cr&+| a1
/U$aaDd]o'Z(5H1MD.&pn
ZF#H6)MO2yx[ptY9F&^Ot]PK} PK ͺDR ) Themes/com.stream_pi.defaulthighcontrast/UT
Z4`9`9`ux PK ѸDR - Themes/com.stream_pi.defaulthighcontrast/res/UT
0`9`9`ux PK ѸDR " 6 Themes/com.stream_pi.defaulthighcontrast/res/style.cssUT
0`9`9`ux UK0.`ƹB 8BѐIA^ſHYN,D톅N;=B͖L5/
'/^σnDIvv3=&`k 6E="%GT];xUP
/U$aaDd]o'Z(5H1MD.&pn
ZF#H6)MO2yx[ptY9F&^Ot]PK} PK ͺDR ) Themes/com.stream_pi.defaulthighcontrast/UT
Z4`9`9`ux PK ѸDR - Themes/com.stream_pi.defaulthighcontrast/res/UT
0`9`9`ux PK ѸDR " 6 Themes/com.stream_pi.defaulthighcontrast/res/style.cssUT
0`9`9`ux UK0.`ƹB 8BѐIA^ſHYN,D톅N;=B͖L5/
'/^σnDIvv3=&`k 6E="%GT];xUP
RPEHL\{윞2^3NΚt/9A7dnlWF8Xfƞ*5V.aZ",(B2V(tFχy|Qg(QLZAN;+z%*'MHk a*5<w'Z!nO걘k( k~":yڡԏ<ވ"6\`:lBн/އuDLNy-+RMmBq;mM<KlYA\A0`b<RGnl.K#wb?p__]vDaeΙ/C[h PK " PK ͺDR 2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlUT
Z4`9`9`ux uP10ܑC 40 x)n&(q R|w>O]n輶,chJ{֦.Ŋ3V,t; #x4S+IFm*Pm%u6OlwJs)x RD |" >9H}H>(ЋK0:ҟPKGzK PK DR "