From 378240e6b68016359d20da0e96db564b23638176 Mon Sep 17 00:00:00 2001 From: Dimitris Anyfadakis Date: Sun, 31 Mar 2024 13:31:34 +0200 Subject: [PATCH] Add log4j2 logger --- pom.xml | 10 + .../java/controller/DiagramController.java | 3 +- .../java/manager/ClassDiagramManager.java | 15 +- src/main/java/manager/DiagramManager.java | 3 +- .../java/manager/PackageDiagramManager.java | 18 +- .../ClassDiagramArrangementManager.java | 5 +- .../DiagramArrangementManagerInterface.java | 3 +- .../PackageDiagramArrangementManager.java | 5 +- .../algorithms/LayoutAlgorithmType.java | 18 +- .../arrangement/geometry/DiagramGeometry.java | 10 +- .../diagram/exportation/GraphMLFile.java | 11 +- .../JavaFXClassDiagramExporter.java | 5 +- .../JavaFXPackageDiagramExporter.java | 5 +- .../PlantUMLClassDiagramImageExporter.java | 13 +- .../PlantUMLClassDiagramTextExporter.java | 5 +- .../PlantUMLPackageDiagramImageExporter.java | 10 +- .../javafx/JavaFXClassDiagramLoader.java | 16 +- .../javafx/JavaFXPackageDiagramLoader.java | 23 +- .../plantuml/PlantUMLClassifierVertexArc.java | 5 - .../plantuml/PlantUMLPackageVertexArc.java | 5 - src/main/java/parser/FileVisitor.java | 114 +++-- .../java/parser/IRelationshipIdentifier.java | 1 - src/main/java/parser/ProjectParser.java | 5 +- src/main/java/parser/factory/Parser.java | 1 - src/main/java/parser/tree/LeafNode.java | 8 +- src/main/java/parser/tree/PackageNode.java | 7 +- src/main/java/view/AboutPageController.java | 2 - src/main/java/view/AppStarterHelper.java | 18 +- src/main/java/view/DiagramCreation.java | 1 - src/main/java/view/DiagramVisualization.java | 50 +- .../view/DiagramVisualizationController.java | 29 +- src/main/java/view/MenuUtility.java | 1 - src/main/java/view/TreeViewResizer.java | 8 +- src/main/resources/logging/log4j2.xml | 12 + .../PlantUMLClassDiagramTextExporterTest.java | 15 +- .../graphml/GraphMLPackageVertexArcTest.java | 24 +- .../graphml/GraphMLPackageVertexTest.java | 2 - .../javafx/JavaFXClassDiagramLoaderTest.java | 1 - .../PlantUMLClassifierVertexTest.java | 2 - src/test/java/parser/FileVisitorTest.java | 10 +- src/test/java/parser/InterpreterTest.java | 42 +- src/test/java/parser/ProjectParserTest.java | 450 +++++++++--------- 42 files changed, 524 insertions(+), 467 deletions(-) create mode 100644 src/main/resources/logging/log4j2.xml diff --git a/pom.xml b/pom.xml index bde2e0b..13dd27c 100644 --- a/pom.xml +++ b/pom.xml @@ -130,6 +130,16 @@ maven-assembly-plugin 3.6.0 + + org.apache.logging.log4j + log4j-api + 2.17.1 + + + org.apache.logging.log4j + log4j-core + 2.17.1 + diff --git a/src/main/java/controller/DiagramController.java b/src/main/java/controller/DiagramController.java index 2c5d7af..93b6d5b 100644 --- a/src/main/java/controller/DiagramController.java +++ b/src/main/java/controller/DiagramController.java @@ -4,6 +4,7 @@ import manager.DiagramManager; import manager.DiagramManagerFactory; import manager.SourceProject; +import model.diagram.arrangement.algorithms.LayoutAlgorithmType; import java.io.File; import java.nio.file.Path; @@ -47,7 +48,7 @@ public SmartGraphPanel applyLayout() @Override public SmartGraphPanel applySpecificLayout(String choice) { - return diagramManager.applySpecificLayout(choice); + return diagramManager.applySpecificLayout(LayoutAlgorithmType.get(choice)); } @Override diff --git a/src/main/java/manager/ClassDiagramManager.java b/src/main/java/manager/ClassDiagramManager.java index 83d6548..cab6e2f 100644 --- a/src/main/java/manager/ClassDiagramManager.java +++ b/src/main/java/manager/ClassDiagramManager.java @@ -6,6 +6,7 @@ import model.diagram.ShadowCleaner; import model.diagram.arrangement.ClassDiagramArrangementManager; import model.diagram.arrangement.DiagramArrangementManagerInterface; +import model.diagram.arrangement.algorithms.LayoutAlgorithmType; import model.diagram.arrangement.geometry.DiagramGeometry; import model.diagram.exportation.CoordinatesUpdater; import model.diagram.exportation.DiagramExporter; @@ -148,10 +149,7 @@ public SmartGraphPanel applyLayout() DiagramGeometry nodesGeometry = classDiagram.getDiagramGeometry(); for (Vertex vertex : vertexCollection) { - if (!nodesGeometry.containsKey(vertex.element())) - { - continue; - } + if (!nodesGeometry.containsKey(vertex.element())) continue; Pair coordinates = nodesGeometry.getVertexGeometry(vertex.element()); graphView.setVertexPosition(vertex, coordinates.getValue0(), coordinates.getValue1()); @@ -161,15 +159,12 @@ public SmartGraphPanel applyLayout() } @Override - public SmartGraphPanel applySpecificLayout(String choice) + public SmartGraphPanel applySpecificLayout(LayoutAlgorithmType algorithmType) { - DiagramGeometry nodesGeometry = classDiagramArrangement.applyNewLayout(choice); + DiagramGeometry nodesGeometry = classDiagramArrangement.applyLayout(algorithmType); for (Vertex vertex : vertexCollection) { - if (!nodesGeometry.containsKey(vertex.element())) - { - continue; - } + if (!nodesGeometry.containsKey(vertex.element())) continue; Pair coordinates = nodesGeometry.getVertexGeometry(vertex.element()); graphView.setVertexPosition(vertex, diff --git a/src/main/java/manager/DiagramManager.java b/src/main/java/manager/DiagramManager.java index acd3fb7..037f346 100644 --- a/src/main/java/manager/DiagramManager.java +++ b/src/main/java/manager/DiagramManager.java @@ -1,6 +1,7 @@ package manager; import com.brunomnsilva.smartgraph.graphview.SmartGraphPanel; +import model.diagram.arrangement.algorithms.LayoutAlgorithmType; import model.diagram.arrangement.geometry.DiagramGeometry; import java.io.File; @@ -90,7 +91,7 @@ public interface DiagramManager SmartGraphPanel applyLayout(); // TODO JavaDoc - SmartGraphPanel applySpecificLayout(String choice); + SmartGraphPanel applySpecificLayout(LayoutAlgorithmType algorithmType); // TODO JavaDoc SmartGraphPanel visualizeLoadedJavaFXGraph(); diff --git a/src/main/java/manager/PackageDiagramManager.java b/src/main/java/manager/PackageDiagramManager.java index f615aa1..c6de985 100644 --- a/src/main/java/manager/PackageDiagramManager.java +++ b/src/main/java/manager/PackageDiagramManager.java @@ -6,6 +6,7 @@ import model.diagram.PackageDiagram; import model.diagram.arrangement.DiagramArrangementManagerInterface; import model.diagram.arrangement.PackageDiagramArrangementManager; +import model.diagram.arrangement.algorithms.LayoutAlgorithmType; import model.diagram.arrangement.geometry.DiagramGeometry; import model.diagram.exportation.CoordinatesUpdater; import model.diagram.exportation.DiagramExporter; @@ -16,19 +17,19 @@ import model.diagram.javafx.JavaFXPackageDiagramLoader; import model.diagram.javafx.JavaFXPackageVisualization; import model.diagram.javafx.JavaFXVisualization; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.javatuples.Pair; import java.io.File; import java.nio.file.Path; import java.util.Collection; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; public class PackageDiagramManager implements DiagramManager { - private static final Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + private static final Logger logger = LogManager.getLogger(PackageDiagramManager.class); private PackageDiagram packageDiagram; private DiagramArrangementManagerInterface packageDiagramArrangement; @@ -149,7 +150,7 @@ public SmartGraphPanel applyLayout() { if (!nodesGeometry.containsKey(vertex.element())) { - logger.log(Level.INFO, vertex.element()); + logger.debug("Vertex: {} not in vertices collection.", vertex.element()); continue; } @@ -161,15 +162,12 @@ public SmartGraphPanel applyLayout() } @Override - public SmartGraphPanel applySpecificLayout(String choice) + public SmartGraphPanel applySpecificLayout(LayoutAlgorithmType algorithmType) { - DiagramGeometry nodesGeometry = packageDiagramArrangement.applyNewLayout(choice); + DiagramGeometry nodesGeometry = packageDiagramArrangement.applyLayout(algorithmType); for (Vertex vertex : vertexCollection) { - if (!nodesGeometry.containsKey(vertex.element())) - { - continue; - } + if (!nodesGeometry.containsKey(vertex.element())) continue; Pair coordinates = nodesGeometry.getVertexGeometry(vertex.element()); graphView.setVertexPosition(vertex, coordinates.getValue0(), coordinates.getValue1()); diff --git a/src/main/java/model/diagram/arrangement/ClassDiagramArrangementManager.java b/src/main/java/model/diagram/arrangement/ClassDiagramArrangementManager.java index 764c130..83c4d31 100644 --- a/src/main/java/model/diagram/arrangement/ClassDiagramArrangementManager.java +++ b/src/main/java/model/diagram/arrangement/ClassDiagramArrangementManager.java @@ -64,10 +64,9 @@ public DiagramGeometry arrangeDiagram() @Override - public DiagramGeometry applyNewLayout(String algorithmType) + public DiagramGeometry applyLayout(LayoutAlgorithmType algorithmType) { - LayoutAlgorithmType algorithmEnumType = LayoutAlgorithmType.get(algorithmType); - LayoutAlgorithm layout = LayoutAlgorithmFactory.createLayoutAlgorithm(algorithmEnumType); + LayoutAlgorithm layout = LayoutAlgorithmFactory.createLayoutAlgorithm(algorithmType); layout.setGraph(graph); return layout.arrangeDiagram(); } diff --git a/src/main/java/model/diagram/arrangement/DiagramArrangementManagerInterface.java b/src/main/java/model/diagram/arrangement/DiagramArrangementManagerInterface.java index f085df5..f5591bc 100644 --- a/src/main/java/model/diagram/arrangement/DiagramArrangementManagerInterface.java +++ b/src/main/java/model/diagram/arrangement/DiagramArrangementManagerInterface.java @@ -1,5 +1,6 @@ package model.diagram.arrangement; +import model.diagram.arrangement.algorithms.LayoutAlgorithmType; import org.javatuples.Pair; import model.diagram.arrangement.geometry.DiagramGeometry; @@ -24,6 +25,6 @@ public interface DiagramArrangementManagerInterface DiagramGeometry arrangeDiagram(); // TODO JavaDoc - DiagramGeometry applyNewLayout(String choice); + DiagramGeometry applyLayout(LayoutAlgorithmType algorithmType); } diff --git a/src/main/java/model/diagram/arrangement/PackageDiagramArrangementManager.java b/src/main/java/model/diagram/arrangement/PackageDiagramArrangementManager.java index c67a414..50008d2 100644 --- a/src/main/java/model/diagram/arrangement/PackageDiagramArrangementManager.java +++ b/src/main/java/model/diagram/arrangement/PackageDiagramArrangementManager.java @@ -64,10 +64,9 @@ public DiagramGeometry arrangeDiagram() @Override - public DiagramGeometry applyNewLayout(String algorithmType) + public DiagramGeometry applyLayout(LayoutAlgorithmType algorithmType) { - LayoutAlgorithmType algorithmEnumType = LayoutAlgorithmType.get(algorithmType); - LayoutAlgorithm layout = LayoutAlgorithmFactory.createLayoutAlgorithm(algorithmEnumType); + LayoutAlgorithm layout = LayoutAlgorithmFactory.createLayoutAlgorithm(algorithmType); layout.setGraph(graph); return layout.arrangeDiagram(); } diff --git a/src/main/java/model/diagram/arrangement/algorithms/LayoutAlgorithmType.java b/src/main/java/model/diagram/arrangement/algorithms/LayoutAlgorithmType.java index af43141..f432605 100644 --- a/src/main/java/model/diagram/arrangement/algorithms/LayoutAlgorithmType.java +++ b/src/main/java/model/diagram/arrangement/algorithms/LayoutAlgorithmType.java @@ -1,8 +1,9 @@ package model.diagram.arrangement.algorithms; +import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; public enum LayoutAlgorithmType { @@ -17,17 +18,20 @@ public enum LayoutAlgorithmType static { - Map map = new HashMap<>(); - for (LayoutAlgorithmType layoutAlgorithmType : LayoutAlgorithmType.values()) - { - map.put(layoutAlgorithmType.toString().toLowerCase(), layoutAlgorithmType); - } + Map map = Arrays.stream(LayoutAlgorithmType.values()) + .collect(Collectors.toMap(LayoutAlgorithmType::toString, it -> it)); + ALGORITHM_TYPE_MAP = Collections.unmodifiableMap(map); } public static LayoutAlgorithmType get(String algorithmType) { - return ALGORITHM_TYPE_MAP.get(algorithmType.toLowerCase()); + return ALGORITHM_TYPE_MAP.get(algorithmType); } + @Override + public String toString() + { + return super.toString().toLowerCase(); + } } diff --git a/src/main/java/model/diagram/arrangement/geometry/DiagramGeometry.java b/src/main/java/model/diagram/arrangement/geometry/DiagramGeometry.java index 27a2799..42c80a7 100644 --- a/src/main/java/model/diagram/arrangement/geometry/DiagramGeometry.java +++ b/src/main/java/model/diagram/arrangement/geometry/DiagramGeometry.java @@ -51,14 +51,8 @@ public void correctPositions(double x, double y) double newX = entry.getValue().getValue0() + x; double newY = entry.getValue().getValue1() + y; geometryMap.put(entry.getKey(), new Pair<>(entry.getValue().getValue0() + x, entry.getValue().getValue1() + y)); - if (newX < minX) - { - minX = newX; - } - if (newY < minY) - { - minY = newY; - } + minX = Math.min(newX, minX); + minY = Math.min(newY, minY); } xDifference = minX - MIN_X_WINDOW_VALUE; yDifference = minY - MIN_Y_WINDOW_VALUE; diff --git a/src/main/java/model/diagram/exportation/GraphMLFile.java b/src/main/java/model/diagram/exportation/GraphMLFile.java index 388cc8a..dc05e7b 100644 --- a/src/main/java/model/diagram/exportation/GraphMLFile.java +++ b/src/main/java/model/diagram/exportation/GraphMLFile.java @@ -1,6 +1,8 @@ package model.diagram.exportation; import model.diagram.graphml.GraphMLSyntax; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.FileWriter; @@ -9,8 +11,9 @@ public class GraphMLFile { + private static final Logger logger = LogManager.getLogger(GraphMLFile.class); - private FileWriter graphMLWriter; + private FileWriter graphMLWriter; private StringBuilder graphMLBuffer; private File graphMLFile; @@ -19,14 +22,14 @@ public void createGraphMLFile(Path graphMLSavePath) { try { - graphMLFile = graphMLSavePath.toFile(); + graphMLFile = graphMLSavePath.toFile(); graphMLWriter = new FileWriter(graphMLFile); graphMLBuffer = new StringBuilder(); graphMLBuffer.append(GraphMLSyntax.getInstance().getGraphMLPrefix()); } catch (IOException e) { - e.printStackTrace(); + logger.error("Can't write to file: {}", graphMLFile.getAbsoluteFile()); throw new RuntimeException(e); } } @@ -42,7 +45,7 @@ public void closeGraphMLFile() } catch (IOException e) { - e.printStackTrace(); + logger.error("Can't write buffer to file: {}", graphMLFile.getAbsoluteFile()); throw new RuntimeException(e); } } diff --git a/src/main/java/model/diagram/exportation/JavaFXClassDiagramExporter.java b/src/main/java/model/diagram/exportation/JavaFXClassDiagramExporter.java index ce773a6..15d8a53 100644 --- a/src/main/java/model/diagram/exportation/JavaFXClassDiagramExporter.java +++ b/src/main/java/model/diagram/exportation/JavaFXClassDiagramExporter.java @@ -4,6 +4,8 @@ import com.google.gson.GsonBuilder; import model.diagram.ClassDiagram; import model.graph.ClassifierVertex; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.FileWriter; @@ -12,6 +14,7 @@ public class JavaFXClassDiagramExporter implements DiagramExporter { + private static final Logger logger = LogManager.getLogger(JavaFXClassDiagramExporter.class); private final ClassDiagram classDiagram; @@ -38,7 +41,7 @@ public File exportDiagram(Path exportPath) } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to write json to file with path: {}", exportPath.toAbsolutePath()); throw new RuntimeException(e); } diff --git a/src/main/java/model/diagram/exportation/JavaFXPackageDiagramExporter.java b/src/main/java/model/diagram/exportation/JavaFXPackageDiagramExporter.java index f039d49..be0f63d 100644 --- a/src/main/java/model/diagram/exportation/JavaFXPackageDiagramExporter.java +++ b/src/main/java/model/diagram/exportation/JavaFXPackageDiagramExporter.java @@ -4,6 +4,8 @@ import com.google.gson.GsonBuilder; import model.diagram.PackageDiagram; import model.graph.PackageVertex; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.FileWriter; @@ -12,6 +14,7 @@ public class JavaFXPackageDiagramExporter implements DiagramExporter { + private static final Logger logger = LogManager.getLogger(JavaFXPackageDiagramExporter.class); private final PackageDiagram packageDiagram; @@ -37,7 +40,7 @@ public File exportDiagram(Path exportPath) } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to write json to file with path: {}", exportPath.toAbsolutePath()); throw new RuntimeException(e); } diff --git a/src/main/java/model/diagram/exportation/PlantUMLClassDiagramImageExporter.java b/src/main/java/model/diagram/exportation/PlantUMLClassDiagramImageExporter.java index e16fc50..b5b9feb 100644 --- a/src/main/java/model/diagram/exportation/PlantUMLClassDiagramImageExporter.java +++ b/src/main/java/model/diagram/exportation/PlantUMLClassDiagramImageExporter.java @@ -4,6 +4,8 @@ import model.diagram.plantuml.PlantUMLClassifierVertex; import model.diagram.plantuml.PlantUMLClassifierVertexArc; import net.sourceforge.plantuml.SourceStringReader; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -16,6 +18,7 @@ public class PlantUMLClassDiagramImageExporter implements DiagramExporter { + private static final Logger logger = LogManager.getLogger(PlantUMLPackageDiagramImageExporter.class); private final StringBuilder bufferBody; @@ -67,12 +70,17 @@ private void exportImage(File plantUMLFile, String plantCode) in = new ByteArrayInputStream(data); convImg = ImageIO.read(in); } + catch (IOException e) + { + logger.error("Failed to read from input stream"); + throw new RuntimeException(e); + } } ImageIO.write(convImg, "png", plantUMLFile); } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to write image to file: {}", plantUMLFile.getAbsolutePath()); throw new RuntimeException(e); } } @@ -81,11 +89,10 @@ private void exportImage(File plantUMLFile, String plantCode) private String wrapWidthChanger(String plantCode, int wrapWidth) { String updatedString; - //if (counter == 0) { int indexOfNewLine = plantCode.indexOf("\n"); String firstPart = plantCode.substring(0, indexOfNewLine + 1); String secondPart = plantCode.substring(indexOfNewLine + 1); - updatedString = firstPart + "skinparam wrapWidth " + wrapWidth + "\n" + secondPart; + updatedString = String.format("%sskinparam wrapWidth %d\n%s", firstPart, wrapWidth, secondPart); // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // // KEEP REDUCING THE WRAPWIDTH PARAMETER IN ORDER TO FIT PROPERLY THE IMAGE // // DOESNT WORK PROPERLY, COMMENTED JUST TO KEEP THE IDEA. // diff --git a/src/main/java/model/diagram/exportation/PlantUMLClassDiagramTextExporter.java b/src/main/java/model/diagram/exportation/PlantUMLClassDiagramTextExporter.java index 24b46d5..383e6b8 100644 --- a/src/main/java/model/diagram/exportation/PlantUMLClassDiagramTextExporter.java +++ b/src/main/java/model/diagram/exportation/PlantUMLClassDiagramTextExporter.java @@ -3,6 +3,8 @@ import model.diagram.ClassDiagram; import model.diagram.plantuml.PlantUMLClassifierVertex; import model.diagram.plantuml.PlantUMLClassifierVertexArc; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.BufferedWriter; import java.io.File; @@ -12,6 +14,7 @@ public class PlantUMLClassDiagramTextExporter implements DiagramExporter { + private static final Logger logger = LogManager.getLogger(PlantUMLClassDiagramTextExporter.class); private final StringBuilder bufferBody; @@ -48,7 +51,7 @@ private void writeFile(File plantUMLFile, String plantCode) } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to write to file: {}", plantUMLFile.getAbsolutePath()); throw new RuntimeException(e); } } diff --git a/src/main/java/model/diagram/exportation/PlantUMLPackageDiagramImageExporter.java b/src/main/java/model/diagram/exportation/PlantUMLPackageDiagramImageExporter.java index dce0c99..682b391 100644 --- a/src/main/java/model/diagram/exportation/PlantUMLPackageDiagramImageExporter.java +++ b/src/main/java/model/diagram/exportation/PlantUMLPackageDiagramImageExporter.java @@ -4,6 +4,8 @@ import model.diagram.plantuml.PlantUMLPackageVertex; import model.diagram.plantuml.PlantUMLPackageVertexArc; import net.sourceforge.plantuml.SourceStringReader; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; @@ -16,6 +18,7 @@ public class PlantUMLPackageDiagramImageExporter implements DiagramExporter { + private static final Logger logger = LogManager.getLogger(PlantUMLPackageDiagramImageExporter.class); private final StringBuilder bufferBody; @@ -70,12 +73,17 @@ private void exportImage(File plantUMLFile, String plantCode) convImg = ImageIO.read(in); width = convImg.getWidth(); } + catch (IOException e) + { + logger.error("Failed to read from input stream"); + throw new RuntimeException(e); + } } ImageIO.write(convImg, "png", plantUMLFile); } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to write image to file: {}", plantUMLFile.getAbsolutePath()); throw new RuntimeException(e); } } diff --git a/src/main/java/model/diagram/javafx/JavaFXClassDiagramLoader.java b/src/main/java/model/diagram/javafx/JavaFXClassDiagramLoader.java index d666514..5c0c387 100644 --- a/src/main/java/model/diagram/javafx/JavaFXClassDiagramLoader.java +++ b/src/main/java/model/diagram/javafx/JavaFXClassDiagramLoader.java @@ -5,6 +5,8 @@ import com.google.gson.JsonParseException; import model.graph.ArcType; import model.graph.ClassifierVertex; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.javatuples.Triplet; import java.io.IOException; @@ -19,6 +21,7 @@ public class JavaFXClassDiagramLoader { + private static final Logger logger = LogManager.getLogger(JavaFXClassDiagramLoader.class); private final Path graphSavePath; @@ -46,7 +49,7 @@ public Set loadDiagram() throws JsonParseException } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to read bytes from file: {}", graphSavePath.toAbsolutePath()); throw new RuntimeException(e); } return sinkVertices; @@ -62,17 +65,14 @@ private void deserializeArcs(Set sinkVertices) { Optional sourceVertex = sinkVertices .stream() - .filter(sinkVertex1 -> sinkVertex1.getName().equals(arc.getValue0())) + .filter(it -> it.getName().equals(arc.getValue0())) .findFirst(); Optional targetVertex = sinkVertices .stream() - .filter(sinkVertex1 -> sinkVertex1.getName().equals(arc.getValue1())) + .filter(it -> it.getName().equals(arc.getValue1())) .findFirst(); - if (sourceVertex.isEmpty() || - targetVertex.isEmpty()) - { - continue; - } + if (sourceVertex.isEmpty() || targetVertex.isEmpty()) continue; + classifierVertex.addArc(sourceVertex.get(), targetVertex.get(), ArcType.get(arc.getValue2())); } } diff --git a/src/main/java/model/diagram/javafx/JavaFXPackageDiagramLoader.java b/src/main/java/model/diagram/javafx/JavaFXPackageDiagramLoader.java index a372bcf..d3dd6b5 100644 --- a/src/main/java/model/diagram/javafx/JavaFXPackageDiagramLoader.java +++ b/src/main/java/model/diagram/javafx/JavaFXPackageDiagramLoader.java @@ -5,6 +5,8 @@ import com.google.gson.JsonParseException; import model.graph.ArcType; import model.graph.PackageVertex; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.javatuples.Triplet; import java.io.IOException; @@ -19,6 +21,7 @@ public class JavaFXPackageDiagramLoader { + private static final Logger logger = LogManager.getLogger(JavaFXPackageDiagramLoader.class); private final Path graphSavePath; @@ -36,16 +39,18 @@ public Set loadDiagram() throws JsonParseException { byte[] encodedBytes = Files.readAllBytes(graphSavePath); String json = new String(encodedBytes, StandardCharsets.ISO_8859_1); - Gson gson = new GsonBuilder().registerTypeAdapter(PackageVertex.class, - new PackageVertexDeserializer()) - .create(); + Gson gson = new GsonBuilder() + .registerTypeAdapter(PackageVertex.class, + new PackageVertexDeserializer()) + .create(); PackageVertex[] verticesArray = gson.fromJson(json, PackageVertex[].class); Collections.addAll(vertices, verticesArray); deserializeArcs(vertices); } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to read bytes from file: {}", graphSavePath.toAbsolutePath()); + throw new RuntimeException(e); } return vertices; } @@ -60,16 +65,14 @@ private void deserializeArcs(Set vertices) { Optional sourceVertex = vertices .stream() - .filter(vertex1 -> vertex1.getName().equals(arc.getValue0())) + .filter(it -> it.getName().equals(arc.getValue0())) .findFirst(); Optional targetVertex = vertices .stream() - .filter(vertex1 -> vertex1.getName().equals(arc.getValue1())) + .filter(it -> it.getName().equals(arc.getValue1())) .findFirst(); - if (sourceVertex.isEmpty() || targetVertex.isEmpty()) - { - continue; - } + if (sourceVertex.isEmpty() || targetVertex.isEmpty()) continue; + vertex.addArc(sourceVertex.get(), targetVertex.get(), ArcType.get(arc.getValue2())); } } diff --git a/src/main/java/model/diagram/plantuml/PlantUMLClassifierVertexArc.java b/src/main/java/model/diagram/plantuml/PlantUMLClassifierVertexArc.java index 35d2e9f..1562e90 100644 --- a/src/main/java/model/diagram/plantuml/PlantUMLClassifierVertexArc.java +++ b/src/main/java/model/diagram/plantuml/PlantUMLClassifierVertexArc.java @@ -1,13 +1,8 @@ package model.diagram.plantuml; import model.diagram.ClassDiagram; -import model.graph.Arc; import model.graph.ArcType; -import model.graph.ClassifierVertex; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; import java.util.stream.Collectors; public class PlantUMLClassifierVertexArc diff --git a/src/main/java/model/diagram/plantuml/PlantUMLPackageVertexArc.java b/src/main/java/model/diagram/plantuml/PlantUMLPackageVertexArc.java index 8518185..22a7d16 100644 --- a/src/main/java/model/diagram/plantuml/PlantUMLPackageVertexArc.java +++ b/src/main/java/model/diagram/plantuml/PlantUMLPackageVertexArc.java @@ -1,13 +1,8 @@ package model.diagram.plantuml; import model.diagram.PackageDiagram; -import model.graph.Arc; import model.graph.ArcType; -import model.graph.PackageVertex; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; import java.util.stream.Collectors; public class PlantUMLPackageVertexArc diff --git a/src/main/java/parser/FileVisitor.java b/src/main/java/parser/FileVisitor.java index aeeb706..2a3a2f4 100644 --- a/src/main/java/parser/FileVisitor.java +++ b/src/main/java/parser/FileVisitor.java @@ -1,5 +1,6 @@ package parser; +import com.github.javaparser.JavaParser; import com.github.javaparser.ParserConfiguration; import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.CompilationUnit; @@ -10,10 +11,14 @@ import com.github.javaparser.ast.body.FieldDeclaration; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.body.RecordDeclaration; +import com.github.javaparser.ast.body.VariableDeclarator; import com.github.javaparser.ast.expr.ObjectCreationExpr; import com.github.javaparser.ast.expr.VariableDeclarationExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; import com.github.javaparser.ast.type.ClassOrInterfaceType; import com.github.javaparser.ast.visitor.VoidVisitorAdapter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import parser.tree.LeafNode; import parser.tree.LeafNodeBuilder; import parser.tree.ModifierType; @@ -33,13 +38,15 @@ import java.util.stream.Collectors; /** - * This class is responsible for the creation of the AST of a Java source file using Javaparser. + * This class is responsible for the creation of the AST of a Java source file using {@link JavaParser}. * Using the different visitors, it parses the file's inheritance declarations, * constructor, methods parameters, return types, field & local variable declarations * as well as the instantiated objects that aren't assigned to a variable. */ public class FileVisitor { + private static final Logger logger = LogManager.getLogger(FileVisitor.class); + private final InheritanceVisitor inheritanceVisitor = new InheritanceVisitor(); private final ConstructorVisitor constructorVisitor = new ConstructorVisitor(); private final FieldVisitor fieldNameVisitor = new FieldVisitor(); @@ -69,9 +76,9 @@ public class FileVisitor /** - * The FileVisitor's default constructor + * The FileVisitor's default constructor. * - * @param parentNode the LeafNode representing the Java source file that we are visiting + * @param parentNode the LeafNode representing the Java source file that we are visiting. */ public FileVisitor(PackageNode parentNode, Path path) { @@ -125,7 +132,7 @@ public LeafNode createAST() } catch (FileNotFoundException e) { - e.printStackTrace(); + logger.debug("File with path: {} not found", path); throw new RuntimeException(e); } @@ -162,6 +169,7 @@ public void visit(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, Void { innerBaseClass = classOrInterfaceDeclaration.getExtendedTypes().get(0).getNameAsString(); } + List innerImplementedInterfaces = new ArrayList<>(); for (ClassOrInterfaceType c : classOrInterfaceDeclaration.getImplementedTypes()) { @@ -179,22 +187,22 @@ public void visit(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, Void } nodeName = classOrInterfaceDeclaration.getNameAsString(); - NodeType localNodeType; - if (classOrInterfaceDeclaration.isInterface()) - { - localNodeType = NodeType.INTERFACE; - } - else + NodeType localNodeType = classOrInterfaceDeclaration.isInterface() ? + NodeType.INTERFACE : + NodeType.CLASS; + + if (!classOrInterfaceDeclaration.getExtendedTypes().isEmpty()) { - localNodeType = NodeType.CLASS; - classOrInterfaceDeclaration.getExtendedTypes() - .forEach(classOrInterfaceType -> baseClass = classOrInterfaceType.getNameAsString()); + baseClass = classOrInterfaceDeclaration.getExtendedTypes().get(0).getNameAsString(); } nodeType = localNodeType; - classOrInterfaceDeclaration.getImplementedTypes() - .forEach(classOrInterfaceType -> implementedInterfaces.add(classOrInterfaceType.getNameAsString())); - + ArrayList implementedTypes = + classOrInterfaceDeclaration.getImplementedTypes() + .stream() + .map(NodeWithSimpleName::getNameAsString) + .collect(Collectors.toCollection(ArrayList::new)); + implementedInterfaces.addAll(implementedTypes); } } @@ -206,20 +214,13 @@ public void visit(ConstructorDeclaration constructorDeclaration, Void arg) { super.visit(constructorDeclaration, arg); - ModifierType modifierType; - if (constructorDeclaration.getModifiers().isEmpty()) - { - modifierType = ModifierType.PACKAGE_PRIVATE; - } - else - { - modifierType = ModifierType.get(constructorDeclaration.getModifiers().get(0).toString()); - } + ModifierType modifierType = constructorDeclaration.getModifiers().isEmpty() ? + ModifierType.PACKAGE_PRIVATE : + ModifierType.get(constructorDeclaration.getModifiers().get(0).toString()); - Map parameters = new HashMap<>(); - constructorDeclaration.getParameters() - .forEach(parameter -> parameters.put(parameter.getNameAsString(), - getType(parameter.getTypeAsString()))); + Map parameters = constructorDeclaration.getParameters().stream() + .collect(Collectors.toMap(NodeWithSimpleName::getNameAsString, + parameter -> getType(parameter.getTypeAsString()))); methods.add(new LeafNode.Method(constructorDeclaration.getNameAsString(), "Constructor", modifierType, @@ -229,27 +230,22 @@ public void visit(ConstructorDeclaration constructorDeclaration, Void arg) private class FieldVisitor extends VoidVisitorAdapter { - private ModifierType modifierType; - @Override public void visit(FieldDeclaration fieldDeclaration, Void arg) { super.visit(fieldDeclaration, arg); - fieldDeclaration.getVariables().forEach(variable -> { - if (fieldDeclaration.getModifiers().isEmpty()) - { - this.modifierType = ModifierType.PACKAGE_PRIVATE; - } - else - { - this.modifierType = ModifierType.get(fieldDeclaration.getModifiers().get(0).toString()); - } + for (VariableDeclarator variable : fieldDeclaration.getVariables()) + { + ModifierType modifierType = fieldDeclaration.getModifiers().isEmpty() ? + ModifierType.PACKAGE_PRIVATE : + ModifierType.get(fieldDeclaration.getModifiers().get(0).toString()); + fields.add(new LeafNode.Field(variable.getNameAsString(), getType(variable.getTypeAsString()), modifierType)); - }); + } } } @@ -263,14 +259,12 @@ public void visit(VariableDeclarationExpr variableDeclarationExpr, Void arg) Pattern pattern = Pattern.compile("[A-Za-z0-9]+ [A-Za-z0-9]+ = new ([A-Za-z0-9]+)\\([A-Za-z0-9]*[, A-Za-z0-9*]*\\)"); Matcher matcher = pattern.matcher(variableDeclarationExpr.toString()); - if (!matcher.find()) - { - return; - } + if (!matcher.find()) return; + objectTypes.add(matcher.group(1)); variableDeclarationExpr.getVariables() - .forEach(variableDeclaration -> variablesMap.put(variableDeclaration.getNameAsString(), - getType(variableDeclaration.getTypeAsString()))); + .forEach(it -> variablesMap.put(it.getNameAsString(), + getType(it.getTypeAsString()))); } } @@ -282,19 +276,13 @@ public void visit(MethodDeclaration methodDeclaration, Void arg) { super.visit(methodDeclaration, arg); - ModifierType modifierType; - if (methodDeclaration.getModifiers().isEmpty()) - { - modifierType = ModifierType.PACKAGE_PRIVATE; - } - else - { - modifierType = ModifierType.get(methodDeclaration.getModifiers().get(0).toString()); - } - Map parameters = new HashMap<>(); - methodDeclaration.getParameters() - .forEach(parameter -> parameters.put(parameter.getNameAsString(), - getType(parameter.getTypeAsString()))); + ModifierType modifierType = methodDeclaration.getModifiers().isEmpty() ? + ModifierType.PACKAGE_PRIVATE : + ModifierType.get(methodDeclaration.getModifiers().get(0).toString()); + + Map parameters = methodDeclaration.getParameters().stream() + .collect(Collectors.toMap(NodeWithSimpleName::getNameAsString, + parameter -> getType(parameter.getTypeAsString()))); methods.add(new LeafNode.Method(methodDeclaration.getNameAsString(), getType(methodDeclaration.getTypeAsString()), modifierType, @@ -332,6 +320,7 @@ public void visit(EnumDeclaration enumDeclaration, Void arg) private class MemberVisitor extends VoidVisitorAdapter { + @Override public void visit(EnumDeclaration enumDeclaration, Void arg) { super.visit(enumDeclaration, arg); @@ -339,7 +328,7 @@ public void visit(EnumDeclaration enumDeclaration, Void arg) enums.add(enumDeclaration.getNameAsString()); } - + @Override public void visit(RecordDeclaration n, Void arg) { super.visit(n, arg); @@ -352,6 +341,7 @@ public void visit(RecordDeclaration n, Void arg) private class ImportVisitor extends VoidVisitorAdapter { + @Override public void visit(ImportDeclaration importDeclaration, Void arg) { super.visit(importDeclaration, arg); @@ -371,8 +361,10 @@ private List populateCreatedObjects() .map(LeafNode.Field::fieldType) .collect(Collectors.toCollection(ArrayList::new)), createdObjects); + notAssignedCreatedObjects = filterAssignedCreatedObjects(new ArrayList<>(variablesMap.values()), notAssignedCreatedObjects); + notAssignedCreatedObjects = filterAssignedCreatedObjects(objectTypes, notAssignedCreatedObjects); return notAssignedCreatedObjects; diff --git a/src/main/java/parser/IRelationshipIdentifier.java b/src/main/java/parser/IRelationshipIdentifier.java index df0b6fa..bb085b8 100644 --- a/src/main/java/parser/IRelationshipIdentifier.java +++ b/src/main/java/parser/IRelationshipIdentifier.java @@ -6,7 +6,6 @@ import parser.tree.Relationship; import java.nio.file.Path; -import java.util.List; import java.util.Map; import java.util.Set; diff --git a/src/main/java/parser/ProjectParser.java b/src/main/java/parser/ProjectParser.java index 88f1a4d..7e14f52 100644 --- a/src/main/java/parser/ProjectParser.java +++ b/src/main/java/parser/ProjectParser.java @@ -1,5 +1,7 @@ package parser; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import parser.factory.Parser; import parser.tree.LeafNode; import parser.tree.PackageNode; @@ -14,6 +16,7 @@ public class ProjectParser implements Parser { + private static final Logger logger = LogManager.getLogger(ProjectParser.class); private final Map packageNodes; @@ -73,7 +76,7 @@ else if (isJavaSourceFile(path)) } catch (Exception e) { - e.printStackTrace(); + logger.error("Failed to open a directory stream for path: {}", currentNode.getPath().toAbsolutePath()); throw new RuntimeException(e); } } diff --git a/src/main/java/parser/factory/Parser.java b/src/main/java/parser/factory/Parser.java index 841527f..7004a8e 100644 --- a/src/main/java/parser/factory/Parser.java +++ b/src/main/java/parser/factory/Parser.java @@ -5,7 +5,6 @@ import parser.tree.Relationship; import java.nio.file.Path; -import java.util.List; import java.util.Map; import java.util.Set; diff --git a/src/main/java/parser/tree/LeafNode.java b/src/main/java/parser/tree/LeafNode.java index 6b6b028..7b64fad 100644 --- a/src/main/java/parser/tree/LeafNode.java +++ b/src/main/java/parser/tree/LeafNode.java @@ -19,14 +19,14 @@ public record LeafNode(Path path, List records, List innerClasses, List innerEnums, - List createdObjects) { - + List createdObjects) +{ public List getMethodReturnTypes() { return methods .stream() - .map(method -> method.returnType) + .map(it -> it.returnType) .collect(Collectors.toCollection(ArrayList::new)); } @@ -35,7 +35,7 @@ public List getMethodParameterTypes() { return methods .stream() - .flatMap(method -> method + .flatMap(it -> it .parameters() .values() .stream()) diff --git a/src/main/java/parser/tree/PackageNode.java b/src/main/java/parser/tree/PackageNode.java index 174a64d..1131766 100644 --- a/src/main/java/parser/tree/PackageNode.java +++ b/src/main/java/parser/tree/PackageNode.java @@ -1,5 +1,8 @@ package parser.tree; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -16,6 +19,8 @@ */ public final class PackageNode { + private static final Logger logger = LogManager.getLogger(PackageNode.class); + private final Map subNodes; private final Map leafNodes; private final Path path; @@ -57,7 +62,7 @@ private static boolean isValid(Path path) } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to stream file in path: {}", path); throw new RuntimeException(e); } return isValid; diff --git a/src/main/java/view/AboutPageController.java b/src/main/java/view/AboutPageController.java index 8bccd45..a3dc690 100644 --- a/src/main/java/view/AboutPageController.java +++ b/src/main/java/view/AboutPageController.java @@ -1,6 +1,5 @@ package view; -import javafx.application.HostServices; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.MenuBar; @@ -9,7 +8,6 @@ import javafx.scene.web.WebView; import java.net.URL; -import java.util.Objects; import java.util.ResourceBundle; public class AboutPageController implements Initializable diff --git a/src/main/java/view/AppStarterHelper.java b/src/main/java/view/AppStarterHelper.java index 7b833e3..398c75f 100644 --- a/src/main/java/view/AppStarterHelper.java +++ b/src/main/java/view/AppStarterHelper.java @@ -7,13 +7,22 @@ import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.stage.Stage; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; +import java.util.Objects; public class AppStarterHelper extends Application { + private static final Logger logger = LogManager.getLogger(AppStarterHelper.class); + + private static final String PROJECT_LOAD_VIEW = "/fxml/ProjectLoadView.fxml"; + private static final String LOGO_PNG = "/assets/logo.png"; + + public static void main(String[] args) { launch(); @@ -25,10 +34,10 @@ public void start(Stage primaryStage) { try { - URL url = getClass().getResource("/fxml/ProjectLoadView.fxml"); - Parent root = FXMLLoader.load(url); + URL url = getClass().getResource(PROJECT_LOAD_VIEW); + Parent root = FXMLLoader.load(Objects.requireNonNull(url)); Scene scene = new Scene(root); - Image iconImage = new Image(getClass().getResourceAsStream("/assets/logo.png")); + Image iconImage = new Image(Objects.requireNonNull(getClass().getResourceAsStream(LOGO_PNG))); primaryStage.getIcons().add(iconImage); primaryStage.setTitle("Object Oriented Architecture Diagrammer"); primaryStage.setScene(scene); @@ -40,7 +49,8 @@ public void start(Stage primaryStage) } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to load {}", PROJECT_LOAD_VIEW); + throw new RuntimeException(e); } } diff --git a/src/main/java/view/DiagramCreation.java b/src/main/java/view/DiagramCreation.java index 46d31b9..12d091a 100644 --- a/src/main/java/view/DiagramCreation.java +++ b/src/main/java/view/DiagramCreation.java @@ -2,7 +2,6 @@ import controller.Controller; import controller.ControllerFactory; -import controller.ControllerType; import javafx.fxml.FXML; import javafx.scene.control.MenuBar; diff --git a/src/main/java/view/DiagramVisualization.java b/src/main/java/view/DiagramVisualization.java index fb2b809..de11246 100644 --- a/src/main/java/view/DiagramVisualization.java +++ b/src/main/java/view/DiagramVisualization.java @@ -8,15 +8,18 @@ import javafx.scene.Scene; import javafx.scene.control.MenuBar; import javafx.stage.Stage; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.IOException; import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; public class DiagramVisualization { - private static final Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + private static final Logger logger = LogManager.getLogger(DiagramVisualization.class); + + private static final String DIAGRAM_VISUALIZATION_VIEW = "/fxml/DiagramVisualizationView.fxml"; + private static final String PROJECT_LOAD_VIEW = "/fxml/ProjectLoadView.fxml"; private static final int EDGE_STARTING_NODE = 0; private static final int EDGE_ENDING_NODE = 1; @@ -41,7 +44,7 @@ public void loadDiagramVisualization(SmartGraphPanel graphView) this.graphView = graphView; try { - URL url = getClass().getResource("/fxml/DiagramVisualizationView.fxml"); + URL url = getClass().getResource(DIAGRAM_VISUALIZATION_VIEW); FXMLLoader loader = new FXMLLoader(); loader.setLocation(url); Parent diagramVisualizationParent = loader.load(); @@ -60,7 +63,8 @@ public void loadDiagramVisualization(SmartGraphPanel graphView) } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to load {}", DIAGRAM_VISUALIZATION_VIEW); + throw new RuntimeException(e); } } @@ -70,7 +74,7 @@ public void loadLoadedDiagramVisualization(SmartGraphPanel graph this.graphView = graphView; try { - URL url = getClass().getResource("/fxml/ProjectLoadView.fxml"); + URL url = getClass().getResource(PROJECT_LOAD_VIEW); FXMLLoader loader = new FXMLLoader(); loader.setLocation(url); @@ -92,12 +96,13 @@ public void loadLoadedDiagramVisualization(SmartGraphPanel graph { // Just continue. Handling here the exception to not show the error to the user. // We do this, because this error doesn't affect the system. - logger.log(Level.WARNING, e.toString()); + logger.error("Failed to initialize Graph View.\n{}", e.toString()); } } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to load {}", PROJECT_LOAD_VIEW); + throw new RuntimeException(e); } } @@ -111,24 +116,24 @@ public void addGraphActions() private void addVertexActions() { - graphView.setVertexDoubleClickAction(graphVertex -> - PopupWindow.createPopupInfoWindow(String.format("Vertex contains element: %s", - graphVertex.getUnderlyingVertex().element()), - "Node Information")); + graphView.setVertexDoubleClickAction(it -> + PopupWindow.createPopupInfoWindow(String.format("Vertex contains element: %s", + it.getUnderlyingVertex().element()), + "Node Information")); } private void addEdgeActions() { - graphView.setEdgeDoubleClickAction(graphEdge -> - PopupWindow.createPopupInfoWindow(String.format("Edge starting node: %s", - graphEdge.getUnderlyingEdge().element().split("_")[EDGE_STARTING_NODE]) + - "\n" + String.format("Edge ending node: %s", - graphEdge.getUnderlyingEdge().element().split("_")[EDGE_ENDING_NODE]) + + graphView.setEdgeDoubleClickAction(it -> + PopupWindow.createPopupInfoWindow(String.format("Edge starting node: %s", + it.getUnderlyingEdge().element().split("_")[EDGE_STARTING_NODE]) + + "\n" + String.format("Edge ending node: %s", + it.getUnderlyingEdge().element().split("_")[EDGE_ENDING_NODE]) + "\n" + String.format("Type of relationship: %s", - Character.toUpperCase(graphEdge.getUnderlyingEdge().element().split("_")[EDGE_TYPE].charAt(0)) + - graphEdge.getUnderlyingEdge().element().split("_")[EDGE_TYPE].substring(1)), - "Edge Information")); + Character.toUpperCase(it.getUnderlyingEdge().element().split("_")[EDGE_TYPE].charAt(0)) + + it.getUnderlyingEdge().element().split("_")[EDGE_TYPE].substring(1)), + "Edge Information")); } @@ -138,5 +143,8 @@ public void setDiagramController(Controller diagramController) } - public void setProjectTreeView(ProjectTreeView projectTreeView) {this.projectTreeView = projectTreeView;} + public void setProjectTreeView(ProjectTreeView projectTreeView) + { + this.projectTreeView = projectTreeView; + } } diff --git a/src/main/java/view/DiagramVisualizationController.java b/src/main/java/view/DiagramVisualizationController.java index f8e5a41..1d1f1a6 100644 --- a/src/main/java/view/DiagramVisualizationController.java +++ b/src/main/java/view/DiagramVisualizationController.java @@ -17,6 +17,8 @@ import javafx.scene.layout.BorderPane; import javafx.scene.paint.Color; import javafx.stage.Stage; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.imageio.ImageIO; import java.io.File; @@ -26,6 +28,11 @@ public class DiagramVisualizationController { + private static final Logger logger = LogManager.getLogger(DiagramVisualizationController.class); + + private static final String BACKGROUND_COLOR = "#F4FFFB"; + public static final String DIAGRAM_CREATION_VIEW = "/fxml/DiagramCreationView.fxml"; + @FXML BorderPane borderPane; @FXML @@ -47,8 +54,8 @@ public void visualizeGraph(SmartGraphPanel graphView) graphViewNormalScaleX = graphView.getScaleX(); graphViewNormalScaleY = graphView.getScaleY(); - String graphViewBackgroundColor = "#F4FFFB"; - Color zoomPaneBackgroundColor = Color.web(graphViewBackgroundColor); + + Color zoomPaneBackgroundColor = Color.web(BACKGROUND_COLOR); zoomPane.setBackground(new Background(new BackgroundFill(zoomPaneBackgroundColor, null, null))); graphView.minWidthProperty().bind(borderPane.widthProperty()); graphView.minHeightProperty().bind(borderPane.heightProperty()); @@ -77,10 +84,8 @@ public void exportDiagramAsImage() try { File selectedDirectory = FileAndDirectoryUtility.saveFile("Export Diagram as PNG", menuBar, "PNG files"); - if (selectedDirectory == null) - { - return; - } + if (selectedDirectory == null) return; + double changeScaleX = graphView.getScaleX(); double changeScaleY = graphView.getScaleY(); graphView.setScaleX(graphViewNormalScaleX); @@ -92,7 +97,8 @@ public void exportDiagramAsImage() } catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to write image to directory."); + throw new RuntimeException(e); } } @@ -112,7 +118,7 @@ public void closeDiagram() { try { - URL url = MenuUtility.class.getResource("/fxml/DiagramCreationView.fxml"); + URL url = MenuUtility.class.getResource(DIAGRAM_CREATION_VIEW); FXMLLoader loader = new FXMLLoader(); loader.setLocation(url); Parent diagramCreationParent = loader.load(); @@ -121,13 +127,14 @@ public void closeDiagram() diagramCreationController.setProject(); Scene diagramCreationScene = new Scene(diagramCreationParent); - Stage window = (Stage)menuBar.getScene().getWindow(); + Stage window = (Stage) menuBar.getScene().getWindow(); window.setScene(diagramCreationScene); window.show(); } - catch (Exception e) + catch (IOException e) { - e.printStackTrace(); + logger.error("Failed to load FXML {}", DIAGRAM_CREATION_VIEW); + throw new RuntimeException(e); } } diff --git a/src/main/java/view/MenuUtility.java b/src/main/java/view/MenuUtility.java index 3e0c5fe..43a062c 100644 --- a/src/main/java/view/MenuUtility.java +++ b/src/main/java/view/MenuUtility.java @@ -3,7 +3,6 @@ import com.google.gson.JsonParseException; import controller.Controller; import controller.ControllerFactory; -import controller.ControllerType; import javafx.event.ActionEvent; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; diff --git a/src/main/java/view/TreeViewResizer.java b/src/main/java/view/TreeViewResizer.java index c3462bf..2173a32 100644 --- a/src/main/java/view/TreeViewResizer.java +++ b/src/main/java/view/TreeViewResizer.java @@ -30,9 +30,7 @@ public void makeResizable(Region region) } - EventHandler onMousePressedEventHandler = event -> { - mouseX = event.getSceneX(); - }; + EventHandler onMousePressedEventHandler = it -> mouseX = it.getSceneX(); EventHandler onMouseDraggedEventHandler = event -> { double deltaX = event.getSceneX() - mouseX; @@ -81,7 +79,5 @@ else if (sceneX > nodeX - 10 && sceneX < nodeX + 10) } }; - EventHandler onMouseReleasedEventHandler = event -> { - region.setCursor(Cursor.DEFAULT); - }; + EventHandler onMouseReleasedEventHandler = it -> region.setCursor(Cursor.DEFAULT); } \ No newline at end of file diff --git a/src/main/resources/logging/log4j2.xml b/src/main/resources/logging/log4j2.xml new file mode 100644 index 0000000..9e03b37 --- /dev/null +++ b/src/main/resources/logging/log4j2.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/java/model/exportation/PlantUMLClassDiagramTextExporterTest.java b/src/test/java/model/exportation/PlantUMLClassDiagramTextExporterTest.java index be97693..627ffd8 100644 --- a/src/test/java/model/exportation/PlantUMLClassDiagramTextExporterTest.java +++ b/src/test/java/model/exportation/PlantUMLClassDiagramTextExporterTest.java @@ -59,12 +59,15 @@ void exportDiagramTest() String actualFileContents = lines.collect(Collectors.joining("\n")); lines.close(); - String expectedFileContents = "@startuml\n" + - "skinparam class {\n" + - " BackgroundColor lightyellow\n" + - " BorderColor black\n" + - " ArrowColor black\n" + - "}\n\n"; + String expectedFileContents = """ + @startuml + skinparam class { + BackgroundColor lightyellow + BorderColor black + ArrowColor black + } + + """; expectedFileContents += sinkVertexBuffer + "\n\n" + diff --git a/src/test/java/model/graphml/GraphMLPackageVertexArcTest.java b/src/test/java/model/graphml/GraphMLPackageVertexArcTest.java index 7e422a2..457e238 100644 --- a/src/test/java/model/graphml/GraphMLPackageVertexArcTest.java +++ b/src/test/java/model/graphml/GraphMLPackageVertexArcTest.java @@ -48,17 +48,19 @@ void convertVertexArcsToGraphMLTest() for (Arc e : arcs) { - expected.append(String.format(" \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " ", + expected.append(String.format(""" + + + + + + + + + + + \ + """, edgeId, packageDiagramManager.getPackageDiagram().getGraphNodes().get(e.sourceVertex()), packageDiagramManager.getPackageDiagram().getGraphNodes().get(e.targetVertex()))); diff --git a/src/test/java/model/graphml/GraphMLPackageVertexTest.java b/src/test/java/model/graphml/GraphMLPackageVertexTest.java index 2a17abe..4fadd3f 100644 --- a/src/test/java/model/graphml/GraphMLPackageVertexTest.java +++ b/src/test/java/model/graphml/GraphMLPackageVertexTest.java @@ -8,8 +8,6 @@ import utils.PathConstructor; import java.io.File; -import java.io.IOException; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Map; diff --git a/src/test/java/model/javafx/JavaFXClassDiagramLoaderTest.java b/src/test/java/model/javafx/JavaFXClassDiagramLoaderTest.java index 5de8b5b..142f344 100644 --- a/src/test/java/model/javafx/JavaFXClassDiagramLoaderTest.java +++ b/src/test/java/model/javafx/JavaFXClassDiagramLoaderTest.java @@ -7,7 +7,6 @@ import model.diagram.javafx.JavaFXClassDiagramLoader; import model.graph.Arc; import model.graph.ClassifierVertex; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import utils.PathConstructor; diff --git a/src/test/java/model/plantuml/PlantUMLClassifierVertexTest.java b/src/test/java/model/plantuml/PlantUMLClassifierVertexTest.java index 6f8c4dd..59e3b9f 100644 --- a/src/test/java/model/plantuml/PlantUMLClassifierVertexTest.java +++ b/src/test/java/model/plantuml/PlantUMLClassifierVertexTest.java @@ -6,8 +6,6 @@ import utils.PathConstructor; import java.io.File; -import java.io.IOException; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; diff --git a/src/test/java/parser/FileVisitorTest.java b/src/test/java/parser/FileVisitorTest.java index b9a7ddf..961a07c 100644 --- a/src/test/java/parser/FileVisitorTest.java +++ b/src/test/java/parser/FileVisitorTest.java @@ -58,7 +58,7 @@ void methodReturnTypesTest() Collections.sort(methodReturnTypesActual); Collections.sort(methodReturnTypesExpected); assertTrue(methodReturnTypesActual.size() == methodReturnTypesExpected.size() && - methodReturnTypesExpected.containsAll(methodReturnTypesActual) && + methodReturnTypesExpected.containsAll(methodReturnTypesActual) && methodReturnTypesActual.containsAll(methodReturnTypesExpected)); } @@ -92,7 +92,7 @@ void methodParameterTypesTest() Collections.sort(methodParameterTypesTest); Collections.sort(methodParameterTypes); assertTrue(methodParameterTypesTest.size() == methodParameterTypes.size() && - methodParameterTypes.containsAll(methodParameterTypesTest) && + methodParameterTypes.containsAll(methodParameterTypesTest) && methodParameterTypesTest.containsAll(methodParameterTypes)); } @@ -129,7 +129,7 @@ void fieldTypesTest() Collections.sort(fieldTypes); assertTrue(fieldTypesTest.size() == fieldTypes.size() && - fieldTypes.containsAll(fieldTypesTest) && + fieldTypes.containsAll(fieldTypesTest) && fieldTypesTest.containsAll(fieldTypes)); } @@ -157,7 +157,7 @@ void variableTypesTest() Collections.sort(variablesTypesTest); Collections.sort(variablesTypes); assertTrue(variablesTypesTest.size() == variablesTypes.size() && - variablesTypes.containsAll(variablesTypesTest) && + variablesTypes.containsAll(variablesTypesTest) && variablesTypesTest.containsAll(variablesTypes)); } @@ -190,7 +190,7 @@ void objectCreationTest() Collections.sort(objectsCreatedActual); Collections.sort(objectsCreatedExpected); assertTrue(objectsCreatedActual.size() == objectsCreatedExpected.size() && - objectsCreatedExpected.containsAll(objectsCreatedActual) && + objectsCreatedExpected.containsAll(objectsCreatedActual) && objectsCreatedActual.containsAll(objectsCreatedExpected)); } diff --git a/src/test/java/parser/InterpreterTest.java b/src/test/java/parser/InterpreterTest.java index acc9360..fb18622 100644 --- a/src/test/java/parser/InterpreterTest.java +++ b/src/test/java/parser/InterpreterTest.java @@ -56,10 +56,10 @@ public void convertTreeToGraphTest() { assertTrue(neighbours .stream() - .anyMatch(neighbour1 -> - neighbour1.getPath().toString().equals(subNode.getKey().toString()) && - neighbour1.getName().equals(subNode.getValue().getNodeName()) && - neighbour1.getVertexType().toString().equals(subNode.getValue().getNodeType().toString()))); + .anyMatch(it -> + it.getPath().toString().equals(subNode.getKey().toString()) && + it.getName().equals(subNode.getValue().getNodeName()) && + it.getVertexType().toString().equals(subNode.getValue().getNodeType().toString()))); } Map>> packageNodeRelationships = interpreter.getPackageNodeRelationships(); @@ -89,8 +89,10 @@ public void convertTreeToGraphTest() { ClassifierVertex classifierVertex = sinkVertices .stream() - .filter(sinkVertex1 -> - sinkVertex1.getName().equals(leafNodeEntry.getKey())).findAny().orElseGet(Assertions::fail); + .filter(it -> + it.getName().equals(leafNodeEntry.getKey())) + .findAny() + .orElseGet(Assertions::fail); List leafMethods = leafNodeEntry.getValue().methods(); List vertexMethods = classifierVertex.getMethods(); @@ -98,12 +100,12 @@ public void convertTreeToGraphTest() { assertTrue(vertexMethods .stream() - .anyMatch(m -> - m.name().equals(leafMethod.methodName()) && - m.parameters().size() == leafMethod.parameters().size() && - m.parameters().equals(leafMethod.parameters()) && - m.returnType().equals(leafMethod.returnType()) && - m.modifier().toString().equals(leafMethod.modifierType().toString()))); + .anyMatch(it -> + it.name().equals(leafMethod.methodName()) && + it.parameters().size() == leafMethod.parameters().size() && + it.parameters().equals(leafMethod.parameters()) && + it.returnType().equals(leafMethod.returnType()) && + it.modifier().toString().equals(leafMethod.modifierType().toString()))); } List leafFields = leafNodeEntry.getValue().fields(); @@ -112,10 +114,10 @@ public void convertTreeToGraphTest() { assertTrue(vertexFields .stream() - .anyMatch(f -> - f.name().equals(leafField.fieldNames()) && - f.type().equals(leafField.fieldType()) && - f.modifier().toString().equals(leafField.modifierType().toString()))); + .anyMatch(it -> + it.name().equals(leafField.fieldNames()) && + it.type().equals(leafField.fieldType()) && + it.modifier().toString().equals(leafField.modifierType().toString()))); } Map>> leafNodeRelationships = interpreter.getLeafNodeRelationships(); @@ -132,10 +134,10 @@ public void convertTreeToGraphTest() { assertTrue(sinkVertexArcs .stream() - .anyMatch(a -> - a.arcType().toString().equals(relationship.relationshipType().toString()) && - a.sourceVertex().getPath().equals(relationship.startingNode().path()) && - a.targetVertex().getPath().equals(relationship.endingNode().path()))); + .anyMatch(it -> + it.arcType().toString().equals(relationship.relationshipType().toString()) && + it.sourceVertex().getPath().equals(relationship.startingNode().path()) && + it.targetVertex().getPath().equals(relationship.endingNode().path()))); } } } diff --git a/src/test/java/parser/ProjectParserTest.java b/src/test/java/parser/ProjectParserTest.java index dfa1154..fb9b069 100644 --- a/src/test/java/parser/ProjectParserTest.java +++ b/src/test/java/parser/ProjectParserTest.java @@ -153,7 +153,7 @@ void parsingTest() Collections.sort(testingLeafNodes); Collections.sort(COMMANDS_LEAF_NODES); assertTrue(testingLeafNodes.size() == COMMANDS_LEAF_NODES.size() && - COMMANDS_LEAF_NODES.containsAll(testingLeafNodes) && + COMMANDS_LEAF_NODES.containsAll(testingLeafNodes) && testingLeafNodes.containsAll(COMMANDS_LEAF_NODES)); testingLeafNodes.clear(); @@ -216,7 +216,7 @@ void parsingTest() Collections.sort(testingLeafNodes); Collections.sort(MODELS_LEAF_NODES); assertTrue(testingLeafNodes.size() == MODELS_LEAF_NODES.size() && - MODELS_LEAF_NODES.containsAll(testingLeafNodes) && + MODELS_LEAF_NODES.containsAll(testingLeafNodes) && testingLeafNodes.containsAll(MODELS_LEAF_NODES)); testingLeafNodes.clear(); @@ -264,7 +264,7 @@ void parsingTest() Collections.sort(testingLeafNodes); Collections.sort(STRATEGIES_LEAF_NODES); assertTrue(testingLeafNodes.size() == STRATEGIES_LEAF_NODES.size() && - STRATEGIES_LEAF_NODES.containsAll(testingLeafNodes) && + STRATEGIES_LEAF_NODES.containsAll(testingLeafNodes) && testingLeafNodes.containsAll(STRATEGIES_LEAF_NODES)); testingLeafNodes.clear(); @@ -309,7 +309,7 @@ void parsingTest() Collections.sort(testingLeafNodes); Collections.sort(VIEWS_LEAF_NODES); assertTrue(testingLeafNodes.size() == VIEWS_LEAF_NODES.size() && - VIEWS_LEAF_NODES.containsAll(testingLeafNodes) && + VIEWS_LEAF_NODES.containsAll(testingLeafNodes) && testingLeafNodes.containsAll(VIEWS_LEAF_NODES)); testingLeafNodes.clear(); @@ -342,26 +342,27 @@ void parsingTest() Collections.sort(testingSubPackages); Collections.sort(SOURCES_SUB_PACKAGES); assertTrue(testingSubPackages.size() == SOURCES_SUB_PACKAGES.size() && - SOURCES_SUB_PACKAGES.containsAll(testingSubPackages) && + SOURCES_SUB_PACKAGES.containsAll(testingSubPackages) && testingSubPackages.containsAll(SOURCES_SUB_PACKAGES)); assertEquals(0, sourcePackage.getLeafNodes().size()); } - public static final List SOURCES_SUB_PACKAGES = new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model")), + public static final List SOURCES_SUB_PACKAGES = + new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model")), Paths.get(PathConstructor.getCurrentPath().normalize().toString(), PathConstructor.constructPath("src", "test", @@ -370,207 +371,212 @@ void parsingTest() "src", "view")))); - public static final List VIEWS_LEAF_NODES = new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "view", - "ChooseTemplate.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "view", - "LatexEditorView.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "view", - "MainWindow.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "view", - "OpeningWindow.java")))); - - public static final List CONTROLLERS_LEAF_NODES = new ArrayList<>(List.of(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "LatexEditorController.java")))); - - public static final List STRATEGIES_LEAF_NODES = new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "strategies", - "StableVersionsStrategy.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "strategies", - "VersionsStrategy.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "strategies", - "VolatileVersionsStrategy.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "strategies", - "VersionsStrategyFactory.java")))); - - public static final List MODELS_LEAF_NODES = new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "Document.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "DocumentManager.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "model", - "VersionsManager.java")))); - - public static final List COMMANDS_LEAF_NODES = new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "AddLatexCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "Command.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "CommandFactory.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "CreateCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "EditCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "LoadCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "SaveCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "ChangeVersionsStrategyCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "DisableVersionsManagementCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "EnableVersionsManagementCommand.java")), - Paths.get(PathConstructor.getCurrentPath().normalize().toString(), - PathConstructor.constructPath("src", - "test", - "resources", - "LatexEditor", - "src", - "controller", - "commands", - "RollbackToPreviousVersionCommand.java")))); + public static final List VIEWS_LEAF_NODES = + new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "view", + "ChooseTemplate.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "view", + "LatexEditorView.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "view", + "MainWindow.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "view", + "OpeningWindow.java")))); + + public static final List CONTROLLERS_LEAF_NODES = + new ArrayList<>(List.of(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "LatexEditorController.java")))); + + public static final List STRATEGIES_LEAF_NODES = + new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "strategies", + "StableVersionsStrategy.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "strategies", + "VersionsStrategy.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "strategies", + "VolatileVersionsStrategy.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "strategies", + "VersionsStrategyFactory.java")))); + + public static final List MODELS_LEAF_NODES = + new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "Document.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "DocumentManager.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "model", + "VersionsManager.java")))); + + public static final List COMMANDS_LEAF_NODES = + new ArrayList<>(Arrays.asList(Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "AddLatexCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "Command.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "CommandFactory.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "CreateCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "EditCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "LoadCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "SaveCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "ChangeVersionsStrategyCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "DisableVersionsManagementCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "EnableVersionsManagementCommand.java")), + Paths.get(PathConstructor.getCurrentPath().normalize().toString(), + PathConstructor.constructPath("src", + "test", + "resources", + "LatexEditor", + "src", + "controller", + "commands", + "RollbackToPreviousVersionCommand.java")))); }