|  | @@ -12,9 +12,12 @@ import java.io.File;
 | 
											
												
													
														|  |  import java.io.FileNotFoundException;
 |  |  import java.io.FileNotFoundException;
 | 
											
												
													
														|  |  import java.io.FileReader;
 |  |  import java.io.FileReader;
 | 
											
												
													
														|  |  import java.io.IOException;
 |  |  import java.io.IOException;
 | 
											
												
													
														|  | 
 |  | +import java.util.concurrent.atomic.AtomicBoolean;
 | 
											
												
													
														|  |  import javafx.application.Application;
 |  |  import javafx.application.Application;
 | 
											
												
													
														|  |  import javafx.application.Platform;
 |  |  import javafx.application.Platform;
 | 
											
												
													
														|  |  import javafx.scene.Scene;
 |  |  import javafx.scene.Scene;
 | 
											
												
													
														|  | 
 |  | +import javafx.scene.control.Alert;
 | 
											
												
													
														|  | 
 |  | +import javafx.scene.control.Alert.AlertType;
 | 
											
												
													
														|  |  import javafx.scene.image.Image;
 |  |  import javafx.scene.image.Image;
 | 
											
												
													
														|  |  import javafx.scene.layout.VBox;
 |  |  import javafx.scene.layout.VBox;
 | 
											
												
													
														|  |  import javafx.scene.web.WebView;
 |  |  import javafx.scene.web.WebView;
 | 
											
										
											
												
													
														|  | @@ -25,61 +28,66 @@ import javafx.stage.Stage;
 | 
											
												
													
														|  |   * @author Loquicom <contact@loquicom.fr>
 |  |   * @author Loquicom <contact@loquicom.fr>
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  public class WebFx extends Application implements Runnable {
 |  |  public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public static Stage stage;
 |  |      public static Stage stage;
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public static AtomicBoolean ini = new AtomicBoolean(false);
 | 
											
												
													
														|  | 
 |  | +    public static AtomicBoolean wait = new AtomicBoolean(false);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    protected double zoom = 1;
 | 
											
												
													
														|  |      protected int width = 800;
 |  |      protected int width = 800;
 | 
											
												
													
														|  |      protected int height = 800;
 |  |      protected int height = 800;
 | 
											
												
													
														|  |      protected String title = "WFX";
 |  |      protected String title = "WFX";
 | 
											
												
													
														|  |      protected String html = "<div style=\"margin-top: 48vh\"><h1 style=\"font-family: Arial\"><div style=\"text-align: center\">Loading...</div></h1></div>";
 |  |      protected String html = "<div style=\"margin-top: 48vh\"><h1 style=\"font-family: Arial\"><div style=\"text-align: center\">Loading...</div></h1></div>";
 | 
											
												
													
														|  |      protected String icon = null;
 |  |      protected String icon = null;
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public WebFx() {
 |  |      public WebFx() {
 | 
											
												
													
														|  |          WebFxConfig config = WebFxConfig.getInstance();
 |  |          WebFxConfig config = WebFxConfig.getInstance();
 | 
											
												
													
														|  |          config.setUpWebFx(this);
 |  |          config.setUpWebFx(this);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public WebFx(String configPath) {
 |  |      public WebFx(String configPath) {
 | 
											
												
													
														|  |          WebFxConfig config = WebFxConfig.getInstance(configPath);
 |  |          WebFxConfig config = WebFxConfig.getInstance(configPath);
 | 
											
												
													
														|  |          config.setUpWebFx(this);
 |  |          config.setUpWebFx(this);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /* --- Getter/Setter --- */
 |  |      /* --- Getter/Setter --- */
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public void setZoom(double zoom) {
 | 
											
												
													
														|  | 
 |  | +        this.zoom = zoom;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public void setSize(int width, int height) {
 |  |      public void setSize(int width, int height) {
 | 
											
												
													
														|  |          this.width = width;
 |  |          this.width = width;
 | 
											
												
													
														|  |          this.height = height;
 |  |          this.height = height;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | -    public void setTitle(String title){
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public void setTitle(String title) {
 | 
											
												
													
														|  |          this.title = title;
 |  |          this.title = title;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | -    public void setHtml(String html){
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public void setHtml(String html) {
 | 
											
												
													
														|  |          this.html = html;
 |  |          this.html = html;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | -    public void setHtmlFile(String htmlFile){
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public void setHtmlFile(String htmlFile) {
 | 
											
												
													
														|  |          String content = this.fileGetContent(htmlFile);
 |  |          String content = this.fileGetContent(htmlFile);
 | 
											
												
													
														|  | -        if(content != null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (content != null) {
 | 
											
												
													
														|  |              this.html = content;
 |  |              this.html = content;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | -    public void setIcon(String path){
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public void setIcon(String path) {
 | 
											
												
													
														|  |          this.icon = "file:" + path;
 |  |          this.icon = "file:" + path;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /* --- Méthodes JavaFx --- */
 |  |      /* --- Méthodes JavaFx --- */
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  |      public void launch() {
 |  |      public void launch() {
 | 
											
												
													
														|  |          Application.launch();
 |  |          Application.launch();
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      public void end() {
 |  |      public void end() {
 | 
											
												
													
														|  |          Platform.exit();
 |  |          Platform.exit();
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public void start(final Stage stage) {
 |  |      public void start(final Stage stage) {
 | 
											
												
													
														|  |          //Creation element graphiques
 |  |          //Creation element graphiques
 | 
											
										
											
												
													
														|  | @@ -87,6 +95,7 @@ public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  |          VBox root = new VBox();
 |  |          VBox root = new VBox();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          //Modification taille
 |  |          //Modification taille
 | 
											
												
													
														|  | 
 |  | +        wv.setZoom(this.zoom);
 | 
											
												
													
														|  |          wv.setMinWidth(this.width);
 |  |          wv.setMinWidth(this.width);
 | 
											
												
													
														|  |          wv.setMinHeight(this.height);
 |  |          wv.setMinHeight(this.height);
 | 
											
												
													
														|  |          root.setMinWidth(this.width);
 |  |          root.setMinWidth(this.width);
 | 
											
										
											
												
													
														|  | @@ -108,17 +117,16 @@ public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  |                  + "-fx-border-insets: 5;"
 |  |                  + "-fx-border-insets: 5;"
 | 
											
												
													
														|  |                  + "-fx-border-radius: 5;"
 |  |                  + "-fx-border-radius: 5;"
 | 
											
												
													
														|  |                  + "-fx-border-color: blue;");*/
 |  |                  + "-fx-border-color: blue;");*/
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |          //Creation et ajout de la scene
 |  |          //Creation et ajout de la scene
 | 
											
												
													
														|  |          Scene scene = new Scene(root);
 |  |          Scene scene = new Scene(root);
 | 
											
												
													
														|  |          WebFx.stage.setScene(scene);
 |  |          WebFx.stage.setScene(scene);
 | 
											
												
													
														|  | -        
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          //Parametrage stage
 |  |          //Parametrage stage
 | 
											
												
													
														|  |          WebFx.stage.setTitle(title);
 |  |          WebFx.stage.setTitle(title);
 | 
											
												
													
														|  | -        if(this.icon != null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (this.icon != null) {
 | 
											
												
													
														|  |              WebFx.stage.getIcons().add(new Image(this.icon));
 |  |              WebFx.stage.getIcons().add(new Image(this.icon));
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          //Handler
 |  |          //Handler
 | 
											
												
													
														|  |          WebFx.stage.setOnCloseRequest(event -> {
 |  |          WebFx.stage.setOnCloseRequest(event -> {
 | 
											
												
													
														|  |              BomberStudent.end();
 |  |              BomberStudent.end();
 | 
											
										
											
												
													
														|  | @@ -129,10 +137,10 @@ public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          //Affiche la fenetre
 |  |          //Affiche la fenetre
 | 
											
												
													
														|  |          WebFx.stage.show();
 |  |          WebFx.stage.show();
 | 
											
												
													
														|  | 
 |  | +        ini.set(true);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /* --- Méthodes modification fenetre --- */
 |  |      /* --- Méthodes modification fenetre --- */
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  |      public void loadHtml(String html) {
 |  |      public void loadHtml(String html) {
 | 
											
												
													
														|  |          Platform.runLater(new Runnable() {
 |  |          Platform.runLater(new Runnable() {
 | 
											
												
													
														|  |              @Override
 |  |              @Override
 | 
											
										
											
												
													
														|  | @@ -143,31 +151,44 @@ public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          });
 |  |          });
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | -    public boolean loadFile(String path){
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public boolean loadFile(String path) {
 | 
											
												
													
														|  |          //Recup le contenu du fichier
 |  |          //Recup le contenu du fichier
 | 
											
												
													
														|  |          String fileContent = this.fileGetContent(path);
 |  |          String fileContent = this.fileGetContent(path);
 | 
											
												
													
														|  | -        if(fileContent == null){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (fileContent == null) {
 | 
											
												
													
														|  |              return false;
 |  |              return false;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          //Chargement de l'html
 |  |          //Chargement de l'html
 | 
											
												
													
														|  |          this.loadHtml(fileContent);
 |  |          this.loadHtml(fileContent);
 | 
											
												
													
														|  |          return true;
 |  |          return true;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    public void alert(String title, String text) {
 | 
											
												
													
														|  | 
 |  | +        wait.set(true);
 | 
											
												
													
														|  | 
 |  | +        Platform.runLater(new Runnable() {
 | 
											
												
													
														|  | 
 |  | +            @Override
 | 
											
												
													
														|  | 
 |  | +            public void run() {
 | 
											
												
													
														|  | 
 |  | +                Alert alert = new Alert(AlertType.INFORMATION);
 | 
											
												
													
														|  | 
 |  | +                alert.setTitle(title);
 | 
											
												
													
														|  | 
 |  | +                alert.setHeaderText(null);
 | 
											
												
													
														|  | 
 |  | +                alert.setContentText(text);
 | 
											
												
													
														|  | 
 |  | +                alert.showAndWait();
 | 
											
												
													
														|  | 
 |  | +                WebFx.wait.set(false);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        });
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |      
 |  |      
 | 
											
												
													
														|  |      /* --- Methode Runneable --- */
 |  |      /* --- Methode Runneable --- */
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public void run() {
 |  |      public void run() {
 | 
											
												
													
														|  |          this.launch();
 |  |          this.launch();
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /* --- Methodes privées --- */
 |  |      /* --- Methodes privées --- */
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | -    private String fileGetContent(String path){
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private String fileGetContent(String path) {
 | 
											
												
													
														|  |          //Ouverture fichier
 |  |          //Ouverture fichier
 | 
											
												
													
														|  |          File f = new File(path);
 |  |          File f = new File(path);
 | 
											
												
													
														|  | -        if(!( f.exists() && f.canRead() )){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (!(f.exists() && f.canRead())) {
 | 
											
												
													
														|  |              return null;
 |  |              return null;
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          //Lecture fichier
 |  |          //Lecture fichier
 | 
											
										
											
												
													
														|  | @@ -175,8 +196,8 @@ public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              String buf;
 |  |              String buf;
 | 
											
												
													
														|  |              BufferedReader br = new BufferedReader(new FileReader(f));
 |  |              BufferedReader br = new BufferedReader(new FileReader(f));
 | 
											
												
													
														|  | -            while((buf = br.readLine()) != null){
 |  | 
 | 
											
												
													
														|  | -               fileContent += buf;
 |  | 
 | 
											
												
													
														|  | 
 |  | +            while ((buf = br.readLine()) != null) {
 | 
											
												
													
														|  | 
 |  | +                fileContent += buf;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              br.close();
 |  |              br.close();
 | 
											
												
													
														|  |          } catch (FileNotFoundException ex) {
 |  |          } catch (FileNotFoundException ex) {
 | 
											
										
											
												
													
														|  | @@ -188,5 +209,5 @@ public class WebFx extends Application implements Runnable {
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          return fileContent;
 |  |          return fileContent;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  }
 |  |  }
 |