diff --git a/src/main/java/fr/inra/po2vocabmanager/MainApp.java b/src/main/java/fr/inra/po2vocabmanager/MainApp.java index 1b6600084cccea07d148a12c693e110e5dd3dfbe..3b9ff8d2de8ad1544278109f711f1c348d7e70f9 100644 --- a/src/main/java/fr/inra/po2vocabmanager/MainApp.java +++ b/src/main/java/fr/inra/po2vocabmanager/MainApp.java @@ -34,6 +34,7 @@ import fr.inrae.po2engine.externalTools.RDF4JTools; import fr.inrae.po2engine.model.*; import fr.inrae.po2engine.model.dataModel.GeneralFile; import fr.inrae.po2engine.model.dataModel.ItineraryFile; +import fr.inrae.po2engine.utils.PO2Properties; import fr.inrae.po2engine.utils.ProgressPO2; import fr.inrae.po2engine.utils.Report; import fr.inrae.po2engine.utils.Tools; @@ -197,8 +198,7 @@ public class MainApp extends Application implements Launcher { @Override public void start(Stage primaryStage) throws Exception { MainApp.primaryStage = primaryStage; - splashScreenStage = new Stage(); - splashScreenStage.initStyle(StageStyle.UNDECORATED); + splashScreenStage = new Stage(StageStyle.UNDECORATED); run(null); // call manually the run method (update4J launcher) } @@ -220,8 +220,10 @@ public class MainApp extends Application implements Launcher { UITools.initProgressBar(); Application.setUserAgentStylesheet(null); -// StyleManager.getInstance().addUserAgentStylesheet("file:resources/stylesheet/stylesheet.css"); - title.bind(Bindings.when(fileName.isEqualTo("")).then(appName).otherwise(Bindings.concat(appName).concat(" - ").concat(fileName).concat(" - V ").concat(version))); + + StringProperty inprod = new SimpleStringProperty(); + inprod.bind(Bindings.when(PO2Properties.productionModeProperty().not()).then("!!! sandbox !!! ").otherwise("")); + title.bind(Bindings.when(fileName.isEqualTo("")).then(inprod.concat(appName)).otherwise(inprod.concat(appName).concat(" - ").concat(fileName).concat(" - V ").concat(version))); primaryStage.titleProperty().bind(Bindings.when(modified).then(title.concat(" *")).otherwise(title)); try { FXMLLoader loader = UITools.getFXMLLoader("view/Splash.fxml"); @@ -233,7 +235,6 @@ public class MainApp extends Application implements Launcher { splashScreenStage.getIcons().add(UITools.getImage("resources/images/PO2Manager.png")); splashScreenStage.setScene(sSplash); - splashScreenStage.show(); c.startSplash(this); @@ -652,6 +653,46 @@ public class MainApp extends Application implements Launcher { ); } + public boolean canLeaveApp() { + String message = "All "; + Boolean isModified = false; + if (ontologyControler.isModified()) { + message += "ontology "; + isModified = true; + } + if(dataControler.isModified()) { + if(isModified) { + message += "and "; + } + message += "project "; + isModified = true; + } + message += "unsaved will be lost. Are you sure ?"; + if(isModified) { + Alert confirm = new Alert(AlertType.CONFIRMATION); + confirm.setTitle("Change"); + confirm.setHeaderText(message); + ButtonType buttonCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); + ButtonType buttonYes = new ButtonType("Yes", ButtonData.YES); + confirm.getButtonTypes().setAll(buttonCancel, buttonYes); + confirm.initOwner(primaryStage); +// + Optional<ButtonType> result = confirm.showAndWait(); + if (result.isPresent()) { + if (result.get().equals(buttonCancel)) { + return false; + } + } + } + if (ontologyControler.getCurrentOntology() != null) { + ontologyControler.getCurrentOntology().unlockMode(); + } + if (dataControler.getCurrentData() != null) { + dataControler.getCurrentData().unlockMode(); + } + return true; + } + /** * Init the rootLayout */ @@ -676,48 +717,17 @@ public class MainApp extends Application implements Launcher { @Override public void handle(WindowEvent event) { - String message = "All "; - Boolean isModified = false; - if (ontologyControler.isModified()) { - message += "ontology "; - isModified = true; - } - if(dataControler.isModified()) { - if(isModified) { - message += "and "; + if(canLeaveApp()) { + if(executor != null) { + executor.shutdown(); + Tools.shutDownExecutor(); + MainApp.logger.debug("user leave app !"); } - message += "project "; - isModified = true; - } - message += "unsaved will be lost. Are you sure ?"; - if(isModified) { - Alert confirm = new Alert(AlertType.CONFIRMATION); - confirm.setTitle("Change"); - confirm.setHeaderText(message); - ButtonType buttonCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); - ButtonType buttonYes = new ButtonType("Yes", ButtonData.YES); - confirm.getButtonTypes().setAll(buttonCancel, buttonYes); - confirm.initOwner(primaryStage); -// - Optional<ButtonType> result = confirm.showAndWait(); - if (result.isPresent()) { - if (result.get().equals(buttonCancel)) { - event.consume(); - return; - } - } - } - if (ontologyControler.getCurrentOntology() != null) { - ontologyControler.getCurrentOntology().unlockMode(); - } - if (dataControler.getCurrentData() != null) { - dataControler.getCurrentData().unlockMode(); - } - if(executor != null) { - executor.shutdown(); - Tools.shutDownExecutor(); + } else { + event.consume(); } - MainApp.logger.debug("user leave app !"); + + } }); logger.debug("Initialisation du RootLayout OK"); diff --git a/src/main/java/fr/inra/po2vocabmanager/utils/UITools.java b/src/main/java/fr/inra/po2vocabmanager/utils/UITools.java index d2c1677842ca872e3eb1266254877cb6356c90e2..f9d56cad969a14b24f2ce4d14db6fdecadfbe016 100644 --- a/src/main/java/fr/inra/po2vocabmanager/utils/UITools.java +++ b/src/main/java/fr/inra/po2vocabmanager/utils/UITools.java @@ -212,6 +212,7 @@ public class UITools { } public static void initProgressBar() { + Tools.initProgress(); progressStage = new Stage(); progressStage.setMinWidth(300); listVBox = new VBox(5); diff --git a/src/main/java/fr/inra/po2vocabmanager/view/RootLayoutController.java b/src/main/java/fr/inra/po2vocabmanager/view/RootLayoutController.java index b2bc6372cc5585c22e20d1865b6374fe6acacc1d..d928f9ec79fe3c7bdcea9ac5000e71de4284127d 100644 --- a/src/main/java/fr/inra/po2vocabmanager/view/RootLayoutController.java +++ b/src/main/java/fr/inra/po2vocabmanager/view/RootLayoutController.java @@ -25,6 +25,7 @@ import fr.inrae.po2engine.externalTools.CloudConnector; import fr.inrae.po2engine.model.Datas; import fr.inrae.po2engine.model.Ontology; import fr.inrae.po2engine.model.dataModel.ProjectFile; +import fr.inrae.po2engine.utils.PO2Properties; import fr.inrae.po2engine.utils.Tools; import javafx.application.Platform; import javafx.beans.binding.Bindings; @@ -74,6 +75,8 @@ public class RootLayoutController { @FXML MenuItem itemExportOnto; @FXML + MenuItem switchMode; + @FXML Menu view; @FXML Menu conceptScheme; @@ -134,6 +137,15 @@ public class RootLayoutController { itemNewProject.visibleProperty().bind(mainApp.onDataViewProperty()); itemNewProject.disableProperty().bind(mainApp.onDataViewProperty().not()); + + switchMode.textProperty().bind(Bindings.when(PO2Properties.productionModeProperty()).then("Switch to SandBox").otherwise("Switch to Production")); + switchMode.setOnAction(event -> { + if(mainApp.canLeaveApp()) { + PO2Properties.setProductionMode(!PO2Properties.isProductionMode()); + MainApp.logger.info("switching mode. In production : " +PO2Properties.isProductionMode()); + mainApp.run(null); + } + }); } public void exportOnto() { diff --git a/src/main/java/fr/inra/po2vocabmanager/view/SplashController.java b/src/main/java/fr/inra/po2vocabmanager/view/SplashController.java index 5b79efbf6d5199ac1ab555132a57703d1399e5fe..9df78f9ba4ae7e5afe1b8a7a94807aa7cef0f318 100644 --- a/src/main/java/fr/inra/po2vocabmanager/view/SplashController.java +++ b/src/main/java/fr/inra/po2vocabmanager/view/SplashController.java @@ -117,6 +117,7 @@ public class SplashController implements Initializable { } + CloudConnector.reset(); CloudConnector.listOntology(doubleProgress, 0.5); CloudConnector.listData(doubleProgress,0.5); CloudConnector.refreshPlatform(); diff --git a/src/main/resources/PO2Engine.properties b/src/main/resources/PO2Engine.properties index 79ed2093f11e1e2ca0276b4d2c28ccc377dafd72..93120ce8fc745a8cb236326653bbf65ad6426ead 100644 --- a/src/main/resources/PO2Engine.properties +++ b/src/main/resources/PO2Engine.properties @@ -16,9 +16,8 @@ # SPDX-License-Identifier: MIT # -# Serveur de test : icotest.iate.inra.fr -# Serveur de production : quantum.mia-ps.inrae.fr -server.host=quantum.mia-ps.inrae.fr +server.production_host=quantum.mia-ps.inrae.fr +server.sandbox_host=icotest.iate.inra.fr nextCloud.listFile.login=listFiles nextCloud.listFile.password=guG7yais diff --git a/src/main/resources/fr/inra/po2vocabmanager/view/RootLayout.fxml b/src/main/resources/fr/inra/po2vocabmanager/view/RootLayout.fxml index 7bb1b2b963924a716138f8992feea09fa45c865f..b9f410965e8d2f264b50d7c4baf988a341edbb91 100644 --- a/src/main/resources/fr/inra/po2vocabmanager/view/RootLayout.fxml +++ b/src/main/resources/fr/inra/po2vocabmanager/view/RootLayout.fxml @@ -18,13 +18,10 @@ ~ SPDX-License-Identifier: MIT --> -<?import javafx.scene.control.Menu?> -<?import javafx.scene.control.MenuBar?> -<?import javafx.scene.control.MenuItem?> +<?import javafx.scene.control.*?> <?import javafx.scene.input.KeyCodeCombination?> <?import javafx.scene.layout.BorderPane?> - -<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="700.0" prefWidth="1300.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.inra.po2vocabmanager.view.RootLayoutController"> +<BorderPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="700.0" prefWidth="1300.0" xmlns="http://javafx.com/javafx/21.0.1" fx:controller="fr.inra.po2vocabmanager.view.RootLayoutController"> <top> <MenuBar BorderPane.alignment="CENTER"> <menus> @@ -64,6 +61,7 @@ </items> </Menu> <MenuItem mnemonicParsing="false" onAction="#showUnitCode" text="Show unit code" /> + <MenuItem fx:id="switchMode" mnemonicParsing="false" text="Switch to SandBox" /> </items> </Menu> <Menu mnemonicParsing="false" text="Help"> diff --git a/src/main/resources/resources/manifest b/src/main/resources/resources/manifest index 9daa1ae07c20d98d860c22d3f2ba754308f1320e..1c05a258e5ff334eefa4d2e79bddfb2e87e31472 100644 --- a/src/main/resources/resources/manifest +++ b/src/main/resources/resources/manifest @@ -6,9 +6,9 @@ Name: app_info Specification-Title: PO2Manager Specification-Version: 1.6.6.0 Specification-Vendor: fr.inrae -Compilation-DSTAMP: 20240319 -Compilation-TSTAMP: 1601 -Compilation-Date: March 19 2024 +Compilation-DSTAMP: 20240321 +Compilation-TSTAMP: 1037 +Compilation-Date: March 21 2024 Compilation-format: Changelog-URL: https://quantum.mia-ps.inrae.fr/PO2Manager/download/cha ngelog.txt