Skip to content

Commit c437cff

Browse files
committed
#1454 - Initial commit with new module project, frontend implementation and basic class structure
1 parent 7b6bf79 commit c437cff

File tree

16 files changed

+677
-0
lines changed

16 files changed

+677
-0
lines changed

cobigen-gui/gui-systemtest/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>com.devonfw.cobigen</groupId>
5+
<artifactId>gui-parent</artifactId>
6+
<version>${revision}</version>
7+
</parent>
8+
<artifactId>gui-systemtest</artifactId>
9+
</project>

cobigen-gui/gui/pom.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<artifactId>gui-parent</artifactId>
6+
<groupId>com.devonfw.cobigen</groupId>
7+
<version>${revision}</version>
8+
</parent>
9+
<groupId>com.devonfw.cobigen</groupId>
10+
<artifactId>gui</artifactId>
11+
<version>${revision}</version>
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.source>11</maven.compiler.source>
15+
<maven.compiler.target>11</maven.compiler.target>
16+
</properties>
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.openjfx</groupId>
20+
<artifactId>javafx-controls</artifactId>
21+
<version>19</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.openjfx</groupId>
25+
<artifactId>javafx-fxml</artifactId>
26+
<version>19</version>
27+
</dependency>
28+
</dependencies>
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-compiler-plugin</artifactId>
34+
<version>3.8.0</version>
35+
<configuration>
36+
<release>11</release>
37+
</configuration>
38+
</plugin>
39+
<plugin>
40+
<groupId>org.openjfx</groupId>
41+
<artifactId>javafx-maven-plugin</artifactId>
42+
<version>0.0.8</version>
43+
<executions>
44+
<execution>
45+
<!-- Default configuration for running -->
46+
<!-- Usage: mvn clean javafx:run -->
47+
<id>default-cli</id>
48+
<configuration>
49+
<mainClass>org.gui.Main</mainClass>
50+
</configuration>
51+
</execution>
52+
</executions>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module gui {
2+
requires javafx.controls;
3+
4+
requires javafx.fxml;
5+
6+
requires transitive javafx.graphics;
7+
8+
opens org.gui to javafx.fxml;
9+
10+
exports org.gui;
11+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package org.gui;
2+
3+
import javafx.application.Application;
4+
import javafx.collections.FXCollections;
5+
import javafx.collections.ObservableList;
6+
import javafx.scene.Scene;
7+
import javafx.scene.control.ListCell;
8+
import javafx.scene.control.ListView;
9+
import javafx.scene.layout.HBox;
10+
import javafx.stage.Stage;
11+
12+
public class CellFactory extends Application {
13+
@Override
14+
public void start(Stage stage) {
15+
16+
ObservableList<TemplateSetCell> wordsList = FXCollections.observableArrayList();
17+
wordsList.add(new TemplateSetCell("First Word", "Definition of First Word"));
18+
wordsList.add(new TemplateSetCell("Second Word", "Definition of Second Word"));
19+
wordsList.add(new TemplateSetCell("Third Word", "Definition of Third Word"));
20+
ListView<TemplateSetCell> listViewOfWords = new ListView<>(wordsList);
21+
listViewOfWords.setCellFactory(param -> new ListCell<TemplateSetCell>() {
22+
@Override
23+
protected void updateItem(TemplateSetCell item, boolean empty) {
24+
25+
super.updateItem(item, empty);
26+
27+
if (empty || item == null || item.getWord() == null) {
28+
setText(null);
29+
} else {
30+
setText(item.getWord());
31+
}
32+
}
33+
});
34+
stage.setScene(new Scene(listViewOfWords));
35+
stage.show();
36+
}
37+
38+
public static class TemplateSetCell extends HBox {
39+
40+
private final String word;
41+
42+
private final String definition;
43+
44+
public TemplateSetCell(String word, String definition) {
45+
46+
this.word = word;
47+
this.definition = definition;
48+
}
49+
50+
public String getWord() {
51+
52+
return this.word;
53+
}
54+
55+
public String getDefinition() {
56+
57+
return this.definition;
58+
}
59+
}
60+
61+
public static void main(String[] args) {
62+
63+
launch(args);
64+
}
65+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.gui;
2+
3+
import java.net.URL;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import java.util.List;
7+
import java.util.ResourceBundle;
8+
import java.util.stream.Collectors;
9+
10+
import javafx.fxml.FXML;
11+
import javafx.fxml.Initializable;
12+
import javafx.scene.control.Button;
13+
import javafx.scene.control.ListView;
14+
import javafx.scene.control.TextField;
15+
import javafx.scene.input.KeyEvent;
16+
17+
/**
18+
* Controller for the Template Set Management GUI
19+
*/
20+
public class Controller implements Initializable {
21+
22+
ArrayList<String> templateSets = new ArrayList<>(Arrays.asList("templates-devon4j-tests", "templates-devon4j-utils",
23+
"crud-openapi-net", "crud-angular-client-app", "crud-ionic-client-app", "rest-documentation"));
24+
25+
@FXML
26+
public Button clearSearchResultsButton;
27+
28+
@FXML
29+
public TextField searchBar;
30+
31+
// TODO: Transform to ListView<HBox>
32+
@FXML
33+
public ListView<String> searchResultsView;
34+
35+
@FXML
36+
public void search(KeyEvent event) {
37+
38+
this.searchResultsView.getItems().clear();
39+
this.searchResultsView.getItems().addAll(searchTemplateSets(this.searchBar.getText(), this.templateSets));
40+
}
41+
42+
/**
43+
* Called when clearSearchResultsButton is pressed
44+
*/
45+
@FXML
46+
public void clearSearchResults() {
47+
48+
this.searchBar.clear();
49+
this.searchResultsView.getItems().clear();
50+
this.searchResultsView.getItems().addAll(this.templateSets);
51+
}
52+
53+
/**
54+
* Initial View
55+
*/
56+
@Override
57+
public void initialize(URL arg0, ResourceBundle arg1) {
58+
59+
this.searchResultsView.getItems().addAll(this.templateSets);
60+
}
61+
62+
/**
63+
* @param text
64+
* @param templateSets2
65+
* @return
66+
*/
67+
private List<String> searchTemplateSets(String searchWords, List<String> listOfStrings) {
68+
69+
List<String> searchTemplateSetsArray = Arrays.asList(searchWords.trim().split(" "));
70+
71+
return listOfStrings.stream().filter(input -> {
72+
return searchTemplateSetsArray.stream().allMatch(word -> input.toLowerCase().contains(word.toLowerCase()));
73+
}).collect(Collectors.toList());
74+
}
75+
76+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.gui;
2+
3+
/**
4+
* TODO nneuhaus This type ...
5+
*
6+
*/
7+
public class DetailsController {
8+
9+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.scene.layout.AnchorPane?>
4+
5+
<AnchorPane fx:id="detailsPane" minHeight="0.0" minWidth="0.0" prefHeight="459.0" prefWidth="455.0">
6+
<children>
7+
<SplitPane fx:id="horizontalSplitPane" dividerPositions="0.1119186046511628" orientation="VERTICAL" prefHeight="461.0" prefWidth="432.0">
8+
<items>
9+
<AnchorPane fx:id="headerPane" minHeight="0.0" minWidth="0.0" prefHeight="57.0" prefWidth="429.0">
10+
<children>
11+
<Text fx:id="headersText" layoutX="5.0" layoutY="31.0" strokeType="OUTSIDE" strokeWidth="0.0" text="HOME">
12+
<font>
13+
<Font size="18.0" />
14+
</font>
15+
</Text>
16+
</children>
17+
</AnchorPane>
18+
<AnchorPane fx:id="detailsPane" minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
19+
<children>
20+
<Label fx:id="howItWorksLabel" layoutX="6.0" layoutY="6.0" text="How it Works">
21+
<font>
22+
<Font size="14.0" />
23+
</font>
24+
</Label>
25+
<Separator fx:id="howItWorksSeparator" layoutX="2.0" layoutY="35.0" prefHeight="3.0" prefWidth="432.0" />
26+
<Text layoutX="9.0" layoutY="59.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Search for template sets in the search bar on the left" wrappingWidth="340.80274963378906" />
27+
<Text layoutX="19.0" layoutY="117.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Install Template Set" wrappingWidth="108.13612365722656" />
28+
<Text layoutX="165.0" layoutY="117.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Delete Template Set" wrappingWidth="108.13612365722656" />
29+
<Text layoutX="305.0" layoutY="117.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Update Template Set" wrappingWidth="114.13612365722656" />
30+
<Button layoutX="59.0" layoutY="73.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="7.0" style="-fx-background-color: BLUE;" text="+" textFill="WHITE">
31+
<font>
32+
<Font name="System Bold" size="12.0" />
33+
</font>
34+
</Button>
35+
<Button layoutX="207.0" layoutY="73.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="7.0" style="-fx-background-color: BLUE;" text="*" textFill="WHITE">
36+
<font>
37+
<Font name="System Bold" size="12.0" />
38+
</font>
39+
</Button>
40+
<Button layoutX="346.0" layoutY="73.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="7.0" style="-fx-background-color: BLUE;" text="~" textFill="WHITE">
41+
<font>
42+
<Font name="System Bold" size="12.0" />
43+
</font>
44+
</Button>
45+
<Label layoutX="7.0" layoutY="300.0" text="Wiki">
46+
<font>
47+
<Font size="14.0" />
48+
</font>
49+
</Label>
50+
<Separator fx:id="wikiSeparator" layoutX="-1.0" layoutY="329.0" prefHeight="3.0" prefWidth="432.0" />
51+
<Text layoutX="9.0" layoutY="351.0" strokeType="OUTSIDE" strokeWidth="0.0" text="More information can be found in our Wiki: --&gt; https://github.com/devonfw/cobigen/wiki" wrappingWidth="246.13607788085938" />
52+
<Text layoutX="36.0" layoutY="208.0" strokeType="OUTSIDE" strokeWidth="0.0" text="&quot;Tree view for example template set with increments and templates&quot;" />
53+
</children>
54+
</AnchorPane>
55+
</items>
56+
</SplitPane>
57+
</children>
58+
</AnchorPane>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.gui;
2+
3+
import java.io.FileInputStream;
4+
5+
import javafx.application.Application;
6+
import javafx.fxml.FXMLLoader;
7+
import javafx.scene.Scene;
8+
import javafx.scene.layout.AnchorPane;
9+
import javafx.stage.Stage;
10+
11+
public class Main extends Application {
12+
13+
public static void main(String[] args) {
14+
15+
launch(args);
16+
}
17+
18+
@Override
19+
public void start(Stage primaryStage) {
20+
21+
try {
22+
// Create the FXMLLoader
23+
FXMLLoader loader = new FXMLLoader();
24+
// Path to the FXML File
25+
String fxmlDocPath = "C:\\projects\\my-project\\workspaces\\main\\cobigen\\cobigen-gui\\gui\\src\\main\\java\\org\\gui\\TemplateSetManagementGui.fxml";
26+
FileInputStream fxmlStream = new FileInputStream(fxmlDocPath);
27+
// Create the Pane and all Details
28+
AnchorPane root = (AnchorPane) loader.load(fxmlStream);
29+
// Create the Scene
30+
Scene scene = new Scene(root);
31+
// Set the Scene to the Stage
32+
primaryStage.setScene(scene);
33+
// Set the Title to the Stage
34+
primaryStage.setTitle("A SceneBuilder Example");
35+
// Display the Stage
36+
primaryStage.show();
37+
38+
} catch (Exception e) {
39+
e.printStackTrace();
40+
}
41+
}
42+
43+
}

0 commit comments

Comments
 (0)