88import javafx .scene .Node ;
99import javafx .scene .Parent ;
1010import javafx .scene .Scene ;
11- import javafx .scene .control .Button ;
12- import javafx .scene .control .CheckBox ;
13- import javafx .scene .control .Label ;
14- import javafx .scene .control .TextField ;
11+ import javafx .scene .control .*;
1512import javafx .stage .DirectoryChooser ;
1613import javafx .stage .Stage ;
1714import org .springframework .beans .factory .annotation .Autowired ;
@@ -29,6 +26,8 @@ public class WelcomeViewFXController {
2926 @ FXML private Label informationLabel ;
3027 @ FXML private CheckBox appButton ;
3128 @ FXML private CheckBox systemButton ;
29+ @ FXML private CheckBox securityButton ;
30+ @ FXML private Label securityLabel ;
3231
3332 @ Autowired public appConfig appConfig ;
3433
@@ -48,15 +47,17 @@ private void scan(ActionEvent event) throws IOException {
4847 return ;
4948 }
5049
51- if (!appButton .isSelected () && !systemButton .isSelected ()) {
50+ if (!appButton .isSelected () && !systemButton .isSelected () && ! securityButton . isSelected () ) {
5251 informationLabel .setText ("Please select at least one type of logs" );
5352 return ;
5453 }
5554
55+
56+
5657 ApplicationContext springContext = ApplicationContextProvider .getApplicationContext ();
5758
5859 FXMLLoader loader = new FXMLLoader (getClass ().getResource ("/view/LoadingScreen.fxml" ));
59- loader .setControllerFactory (springContext ::getBean ); // <-- magiczna linia
60+ loader .setControllerFactory (springContext ::getBean ); // Spring Boot starter by JavaFX !!IMPORTANT!!
6061 Parent root = loader .load ();
6162
6263 Stage stage = (Stage ) ((Node ) event .getSource ()).getScene ().getWindow ();
@@ -99,4 +100,33 @@ private void systemButtonON(ActionEvent event) throws IOException {
99100 appConfig .setCsvSystem (systemButton .isSelected ());
100101 IO .println ("System logs export : " + appConfig .isCsvSystem ());
101102 }
103+
104+ @ FXML
105+ private void securityButtonON (ActionEvent event ) throws IOException {
106+ if (securityButton .isSelected ()) {
107+ boolean proceed = askForSecurityPermission ();
108+ if (!proceed ) {
109+ securityButton .setSelected (false );
110+ securityLabel .setText ("Admin permission required!" );
111+ appConfig .setCsvSecurity (false );
112+ return ;
113+ } else {
114+ securityLabel .setText ("Admin permission granted!" );
115+ appConfig .setCsvSecurity (true );
116+ }
117+ } else {
118+ appConfig .setCsvSecurity (false );
119+ securityLabel .setText ("(Requires Admin Permission)" );
120+ }
121+ }
122+
123+ private boolean askForSecurityPermission () {
124+ Alert alert = new Alert (Alert .AlertType .CONFIRMATION );
125+ alert .setTitle ("Administrator permission required" );
126+ alert .setHeaderText ("Security log requires admin privileges" );
127+ alert .setContentText ("To read Security logs, Windows requires administrator approval.\n \n " +
128+ "Click OK to continue (you may see a UAC popup)." );
129+
130+ return alert .showAndWait ().filter (btn -> btn == ButtonType .OK ).isPresent ();
131+ }
102132}
0 commit comments