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 13ad607321..86f882017c 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 @@ -36,6 +36,9 @@ public class Controller implements Initializable { @FXML private AnchorPane homePane; + @FXML + private AnchorPane templateSetDetailsPane; + @FXML public Button homeButton; @@ -78,8 +81,10 @@ public void loadHome(javafx.event.ActionEvent actionEvent) throws IOException { * @param actionEvent * @throws IOException */ - public void details(javafx.event.ActionEvent actionEvent) throws IOException { + public void loadDetails(javafx.event.ActionEvent actionEvent) throws IOException { + this.templateSetDetailsPane = FXMLLoader.load(getClass().getResource("fxml/TemplateSetDetails.fxml")); + this.detailsPane.getChildren().setAll(this.templateSetDetailsPane); } /** 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 468b6d27d8..517058d15e 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,9 +1,94 @@ package com.devonfw.cobigen.gui.controllers; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; + +import com.devonfw.cobigen.gui.services.TreeViewBuilder; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.TreeView; +import javafx.scene.layout.AnchorPane; + /** * TODO nneuhaus This type ... * */ -public class DetailsController { +public class DetailsController implements Initializable { + + // TODO: getIncrements() + private List INCREMENTS = new ArrayList<>(); + + @FXML + AnchorPane treeViewPane; + + @Override + public void initialize(URL location, ResourceBundle resources) { + + showName(); + showVersion(); + showTreeView(TreeViewBuilder.buildTreeView(TreeViewBuilder.transformIncrementsToArray(this.INCREMENTS))); + + } + + /** + * + */ + private void showName() { + + // TODO: getName() + + } + + /** + * + */ + private void showVersion() { + + // TODO: getVersion() + + } + + /** + * @param treeView + */ + public void showTreeView(TreeView treeView) { + + treeView.setId("treeView"); + AnchorPane.setTopAnchor(treeView, 0.0); + AnchorPane.setRightAnchor(treeView, 0.0); + AnchorPane.setBottomAnchor(treeView, 0.0); + AnchorPane.setLeftAnchor(treeView, 0.0); + this.treeViewPane.getChildren().add(treeView); + } + + /** + * @param actionEvent + */ + @FXML + public void installTemplateSet(javafx.event.ActionEvent actionEvent) { + + // TODO + } + + /** + * @param actionEvent + */ + @FXML + public void updateTemplateSet(javafx.event.ActionEvent actionEvent) { + + // TODO + } + + /** + * @param actionEvent + */ + @FXML + public void uninstallTemplateSet(javafx.event.ActionEvent actionEvent) { + + // TODO + } } diff --git a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TreeViewBuilder.java b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TreeViewBuilder.java index f8fe276687..c9607c3a7c 100644 --- a/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TreeViewBuilder.java +++ b/cobigen/gui/src/main/java/com/devonfw/cobigen/gui/services/TreeViewBuilder.java @@ -32,18 +32,18 @@ public static String[] transformIncrementsToArray(List templateSetIncrem } /** - * @param listOfItems list to - * @return + * @param arrayOfItems to transform to tree + * @return the complete TreeView */ - public static TreeView buildTreeView(String[] listOfItems) { + public static TreeView buildTreeView(String[] arrayOfItems) { TreeItem rootItem = new TreeItem<>("Increments"); rootItem.setExpanded(true); - for (int i = 0; i < listOfItems.length; i++) { - TreeItem increment = new TreeItem<>(listOfItems[i]); + for (int i = 0; i < arrayOfItems.length; i++) { + TreeItem increment = new TreeItem<>(arrayOfItems[i]); i++; - TreeItem incrementDescription = new TreeItem<>(listOfItems[i]); + TreeItem incrementDescription = new TreeItem<>(arrayOfItems[i]); increment.getChildren().add(incrementDescription); rootItem.getChildren().add(increment); } diff --git a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetDetails.fxml b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetDetails.fxml deleted file mode 100644 index 5599e8b1da..0000000000 --- a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/TemplateSetDetails.fxml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Home.fxml b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Home.fxml index fe19103915..2194ea41cf 100644 --- a/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Home.fxml +++ b/cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/fxml/Home.fxml @@ -28,12 +28,12 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java index 8b9388e2d5..d90662e25c 100644 --- a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java @@ -4,6 +4,7 @@ import org.testfx.api.FxRobotException; import org.testfx.assertions.api.Assertions; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.Hyperlink; import javafx.scene.control.TreeItem; @@ -76,7 +77,12 @@ public void testFoldingIncrementTreeView() { this.incrementsTreeView = (TreeView) this.mainRoot.lookup(TREEVIEW); TreeItem root = this.incrementsTreeView.getRoot(); Assertions.assertThat(root.isExpanded()); - // TODO + ObservableList> children = root.getChildren(); + for (int i = 0; i < children.size(); i++) { + TreeItem child = children.get(i); + Assertions.assertThat(!child.isExpanded()); + Assertions.assertThat(child.getChildren().get(0).isLeaf()); + } } }