diff --git a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java index 14db165eca4169037faabeb7e02bdf2f3a77aeb3..69213286ab10c7a2e09563373c1fe4c151100e13 100644 --- a/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +++ b/src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java @@ -198,6 +198,53 @@ public class FlashSceneController extends AbstractSubSteppedController implement } } + /** + * @@inheritDoc + */ + @Override + public void onStepSuccess(DataBundle bundle) { + logger.debug("onStepSuccess"); + //Handle old stuff first + + UiUtils.hideNode(instructionsVBox); + UiUtils.hideNode(instructionImage); + UiUtils.hideNode(stepTitleIcon); + + //@TODO : change below instruction because it isn't displayed on step of load type. + instructionsFlow.getChildren().clear(); + parentController.setNextButtonVisible(false); + + //Create new stuff + final VBox successContainer = new VBox(); + successContainer.setAlignment(Pos.TOP_LEFT); + final Label successLabel = new Label(" Step succeed!"); + final Button okBtn = new Button("Ok"); //@TODO: the button is display on same line as text. This isn't what I want + + final ObservableList containerChildren = instructionsContainer.getChildren(); + + instructionsFlow.getChildren().add(new Label(stepTitleLabel.getText()+" succeed!")); + okBtn.setOnMouseClicked(( MouseEvent event) -> { + //Remove success node + containerChildren.remove(successContainer); + //Display again instructionsVBox, image and icon + //NOTE: there will probably be an issue with load step type + UiUtils.showNode(instructionsVBox); + UiUtils.showNode(instructionImage); + UiUtils.showNode(stepTitleIcon); + + //Unlock Flash Thread + synchronized(pauseLock){ + pauseLock.notify(); + } + + parentController.setNextButtonVisible(true); + }); + + successContainer.getChildren().addAll(successLabel, okBtn); + containerChildren.add(successContainer); + } + + /** * Update text and images instructions * @param instructionsKey diff --git a/src/main/java/ecorp/easy/installer/threads/FlashThread.java b/src/main/java/ecorp/easy/installer/threads/FlashThread.java index e6677dbc224e4862a3370f4416673b175fa46c3f..1d6ad21b6a7b640b8823c5a5f9ea49e0878ad27e 100644 --- a/src/main/java/ecorp/easy/installer/threads/FlashThread.java +++ b/src/main/java/ecorp/easy/installer/threads/FlashThread.java @@ -229,11 +229,7 @@ public class FlashThread extends Thread { if(stepType.equals(AppConstants.ASK_ACCOUNT_KEY) || stepType.equals(AppConstants.UNLOCK_OEM_KEY)) { - try{ - synchronized(pauseLock){ pauseLock.wait(); } - }catch (InterruptedException e) { - logger.error("error = "+e.toString()); - } + waitPauseLock(); } } @@ -246,6 +242,22 @@ public class FlashThread extends Thread { protected void doAfterToRunCommand() throws Exception{ atLeastOneError = (atLeastOneError || !success || cancelled); sendIssueLog = (atLeastOneError && !cancelled); + + final Command cmd = commands.get(currentStepCode); + + final String stepType = cmd.getNewUIValues().getType(); + + if(success + //Show only for "action" or "load" step + && !stepType.equals(AppConstants.ASK_ACCOUNT_KEY) + && !stepType.equals(AppConstants.UNLOCK_OEM_KEY) ) + { + //Update UI + Platform.runLater(()->{ + application.onStepSuccess(null); + }); + waitPauseLock(); + } } @@ -276,6 +288,17 @@ public class FlashThread extends Thread { }); } + /** + * Block the thread until pauseLock.notify() is called + */ + private void waitPauseLock(){ + try{ + synchronized(pauseLock){ pauseLock.wait(); } + }catch (InterruptedException e) { + logger.error("error = "+e.toString()); + } + } + protected void runInitialization() { running = true; } diff --git a/src/main/java/ecorp/easy/installer/utils/IFlashHandler.java b/src/main/java/ecorp/easy/installer/utils/IFlashHandler.java index 99b1e60da9383ae1f9e5175596250c30f46cbeea..d935445b80642bddce48f2b56dc8f3b46844edd7 100644 --- a/src/main/java/ecorp/easy/installer/utils/IFlashHandler.java +++ b/src/main/java/ecorp/easy/installer/utils/IFlashHandler.java @@ -33,4 +33,10 @@ public interface IFlashHandler { public void onFlashStop(DataBundle bundle); public void onLogToDisplayRecieved(String log); + + /** + * Update UI when the current step succeeded + * @param bundle data transfered from the thread + */ + public void onStepSuccess(DataBundle bundle); }