diff --git a/cobigen/gui/pom.xml b/cobigen/gui/pom.xml
index a2ef2cf548..24cfb2dc15 100644
--- a/cobigen/gui/pom.xml
+++ b/cobigen/gui/pom.xml
@@ -67,6 +67,13 @@
core-artifact-retriever
${revision}
+
+ com.devonfw.cobigen
+ core
+ ${revision}
+
+
+
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/App.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/App.java
index bf0fc0ca7b..b499cc3b84 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/App.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/App.java
@@ -75,7 +75,6 @@ public void start(Stage primaryStage) throws IOException {
this.window = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("fxml/Primary.fxml"));
- System.out.println(1);
App.scene = new Scene(root);
App.scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm());
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/Controller.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/Controller.java
index 1cdc26228c..b598de3aaf 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/Controller.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/Controller.java
@@ -26,10 +26,15 @@
* Controller for the Template Set Management GUI
*/
public class Controller implements Initializable {
-
+ /*
+ * home Controller to show home page
+ */
@FXML
private Parent home;
+ /*
+ * Details Controller for template set details
+ */
@FXML
private Parent details;
@@ -42,6 +47,7 @@ public class Controller implements Initializable {
@FXML
public DetailsController detailsController;
+ // deals with menu.fxml
@FXML
private AnchorPane leftPane;
@@ -54,6 +60,7 @@ public class Controller implements Initializable {
@FXML
private AnchorPane detailsPane;
+ // top bit of the gui
@FXML
private Pane topPane;
@@ -101,6 +108,7 @@ public void loadDetails() throws IOException {
// selected from observable list
TemplateSet selectedItem = this.menuController.searchResultsView.getSelectionModel().getSelectedItem();
+ // changing visibility between scenes
if (selectedItem == null) {
this.home.setVisible(true);
this.details.setVisible(false);
@@ -108,7 +116,10 @@ public void loadDetails() throws IOException {
this.home.setVisible(false);
this.details.setVisible(true);
+ // Getting the tree view of increments of selected template set
+
// Extract all increments from selected templateSet in list
+ // should not happen here
List templatesetIncrements = selectedItem.getTemplateSetConfiguration()
.getTemplatesConfiguration().getIncrements().getIncrementList();
@@ -120,6 +131,11 @@ public void loadDetails() throws IOException {
// TODO
this.detailsController.showName(selectedItem.getTemplateSetVersion());
+
+ // retrieving template-Set selected and pass it to details Controller
+ this.detailsController
+ .setTemplateSet(this.menuController.searchResultsView.getSelectionModel().getSelectedItem());
+
}
}
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/DetailsController.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/DetailsController.java
index fc159e1e99..f40f0de9a3 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/DetailsController.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/DetailsController.java
@@ -1,12 +1,21 @@
package com.devonfw.cobigen.gui.controllers;
+import java.io.IOException;
import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
+import com.devonfw.cobigen.api.util.CobiGenPaths;
+import com.devonfw.cobigen.retriever.reader.to.model.TemplateSet;
+
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TreeView;
@@ -22,6 +31,8 @@ public class DetailsController implements Initializable {
// TODO: getIncrements()
private List INCREMENTS = new ArrayList<>();
+ private TemplateSet templateSet;
+
@FXML
Label titleLabel;
@@ -46,6 +57,26 @@ public void initialize(URL location, ResourceBundle resources) {
}
+ /**
+ * returns an instance of selected template Set to be operated on
+ *
+ * @return templateSet
+ */
+ public TemplateSet getTemplateSet() {
+
+ return this.templateSet;
+ }
+
+ /**
+ * Set the instance of selected template Set
+ *
+ * @param templateSet new value of {@link #gettemplateSet}.
+ */
+ public void setTemplateSet(TemplateSet templateSet) {
+
+ this.templateSet = templateSet;
+ }
+
/**
*
*/
@@ -80,12 +111,30 @@ public void showTreeView(TreeView treeView) {
/**
* @param actionEvent
+ * @throws IOException
*/
@FXML
- public void installTemplateSet(javafx.event.ActionEvent actionEvent) {
-
- // What does it exactly mean by installing and where
- // TODO
+ public void installTemplateSet(javafx.event.ActionEvent actionEvent) throws IOException {
+
+ // Retrieving trigger information and move the template set file to user folder
+ String triggerName = this.templateSet.getTemplateSetConfiguration().getContextConfiguration().getTriggers().getId();
+ String FileName = triggerName.replace("_", "-") + "-" + this.templateSet.getTemplateSetVersion()
+ + "-template-set.xml";
+ Path cobigenHome = CobiGenPaths.getCobiGenHomePath();
+ Path sourceFilePath = cobigenHome.resolve("template-set-list").resolve(FileName);
+ String destinationPath = "C:\\Users\\alsaad\\template-set-installed\\" + FileName;
+ Path destinationFilePath = Paths.get(destinationPath);
+ if (!Files.exists(destinationFilePath)) {
+ Files.copy(sourceFilePath, destinationFilePath);
+ System.out.println(sourceFilePath.toString());
+ System.out.println(destinationFilePath);
+ } else {
+ // Alert window if the file is already installed
+ Alert alert = new Alert(AlertType.CONFIRMATION);
+ alert.setTitle("Confirmation");
+ alert.setHeaderText("the selected template-set is already installed");
+ alert.show();
+ }
}
/**
@@ -95,6 +144,7 @@ public void installTemplateSet(javafx.event.ActionEvent actionEvent) {
public void updateTemplateSet(javafx.event.ActionEvent actionEvent) {
// what model is previous and whats the new one
+ // new version rein packen
// TODO
}
@@ -106,6 +156,7 @@ public void updateTemplateSet(javafx.event.ActionEvent actionEvent) {
public void uninstallTemplateSet(javafx.event.ActionEvent actionEvent) {
// what is referred to by the word uninstall.
+ // Delete template set from user ordenr
// TODO
}
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/MenuController.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/MenuController.java
index f70e215b39..073c27a6b9 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/MenuController.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/controllers/MenuController.java
@@ -5,19 +5,17 @@
import java.util.ResourceBundle;
import com.devonfw.cobigen.gui.Controller;
-import com.devonfw.cobigen.gui.model.ModifyableTemplateSet;
import com.devonfw.cobigen.gui.model.TemplateSetModel;
import com.devonfw.cobigen.gui.services.TemplateSetCell;
+import com.devonfw.cobigen.retriever.reader.to.model.TemplateSet;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
-import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
-import javafx.scene.input.MouseEvent;
/**
* TODO nneuhaus This type ...
@@ -41,16 +39,15 @@ public class MenuController implements Initializable {
public Button goSearch;
@FXML
- public ListView searchResultsView;
-
- private TemplateSetModel tsModel = new TemplateSetModel();
+ public ListView searchResultsView;
/**
* The constructor.
*/
public MenuController() {
- this.tsModel.loadallAvaliableTemplateSets();
+ TemplateSetModel.getInstance().loadallAvaliableTemplateSets();
+ // Where do we need tags
// List tagsList = new ArrayList<>();
// tagsList.addAll(templateSet.getTemplateSetConfiguration().getContextConfiguration().getTags().getTagsList());
}
@@ -69,10 +66,9 @@ public void injectController(Controller controller) {
@Override
public void initialize(URL location, ResourceBundle resources) {
- // the line sets up the template cells in observable list
+ // the line below sets up the template set cells in observable list
this.searchResultsView.setCellFactory(resultsView -> new TemplateSetCell());
- // home button brings back the previous state
this.homeButton.setOnAction(event -> {
try {
this.controller.loadHome(event);
@@ -82,29 +78,27 @@ public void initialize(URL location, ResourceBundle resources) {
});
// binds the List with model
- this.searchResultsView.setItems(this.tsModel.getTemplateSetObservableList());
+ this.searchResultsView.setItems(TemplateSetModel.getInstance().getTemplateSetObservableList());
// Load increments of selected template set
- this.searchResultsView.setOnMouseClicked(new EventHandler() {
-
- @Override
- public void handle(MouseEvent event) {
+ // call back functions
+ this.searchResultsView.setOnMouseClicked(event -> {
- try {
- MenuController.this.controller.loadDetails();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ try {
+ MenuController.this.controller.loadDetails();
+ } catch (IOException e) {
+ e.printStackTrace();
}
+
});
// Initialize filtered List
- ObservableList listCopy = this.tsModel.getTemplateSetObservableList();
- FilteredList filteredData = new FilteredList<>(this.tsModel.getTemplateSetObservableList(),
- b -> true);
+ ObservableList listCopy = TemplateSetModel.getInstance().getTemplateSetObservableList();
+ FilteredList filteredData = new FilteredList<>(
+ TemplateSetModel.getInstance().getTemplateSetObservableList(), b -> true);
- // no idea what it does
+ // look after the searched text in search bar
this.searchBar.textProperty().addListener((observable, oldValue, newValue) -> {
filteredData.setPredicate(templateSets -> {
// if no search value, then display all records or whatever records it currently has, no changes
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/ModifyableTemplateSet.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/ModifyableTemplateSet.java
deleted file mode 100644
index d2e4d9e184..0000000000
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/ModifyableTemplateSet.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.devonfw.cobigen.gui.model;
-
-import com.devonfw.cobigen.retriever.reader.to.model.TemplateSet;
-import com.devonfw.cobigen.retriever.reader.to.model.TemplateSetConfiguration;
-
-/**
- * TODO alsaad This type ...
- *
- */
-public class ModifyableTemplateSet extends TemplateSet {
-
- /**
- * The constructor.
- *
- * @param templateSetVersion
- * @param templateSetConfiguration
- * @param templateSet name
- */
- public ModifyableTemplateSet(String templateSetVersion, TemplateSetConfiguration templateSetConfiguration,
- String name) {
-
- super(templateSetVersion, templateSetConfiguration);
- this.name = name;
- }
-
- private String name;
-
- /**
- * @return name
- */
- public String getName() {
-
- return this.name;
- }
-
- /**
- * @param name new value of {@link #getname}.
- */
- public void setName(String name) {
-
- this.name = name;
- }
-
-}
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/TemplateSetModel.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/TemplateSetModel.java
index 9a3a24dfe4..128187fc3e 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/TemplateSetModel.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/model/TemplateSetModel.java
@@ -1,10 +1,12 @@
package com.devonfw.cobigen.gui.model;
+import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
+import com.devonfw.cobigen.api.util.CobiGenPaths;
import com.devonfw.cobigen.retriever.ArtifactRetriever;
import com.devonfw.cobigen.retriever.reader.to.model.TemplateSet;
@@ -12,51 +14,51 @@
import javafx.collections.ObservableList;
/**
- * TODO alsaad This type ...
+ * Singleton Model Class
*
*/
public class TemplateSetModel {
- private final ObservableList templateSetObservableList;
+ private static TemplateSetModel tsModel;
- private List templatesetNames = new ArrayList<>();
+ private final ObservableList templateSetObservableList;
- public TemplateSetModel() {
+ private TemplateSetModel() {
this.templateSetObservableList = FXCollections.observableArrayList();
}
+ public static TemplateSetModel getInstance() {
+
+ if (tsModel == null) {
+ tsModel = new TemplateSetModel();
+ }
+
+ // returns the singleton object
+ return tsModel;
+ }
+
/**
* @return templateSetObservableList
*/
- public ObservableList getTemplateSetObservableList() {
+ public ObservableList getTemplateSetObservableList() {
return this.templateSetObservableList;
}
public void loadallAvaliableTemplateSets() {
- // Load all the paths of template set from cobigen home folder or where?
- // How to access paths of all template sets and load it here
- /** Test data root path */
- final String testdataRoot = "src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest";
- List mTS = new ArrayList<>();
-
+ // Load all the paths of template set from cobigen home folder
+ // all templates in template-set-list folder
+ File templatesetFolder = new File(CobiGenPaths.getCobiGenHomePath().resolve("template-set-list").toString());
+ File[] templatesetFileslist = templatesetFolder.listFiles();
List templateSetFiles = new ArrayList<>();
- templateSetFiles.add(Paths.get(testdataRoot).resolve("crud-java-server-app-2021.08.001-template-set.xml"));
- this.templatesetNames.add(templateSetFiles.get(0).getFileName().toString());
- templateSetFiles.add(Paths.get(testdataRoot).resolve("template-set.xml"));
- this.templatesetNames.add(templateSetFiles.get(1).getFileName().toString());
+ for (File file : templatesetFileslist) {
+ templateSetFiles.add(Paths.get(file.getPath()));
+ }
List templateSets = ArtifactRetriever.retrieveTemplateSetData(templateSetFiles);
- int i = 0;
- for (TemplateSet set : templateSets) {
- ModifyableTemplateSet mts = new ModifyableTemplateSet(set.getTemplateSetVersion(),
- set.getTemplateSetConfiguration(), this.templatesetNames.get(i++));
- mTS.add(mts);
-
- }
- this.templateSetObservableList.addAll(mTS);
+ this.templateSetObservableList.addAll(templateSets);
}
}
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCell.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCell.java
index 9c7cc5686f..2429980059 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCell.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCell.java
@@ -2,7 +2,7 @@
import java.io.IOException;
-import com.devonfw.cobigen.gui.model.ModifyableTemplateSet;
+import com.devonfw.cobigen.retriever.reader.to.model.TemplateSet;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
@@ -15,7 +15,7 @@
* TODO nneuhaus This type ...
*
*/
-public class TemplateSetCell extends ListCell {
+public class TemplateSetCell extends ListCell {
FXMLLoader loader;
@@ -30,7 +30,7 @@ public class TemplateSetCell extends ListCell {
// when this method suppose to be called
@Override
- protected void updateItem(ModifyableTemplateSet templateSet, boolean empty) {
+ protected void updateItem(TemplateSet templateSet, boolean empty) {
super.updateItem(templateSet, empty);
if (empty || templateSet == null) {
@@ -49,7 +49,9 @@ protected void updateItem(ModifyableTemplateSet templateSet, boolean empty) {
e.printStackTrace();
}
}
- this.titleLabel.setText(templateSet.getName());
+ // name of template set. should not happen here
+ this.titleLabel
+ .setText(templateSet.getTemplateSetConfiguration().getContextConfiguration().getTriggers().getId());
this.installButton.setOnAction(event -> {
System.out.println("INSTALLIEREN!!!");
});
diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCellFactory.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCellFactory.java
index bd92334e91..2d4cea3561 100644
--- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCellFactory.java
+++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TemplateSetCellFactory.java
@@ -1,6 +1,6 @@
package com.devonfw.cobigen.gui.services;
-import com.devonfw.cobigen.gui.model.ModifyableTemplateSet;
+import com.devonfw.cobigen.retriever.reader.to.model.TemplateSet;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
@@ -10,11 +10,10 @@
* TODO nneuhaus This type ...
*
*/
-public class TemplateSetCellFactory
- implements Callback, ListCell> {
+public class TemplateSetCellFactory implements Callback, ListCell> {
@Override
- public ListCell call(ListView param) {
+ public ListCell call(ListView param) {
return new TemplateSetCell();
}
diff --git a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest/crud-java-server-app-2021.08.001-template-set.xml b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest/crud-java-server-app-2021.08.001-template-set.xml
deleted file mode 100644
index 2172843a2b..0000000000
--- a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest/crud-java-server-app-2021.08.001-template-set.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest/template-set.xml b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest/template-set.xml
deleted file mode 100644
index 56f898158a..0000000000
--- a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetArtifactReaderTest/template-set.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Details.fxml b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Details.fxml
index dfab4d162b..1af2d7d62c 100644
--- a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Details.fxml
+++ b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Details.fxml
@@ -11,65 +11,46 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-