first commit

This commit is contained in:
Michael Hayder 2025-01-05 15:12:26 +01:00
commit 411c04f26e
25 changed files with 592 additions and 0 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

13
.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="superclass-app" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

20
.idea/jarRepositories.xml generated Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

12
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK" />
</project>

6
.idea/templateLanguages.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="TemplateDataLanguageMappings">
<file url="PROJECT" dialect="JVM" />
</component>
</project>

0
.mvn/jvm.config Normal file
View File

0
.mvn/maven.config Normal file
View File

0
README.md Normal file
View File

124
pom.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.altimate.app</groupId>
<artifactId>superclass-app</artifactId>
<version>1.0-SNAPSHOT</version>
<name>superclass-app</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.version>21</javafx.version>
<javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<!-- Optionally: parameterized tests support -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
<configuration>
<mainClass>net.altimate.app.App</mainClass>
</configuration>
</plugin>
</plugins>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -0,0 +1,308 @@
package net.altimate.app;
import java.lang.Object;
import java.lang.Class;
import java.time.format.DateTimeFormatter;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class App extends Application {
Scene sceneHome;
Scene sceneCreate;
Scene sceneList;
public final String filesDirectory = "/tmp/files";
public static void main(String args[]){
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
//GridPane grid = new GridPane();
//grid.setPadding(new Insets(10, 10, 10, 10));
//grid.setVgap(5);
//grid.setHgap(5);
//Start = new Scene(grid, 600, 300);
setupSceneList(primaryStage);
setupSceneHome(primaryStage);
setupSceneCreate(primaryStage);
primaryStage.setTitle("Work out a S.M.A.R.T. Target ");
primaryStage.setScene(sceneHome);
primaryStage.show();
}
private void navigationButtons(Stage primaryStage, GridPane grid, Label label) {
boolean reloadValue = false;
Button home = new Button("Home");
GridPane.setConstraints(home, 0, 0);
home.setOnAction(e -> primaryStage.setScene(sceneHome));
grid.getChildren().add(home);
Button create = new Button("Create");
GridPane.setConstraints(create, 1, 0);
create.setOnAction(e -> primaryStage.setScene(sceneCreate));
grid.getChildren().add(create);
Button list = new Button("List");
GridPane.setConstraints(list, 2, 0);
//list.setOnAction(e -> primaryStage.setScene(sceneList));
grid.getChildren().add(list);
list.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
primaryStage.setScene(sceneList);
}
});
}
// grid, textfieldname , textfield, TextPrefColumnCount, rowColumn, rowIndex
private void addTextfield(GridPane grid, String textFieldName, String textFieldText, int prefColumnCount, int rowColumn, int rowIndex) {
final TextField nameSmartZiel = new TextField();
nameSmartZiel.setPromptText(textFieldText);
nameSmartZiel.setPrefColumnCount(1);
GridPane.setConstraints(nameSmartZiel,rowColumn,rowIndex);
grid.getChildren().add(nameSmartZiel);
}
public void setupSceneHome(Stage primaryStage) throws Exception {
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(5);
grid.setHgap(5);
sceneHome = new Scene(grid, 600, 300);
Label label = new Label("This is the Home Scene");
navigationButtons(primaryStage, grid, label);
//Button button = new Button("Forward");
//button.setOnAction(e -> primaryStage.setScene(sceneList));
//TextField text = new TextField();
//text.setMaxWidth(100);
//layout.getChildren().addAll(label1, button);
}
public void setupSceneCreate(Stage primaryStage) throws Exception {
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(5);
grid.setHgap(5);
sceneCreate = new Scene(grid, 600, 300);
Label label = new Label();
navigationButtons(primaryStage, grid, label);
DatePicker checkInDatePicker;
checkInDatePicker = new DatePicker();
final TextField nameSmartZiel = new TextField();
nameSmartZiel.setPromptText("Gib dm Smart Ziel einen Namen");
nameSmartZiel.setPrefColumnCount(1);
GridPane.setConstraints(nameSmartZiel,0,1);
grid.getChildren().add(nameSmartZiel);
final TextField sinnesSpezifisch = new TextField();
sinnesSpezifisch.setPromptText("wie ist es sinnespezifisch wahrnehmbar");
sinnesSpezifisch.setPrefColumnCount(1);
//sinnesSpezifisch.getText();
GridPane.setConstraints(sinnesSpezifisch, 0, 2);
grid.getChildren().add(sinnesSpezifisch);
final TextField messBar = new TextField();
messBar.setPrefColumnCount(20);
messBar.setPromptText("Wie ist es messabr, wenn Du es erreicht hat");
GridPane.setConstraints(messBar, 0, 3);
grid.getChildren().add(messBar);
final TextField attraktiv = new TextField();
attraktiv.setPrefColumnCount(20);
attraktiv.setPromptText("Ist es attraktiv?");
GridPane.setConstraints(attraktiv, 0, 4);
grid.getChildren().add(attraktiv);
final TextField realistisch = new TextField();
realistisch.setPrefColumnCount(20);
realistisch.setPromptText("Ist es realistisch selbst erreichbar ?");
GridPane.setConstraints(realistisch, 0, 5);
grid.getChildren().add(realistisch);
final Label checkInlabel = new Label("Terminiert bis");
grid.add(checkInlabel, 0, 6);
grid.add(checkInDatePicker, 0, 7);
Button submit = new Button("Submit");
GridPane.setConstraints(submit, 0, 8);
grid.getChildren().add(submit);
Button clear = new Button("Clear");
GridPane.setConstraints(clear, 1, 8);
grid.getChildren().add(clear);
submit.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
if (
(nameSmartZiel.getText() != null && !nameSmartZiel.getText().isEmpty())
&& (sinnesSpezifisch.getText() != null && !sinnesSpezifisch.getText().isEmpty())
&& (messBar.getText() != null && !messBar.getText().isEmpty())
&& (attraktiv.getText() != null && !attraktiv.getText().isEmpty())
&& (realistisch.getText() != null && !realistisch.getText().isEmpty())
) {
label.setText( nameSmartZiel.getText() + " " + sinnesSpezifisch.getText() + " " +
messBar.getText() + " " + attraktiv.getText() + " " + realistisch.getText() + ", "
+ "thanks" + checkInDatePicker.getValue());
String date = checkInDatePicker.getValue().format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));
String[] createSmart = {
nameSmartZiel.getText() + "|" +
sinnesSpezifisch.getText() + "|" +
messBar.getText() + "|" +
attraktiv.getText() + "|" +
realistisch.getText() + "|" +
date
};
long seconds = System.currentTimeMillis() / 1000l;
CreateFile.writeFile(filesDirectory + "/" + seconds + ".smart", createSmart);
} else {
label.setText("You have not filed out the complete form");
}
}
});
clear.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
nameSmartZiel.clear();
sinnesSpezifisch.clear();
messBar.clear();
attraktiv.clear();
realistisch.clear();
checkInlabel.setText(null);
label.setText(null);
}
});
//addTextfield(grid, "sinnesSpezifisch", "blash", 1, 1, 1);
//Button button = new Button("Home");
//button.setOnAction(e -> primaryStage.setScene(sceneHome));
//TextField text = new TextField();
//text.setMaxWidth(100);
//layout.getChildren().addAll(label1, button);
}
public void setupSceneList(Stage primaryStage) throws Exception {
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(5);
grid.setHgap(5);
//layout.setAlignment(Pos.CENTER);
sceneList = new Scene(grid, 600, 300);
Label label = new Label();
navigationButtons(primaryStage, grid, label);
Button reload = new Button("Reload");
GridPane.setConstraints(reload, 1, 8);
grid.getChildren().add(reload);
reload.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ListFilesInDir.listFilesInDir(filesDirectory);
ListView<String> list1 = new ListView<String>();
ObservableList<String> items = FXCollections.observableArrayList (ListFilesInDir.listFilesInDir(filesDirectory));
list1.setItems(items);
GridPane.setConstraints(list1, 0, 1);
grid.getChildren().add(list1);
String fileName = "/tmp/files/1735938766.smart";
//ReadFile.readFile(fileName);
System.out.println(ReadFile.readFile(fileName));
}
});
//ListFilesInDir.listFilesInDir(filesDirectory);
//ListView<String> list1 = new ListView<String>();
//ObservableList<String> items = FXCollections.observableArrayList (ListFilesInDir.listFilesInDir(filesDirectory));
//list1.setItems(items);
//GridPane.setConstraints(list1, 0, 1);
//grid.getChildren().add(list1);
//Button button = new Button("Backward");
//button.setOnAction(e -> primaryStage.setScene(sceneHome));
//TextField text = new TextField();
//text.setMaxWidth(100);
//grid.getChildren().addAll(label, button);
}
}

View File

@ -0,0 +1,26 @@
package net.altimate.app;
// write file
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
public class CreateFile {
public static void writeFile (String filename, String[] createSmart ) {
try {
FileWriter myWriter = new FileWriter(filename);
// myWriter.write("Files in Java might be tricky, but it is fun enough!");
myWriter.write(Arrays.toString(createSmart));
myWriter.close();
} catch (IOException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,29 @@
package net.altimate.app;
import java.io.File;
public class ListFilesInDir {
public static String[] listFilesInDir ( String directory ) {
File filesInDir = null;
File[] paths;
try {
filesInDir = new File(directory);
paths = filesInDir.listFiles();
for(File path:paths) {
System.out.println(path.getName());
}
} catch(Exception efile) {
efile.printStackTrace();
}
return filesInDir.list();
}
}

View File

@ -0,0 +1,24 @@
package net.altimate.app;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class ReadFile {
public static String readFile(String fileName) {
try {
String s = Files.readString(Path.of(fileName));
String s1 = s;
System.out.println(s1);
return s1;
} catch (IOException e) {
e.printStackTrace();
}
String o = null;
return o;
}
}

View File

@ -0,0 +1,19 @@
package net.altimate.app;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/
public class AppTest {
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue() {
assertTrue(true);
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
/home/mic/DM/workspaces/tmp/superclass-app/src/main/java/net/altimate/app/App.java