Replace Uebung7Gui.java

parent bafa8359
Pipeline #2811 skipped
......@@ -74,22 +74,25 @@ import javafx.event.EventHandler;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javafx.scene.input.MouseEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.*;
/*import javafx.scene.control.Label;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.control.TreeView;*/
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javafx.scene.text.Text;
/**
......@@ -149,9 +152,21 @@ public class Uebung7Gui extends Application {
bp.setPadding(new Insets(10, 20, 10, 20));
final FileChooser fileChooser = new FileChooser();
final Button btnBrowse = new Button("Arztbrief auswählen");
final Button btnBrowse = new Button("Durchsuchen");
final Button btnJSON = new Button("Als JSON exportieren");
final Button btnAnalyze = new Button("Arztbrief analysieren");
final Button btnAnalyze = new Button("Analysieren");
final ComboBox pfadComboBox = new ComboBox();
pfadComboBox.setEditable(true);
pfadComboBox.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String t1) {
arztbrief = t1;
}
});
btnBrowse.setOnAction(
......@@ -161,7 +176,10 @@ public class Uebung7Gui extends Application {
configureFileChooser(fileChooser);
File file = fileChooser.showOpenDialog(primaryStage);
if (file != null) {
arztbrief = file.getPath();
pfadComboBox.getItems().addAll(
file.getPath()
);
pfadComboBox.setValue(file.getPath());
}
}
});
......@@ -175,16 +193,40 @@ public class Uebung7Gui extends Application {
System.out.println(arztbrief);
}
});
btnJSON.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialDirectory(
new File(System.getProperty("user.home"))
);
//Nur .json Dateien als Möglichkeit festlegen
FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("JSON-Dateien (*.json)", "*.json");
fileChooser.getExtensionFilters().add(extFilter);
//Speicherdialog anzeigen
File file = fileChooser.showSaveDialog(primaryStage);
if(file != null){
//Datei als JSON speichern
SaveFile(file);
}
}
});
// Elemente des TopPanes initialisieren
Insets standardabstand = new Insets (10, 10, 10, 10);
Label toplabel1 = new Label("Arztbrief auswählen");
Label toplabel = new Label("Arztbrief auswählen:");
Label emptylabel = new Label("");
toplabel1.setPadding(standardabstand);
//toplabel.setPadding(standardabstand);
btnAnalyze.setAlignment(toplabel.getAlignment());
HBox topbox1 = new HBox(20);
......@@ -193,11 +235,15 @@ public class Uebung7Gui extends Application {
HBox topbox2 = new HBox(20);
topbox2.setPadding(standardabstand);
VBox main_topbox = new VBox(5);
HBox topbox3 = new HBox(20);
topbox2.setPadding(standardabstand);
VBox main_topbox = new VBox(1);
topbox1.getChildren().setAll(btnBrowse);
topbox1.getChildren().setAll(toplabel, pfadComboBox, btnBrowse);
topbox2.getChildren().setAll(btnAnalyze);
main_topbox.getChildren().setAll(topbox1, topbox2);
topbox3.getChildren().setAll(emptylabel);
main_topbox.getChildren().setAll(topbox1, topbox2, topbox3);
bp.setTop(main_topbox);
......@@ -234,11 +280,13 @@ public class Uebung7Gui extends Application {
primaryStage.setScene(scene);
primaryStage.show();
pfadComboBox.setMaxWidth(scene.getWidth()*0.6);
pfadComboBox.setMinWidth(scene.getWidth()*0.6);
//Elemente der BottomPane initialisieren
//btnJSON.setTranslateX(scene.getWidth()*0.75);
bp.setBottom(btnJSON);
}
/* handle wird aufgerufen sobald ein Button geklickt wird
......@@ -247,10 +295,7 @@ public class Uebung7Gui extends Application {
if (event.getSource() == btnJSON) {
}
}
......@@ -290,6 +335,24 @@ public class Uebung7Gui extends Application {
parent.getChildren().add(item);
return item;
}
private void SaveFile(File file){
try {
FileWriter fileWriter = new FileWriter(file);
//TEST STRING!
String content = "GET JSON STRING VOM BACKEND_____";
fileWriter.write(content);
fileWriter.close();
} catch (IOException ex) {
Logger.getLogger(Uebung7Gui.class.getName()).log(Level.SEVERE, null, ex);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment