309 lines
9.9 KiB
Java
309 lines
9.9 KiB
Java
|
|
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);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|