server

Clone or download

Modified Files

PK
+Rҏ<X_META-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMuRp,HLHUM,KS033r*)%V&&@RtRFгPKҏ<X_PK
+R META-INF/PK
+Rcom/PK
+R com/StreamPi/PK
+Rcom/StreamPi/TextBlockAction/PK
+RMETA-INF/maven/PK
+RMETA-INF/maven/com.StreamPi/PK
+R,META-INF/maven/com.StreamPi/TextBlockAction/PK
+R#xq&2com/StreamPi/TextBlockAction/TextBlockAction.classŚw`Ey&Ov'C „@-B@)@O$<!y;6Գ`\rrwv<Γ;I$xo;էwg/ =Ds$Hҧ3Nkӗڿ
߃ԅ}@<$ArN:% Qq<G 8`~ 8gڃ%h g.D$Q'RY7κsփY/ΎNq֛>XΒ8Yp6A lgC9Y2g9Sp6TFr64Fs6l<g8$&s6s6ep6Lfr,fs6lr6r9,sVYgŜp-⬔Ŝ-l)g8[
Vr欌r*8pvgUqV*j8嬎z΢5pFΚ8qrs&6svg[8ىɜ٩m ,ζsv.gqv>g3 Ӊ['>įNNuI6؅]R,vN.+JFqѲhY^N #TWC-`ˌVD9溲HcqGdN<\ X/VUhDNy.( TGfFk2cu5  Xu-$~,qğ^9 #cԟep`ֺH.`Waphd3kk"z- NS'NXDZ]dX&7`f.Ve$`ނpm/]=Q|yU1\4 Hm$ܤ:4[w1:*q6X,/j͍͌Yv;Н`JREZt&DУhBJ2B&6صo"!vq,nıXiRjjeulD-O=?d{ R,XumHc^k^d4W.# Iez+nbnf̺~B[m!v;OW߆؝; ыڽFb{}iI!v?blZާwB_'7C6rANf@3Lh&͂fCs<(ʅ|BEP1TZBHh@cqxh4JB~th4-CPhwNqhm6 )h
4ۊl-tfB( dfan|YĜYԚ5J'i:1:q: :YFtIL:ڤcL:֤L:ޤLjꦙinfꦡ.+-Ș43;3֙ݙ=,쌬¤٘3ߜ\,v^QV!$P1;++$0(eg9+ֳꟙUZ E99I9Xf$BKw+F 4QPqԯ +Z:i/oqff`I볅ٳx\[ηgvmmo:@pF4k5r#hEgs~|L?k;h/iu?~<N@.3TFe4c(u|QqMqFs,aVUW.4D1CF:^__p.mec4I{_ՔϬnj Oh33"3~I]u WT B94R:tɯKLy[=.fgܯ })\F:r"1G_4tP %Ģ% i•8ܞjCԛ#XfQe"pSU{7;Ȟ`O2:
>K2qS+! D2B(5&a7=" "S;F;TׯD:_uG=(sњv1YaDHhCF nN64#<GP</?/&2õEձ{Ѡor凰Ə "xcGhTnFdFdh#,(,(l{79mގJ=?q#ƻbލzPwꍴ?؆? ѓe:QMq KT&Ar7u.QRd8c/jjt>l_\&bOsugY\w 9Qttu@HC[|`p]kr#ۨwN6F};vF#1wx׎ƃ#n ףceRUy)qq)&{'ze6p {ā;om48Y!&?Dr)FChIqz8L-Xs<&"23GiM,ʠyIi&-9Tru8G:o νD/Sg+h:FsTApt)?_v;g( ?tҰ'h 輏3<JWm|V{HNb݃yo=ؒ];z~_YWʷ[+M>b7U}⿄E9 ~,<OA`V=vox=GvsGπG˻Ѯy)>_G'pͬ` I>Ƥ|0)<|aR^S=iJq0ˁ~8]샣O4X&a:
O_
>WOD u}>ς7gOx6sIs7ʃda}/pI\x!sKEp qЗ0|!^
?~9| Ƈ1R
28E1'8\y zFa G e%wB@{[!<61}݉uR"aql#y%8K8D|?8NH8}48,>1|x-S_ k*F8bn8Lcpu<.xſM{3ƙ 9OIA^~~]L.Fhvrsc ;%cL8w|wpwZ;.ZK(1 "k[AxN<<|X Sh0yD9Rr~en[е>J ]N*j%)9P (C˄.P4yBhӄ.<Q1Gx`c A1J3(E0xSrFW JN4_8dWrDž>{D"%)$Z% ^"4gnnp\d:X EO"%3 拣J48]NR2(q4p {+9`WE9}OzkJfk s ~ <$ J|B>d{DJ%S2b % )OQr`Z% ֋!*% CJ,Às,1!\`0M *%  v)@GRqbDz%k}-R)H;J.5|Qei*b4.%WI^J <KdMb<pbZ
+Db%#IyJgp db
0E*T`_% v@WUbhCLOo?W"u_3W&Ta?%2(Yop [ɨAOdoPb"%W<[dbE& "Jɘ \dB1"8UɵLj\%$*b
%  SrF1?Bɍ?<D%%7|ZUrD M ,[b
x[ #OWD'Rz%O2Z,(y2TS \%O58S,+yb90U +IJn3S&*yA.@K35,}Y?<|FD)8n%5xިyUJopnS7U J^`Qk`.S"ŢD=p; QH%/18D4)yjT2h+y)[+%0+y?f+J^eYW'(y[:N%5xh^ug(ybp7luJ+y Nft%wH'1 I-`pD
p NL>j;{0^ 񱅘Bli!ֵZa-ībS q8Bi!?Z-jb@ Bg!gX
YG-1:q>: :!ƵC !pU u!X,mb~~{Q1="2zzzB g!^Y'@Tzoj#F_وlllaa#{A؃؈m1lO66 6cxF<e#+ۈm6boqFl#Vوm6yB<jA<ژGhcṃycAؿ; +k!̣y16`.h7Wdxb'2=1ouOlOD'zb'r<<O{=Q"O{ <<Q^"=艑4OO8OOLD'rVDl]0ѲpB"PJ=xb'sjUHDN@{BxBz=&O<5XuhzOl-ՓyvO;=y'd'w{r'JO=QrOTx"<Q*OTш쥞'6й%
DOtCmO A<1'z{io{ ;t?~~SǥB;9GQs 8}iӏ:i3JdZg$-uF2g-w&
g
tQؙAeN;s™G'sSSLUBv*g98au*ΩzgE:jphDjrZ(lfg3qZZllZG iw.MմٹNpvfN':wIŜS}t<B;6):yt^lU:y;oҹλtw>Χt]|IW;_ӵw~\Z8M]C7f'M}67nw`FwvSMXN{tNt;w.=Cn=o[JKqw%=3n%]EϹu@/M^r&zB'i{=tϣ w^FݫZm]i4wϏ{|BΞ%w1??uп$쟀kOmI>R{vGS!,_;> ||"d-8!-~Kw=ft4|&t676胃_lef̧q;/G_lȞ5fi{z|1PK#xq&PK
+RNomodule-info.classmON0b(!VH@
`<JSQQؕǞݱg GZ穯oL yL2a^zJmBe /k˃|) :=t ?}8KGF>EvpBFIP Gv񘙈Y*Jr7dA87$SozƱ>'4mgaSB_=
^"ҕw59cWXj5Nt[aۮPKNoPK
++R,р2
3META-INF/maven/com.StreamPi/TextBlockAction/pom.xmlUۊ0}߯oRݔ%(^Rh e¾Qb[V.+KHfStM&w8!OCH|$λ"i7d't"`=$_Y_ (W\&ǜnÇů2BL&>9z}*^?c@!yz2] OY + 3K= hdWL(>EB<M{so_mǢi e@mR+ꠋRi)| f94 ˳VJ'D8+꒟mB]qX E!`֡)Ӛ2lic?=4fqձ?">3vq1r RɊdA?WFwLtm1|Sz\{|7.ςE- 5$__kGm4RQwSϹ goSz
<KI|]4.cm|6^ʍvjˮP)$ͭɹ+Ps(ܿ#~aώE!TC|QsY@1 k≠y cx/Jk6 Xߐ PK,р2
PK
+R
a[]:META-INF/maven/com.StreamPi/TextBlockAction/pom.propertiesSv.JM,IMQHTp,HLHUM,KS033J//-LM .* J,*LKL.V8'g;&dqi[C==.PK
a[]PK+Rҏ<X_META-INF/MANIFEST.MFPK
+R AMETA-INF/PK
+RAcom/PK
+R Acom/StreamPi/PK
+RAcom/StreamPi/TextBlockAction/PK
+RAIMETA-INF/maven/PK
+RAvMETA-INF/maven/com.StreamPi/PK
+R,AMETA-INF/maven/com.StreamPi/TextBlockAction/PK+R#xq&2com/StreamPi/TextBlockAction/TextBlockAction.classPK+RNomodule-info.classPK++R,р2
3META-INF/maven/com.StreamPi/TextBlockAction/pom.xmlPK+R
a[]:META-INF/maven/com.StreamPi/TextBlockAction/pom.propertiesPK z
package com.StreamPi.Server.Controller;
package com.StreamPi.Server.Controller;
import com.StreamPi.ActionAPI.Action.ServerConnection;
import com.StreamPi.ActionAPI.Action.ServerConnection;
import com.StreamPi.ActionAPI.Action.PropertySaver;
import com.StreamPi.ActionAPI.Action.PropertySaver;
import com.StreamPi.ActionAPI.NormalAction.NormalAction;
import com.StreamPi.ActionAPI.NormalAction.NormalAction;
import com.StreamPi.Server.Main;
import com.StreamPi.Server.Main;
import com.StreamPi.Server.Action.NormalActionPlugins;
import com.StreamPi.Server.Action.NormalActionPlugins;
import com.StreamPi.Server.Connection.ClientConnections;
import com.StreamPi.Server.Connection.ClientConnections;
import com.StreamPi.Server.Connection.MainServer;
import com.StreamPi.Server.Connection.MainServer;
import com.StreamPi.Server.IO.Config;
import com.StreamPi.Server.IO.Config;
import com.StreamPi.Server.Info.ServerInfo;
import com.StreamPi.Server.Info.ServerInfo;
import com.StreamPi.Server.Window.Base;
import com.StreamPi.Server.Window.Base;
import com.StreamPi.Server.Window.Dashboard.DonatePopupContent;
import com.StreamPi.Server.Window.Dashboard.DonatePopupContent;
import com.StreamPi.Server.Window.FirstTimeUse.FirstTimeUse;
import com.StreamPi.Server.Window.FirstTimeUse.FirstTimeUse;
import com.StreamPi.Util.Alert.StreamPiAlert;
import com.StreamPi.Util.Alert.StreamPiAlert;
import com.StreamPi.Util.Alert.StreamPiAlertListener;
import com.StreamPi.Util.Alert.StreamPiAlertListener;
import com.StreamPi.Util.Alert.StreamPiAlertType;
import com.StreamPi.Util.Alert.StreamPiAlertType;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.SevereException;
import com.StreamPi.Util.Exception.SevereException;
import com.StreamPi.Util.IOHelper.IOHelper;
import com.StreamPi.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.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.InetAddress;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
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;
final SystemTray systemTray;
final SystemTray systemTray;
public void setupDashWindow() throws SevereException
public void setupDashWindow() throws SevereException
{
{
try
try
{
{
getStage().setTitle("StreamPi Server - "+InetAddress.getLocalHost().getCanonicalHostName()+":"+Config.getInstance().getPort()); //Sets title
getStage().setTitle("StreamPi Server - "+InetAddress.getLocalHost().getCanonicalHostName()+":"+Config.getInstance().getPort()); //Sets title
getStage().setOnCloseRequest(this::onCloseRequest);
getStage().setOnCloseRequest(this::onCloseRequest);
}
}
catch (UnknownHostException e)
catch (UnknownHostException e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException(e.getMessage());
throw new SevereException(e.getMessage());
}
}
}
}
private void checkPrePathDirectory() throws SevereException
private void checkPrePathDirectory() throws SevereException
{
{
try {
try {
File filex = new File(ServerInfo.getInstance().getPrePath());
File filex = new File(ServerInfo.getInstance().getPrePath());
System.out.println("SAX : "+filex.exists());
System.out.println("SAX : "+filex.exists());
if(!filex.exists())
if(!filex.exists())
{
{
filex.mkdirs();
filex.mkdirs();
IOHelper.unzip(Main.class.getResourceAsStream("Default.obj"), ServerInfo.getInstance().getPrePath());
IOHelper.unzip(Main.class.getResourceAsStream("Default.obj"), ServerInfo.getInstance().getPrePath());
}
}
}
}
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 {
checkPrePathDirectory();
checkPrePathDirectory();
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), 512, 300);
Scene s = new Scene(new FirstTimeUse(this, this), 512, 300);
stage.setResizable(false);
stage.setResizable(false);
stage.setScene(s);
stage.setScene(s);
stage.setTitle("StreamPi Server Setup");
stage.setTitle("StreamPi 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())
if(ServerInfo.getInstance().isStartMinimised())
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();
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();
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().getClientsSettings().loadData();
getSettingsPane().getClientsSettings().loadData();
mainServer.setPort(getConfig().getPort());
mainServer.setPort(getConfig().getPort());
mainServer.start();
mainServer.start();
}
}
catch (MinorException e)
catch (MinorException e)
{
{
handleMinorException(e);
handleMinorException(e);
}
}
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(){
systemTray = SystemTray.getSystemTray();
systemTray = SystemTray.getSystemTray();
mainServer = null;
mainServer = null;
}
}
public void onCloseRequest(WindowEvent event)
public void onCloseRequest(WindowEvent event)
{
{
try
try
{
{
if(Config.getInstance().getCloseOnX())
if(Config.getInstance().getCloseOnX())
{
{
getConfig().setStartupWindowSize(
getConfig().setStartupWindowSize(
getWidth(),
getWidth(),
getHeight()
getHeight()
);
);
getConfig().save();
getConfig().save();
onQuitApp();
onQuitApp();
NormalActionPlugins.getInstance().shutDownActions();
NormalActionPlugins.getInstance().shutDownActions();
Platform.exit();
Platform.exit();
}
}
else
else
{
{
minimiseApp();
minimiseApp();
event.consume();
event.consume();
}
}
}
}
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
{
{
if(SystemTray.isSupported())
if(SystemTray.isSupported())
{
{
if(getTrayIcon() == null)
if(getTrayIcon() == null)
initIconTray();
initIconTray();
systemTray.add(getTrayIcon());
systemTray.add(getTrayIcon());
//getStage().setIconified(true);
//getStage().setIconified(true);
getStage().hide();
getStage().hide();
}
}
else
else
{
{
new StreamPiAlert("System Tray Error", "Your System does not support System Tray", StreamPiAlertType.ERROR).show();
new StreamPiAlert("System Tray Error", "Your System does not support System Tray", StreamPiAlertType.ERROR).show();
}
}
}
}
catch(Exception e)
catch(Exception e)
{
{
throw new MinorException(e.getMessage());
throw new MinorException(e.getMessage());
}
}
}
}
public void initIconTray()
public void initIconTray()
{
{
Platform.setImplicitExit(false);
Platform.setImplicitExit(false);
PopupMenu popup = new PopupMenu();
PopupMenu popup = new PopupMenu();
MenuItem showItem = new MenuItem("Show");
MenuItem showItem = new MenuItem("Show");
showItem.addActionListener(l->{
showItem.addActionListener(l->{
systemTray.remove(getTrayIcon());
systemTray.remove(getTrayIcon());
Platform.runLater(()->{
Platform.runLater(()->{
//getStage().setIconified(false);
//getStage().setIconified(false);
getStage().show();
getStage().show();
});
});
});
});
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(showItem);
popup.add(showItem);
popup.addSeparator();
popup.addSeparator();
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")),
"StreamPi Server",
"StreamPi Server",
popup
popup
);
);
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());
getLogger().log(Level.SEVERE, e.getMessage());
e.printStackTrace();
e.printStackTrace();
Platform.runLater(()-> new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show());
Platform.runLater(()-> new StreamPiAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show());
}
}
@Override
@Override
public void handleSevereException(SevereException e) {
public void handleSevereException(SevereException e) {
getLogger().log(Level.SEVERE, e.getMessage());
getLogger().log(Level.SEVERE, e.getMessage());
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 boolean onNormalActionClicked(NormalAction action) {
public synchronized 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)
{
{
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().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.StreamPi.Util.Platform.Platform getPlatform() {
public com.StreamPi.Util.Platform.Platform getPlatform() {
return ServerInfo.getInstance().getPlatformType();
return ServerInfo.getInstance().getPlatformType();
}
}
}
}
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
import com.StreamPi.Server.UIPropertyBox.UIPropertyBox;
import com.StreamPi.Server.UIPropertyBox.UIPropertyBox;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.DisplayTextAlignment;
import com.StreamPi.ActionAPI.Action.DisplayTextAlignment;
import com.StreamPi.ActionAPI.Action.Location;
import com.StreamPi.ActionAPI.Action.Location;
import com.StreamPi.ActionAPI.ActionProperty.ClientProperties;
import com.StreamPi.ActionAPI.ActionProperty.ClientProperties;
import com.StreamPi.ActionAPI.ActionProperty.Property.ControlType;
import com.StreamPi.ActionAPI.ActionProperty.Property.ControlType;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Type;
import com.StreamPi.ActionAPI.ActionProperty.Property.Type;
import com.StreamPi.ActionAPI.OtherActions.CombineAction;
import com.StreamPi.ActionAPI.OtherActions.CombineAction;
import com.StreamPi.ActionAPI.OtherActions.FolderAction;
import com.StreamPi.ActionAPI.OtherActions.FolderAction;
import com.StreamPi.Server.Client.Client;
import com.StreamPi.Server.Client.Client;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Connection.ClientConnection;
import com.StreamPi.Server.Connection.ClientConnection;
import com.StreamPi.Server.Connection.ClientConnections;
import com.StreamPi.Server.Connection.ClientConnections;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Server.Window.ExceptionAndAlertHandler;
import com.StreamPi.Server.Window.ExceptionAndAlertHandler;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.SevereException;
import com.StreamPi.Util.Exception.SevereException;
import com.StreamPi.Util.FormHelper.HBoxInputBox;
import com.StreamPi.Util.FormHelper.HBoxInputBox;
import com.StreamPi.Util.FormHelper.HBoxInputBoxWithFileChooser;
import com.StreamPi.Util.FormHelper.HBoxInputBoxWithFileChooser;
import com.StreamPi.Util.FormHelper.SpaceFiller;
import com.StreamPi.Util.FormHelper.SpaceFiller;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.FXCollections;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.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 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.Arrays;
import java.util.Arrays;
import java.util.List;
import java.util.List;
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);
// VBox.setVgrow(this, Priority.SOMETIMES);
// VBox.setVgrow(this, Priority.SOMETIMES);
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");
// setPadding(new Insets(5,50,5,50));
// setPadding(new Insets(5,50,5,50));
// setMinHeight(245);
// setMinHeight(245);
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(310);
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");
FontIcon deleteIcon = new FontIcon("fas-trash");
FontIcon deleteIcon = new FontIcon("fas-trash");
deleteIcon.setIconColor(Paint.valueOf("#FF0000"));
deleteIcon.setIconColor(Paint.valueOf("#FF0000"));
deleteButton.setTextFill(Paint.valueOf("#FF0000"));
deleteButton.setTextFill(Paint.valueOf("#FF0000"));
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.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_action_heading_label");
actionHeadingLabel.getStyleClass().add("action_details_pane_action_heading_label");
HBox headingHBox = new HBox(actionHeadingLabel);
HBox headingHBox = new HBox(actionHeadingLabel);
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());
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);
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);
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"), new SpaceFiller(SpaceFiller.FillerType.HBox),
new HBox(new Label("Alignment"), new SpaceFiller(SpaceFiller.FillerType.HBox),
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;
System.out.println(action.getActionType());
logger.info("Action Display text : "+action.getDisplayText());
logger.info("Action Display text : "+action.getDisplayText());
clear();
clear();
renderActionProperties(false);
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(boolean isCombineChild) throws MinorException
public void renderActionProperties() throws MinorException
{
{
this.isCombineChild = isCombineChild;
displayNameTextField.setText(action.getDisplayText());
if(action.getLocation().getCol() == -1) //Combine Child action
isCombineChild = true;
else
isCombineChild = false;
displayNameTextField.setText(action.getDisplayText());
System.out.println(action.getDisplayText()+"@@@@::::"+isCombineChild);
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 {
logger.info("@@@@@ : "+action.getClientProperties().getSize());
logger.info("@@@@@ : "+action.getClientProperties().getSize());
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;
}
}
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(new SpaceFiller(SpaceFiller.FillerType.HBox));
hBox.getChildren().add(new SpaceFiller(SpaceFiller.FillerType.HBox));
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)
public void saveAction(Action action, boolean runAsync)
{
{
new Thread(
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
);
)
).start();
}
}
@Override
@Override
public void saveAction()
public void saveAction()
{
{
saveAction(action);
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 Thread(
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
)
);
).start();
}
}
}
}
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.Location;
import com.StreamPi.ActionAPI.Action.Location;
import com.StreamPi.ActionAPI.OtherActions.FolderAction;
import com.StreamPi.ActionAPI.OtherActions.FolderAction;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.MinorException;
import javafx.stage.Window;
import javafx.stage.Window;
public interface ActionDetailsPaneListener {
public interface ActionDetailsPaneListener {
void onActionClicked(Action action, ActionBox actionBox) throws MinorException;
void onActionClicked(Action action, ActionBox actionBox) throws MinorException;
void saveAction();
void saveAction();
void saveAction(Action action);
void saveAction(Action action, boolean runAsync);
void clear();
void clear();
void setSendIcon(boolean sendIcon);
void setSendIcon(boolean sendIcon);
void onOpenFolderButtonClicked();
void onOpenFolderButtonClicked();
Window getCurrentWindow();
Window getCurrentWindow();
}
}
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.Location;
import com.StreamPi.ActionAPI.Action.Location;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Type;
import com.StreamPi.ActionAPI.ActionProperty.Property.Type;
import com.StreamPi.ActionAPI.OtherActions.CombineAction;
import com.StreamPi.ActionAPI.OtherActions.CombineAction;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.MinorException;
import javafx.collections.FXCollections;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
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.text.Font;
import javafx.scene.text.Font;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.LinkedList;
import java.util.LinkedList;
import java.util.List;
import java.util.List;
public class CombineActionPropertiesPane extends VBox {
public class CombineActionPropertiesPane extends VBox {
private CombineAction combineAction;
private CombineAction combineAction;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
private ActionDetailsPane actionDetailsPane;
private ActionDetailsPane actionDetailsPane;
public CombineAction getCombineAction() {
public CombineAction getCombineAction() {
return combineAction;
return combineAction;
}
}
public CombineActionPropertiesPane(CombineAction combineAction, ClientProfile clientProfile, ActionDetailsPane actionDetailsPane) throws MinorException {
public CombineActionPropertiesPane(CombineAction combineAction, ClientProfile clientProfile, ActionDetailsPane actionDetailsPane) throws MinorException {
this.combineAction = combineAction;
this.combineAction = combineAction;
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
this.actionDetailsPane = actionDetailsPane;
this.actionDetailsPane = actionDetailsPane;
setSpacing(10.0);
setSpacing(10.0);
setPadding(new Insets(0,0,10,0));
setPadding(new Insets(0,0,10,0));
renderProps();
renderProps();
}
}
public void renderProps() throws MinorException {
public void renderProps() throws MinorException {
getChildren().clear();
getChildren().clear();
int i = 0;
int i = 0;
for(String actionID : combineAction.getChildrenIDSequential())
for(String actionID : combineAction.getChildrenIDSequential())
{
{
Action action = clientProfile.getActionByID(actionID);
Action action = clientProfile.getActionByID(actionID);
System.out.println("232323xxxxxxxxxxxx : "+action.getID());
System.out.println("232323xxxxxxxxxxxx : "+action.getID());
Button settingsButton = new Button();
Button settingsButton = new Button();
FontIcon settingsFontIcon = new FontIcon("fas-cog");
FontIcon settingsFontIcon = new FontIcon("fas-cog");
settingsButton.setGraphic(settingsFontIcon);
settingsButton.setGraphic(settingsFontIcon);
settingsButton.setOnAction(event -> onSettingsButtonClicked(action));
settingsButton.setOnAction(event -> onSettingsButtonClicked(action));
Button upButton = new Button();
Button upButton = new Button();
FontIcon upButtonFontIcon = new FontIcon("fas-chevron-up");
FontIcon upButtonFontIcon = new FontIcon("fas-chevron-up");
upButton.setGraphic(upButtonFontIcon);
upButton.setGraphic(upButtonFontIcon);
Button downButton = new Button();
Button downButton = new Button();
FontIcon downButtonFontIcon = new FontIcon("fas-chevron-down");
FontIcon downButtonFontIcon = new FontIcon("fas-chevron-down");
downButton.setGraphic(downButtonFontIcon);
downButton.setGraphic(downButtonFontIcon);
Label displayTextLabel = new Label(action.getDisplayText());
Label displayTextLabel = new Label(action.getDisplayText());
displayTextLabel.setId(action.getID());
displayTextLabel.setId(action.getID());
Region r = new Region();
Region r = new Region();
HBox.setHgrow(r, Priority.ALWAYS);
HBox.setHgrow(r, Priority.ALWAYS);
HBox actionHBox = new HBox(displayTextLabel, r, settingsButton, upButton, downButton);
HBox actionHBox = new HBox(displayTextLabel, r, settingsButton, upButton, downButton);
actionHBox.setSpacing(5.0);
actionHBox.setSpacing(5.0);
upButton.setUserData(i);
upButton.setUserData(i);
downButton.setUserData(i);
downButton.setUserData(i);
upButton.setOnAction(this::onUpButtonClicked);
upButton.setOnAction(this::onUpButtonClicked);
downButton.setOnAction(this::onDownButtonClicked);
downButton.setOnAction(this::onDownButtonClicked);
System.out.println("67878678678678");
System.out.println("67878678678678");
getChildren().add(actionHBox);
getChildren().add(actionHBox);
System.out.println("9mhmmn");
System.out.println("9mhmmn");
i++;
i++;
}
}
}
}
public void onSettingsButtonClicked(Action action)
public void onSettingsButtonClicked(Action action)
{
{
actionDetailsPane.clear();
actionDetailsPane.clear();
actionDetailsPane.setAction(action);
actionDetailsPane.setAction(action);
try {
try {
actionDetailsPane.renderActionProperties(true);
actionDetailsPane.renderActionProperties();
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public void onUpButtonClicked(ActionEvent event) {
public void onUpButtonClicked(ActionEvent event) {
try {
try {
Node node = (Node) event.getSource();
Node node = (Node) event.getSource();
int currentIndex = (int) node.getUserData();
int currentIndex = (int) node.getUserData();
if(currentIndex > 0)
if(currentIndex > 0)
{
{
Property current = combineAction.getClientProperties().getSingleProperty(currentIndex+"");
Property current = combineAction.getClientProperties().getSingleProperty(currentIndex+"");
Property aboveOne = combineAction.getClientProperties().getSingleProperty((currentIndex-1)+"");
Property aboveOne = combineAction.getClientProperties().getSingleProperty((currentIndex-1)+"");
combineAction.addChild(current.getRawValue(), currentIndex-1);
combineAction.addChild(current.getRawValue(), currentIndex-1);
combineAction.addChild(aboveOne.getRawValue(), currentIndex);
combineAction.addChild(aboveOne.getRawValue(), currentIndex);
actionDetailsPane.saveAction();
actionDetailsPane.saveAction();
renderProps();
renderProps();
}
}
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public void onDownButtonClicked(ActionEvent event)
public void onDownButtonClicked(ActionEvent event)
{
{
try {
try {
Node node = (Node) event.getSource();
Node node = (Node) event.getSource();
int currentIndex = (int) node.getUserData();
int currentIndex = (int) node.getUserData();
if(currentIndex < getChildren().size() - 1)
if(currentIndex < getChildren().size() - 1)
{
{
Property current = combineAction.getClientProperties().getSingleProperty(currentIndex+"");
Property current = combineAction.getClientProperties().getSingleProperty(currentIndex+"");
Property belowOne = combineAction.getClientProperties().getSingleProperty((currentIndex+1)+"");
Property belowOne = combineAction.getClientProperties().getSingleProperty((currentIndex+1)+"");
combineAction.addChild(current.getRawValue(), currentIndex+1);
combineAction.addChild(current.getRawValue(), currentIndex+1);
combineAction.addChild(belowOne.getRawValue(), currentIndex);
combineAction.addChild(belowOne.getRawValue(), currentIndex);
actionDetailsPane.saveAction();
actionDetailsPane.saveAction();
renderProps();
renderProps();
}
}
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public List<String> getFinalChildren()
public List<String> getFinalChildren()
{
{
ArrayList<String> children = new ArrayList<>();
ArrayList<String> children = new ArrayList<>();
for(int i = 0;i<getChildren().size();i++)
for(int i = 0;i<getChildren().size();i++)
{
{
HBox hBox = (HBox) getChildren().get(i);
HBox hBox = (HBox) getChildren().get(i);
Label label = (Label) hBox.getChildren().get(0);
Label label = (Label) hBox.getChildren().get(0);
children.add(label.getId());
children.add(label.getId());
}
}
return children;
return children;
}
}
}
}
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
import java.util.logging.Logger;
import java.util.logging.Logger;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Connection.ClientConnection;
import com.StreamPi.Server.Connection.ClientConnection;
import com.StreamPi.Server.Window.ExceptionAndAlertHandler;
import com.StreamPi.Server.Window.ExceptionAndAlertHandler;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.MinorException;
import com.StreamPi.Util.Exception.SevereException;
import com.StreamPi.Util.Exception.SevereException;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
public class OnDeleteActionTask extends Task<Void>
public class OnDeleteActionTask extends Task<Void>
{
{
private Logger logger;
private Logger logger;
public OnDeleteActionTask(ClientConnection connection, Action action, boolean isCombineChild,
public OnDeleteActionTask(ClientConnection connection, Action action, boolean isCombineChild,
CombineActionPropertiesPane combineActionPropertiesPane, ClientProfile clientProfile, ActionBox actionBox,
CombineActionPropertiesPane combineActionPropertiesPane, ClientProfile clientProfile, ActionBox actionBox,
ActionDetailsPane actionDetailsPane,
ActionDetailsPane actionDetailsPane,
ExceptionAndAlertHandler exceptionAndAlertHandler)
ExceptionAndAlertHandler exceptionAndAlertHandler, boolean runAsync)
{
{
this.connection = connection;
this.connection = connection;
this.action = action;
this.action = action;
this.isCombineChild = isCombineChild;
this.isCombineChild = isCombineChild;
this.combineActionPropertiesPane = combineActionPropertiesPane;
this.combineActionPropertiesPane = combineActionPropertiesPane;
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
this.actionBox = actionBox;
this.actionBox = actionBox;
this.actionDetailsPane = actionDetailsPane;
this.actionDetailsPane = actionDetailsPane;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
logger = Logger.getLogger(getClass().getName());
logger = Logger.getLogger(getClass().getName());
if(runAsync)
new Thread(this).start();
else
runTask();
}
}
private ClientConnection connection;
private ClientConnection connection;
private Action action;
private Action action;
private ActionBox actionBox;
private ActionBox actionBox;
private ActionDetailsPane actionDetailsPane;
private ActionDetailsPane actionDetailsPane;
private boolean isCombineChild;
private boolean isCombineChild;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
private CombineActionPropertiesPane combineActionPropertiesPane;
private CombineActionPropertiesPane combineActionPropertiesPane;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private void runTask()
private void runTask()
{
{
try {
try {
connection.deleteAction(clientProfile.getID(), action.getID());
connection.deleteAction(clientProfile.getID(), action.getID());
clientProfile.removeActionByID(action.getID());
clientProfile.removeActionByID(action.getID());
if(isCombineChild)
if(isCombineChild)
{
{
System.out.println("ACTION ID TO BE REMOVED : "+action.getID());
System.out.println("ACTION ID TO BE REMOVED : "+action.getID());
combineActionPropertiesPane.getCombineAction().removeChild(action.getID());
combineActionPropertiesPane.getCombineAction().removeChild(action.getID());
System.out.println("222155 "+combineActionPropertiesPane.getCombineAction().getClientProperties().getSize());
System.out.println("222155 "+combineActionPropertiesPane.getCombineAction().getClientProperties().getSize());
combineActionPropertiesPane.renderProps();
combineActionPropertiesPane.renderProps();
try {
try {
actionDetailsPane.saveAction(combineActionPropertiesPane.getCombineAction(), false);
System.out.println(combineActionPropertiesPane.getCombineAction().getDisplayText()+"@#@#@#@#@#@#");
actionDetailsPane.onActionClicked(
actionDetailsPane.onActionClicked(
combineActionPropertiesPane.getCombineAction(),
combineActionPropertiesPane.getCombineAction(),
actionBox
actionBox
);
);
actionDetailsPane.saveAction(combineActionPropertiesPane.getCombineAction());
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
else
else
{
{
Platform.runLater(()->{
Platform.runLater(()->{
actionBox.clear();
actionBox.clear();
actionDetailsPane.clear();
actionDetailsPane.clear();
});
});
}
}
// Platform.runLater(()->{
// Platform.runLater(()->{
// saveButton.setDisable(false);
// saveButton.setDisable(false);
// deleteButton.setDisable(false);
// deleteButton.setDisable(false);
// });
// });
}
}
catch (SevereException e)
catch (SevereException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
@Override
@Override
protected Void call() throws Exception
protected Void call() throws Exception
{
{
runTask();
runTask();
return null;
return null;
}
}
}
}
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
package com.StreamPi.Server.Window.Dashboard.ActionsDetailPane;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Arrays;
import java.util.List;
import java.util.List;
import java.util.logging.Logger;
import java.util.logging.Logger;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.Action;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.ActionType;
import com.StreamPi.ActionAPI.Action.DisplayTextAlignment;
import com.StreamPi.ActionAPI.Action.DisplayTextAlignment;
import com.StreamPi.ActionAPI.ActionProperty.ClientProperties;
import com.StreamPi.ActionAPI.ActionProperty.ClientProperties;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Property;
import com.StreamPi.ActionAPI.ActionProperty.Property.Type;
import com.StreamPi.ActionAPI.ActionProperty.Property.Type;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Client.ClientProfile;
import com.StreamPi.Server.Connection.ClientConnection;
import com.StreamPi.Server.Connection.ClientConnection;
import com.StreamPi.Server.UIPropertyBox.UIPropertyBox;
import com.StreamPi.Server.UIPropertyBox.UIPropertyBox;
import com.StreamPi.Server.Window.ExceptionAndAlertHandler;
import com.StreamPi.Server.Window.ExceptionAndAlertHandler;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Server.Window.Dashboard.ActionGridPane.ActionBox;
import com.StreamPi.Util.Exception.SevereException;
import com.StreamPi.Util.Exception.SevereException;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.scene.control.Button;
import javafx.scene.control.Button;
public class OnSaveActionTask extends Task<Void>
public class OnSaveActionTask extends Task<Void>
{
{
private Logger logger;
private Logger logger;
public OnSaveActionTask(ClientConnection connection, Action action, String displayNameText, boolean isCombineChild,
public OnSaveActionTask(ClientConnection connection, Action action, String displayNameText, boolean isCombineChild,
boolean isShowDisplayText, boolean isDefaultDisplayTextColour, String displayTextFontColour, boolean isClearIcon,
boolean isShowDisplayText, boolean isDefaultDisplayTextColour, String displayTextFontColour, boolean isClearIcon,
boolean isHideIcon, DisplayTextAlignment displayTextAlignment, boolean isTransparentBackground, String backgroundColour,
boolean isHideIcon, DisplayTextAlignment displayTextAlignment, boolean isTransparentBackground, String backgroundColour,
CombineActionPropertiesPane combineActionPropertiesPane, ClientProfile clientProfile, boolean sendIcon, ActionBox actionBox,
CombineActionPropertiesPane combineActionPropertiesPane, ClientProfile clientProfile, boolean sendIcon, ActionBox actionBox,
ArrayList<UIPropertyBox> actionClientProperties, ExceptionAndAlertHandler exceptionAndAlertHandler, Button saveButton, Button deleteButton)
ArrayList<UIPropertyBox> actionClientProperties, ExceptionAndAlertHandler exceptionAndAlertHandler, Button saveButton, Button deleteButton,
boolean runAsync)
{
{
this.saveButton = saveButton;
this.saveButton = saveButton;
this.deleteButton = deleteButton;
this.deleteButton = deleteButton;
this.connection = connection;
this.connection = connection;
this.action = action;
this.action = action;
this.displayNameText = displayNameText;
this.displayNameText = displayNameText;
this.isCombineChild = isCombineChild;
this.isCombineChild = isCombineChild;
this.isShowDisplayText = isShowDisplayText;
this.isShowDisplayText = isShowDisplayText;
this.isDefaultDisplayTextColour = isDefaultDisplayTextColour;
this.isDefaultDisplayTextColour = isDefaultDisplayTextColour;
this.displayTextFontColour = displayTextFontColour;
this.displayTextFontColour = displayTextFontColour;
this.isClearIcon = isClearIcon;
this.isClearIcon = isClearIcon;
this.isHideIcon = isHideIcon;
this.isHideIcon = isHideIcon;
this.displayTextAlignment = displayTextAlignment;
this.displayTextAlignment = displayTextAlignment;
this.isTransparentBackground = isTransparentBackground;
this.isTransparentBackground = isTransparentBackground;
this.combineActionPropertiesPane = combineActionPropertiesPane;
this.combineActionPropertiesPane = combineActionPropertiesPane;
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
this.sendIcon = sendIcon;
this.sendIcon = sendIcon;
this.actionBox = actionBox;
this.actionBox = actionBox;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.backgroundColour = backgroundColour;
this.backgroundColour = backgroundColour;
this.actionClientProperties = actionClientProperties;
this.actionClientProperties = actionClientProperties;
logger = Logger.getLogger(getClass().getName());
logger = Logger.getLogger(getClass().getName());
if(runAsync)
new Thread(this).start();
else
runTask();
}
}
private Button saveButton;
private Button saveButton;
private Button deleteButton;
private Button deleteButton;
private boolean isShowDisplayText;
private boolean isShowDisplayText;
private boolean isCombineChild;
private boolean isCombineChild;
private String displayNameText;
private String displayNameText;
private boolean isDefaultDisplayTextColour;
private boolean isDefaultDisplayTextColour;
private ArrayList<UIPropertyBox> actionClientProperties;
private ArrayList<UIPropertyBox> actionClientProperties;
private String displayTextFontColour;
private String displayTextFontColour;
private boolean isClearIcon;
private boolean isClearIcon;
private boolean isHideIcon;
private boolean isHideIcon;
private DisplayTextAlignment displayTextAlignment;
private DisplayTextAlignment displayTextAlignment;
private boolean isTransparentBackground;
private boolean isTransparentBackground;
private String backgroundColour;
private String backgroundColour;
private CombineActionPropertiesPane combineActionPropertiesPane;
private CombineActionPropertiesPane combineActionPropertiesPane;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
private boolean sendIcon;
private boolean sendIcon;
private ActionBox actionBox;
private ActionBox actionBox;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private Action action;
private Action action;
private ClientConnection connection;
private ClientConnection connection;
private void setSaveDeleteButtonState(boolean state)
private void setSaveDeleteButtonState(boolean state)
{
{
Platform.runLater(()->{
Platform.runLater(()->{
saveButton.setDisable(state);
saveButton.setDisable(state);
deleteButton.setDisable(state);
deleteButton.setDisable(state);
});
});
}
}
private void runTask()
private void runTask()
{
{
action.setDisplayText(displayNameText);
action.setDisplayText(displayNameText);
if(!isCombineChild)
if(!isCombineChild)
{
{
setSaveDeleteButtonState(true);
setSaveDeleteButtonState(true);
action.setShowDisplayText(isShowDisplayText);
action.setShowDisplayText(isShowDisplayText);
if(isDefaultDisplayTextColour)
if(isDefaultDisplayTextColour)
action.setDisplayTextFontColourHex("");
action.setDisplayTextFontColourHex("");
else
else
{
{
action.setDisplayTextFontColourHex(displayTextFontColour);
action.setDisplayTextFontColourHex(displayTextFontColour);
//String fontColour = "#" + displayTextColourPicker.getValue().toString().substring(2);
//String fontColour = "#" + displayTextColourPicker.getValue().toString().substring(2);
//action.setDisplayTextFontColourHex(fontColour);
//action.setDisplayTextFontColourHex(fontColour);
}
}
if(isClearIcon)
if(isClearIcon)
{
{
action.setIcon(null);
action.setIcon(null);
action.setHasIcon(false);
action.setHasIcon(false);
action.setShowIcon(false);
action.setShowIcon(false);
}
}
if(action.isHasIcon())
if(action.isHasIcon())
action.setShowIcon(isHideIcon);
action.setShowIcon(isHideIcon);
action.setDisplayTextAlignment(displayTextAlignment);
action.setDisplayTextAlignment(displayTextAlignment);
logger.info("BBBGGG : "+backgroundColour);
logger.info("BBBGGG : "+backgroundColour);
if(isTransparentBackground)
if(isTransparentBackground)
action.setBgColourHex("");
action.setBgColourHex("");
else
else
{
{
//String bgColour = "#" + actionBackgroundColourPicker.getValue().toString().substring(2);
//String bgColour = "#" + actionBackgroundColourPicker.getValue().toString().substring(2);
action.setBgColourHex(backgroundColour);
action.setBgColourHex(backgroundColour);
}
}
}
}
System.out.println("parent : "+action.getParent());
System.out.println("parent : "+action.getParent());
if(action.getActionType() == ActionType.COMBINE)
if(action.getActionType() == ActionType.COMBINE)
{
{
List<String> finalChildren = combineActionPropertiesPane.getFinalChildren();
List<String> finalChildren = combineActionPropertiesPane.getFinalChildren();
System.out.println("2334 "+finalChildren.size());
System.out.println("2334 "+finalChildren.size());
ClientProperties clientProperties = new ClientProperties();
ClientProperties clientProperties = new ClientProperties();
for(int i = 0;i<finalChildren.size();i++)
for(int i = 0;i<finalChildren.size();i++)
{
{
Property property = new Property(i+"", Type.STRING);
Property property = new Property(i+"", Type.STRING);
property.setRawValue(finalChildren.get(i));
property.setRawValue(finalChildren.get(i));
clientProperties.addProperty(property);
clientProperties.addProperty(property);
}
}
action.getClientProperties().set(clientProperties);
action.getClientProperties().set(clientProperties);
}
}
else
else
{
{
//properties
//properties
for (UIPropertyBox clientProperty : actionClientProperties) {
for (UIPropertyBox clientProperty : actionClientProperties) {
action.getClientProperties().get().get(clientProperty.getIndex()).setRawValue(clientProperty.getRawValue());
action.getClientProperties().get().get(clientProperty.getIndex()).setRawValue(clientProperty.getRawValue());
}
}
}
}
try
try
{
{
logger.info("Saving action ... "+action.isHasIcon()+"+"+sendIcon);
logger.info("Saving action ... "+action.isHasIcon()+"+"+sendIcon);
if(action.isHasIcon())
/*if(action.isHasIcon())
{
{
if(clientProfile.getActionByID(action.getID()).getIconAsByteArray() == null)
if(clientProfile.getActionByID(action.getID()).getIconAsByteArray() == null)
{
{
sendIcon = true;
sendIcon = true;
}
}
else
else
{
{
if(!Arrays.equals(action.getIconAsByteArray(), clientProfile.getActionByID(action.getID()).getIconAsByteArray()))
if(!Arrays.equals(action.getIconAsByteArray(), clientProfile.getActionByID(action.getID()).getIconAsByteArray()))
{
{
logger.info("Sending ...");
logger.info("Sending ...");
sendIcon = true;
sendIcon = true;
}
}
}
}
}
}*/
connection.saveActionDetails(clientProfile.getID(), action);
connection.saveActionDetails(clientProfile.getID(), action);
if(sendIcon)
if(sendIcon)
{
{
connection.sendIcon(clientProfile.getID(), action.getID(), action.getIconAsByteArray());
connection.sendIcon(clientProfile.getID(), action.getID(), action.getIconAsByteArray());
}
}
if(!isCombineChild)
if(!isCombineChild)
{
{
Platform.runLater(()->{
Platform.runLater(()->{
actionBox.clear();
actionBox.clear();
actionBox.setAction(action);
actionBox.setAction(action);
actionBox.baseInit();
actionBox.baseInit();
actionBox.init();
actionBox.init();
});
});
setSaveDeleteButtonState(false);
setSaveDeleteButtonState(false);
}
}
clientProfile.removeActionByID(action.getID());
clientProfile.removeActionByID(action.getID());
clientProfile.addAction(action);
clientProfile.addAction(action);
}
}
catch (SevereException e)
catch (SevereException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
catch (CloneNotSupportedException e)
catch (CloneNotSupportedException e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
}
}
@Override
@Override
protected Void call() throws Exception
protected Void call() throws Exception
{
{
runTask();
runTask();
return null;
return null;
}
}
}
}