From 7653f5c8e0c0466184871c0ec6fb544778e57f34 Mon Sep 17 00:00:00 2001 From: Victor Hertel Date: Sat, 1 Jul 2017 16:51:44 +0200 Subject: [PATCH] The basic structure of the generic GUI has been completed. Signed-off-by: Victor Hertel --- .../com/ksatstuttgart/usoc/ConfigHandler.java | 81 ++++++++++++++++++- .../com/ksatstuttgart/usoc/GroundSegment.java | 4 +- .../com/ksatstuttgart/usoc/GuiBuilder.java | 59 +++++++++++--- .../main/resources/config/config.properties | 61 +++++++++++--- .../resources/config/configMod.properties | 59 +++++++++++--- .../resources/fxml/CurrentStatePanel.fxml | 41 +++++++++- 6 files changed, 271 insertions(+), 34 deletions(-) diff --git a/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/ConfigHandler.java b/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/ConfigHandler.java index bdccb8f..e536fd5 100644 --- a/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/ConfigHandler.java +++ b/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/ConfigHandler.java @@ -213,14 +213,87 @@ public static boolean logMod() throws IOException { if ((! config.getProperty("tabTitle[" + counter + "]").equals(getConfigModValue("tabTitle[" + counter + "]")))) { logMod = true; } + if ((! config.getProperty("numberOfControlItems[" + counter + "]").equals(getConfigModValue("numberOfControlItems[" + counter + "]")))) { + logMod = true; + } + if ((! config.getProperty("textArea[" + counter + "]").equals(getConfigModValue("textArea[" + counter + "]")))) { + logMod = true; + } + + // Declares necessary parameters + int numberOfControlItems = Integer.parseInt(config.getProperty("numberOfControlItems[" + counter + "]")); + for (int j=1; j<=numberOfControlItems; j++) { + String control = config.getProperty("control[" + counter + "][" + j + "]"); + + // Checks for type of entered control item + switch (control) { + case "button": + if ((! config.getProperty("bText[" + counter + "][" + j + "]").equals(getConfigModValue("bText[" + counter + "][" + j + "]")))) { + logMod = true; + } + break; + case "textField": + if ((! config.getProperty("promptText[" + counter + "][" + j + "]").equals(getConfigModValue("promptText[" + counter + "][" + j + "]")))) { + logMod = true; + } + break; + case "label": + if ((! config.getProperty("lText[" + counter + "][" + j + "]").equals(getConfigModValue("lText[" + counter + "][" + j + "]")))) { + logMod = true; + } + break; + } + } } - + return logMod; } + /** + * Method checks if properties of the state panel has been modified. + * + * @return + * @throws java.io.IOException + */ + public static boolean stateMod() throws IOException { + + // Stores values from config.properties file into properties object 'configMods' + Properties config = getAllValues(); + int numberOfBoxes = Integer.parseInt(config.getProperty("numberOfBoxes")); + boolean stateMod = false; + + if (! config.getProperty("numberOfBoxes").equals(getConfigModValue("numberOfBoxes"))) { + stateMod = true; + } + + for (int counter=1; counter<=numberOfBoxes; counter++) { + if ((! config.getProperty("boxTitle[" + counter + "]").equals(getConfigModValue("boxTitle[" + counter + "]")))) { + stateMod = true; + } + if ((! config.getProperty("numberOfValues[" + counter + "]").equals(getConfigModValue("numberOfValues[" + counter + "]")))) { + stateMod = true; + } + + // Declares necessary parameters + int numberOfValues = Integer.parseInt(config.getProperty("numberOfValues[" + counter + "]")); + for (int j=1; j<=numberOfValues; j++) { + if ((! config.getProperty("keyword[" + counter + "][" + j + "]").equals(getConfigModValue("keyword[" + counter + "][" + j + "]")))) { + stateMod = true; + } + } + + } + + System.out.println(stateMod); + return stateMod; + } + + + + /** * Method checks if config.properties has been modified. * @@ -230,7 +303,7 @@ public static boolean logMod() throws IOException { public static boolean fileMod() throws IOException { boolean fileMod; - if( !experimentNameMod() && !chartMod() && !logMod() ) { + if( !experimentNameMod() && !chartMod() && !logMod() && !stateMod() ) { fileMod = false; } else { fileMod = true; @@ -310,6 +383,10 @@ public static void rebuildGui() throws IOException { if ( logMod() ) { GuiBuilder.logBuilder(); } + // Checks if log panel properties has been modified since last compilation + if ( stateMod() ) { + GuiBuilder.currentStateBuilder(); + } } else { // Checks if config.properties file has been modified diff --git a/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GroundSegment.java b/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GroundSegment.java index 56c928d..3923810 100755 --- a/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GroundSegment.java +++ b/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GroundSegment.java @@ -53,7 +53,9 @@ public void start(Stage stage) { * Checks whether a regeneration of the FXML structure is * necessary and carries it out in case it is */ - ConfigHandler.rebuildGui(); + //ConfigHandler.rebuildGui(); + ConfigHandler.stateMod(); + ConfigHandler.updateConfigMod(); // Java Swing GUI //new MainController(new MainFrame()); diff --git a/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GuiBuilder.java b/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GuiBuilder.java index e7e93aa..975342d 100644 --- a/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GuiBuilder.java +++ b/Universal-Space-Operations-Center/src/main/java/com/ksatstuttgart/usoc/GuiBuilder.java @@ -87,9 +87,7 @@ public static int[] getGridPosition( int input ) { * @throws java.io.IOException */ public static void chartBuilder() throws IOException { - - // Generates GridPane for charts - + // Declares necessary parameters Properties config = ConfigHandler.getAllValues(); int numberOfCharts = Integer.parseInt(config.getProperty("numberOfCharts")); @@ -300,22 +298,65 @@ public static void logBuilder() throws FileNotFoundException, IOException { */ public static void currentStateBuilder() throws IOException { + // Declares necessary parameters + Properties config = ConfigHandler.getAllValues(); + int numberOfBoxes = Integer.parseInt(config.getProperty("numberOfBoxes")); String fileName = "CurrentStatePanel.fxml"; String filePath = "src/main/resources/fxml/"; + // Writes data in CurrentStatePanel.fxml file PrintWriter writer = new PrintWriter(filePath + fileName); - writer.println(" \n" + " \n"); writer.println(" \n" - + " "); + + " \n" + + " \n" + + " "); - /** - * Method is not complete yet - */ + // Generates boxes + for (int counter=1; counter<=numberOfBoxes; counter++) { + writer.println(" \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " "); + + // Declares necessary parameters + int numberOfValues = Integer.parseInt(config.getProperty("numberOfValues[" + counter + "]")); + int numberOfRows; + + // Sets number of rows depending on required number of control items + if (numberOfValues%2 == 0) { + numberOfRows = numberOfValues/2; + } else { + numberOfRows = (numberOfValues + 1)/2; + } - writer.println(" \n" + // Writes FXML data + for (int i=1; i<=numberOfRows; i++) { + writer.println(" "); + } + writer.println(" \n" + + " \n" + + " \n" + + " "); + } + + writer.println(" \n" + + " \n" + + " \n" + ""); writer.close(); + + // Prints status update + System.out.println("Data panel has been updated!"); } } \ No newline at end of file diff --git a/Universal-Space-Operations-Center/src/main/resources/config/config.properties b/Universal-Space-Operations-Center/src/main/resources/config/config.properties index 542e529..2aec7e9 100644 --- a/Universal-Space-Operations-Center/src/main/resources/config/config.properties +++ b/Universal-Space-Operations-Center/src/main/resources/config/config.properties @@ -78,8 +78,8 @@ y[5] = y-Achse 5 # Log tabs # Mandatory: YES # Expected input: boolean -serialPanel = true -iridiumPanel = true +serialPanel = false +iridiumPanel = false # # Number of additional tabs in the log panel # Mandatory: YES @@ -111,31 +111,72 @@ numberOfAddTabs = 2 # # Mandatory: YES tabTitle[1] = test -tabTitle[2] = Nr. 4 +tabTitle[2] = Nr. 2 # Number of control items within the tab # Mandatory: YES # Expected input: int -numberOfControlItems[1] = 3 +numberOfControlItems[1] = 4 numberOfControlItems[2] = 5 # Textarea # Mandatory: YES # Expected input: boolean textArea[1] = true -textArea[2] = false +textArea[2] = true # Configurtion of control items control[1][1] = button - bText[1][1] = Button 1 + bText[1][1] = Button control[1][2] = label - lText[1][2] = Label 1 + lText[1][2] = Label control[1][3] = textField promptText[1][3] = Prompt Text +control[1][4] = button + bText[1][4] = Hi control[2][1] = button - bText[2][1] = Button 1 + bText[2][1] = Button 2 control[2][2] = label lText[2][2] = Label 1 control[2][3] = textField - promptText[2][3] = Prompt Text + promptText[2][3] = Prompt control[2][4] = label lText[2][4] = Text control[2][5] = textField - promptText[2][5] = Blabla \ No newline at end of file + promptText[2][5] = Blabla + + + + + + +# STATE PROPERTIES +# +# Number of boxes in the state panel +# Mandatory: YES +# Expected input: int +numberOfBoxes = 2 +# +# Parameters have to be passed for the specified number of boxes +# and appropriate to the syntax shown in the example. Keywords and +# values are arranged in rows in a two column grid pane: +# boxTitle[i] = testTitle +# numberOfValues[i] = 3 +# keyword[i][j] = 3 +# with j = {1,2,3,...} as number keyword in box +# with i = {1,2,3,...} as number of boxes +# +# Mandatory: YES +boxTitle[1] = test +boxTitle[2] = Nr. 5 +# Number of values within the box +# Mandatory: YES +# Expected input: int +numberOfValues[1] = 3 +numberOfValues[2] = 5 +# Configurtion of boxes +keyword[1][1] = button +keyword[1][2] = label +keyword[1][3] = textField +keyword[2][1] = button +keyword[2][2] = label +keyword[2][3] = textField +keyword[2][4] = label +keyword[2][5] = textField \ No newline at end of file diff --git a/Universal-Space-Operations-Center/src/main/resources/config/configMod.properties b/Universal-Space-Operations-Center/src/main/resources/config/configMod.properties index a9bb8bc..7b4b47e 100644 --- a/Universal-Space-Operations-Center/src/main/resources/config/configMod.properties +++ b/Universal-Space-Operations-Center/src/main/resources/config/configMod.properties @@ -3,23 +3,60 @@ # The structure is fixed and manual interventions # and modifications are not intended! -- listing properties -- +keyword[2][2]=label +serialPanel=false +keyword[2][5]=textField +boxTitle[1]=test +control[1][1]=button +numberOfControlItems[2]=5 +control[1][4]=button +x[3]=x-Achse 3 +control[2][3]=textField +numberOfValues[1]=3 +promptText[2][3]=Prompt y[1]=y-Achse 1 +bText[1][1]=Button +textArea[2]=true y[4]=y-Achse 4 -numberOfAddTabs=0 -chartTitle[1]=Diagram 1 +bText[1][4]=Hi +lText[1][2]=Label +lText[2][4]=Text +keyword[1][2]=label +chartTitle[3]=Diagram 3 +numberOfBoxes=2 +tabTitle[2]=Nr. 2 +keyword[2][1]=button +keyword[2][4]=label +numberOfCharts=5 +control[1][3]=textField +numberOfControlItems[1]=4 x[2]=x-Achse 2 +promptText[1][3]=Prompt Text x[5]=x-Achse 5 -chartTitle[4]=Diagram 4 -serialPanel=true -y[2]=y-Achse 2 -iridiumPanel=true -y[5]=y-Achse 5 +control[2][2]=label +control[2][5]=textField +promptText[2][5]=Blabla +textArea[1]=true +y[3]=y-Achse 3 experimentName=PAPELL -x[3]=x-Achse 3 +iridiumPanel=false +keyword[1][1]=button chartTitle[2]=Diagram 2 +tabTitle[1]=test chartTitle[5]=Diagram 5 -y[3]=y-Achse 3 -numberOfCharts=5 +numberOfAddTabs=2 +keyword[2][3]=textField +boxTitle[2]=Nr. 5 +control[1][2]=label x[1]=x-Achse 1 -chartTitle[3]=Diagram 3 x[4]=x-Achse 4 +control[2][1]=button +control[2][4]=label +numberOfValues[2]=5 +y[2]=y-Achse 2 +y[5]=y-Achse 5 +bText[2][1]=Button 2 +lText[2][2]=Label 1 +chartTitle[1]=Diagram 1 +keyword[1][3]=textField +chartTitle[4]=Diagram 4 diff --git a/Universal-Space-Operations-Center/src/main/resources/fxml/CurrentStatePanel.fxml b/Universal-Space-Operations-Center/src/main/resources/fxml/CurrentStatePanel.fxml index d780cdf..a294c32 100644 --- a/Universal-Space-Operations-Center/src/main/resources/fxml/CurrentStatePanel.fxml +++ b/Universal-Space-Operations-Center/src/main/resources/fxml/CurrentStatePanel.fxml @@ -2,6 +2,45 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +