Permalink
Browse files

Comments were added to the ConfigHandler class

Signed-off-by: Victor Hertel <victor.hertel@web.de>
  • Loading branch information...
vhertel committed Aug 27, 2017
1 parent fd1e82e commit 367e4fbf1dda72fa665844b03bc67b0e1142f885
@@ -23,7 +23,6 @@
*/
package com.ksatstuttgart.usoc.gui.setup;
import com.ksatstuttgart.usoc.gui.setup.GuiBuilder;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -44,7 +43,8 @@
/**
* Method counts number of items like charts.
* The number of elements of the transmitted keyword is counted according to the
* USOC syntax in the associated .properties file and is returned as an integer.
*
* @param keyword
* @param path
@@ -64,11 +64,10 @@ public static int countItems(String keyword, String path) throws IOException {
return numberOfItems;
}
/**
* Method gets values from properties file.
* All values ​​of the configuration file are read out and returned
* as a Java Properties structure.
*
* @param path
* @return
@@ -93,11 +92,9 @@ public static Properties getAllValues(String path) throws FileNotFoundException,
}
/**
* Method stores values of properties file and the date
* of it's last modification into configMod.properties file.
* The values ​​of the comparison file for detecting changes, configMod.properties,
* are overwritten with the current values ​​of the configuration file, config.properties.
*
* @param origin
* @param destination
@@ -109,21 +106,22 @@ public static void updateConfigMod(String origin, String destination) throws IOE
// Initialize file object
String filePath = "src/main/resources/";
// Writes data in propertes file
// Writes data in properties file
PrintWriter writer = new PrintWriter(filePath + destination);
writer.println("# This document serves as the basis for comparisons");
writer.println("# to determine modified values in the config file.");
writer.println("# The structure is fixed and manual interventions");
writer.println("# and modifications are not intended!");
// Writes all keywords and corresponding values in properties file
config.list(writer);
writer.close();
}
/**
* Method checks if value of properties files are the same.
* It is checked whether the passed keyword has changed since the last compilation.
* For this purpose, the configuration file config.properties is compared to
* the comparison file configMod.properties.
*
* @param keyword
* @param path
@@ -146,11 +144,10 @@ public static boolean valueMod(String keyword, String path, String pathMod) thro
return valueMod;
}
/**
* Method checks if name of experiment has been modified.
* It is checked whether the keyword experimentName has been changed in the
* configuration file since the last compilation. A corresponding boolean is returned.
*
* @param path
* @param pathMod
@@ -164,10 +161,9 @@ public static boolean experimentNameMod(String path, String pathMod) throws IOEx
}
/**
* Method checks if properties of the charts has been modified.
* It is checked whether changes to the configuration file have been made to the
* MainPanel since the last compilation. A corresponding boolean is returned.
*
* @param path
* @param pathMod
@@ -179,10 +175,11 @@ public static boolean mainPanelMod(String path, String pathMod) throws IOExcepti
int numberOfCharts = countItems("chartTitle", path);
boolean mainPanelMod = false;
// Checks whether the number of charts has been changed
if (countItems("chartTitle", path) != countItems("chartTitle", pathMod)) {
mainPanelMod = true;
}
// Checks whether the diagram title or the axis labels have been changed
for (int counter=1; counter<=numberOfCharts; counter++) {
if ( valueMod("chartTitle[" + counter + "]", path, pathMod) ||
valueMod("x[" + counter + "]", path, pathMod) ||
@@ -198,11 +195,10 @@ public static boolean mainPanelMod(String path, String pathMod) throws IOExcepti
return mainPanelMod;
}
/**
* Method checks if properties of the log panel has been modified.
* It is checked whether changes in the configuration file have been made to the
* LogPanel since the last compilation. A corresponding boolean is returned.
*
* @param path
* @param pathMod
@@ -219,28 +215,32 @@ public static boolean logPanelMod(String path, String pathMod) throws IOExceptio
logPanelMod = true;
}
// Checks whether the number of additional tabs has been changed
if (countItems("tabTitle", path) != countItems("tabTitle", pathMod) ||
countItems("textArea", path) != countItems("textArea", pathMod)) {
logPanelMod = true;
}
// Loops through additional tabs
for (int counter=1; counter<=numberOfAddTabs; counter++) {
// Checks whether the tab or the need for the TextArea has been changed
if ( valueMod("tabTitle[" + counter + "]", path, pathMod) ||
valueMod("textArea[" + counter + "]", path, pathMod) ) {
logPanelMod = true;
}
// Checks whether the number of control items within the tab has been changed
if (countItems("control[" + counter + "]", path) != countItems("control[" + counter + "]", pathMod)) {
logPanelMod = true;
}
// Declares necessary parameters
// Loops through control items with the tab
int numberOfControlItems = countItems("control[" + counter + "]", path);
for (int j=1; j<=numberOfControlItems; j++) {
// Checks for type of entered control item
// Checks whether the corresponding formatting has been changed
String control = config.getProperty("control[" + counter + "][" + j + "]");
// Checks for type of entered control item
switch (control) {
case "button":
if ( valueMod("bText[" + counter + "][" + j + "]", path, pathMod) ) {
@@ -259,16 +259,16 @@ public static boolean logPanelMod(String path, String pathMod) throws IOExceptio
break;
}
}
}
return logPanelMod;
}
/**
* Method checks if properties of the state panel has been modified.
* It is checked whether changes in the configuration file have been made to the
* StatePanel since the last compilation. A corresponding boolean is returned.
*
* @param path
* @param pathMod
@@ -278,40 +278,44 @@ public static boolean logPanelMod(String path, String pathMod) throws IOExceptio
public static boolean statePanelMod(String path, String pathMod) throws IOException {
int numberOfBoxes = countItems("boxTitle", path);
boolean statePanelMod = false;
boolean statePanel = valueMod("statePanel", path, pathMod);
boolean statePanelMod = false;
// Checks whether the number of boxes has been changed
if (countItems("boxTitle", path) != countItems("boxTitle", pathMod) || statePanel) {
statePanelMod = true;
}
// Loops through boxes
for (int counter=1; counter<=numberOfBoxes; counter++) {
if (valueMod("boxTitle[" + counter + "]", path, pathMod)) {
statePanelMod = true;
}
// Checks whether the number of keywords within the box has been changed
if (countItems("keyword[" + counter + "]", path) != countItems("keyword[" + counter + "]", pathMod)) {
statePanelMod = true;
}
// Declares necessary parameters
// Loops through items within the box
int numberOfValues = countItems("keyword[" + counter + "]", path);
for (int j=1; j<=numberOfValues; j++) {
// Checks whether a keyword has been changed
if ( valueMod("keyword[" + counter + "][" + j + "]", path, pathMod) ) {
statePanelMod = true;
}
}
}
return statePanelMod;
}
/**
* Method checks if properties file has been modified.
* It is checked whether the configuration file has been changed at any point
* since the last compilation. A corresponding boolean is returned.
*
* @param experimentNameMod
* @param chartMod
@@ -331,11 +335,11 @@ public static boolean fileMod(boolean experimentNameMod, boolean chartMod, boole
return fileMod;
}
/**
* Method checks if syntax of properties file is accurate.
* The syntax of the information in the configuration file is checked
* for correctness. A corresponding boolean is returned.
*
* @param path
* @return
@@ -349,15 +353,18 @@ public static boolean syntaxCheck(String path) throws IOException {
boolean syntaxCheck = true;
// Checks syntax of CHART PROPERTIES
// Check whether all necessary parameters have been passed on for the charts
if ( !(countItems("chartTitle", path) == countItems("x", path) &&
countItems("chartTitle", path) == countItems("y", path)) ) {
System.out.println("Syntax of CHART PROPERTIES is not accurate.");
syntaxCheck = false;
}
// Checks if the value of the GNSS3dView keyword has been specified correctly
if ( !(GNSS3dView.equals("true") || GNSS3dView.equals("false")) ) {
System.out.println("Syntax of GNSS3dView property is not accurate.");
syntaxCheck = false;
}
// Checks if the value of the statePanel keyword has been specified correctly
if ( !(statePanel.equals("true") || statePanel.equals("false")) ) {
System.out.println("Syntax of statePanel property is not accurate.");
syntaxCheck = false;
@@ -367,40 +374,46 @@ public static boolean syntaxCheck(String path) throws IOException {
int numberOfAddTabs = countItems("tabTitle", path);
String serialPanel = config.getProperty("serialPanel");
String iridiumPanel = config.getProperty("iridiumPanel");
// Checks if the value of the serialPanel keyword has been specified correctly
if ( !(serialPanel.equals("true") || serialPanel.equals("false")) ) {
System.out.println("Syntax of serialPanel property is not accurate.");
syntaxCheck = false;
}
// Checks if the value of the iridiumPanel keyword has been specified correctly
if ( !(iridiumPanel.equals("true") || iridiumPanel.equals("false")) ) {
System.out.println("Syntax of iridiumPanel property is not accurate.");
syntaxCheck = false;
}
// Loops through additional tabs
for (int counter=1; counter<=numberOfAddTabs; counter++) {
String textArea = config.getProperty("textArea[" + counter + "]");
int numberOfControlItems = countItems("control[" + counter + "]", path);
// Checks if the value of the textArea keyword has been specified correctly
if ( !(textArea.equals("true") || textArea.equals("false")) ) {
System.out.println("Syntax of textArea property is not accurate.");
syntaxCheck = false;
}
//Loops through control items within the tab
for (int j=1; j<=numberOfControlItems; j++) {
// Checks the specification of the control items
String control = config.getProperty("control[" + counter + "][" + j + "]");
if ( !(control.equals("button") || control.equals("label") || control.equals("textField")) ) {
System.out.println("Syntax of control item properties is not accurate.");
syntaxCheck = false;
}
}
}
return syntaxCheck;
}
/**
* Method checks for modified parameters and rebuilds
* the corresponding GUI structure.
* This method controls the syntax of the configuration file and executes
* the corresponding GuiBuilder methods depending on the change.
*
* @param path
* @param pathMod

0 comments on commit 367e4fb

Please sign in to comment.