Loading src/main/java/ecorp/easy/installer/controllers/MainWindowController.java +37 −23 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package ecorp.easy.installer.controllers; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.subcontrollers.AbstractSubController; import ecorp.easy.installer.EasyInstaller; import ecorp.easy.installer.controllers.stepControllers.CustomExecutableController; import ecorp.easy.installer.controllers.stepControllers.CustomStepController; import ecorp.easy.installer.controllers.stepControllers.StepController; import ecorp.easy.installer.models.Phone; import ecorp.easy.installer.models.steps.IStep; Loading Loading @@ -167,33 +169,34 @@ public class MainWindowController implements Initializable { if(currentSubRootId == null || currentSubRootId.isEmpty()){ currentSubRootId =loadSubUI("1-beforeYouBegin.fxml", "before_mTitle").getId(); currentSubRootId =loadSubUI("1-beforeYouBegin.fxml", "before_mTitle", null).getId(); }else{ switch(currentSubRootId){ case "beforeYouBeginRoot": changeView(currentSubRootId, "2-connectDevice.fxml", "connect_mTitle"); changeView(currentSubRootId, "2-connectDevice.fxml", "connect_mTitle", null); break; case "connectDeviceRoot": changeView(currentSubRootId, "3-enableADB.fxml", "devMode_mTitle"); changeView(currentSubRootId, "3-enableADB.fxml", "devMode_mTitle", null); break; case "enableDevMode": if(AppConstants.isWindowsOs()){ changeView(currentSubRootId, "3-2-checkDriverInstallation.fxml", "checkDriverInstall_mTitle"); changeView(currentSubRootId, "3-2-checkDriverInstallation.fxml", "checkDriverInstall_mTitle", null); }else{ changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle"); changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle", null); disableNextButton(true); } break; case "checkDriverInstallation": changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle"); changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle", null); disableNextButton(true); break; case "deviceDetectedRoot": changeView(currentSubRootId, "5-downloadSrc.fxml", "download_mTitle"); changeView(currentSubRootId, "5-downloadSrc.fxml", "download_mTitle", null); disableNextButton(true); break; case "uiRoot": case "downloadSceneRoot": StepController controller = null; String fxmlName = ""; String title ="installationTitle"; if(currentStepKey.equals(IStep.LAST_STEP_KEY)){ Loading @@ -210,7 +213,11 @@ public class MainWindowController implements Initializable { fxmlName = "6-3-unlockOEM.fxml"; break; case "custom": controller = new CustomStepController(); fxmlName="customStep.fxml"; break; case "custom-executable": controller = new CustomExecutableController(); fxmlName="customStep.fxml"; break; case "executable": Loading @@ -226,7 +233,7 @@ public class MainWindowController implements Initializable { } if(!fxmlName.isBlank()) changeView(currentSubRootId, fxmlName, title); changeView(currentSubRootId, fxmlName, title, controller); else logger.error("No interface to load!"); Loading @@ -242,10 +249,10 @@ public class MainWindowController implements Initializable { fxmlFileName = "9-feedback.fxml"; nextViewTitle ="feedback_mTitle"; } changeView(currentSubRootId, fxmlFileName, nextViewTitle); changeView(currentSubRootId, fxmlFileName, nextViewTitle, null); break; case "congratsRoot": changeView(currentSubRootId, "9-feedback.fxml", "feedback_mTitle"); changeView(currentSubRootId, "9-feedback.fxml", "feedback_mTitle", null); break; case "feedbackRoot": Platform.exit(); Loading @@ -258,7 +265,7 @@ public class MainWindowController implements Initializable { } public void retryToFlash(){ changeView(currentSubRootId, "6-flashScene.fxml", "installationTitle"); changeView(currentSubRootId, "6-flashScene.fxml", "installationTitle", null); } /** Loading @@ -284,8 +291,9 @@ public class MainWindowController implements Initializable { * @param previousNodeId * @param fxmlName * @param viewTitle * @param controller optionnal controller for the new UI. Should be null if already defined in FXML */ public void changeView(final String previousNodeId, final String fxmlName, final String viewTitle){ public void changeView(final String previousNodeId, final String fxmlName, final String viewTitle, StepController controller){ logger.debug("change view()"); Node elementNode = null; //get current subroot Loading @@ -306,7 +314,7 @@ public class MainWindowController implements Initializable { fadeOutTransition.setOnFinished(e -> { removeNodeFromRoot(previousNodeId); logger.debug("removing previous interface finished"); final Node subRoot = loadSubUI(fxmlName, viewTitle); final Node subRoot = loadSubUI(fxmlName, viewTitle, controller); if (subRoot != null) { currentSubRootId= subRoot.getId(); Loading @@ -321,35 +329,41 @@ public class MainWindowController implements Initializable { /** * Load UI from FXML file * @param fxmlName * @param controller an optionnal controller for the UI. Cann be null! * @return */ public FXMLLoader loadFXML(String fxmlName){ public FXMLLoader loadFXML(String fxmlName, StepController controller){ FXMLLoader loader; try{ loader = new FXMLLoader(getClass().getResource(EasyInstaller.FXML_PATH+fxmlName)); loader.setResources(i18n); loader.load(); Object ctrl = loader.getController(); if(ctrl != null && ctrl instanceof AbstractSubController) ((AbstractSubController)ctrl).setParentController(this); if(controller != null){ loader.setController(controller); } try{ loader.load(); }catch(IOException e){ logger.error("fxmlName = {}, error = {}", fxmlName, e.toString()); e.printStackTrace(); return null; } if(controller == null){ final Object ctrl = loader.getController(); if(ctrl != null && ctrl instanceof AbstractSubController) ((AbstractSubController)ctrl).setParentController(this); } return loader; } /** * Load the subScene from FXML and return the controller * @param fxmlName fxml file name * @param viewTitle the title for the new View * @param controller optionnal parameter. It's the controller for the UI if not defined in FXML * @return subRoot. */ public Node loadSubUI(final String fxmlName, final String viewTitle){ public Node loadSubUI(final String fxmlName, final String viewTitle, StepController controller){ if(viewTitle != null) titleLabel.setText(i18n.getString(viewTitle)); FXMLLoader loader = loadFXML(fxmlName); FXMLLoader loader = loadFXML(fxmlName, controller); if(loader == null) return null; Pane subRoot = (Pane) loader.getRoot(); Loading src/main/resources/fxml/customStep.fxml +1 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,7 @@ <VBox fx:id="uiRoot" alignment="TOP_CENTER" spacing="25" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="130.0" AnchorPane.bottomAnchor="80.0" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ecorp.easy.installer.controllers.stepControllers.CustomStepController"> xmlns:fx="http://javafx.com/fxml/1" > <children> <Label fx:id="titleLbl" wrapText="true" styleClass="subtitle" /> <HBox spacing="20" alignment="TOP_CENTER" VBox.vgrow="ALWAYS" maxWidth="1000.0" > Loading Loading
src/main/java/ecorp/easy/installer/controllers/MainWindowController.java +37 −23 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package ecorp.easy.installer.controllers; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.subcontrollers.AbstractSubController; import ecorp.easy.installer.EasyInstaller; import ecorp.easy.installer.controllers.stepControllers.CustomExecutableController; import ecorp.easy.installer.controllers.stepControllers.CustomStepController; import ecorp.easy.installer.controllers.stepControllers.StepController; import ecorp.easy.installer.models.Phone; import ecorp.easy.installer.models.steps.IStep; Loading Loading @@ -167,33 +169,34 @@ public class MainWindowController implements Initializable { if(currentSubRootId == null || currentSubRootId.isEmpty()){ currentSubRootId =loadSubUI("1-beforeYouBegin.fxml", "before_mTitle").getId(); currentSubRootId =loadSubUI("1-beforeYouBegin.fxml", "before_mTitle", null).getId(); }else{ switch(currentSubRootId){ case "beforeYouBeginRoot": changeView(currentSubRootId, "2-connectDevice.fxml", "connect_mTitle"); changeView(currentSubRootId, "2-connectDevice.fxml", "connect_mTitle", null); break; case "connectDeviceRoot": changeView(currentSubRootId, "3-enableADB.fxml", "devMode_mTitle"); changeView(currentSubRootId, "3-enableADB.fxml", "devMode_mTitle", null); break; case "enableDevMode": if(AppConstants.isWindowsOs()){ changeView(currentSubRootId, "3-2-checkDriverInstallation.fxml", "checkDriverInstall_mTitle"); changeView(currentSubRootId, "3-2-checkDriverInstallation.fxml", "checkDriverInstall_mTitle", null); }else{ changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle"); changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle", null); disableNextButton(true); } break; case "checkDriverInstallation": changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle"); changeView(currentSubRootId, "4-deviceDetected.fxml", "detect_mTitle", null); disableNextButton(true); break; case "deviceDetectedRoot": changeView(currentSubRootId, "5-downloadSrc.fxml", "download_mTitle"); changeView(currentSubRootId, "5-downloadSrc.fxml", "download_mTitle", null); disableNextButton(true); break; case "uiRoot": case "downloadSceneRoot": StepController controller = null; String fxmlName = ""; String title ="installationTitle"; if(currentStepKey.equals(IStep.LAST_STEP_KEY)){ Loading @@ -210,7 +213,11 @@ public class MainWindowController implements Initializable { fxmlName = "6-3-unlockOEM.fxml"; break; case "custom": controller = new CustomStepController(); fxmlName="customStep.fxml"; break; case "custom-executable": controller = new CustomExecutableController(); fxmlName="customStep.fxml"; break; case "executable": Loading @@ -226,7 +233,7 @@ public class MainWindowController implements Initializable { } if(!fxmlName.isBlank()) changeView(currentSubRootId, fxmlName, title); changeView(currentSubRootId, fxmlName, title, controller); else logger.error("No interface to load!"); Loading @@ -242,10 +249,10 @@ public class MainWindowController implements Initializable { fxmlFileName = "9-feedback.fxml"; nextViewTitle ="feedback_mTitle"; } changeView(currentSubRootId, fxmlFileName, nextViewTitle); changeView(currentSubRootId, fxmlFileName, nextViewTitle, null); break; case "congratsRoot": changeView(currentSubRootId, "9-feedback.fxml", "feedback_mTitle"); changeView(currentSubRootId, "9-feedback.fxml", "feedback_mTitle", null); break; case "feedbackRoot": Platform.exit(); Loading @@ -258,7 +265,7 @@ public class MainWindowController implements Initializable { } public void retryToFlash(){ changeView(currentSubRootId, "6-flashScene.fxml", "installationTitle"); changeView(currentSubRootId, "6-flashScene.fxml", "installationTitle", null); } /** Loading @@ -284,8 +291,9 @@ public class MainWindowController implements Initializable { * @param previousNodeId * @param fxmlName * @param viewTitle * @param controller optionnal controller for the new UI. Should be null if already defined in FXML */ public void changeView(final String previousNodeId, final String fxmlName, final String viewTitle){ public void changeView(final String previousNodeId, final String fxmlName, final String viewTitle, StepController controller){ logger.debug("change view()"); Node elementNode = null; //get current subroot Loading @@ -306,7 +314,7 @@ public class MainWindowController implements Initializable { fadeOutTransition.setOnFinished(e -> { removeNodeFromRoot(previousNodeId); logger.debug("removing previous interface finished"); final Node subRoot = loadSubUI(fxmlName, viewTitle); final Node subRoot = loadSubUI(fxmlName, viewTitle, controller); if (subRoot != null) { currentSubRootId= subRoot.getId(); Loading @@ -321,35 +329,41 @@ public class MainWindowController implements Initializable { /** * Load UI from FXML file * @param fxmlName * @param controller an optionnal controller for the UI. Cann be null! * @return */ public FXMLLoader loadFXML(String fxmlName){ public FXMLLoader loadFXML(String fxmlName, StepController controller){ FXMLLoader loader; try{ loader = new FXMLLoader(getClass().getResource(EasyInstaller.FXML_PATH+fxmlName)); loader.setResources(i18n); loader.load(); Object ctrl = loader.getController(); if(ctrl != null && ctrl instanceof AbstractSubController) ((AbstractSubController)ctrl).setParentController(this); if(controller != null){ loader.setController(controller); } try{ loader.load(); }catch(IOException e){ logger.error("fxmlName = {}, error = {}", fxmlName, e.toString()); e.printStackTrace(); return null; } if(controller == null){ final Object ctrl = loader.getController(); if(ctrl != null && ctrl instanceof AbstractSubController) ((AbstractSubController)ctrl).setParentController(this); } return loader; } /** * Load the subScene from FXML and return the controller * @param fxmlName fxml file name * @param viewTitle the title for the new View * @param controller optionnal parameter. It's the controller for the UI if not defined in FXML * @return subRoot. */ public Node loadSubUI(final String fxmlName, final String viewTitle){ public Node loadSubUI(final String fxmlName, final String viewTitle, StepController controller){ if(viewTitle != null) titleLabel.setText(i18n.getString(viewTitle)); FXMLLoader loader = loadFXML(fxmlName); FXMLLoader loader = loadFXML(fxmlName, controller); if(loader == null) return null; Pane subRoot = (Pane) loader.getRoot(); Loading
src/main/resources/fxml/customStep.fxml +1 −2 Original line number Diff line number Diff line Loading @@ -30,8 +30,7 @@ <VBox fx:id="uiRoot" alignment="TOP_CENTER" spacing="25" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="130.0" AnchorPane.bottomAnchor="80.0" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ecorp.easy.installer.controllers.stepControllers.CustomStepController"> xmlns:fx="http://javafx.com/fxml/1" > <children> <Label fx:id="titleLbl" wrapText="true" styleClass="subtitle" /> <HBox spacing="20" alignment="TOP_CENTER" VBox.vgrow="ALWAYS" maxWidth="1000.0" > Loading