Loading src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +23 −29 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ch.qos.logback.classic.LoggerContext; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.MainWindowController; import ecorp.easy.installer.graphics.FlashGlobalProgressManager; import ecorp.easy.installer.graphics.Instruction; import ecorp.easy.installer.helpers.DeviceHelper; import ecorp.easy.installer.logger.GUIAppender; import ecorp.easy.installer.logger.LogPathPropertyDefiner; Loading Loading @@ -66,7 +67,7 @@ public class FlashSceneController extends AbstractSubSteppedController implement //Current step UI element @FXML VBox flashSceneRoot; @FXML ProgressBar loadStepProgressIndicator; //'load' step type only @FXML TextFlow instructionsFlow; @FXML VBox instructionsFlow; @FXML Label stepTitleLabel; @FXML ImageView instructionImage; @FXML HBox instructionsContainer; Loading Loading @@ -136,16 +137,16 @@ public class FlashSceneController extends AbstractSubSteppedController implement * Add a new instruction to display without clearing the precedent * @param instruction the instruction to add */ public void addInstructionToDisplay(String instruction){ Label label = new Label(); if(i18n.containsKey(instruction)){ label.setText(i18n.getString(instruction)); }else label.setText("missing translation"); public void addInstructionToDisplay(String instructionKey){ String effectiveTxtKey = "all_lbl_missingTranslation"; if(i18n.containsKey(instructionKey)){ effectiveTxtKey = instructionKey; } Instruction instruction = new Instruction(effectiveTxtKey, i18n.getString(effectiveTxtKey)); label.setWrapText(true); //make text resize if longer than width label.minWidthProperty().bind(instructionsFlow.widthProperty()); //avoid to display two instruction on the same line label.maxWidthProperty().bind(instructionsFlow.widthProperty()); //Set max Width to its parent width instructionsFlow.getChildren().add(label); //instruction.setWrapText(true); //make text resize if longer than width instruction.maxWidthProperty().bind(instructionsFlow.widthProperty()); //Set max Width to its parent width instructionsFlow.getChildren().add(instruction); } /** Loading Loading @@ -301,7 +302,8 @@ public class FlashSceneController extends AbstractSubSteppedController implement //emphasize first Label instructionsVBox.setAlignment(Pos.TOP_LEFT); currentSubStepId = 0; //reset the value emphasizeLabel((Label)instructionsFlow.getChildren().get(0)); ((Instruction)instructionsFlow.getChildren().get(0)).emphasize(); parentController.setNextButtonVisible((instructionsFlow.getChildren().size() >1)); Loading Loading @@ -466,29 +468,21 @@ public class FlashSceneController extends AbstractSubSteppedController implement */ //get CurrentLabel Label currentSubStepLabel = (Label) children.get(currentSubStepId); Instruction currentInstruction = (Instruction) children.get(currentSubStepId); //get previousLabel Label nextSubStepLabel = (Label) children.get(currentSubStepId+1); Instruction nextInstruction = (Instruction) children.get(currentSubStepId+1); //Update the image using instruction key cod for(String instruction:instructionsKey){ if(i18n.containsKey(instruction) && i18n.getString(instruction).equals(nextSubStepLabel.getText() ) ){ Image img; try{ img = new Image(getClass().getResourceAsStream("/images/"+instructionsImagesBundle.getString(instruction))); }catch(Exception e){ logger.warn("onNextButtonClicked(), image key = {}, error = {}", instruction, e.toString()); img = null; } instructionImage.setImage(img); break; } final String nextTxtKey = nextInstruction.getKey(); if(instructionsImagesBundle.containsKey(nextTxtKey) ){ instructionImage.setImage(UiUtils.loadImage(instructionsImagesBundle.getString(nextTxtKey))); }else{ instructionImage.setImage(null); } //Deemphase previous instruction and emphasize new current one if(currentSubStepId < instructionsNumber-1){ deemphasizeLabel(currentSubStepLabel); emphasizeLabel(nextSubStepLabel); currentInstruction.trivialize(); nextInstruction.emphasize(); } } } No newline at end of file src/main/java/ecorp/easy/installer/graphics/Instruction.java 0 → 100644 +80 −0 Original line number Diff line number Diff line /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ecorp.easy.installer.graphics; import javafx.scene.control.Label; import javafx.scene.text.TextAlignment; import javafx.scene.text.TextFlow; /** * This class encapsulates data and behaviour of an instruction * @author vincent */ public class Instruction extends TextFlow{ private final static String HIGHLIGHTED_CSS = "currentSubStep"; private final String key; //Used for picture private final String text; private boolean emphasized; public Instruction(String key, String text) { this.text = text; this.key = key; emphasized = false; formatText(); getStyleClass().add("instructions"); this.setTextAlignment(TextAlignment.LEFT); } /** * Apply style to make is highlighted */ public void emphasize(){ getChildren().get(0).getStyleClass().add(HIGHLIGHTED_CSS); emphasized = true; } /** * Remove the style that make it highlighted */ public void trivialize(){ getChildren().get(0).getStyleClass().remove(HIGHLIGHTED_CSS); emphasized = false; } /** * Indicate if this text is emphasized or not * @return boolean true if emphasized */ public boolean isEmphasized(){ return emphasized; } /** * Share the text key used to get instruction * for translation system. It can be used to load * corresponding picture * @return String the key */ public String getKey(){ return key; } /** * Format the text for display * Note: This method is thought to evolve * to add new feature like detecting URL */ private void formatText() { //add basic behaviour first Label lbl = new Label(text); lbl.setWrapText(true); lbl.maxWidthProperty().bind(this.widthProperty().subtract(53.0)); getChildren().add(lbl); } } src/main/resources/css/style.css +1 −5 Original line number Diff line number Diff line Loading @@ -170,14 +170,10 @@ Button:pressed{ -fx-text-fill: #333333; } #instructionsFlow > Label{ .instructions{ -fx-padding: 0 0 0 60; } #instructionsFlow > .currentSubStep{ -fx-background-insets: -5 -7 -5 53; } /*user feelings */ .feelingBtn{ Loading src/main/resources/fxml/6-flashScene.fxml +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ <children> <Label fx:id="stepTitleLabel" text="Step / Step. Title" styleClass="subtitle" wrapText="true"/> <ProgressBar fx:id="loadStepProgressIndicator" progress="0.0" styleClass="progressBar" minWidth="550"/> <TextFlow fx:id="instructionsFlow" textAlignment="LEFT" VBox.vgrow="ALWAYS" lineSpacing="15.0" /> <VBox fx:id="instructionsFlow" VBox.vgrow="ALWAYS" spacing="15.0" /> </children> </VBox> <ImageView fx:id="instructionImage" preserveRatio="true" fitHeight="515.0" smooth="true"/> Loading Loading
src/main/java/ecorp/easy/installer/controllers/subcontrollers/FlashSceneController.java +23 −29 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ch.qos.logback.classic.LoggerContext; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.MainWindowController; import ecorp.easy.installer.graphics.FlashGlobalProgressManager; import ecorp.easy.installer.graphics.Instruction; import ecorp.easy.installer.helpers.DeviceHelper; import ecorp.easy.installer.logger.GUIAppender; import ecorp.easy.installer.logger.LogPathPropertyDefiner; Loading Loading @@ -66,7 +67,7 @@ public class FlashSceneController extends AbstractSubSteppedController implement //Current step UI element @FXML VBox flashSceneRoot; @FXML ProgressBar loadStepProgressIndicator; //'load' step type only @FXML TextFlow instructionsFlow; @FXML VBox instructionsFlow; @FXML Label stepTitleLabel; @FXML ImageView instructionImage; @FXML HBox instructionsContainer; Loading Loading @@ -136,16 +137,16 @@ public class FlashSceneController extends AbstractSubSteppedController implement * Add a new instruction to display without clearing the precedent * @param instruction the instruction to add */ public void addInstructionToDisplay(String instruction){ Label label = new Label(); if(i18n.containsKey(instruction)){ label.setText(i18n.getString(instruction)); }else label.setText("missing translation"); public void addInstructionToDisplay(String instructionKey){ String effectiveTxtKey = "all_lbl_missingTranslation"; if(i18n.containsKey(instructionKey)){ effectiveTxtKey = instructionKey; } Instruction instruction = new Instruction(effectiveTxtKey, i18n.getString(effectiveTxtKey)); label.setWrapText(true); //make text resize if longer than width label.minWidthProperty().bind(instructionsFlow.widthProperty()); //avoid to display two instruction on the same line label.maxWidthProperty().bind(instructionsFlow.widthProperty()); //Set max Width to its parent width instructionsFlow.getChildren().add(label); //instruction.setWrapText(true); //make text resize if longer than width instruction.maxWidthProperty().bind(instructionsFlow.widthProperty()); //Set max Width to its parent width instructionsFlow.getChildren().add(instruction); } /** Loading Loading @@ -301,7 +302,8 @@ public class FlashSceneController extends AbstractSubSteppedController implement //emphasize first Label instructionsVBox.setAlignment(Pos.TOP_LEFT); currentSubStepId = 0; //reset the value emphasizeLabel((Label)instructionsFlow.getChildren().get(0)); ((Instruction)instructionsFlow.getChildren().get(0)).emphasize(); parentController.setNextButtonVisible((instructionsFlow.getChildren().size() >1)); Loading Loading @@ -466,29 +468,21 @@ public class FlashSceneController extends AbstractSubSteppedController implement */ //get CurrentLabel Label currentSubStepLabel = (Label) children.get(currentSubStepId); Instruction currentInstruction = (Instruction) children.get(currentSubStepId); //get previousLabel Label nextSubStepLabel = (Label) children.get(currentSubStepId+1); Instruction nextInstruction = (Instruction) children.get(currentSubStepId+1); //Update the image using instruction key cod for(String instruction:instructionsKey){ if(i18n.containsKey(instruction) && i18n.getString(instruction).equals(nextSubStepLabel.getText() ) ){ Image img; try{ img = new Image(getClass().getResourceAsStream("/images/"+instructionsImagesBundle.getString(instruction))); }catch(Exception e){ logger.warn("onNextButtonClicked(), image key = {}, error = {}", instruction, e.toString()); img = null; } instructionImage.setImage(img); break; } final String nextTxtKey = nextInstruction.getKey(); if(instructionsImagesBundle.containsKey(nextTxtKey) ){ instructionImage.setImage(UiUtils.loadImage(instructionsImagesBundle.getString(nextTxtKey))); }else{ instructionImage.setImage(null); } //Deemphase previous instruction and emphasize new current one if(currentSubStepId < instructionsNumber-1){ deemphasizeLabel(currentSubStepLabel); emphasizeLabel(nextSubStepLabel); currentInstruction.trivialize(); nextInstruction.emphasize(); } } } No newline at end of file
src/main/java/ecorp/easy/installer/graphics/Instruction.java 0 → 100644 +80 −0 Original line number Diff line number Diff line /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ecorp.easy.installer.graphics; import javafx.scene.control.Label; import javafx.scene.text.TextAlignment; import javafx.scene.text.TextFlow; /** * This class encapsulates data and behaviour of an instruction * @author vincent */ public class Instruction extends TextFlow{ private final static String HIGHLIGHTED_CSS = "currentSubStep"; private final String key; //Used for picture private final String text; private boolean emphasized; public Instruction(String key, String text) { this.text = text; this.key = key; emphasized = false; formatText(); getStyleClass().add("instructions"); this.setTextAlignment(TextAlignment.LEFT); } /** * Apply style to make is highlighted */ public void emphasize(){ getChildren().get(0).getStyleClass().add(HIGHLIGHTED_CSS); emphasized = true; } /** * Remove the style that make it highlighted */ public void trivialize(){ getChildren().get(0).getStyleClass().remove(HIGHLIGHTED_CSS); emphasized = false; } /** * Indicate if this text is emphasized or not * @return boolean true if emphasized */ public boolean isEmphasized(){ return emphasized; } /** * Share the text key used to get instruction * for translation system. It can be used to load * corresponding picture * @return String the key */ public String getKey(){ return key; } /** * Format the text for display * Note: This method is thought to evolve * to add new feature like detecting URL */ private void formatText() { //add basic behaviour first Label lbl = new Label(text); lbl.setWrapText(true); lbl.maxWidthProperty().bind(this.widthProperty().subtract(53.0)); getChildren().add(lbl); } }
src/main/resources/css/style.css +1 −5 Original line number Diff line number Diff line Loading @@ -170,14 +170,10 @@ Button:pressed{ -fx-text-fill: #333333; } #instructionsFlow > Label{ .instructions{ -fx-padding: 0 0 0 60; } #instructionsFlow > .currentSubStep{ -fx-background-insets: -5 -7 -5 53; } /*user feelings */ .feelingBtn{ Loading
src/main/resources/fxml/6-flashScene.fxml +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ <children> <Label fx:id="stepTitleLabel" text="Step / Step. Title" styleClass="subtitle" wrapText="true"/> <ProgressBar fx:id="loadStepProgressIndicator" progress="0.0" styleClass="progressBar" minWidth="550"/> <TextFlow fx:id="instructionsFlow" textAlignment="LEFT" VBox.vgrow="ALWAYS" lineSpacing="15.0" /> <VBox fx:id="instructionsFlow" VBox.vgrow="ALWAYS" spacing="15.0" /> </children> </VBox> <ImageView fx:id="instructionImage" preserveRatio="true" fitHeight="515.0" smooth="true"/> Loading