Skip to content

Commit

Permalink
devonfw#1454 Changes to project structure and home page
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonNew committed Nov 21, 2022
1 parent a5002ef commit bfa89a9
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 252 deletions.
2 changes: 1 addition & 1 deletion cobigen/gui/src/main/java/com/devonfw/cobigen/gui/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void printSomething() {
public void start(Stage primaryStage) throws IOException {

this.window = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("Primary.fxml"));
Parent root = FXMLLoader.load(getClass().getResource("fxml/Primary.fxml"));

App.scene = new Scene(root);
App.scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm());
Expand Down
18 changes: 16 additions & 2 deletions cobigen/gui/src/main/java/com/devonfw/cobigen/gui/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.ResourceBundle;
import java.util.stream.Collectors;

import com.devonfw.cobigen.gui.controllers.HomeController;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
Expand All @@ -22,6 +24,9 @@
*/
public class Controller implements Initializable {

@FXML
private HomeController homeController;

ArrayList<String> templateSets = new ArrayList<>(Arrays.asList("templates-devon4j-tests", "templates-devon4j-utils",
"crud-openapi-net", "crud-angular-client-app", "crud-ionic-client-app", "rest-documentation"));

Expand Down Expand Up @@ -50,14 +55,23 @@ public class Controller implements Initializable {
@Override
public void initialize(URL arg0, ResourceBundle arg1) {

try {
loadHome(null);
} catch (IOException e) {
e.printStackTrace();
}
this.searchResultsView.getItems().addAll(this.templateSets);
}

/**
* @param actionEvent
* @throws IOException
*/
@FXML
public void loadHome(javafx.event.ActionEvent actionEvent) throws IOException {

AnchorPane homePane = FXMLLoader.load(getClass().getResource("Home.fxml"));
this.detailsPane.getChildren().setAll(homePane);
this.homePane = FXMLLoader.load(getClass().getResource("fxml/Home.fxml"));
this.detailsPane.getChildren().setAll(this.homePane);
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.devonfw.cobigen.gui;
package com.devonfw.cobigen.gui.controllers;

/**
* TODO nneuhaus This type ...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.devonfw.cobigen.gui.controllers;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
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 HomeController implements Initializable {

@FXML
AnchorPane treeViewPane;

private String[] EXAMPLE_LIST = { "Title of Increment 1", "Description of Increment 1", "Title of Increment 2",
"Description of Increment 2", "Title of Increment 3", "Description of Increment 3" };

@Override
public void initialize(URL location, ResourceBundle resources) {

TreeView<String> treeView = TreeViewBuilder.buildTreeView(this.EXAMPLE_LIST);
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
* @throws IOException
* @throws URISyntaxException
*/
@FXML
public void openWiki(javafx.event.ActionEvent actionEvent) throws IOException, URISyntaxException {

Desktop.getDesktop().browse(new URI("https://github.com/devonfw/cobigen/wiki"));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.devonfw.cobigen.gui;
package com.devonfw.cobigen.gui.services;

import javafx.application.Application;
import javafx.collections.FXCollections;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.devonfw.cobigen.gui.services;

import java.util.List;

import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;

/**
* Service class to build Tree Views
*
*/
public class TreeViewBuilder {

/**
* @param templateSetIncrements
* @return
*/
// TODO: Change type of parameter templateSetIncrements to List<TemplateSetIncrement>
// Add Description and Explanation?
public static String[] transformIncrementsToArray(List<String> templateSetIncrements) {

String[] incrementsWithDescriptions = new String[templateSetIncrements.size() * 2];

for (int i = 0; i < incrementsWithDescriptions.length; i++) {
if (i % 2 == 0) {
// incrementsWithDescriptions[i] = templateSetIncrements.get(i).getName();
} else {
// incrementsWithDescriptions[i] = templateSetIncrements.get(i).getDescription();
}
}
return incrementsWithDescriptions;
}

/**
* @param listOfItems list to
* @return
*/
public static TreeView<String> buildTreeView(String[] listOfItems) {

TreeItem<String> rootItem = new TreeItem<>("Increments");
rootItem.setExpanded(true);

for (int i = 0; i < listOfItems.length; i++) {
TreeItem<String> increment = new TreeItem<>(listOfItems[i]);
i++;
TreeItem<String> incrementDescription = new TreeItem<>(listOfItems[i]);
increment.getChildren().add(incrementDescription);
rootItem.getChildren().add(increment);
}

TreeView<String> tree = new TreeView<>(rootItem);
return tree;
}

}
25 changes: 0 additions & 25 deletions cobigen/gui/src/main/resources/com/devonfw/cobigen/gui/Home.fxml

This file was deleted.

This file was deleted.

Loading

0 comments on commit bfa89a9

Please sign in to comment.