Skip to content

Commit

Permalink
Validator View
Browse files Browse the repository at this point in the history
  • Loading branch information
GranitGuri committed Jul 2, 2018
1 parent d8cc506 commit cd883a3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/main/java/de/sbtab/controller/SBTabController.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,15 @@ public static boolean validate(SBMLDocument doc) {
public static int numErrors(SBMLDocument doc) {
return doc.checkConsistencyOffline();
}
/**
* Testmethod to get a String-Type Error Code
* @param doc
* @return String-Error
*/
public static String errorToString(SBMLDocument doc) {
int numErrors = doc.checkConsistencyOffline();
String StringError = null;
StringError = doc.getError(0).toString();
return StringError;
}
}
45 changes: 38 additions & 7 deletions src/main/java/de/sbtab/view/SBTabMenuController.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package de.sbtab.view;

import java.awt.Label;
import java.awt.TextArea;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.net.URL;
import java.util.Optional;
import java.util.Properties;
Expand All @@ -22,6 +27,7 @@
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.control.Menu;
import javafx.scene.layout.GridPane;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
Expand Down Expand Up @@ -198,13 +204,38 @@ void doValidate(ActionEvent event) {

}
else{
Alert alert = new Alert(AlertType.CONFIRMATION);
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
alert.setGraphic(new ImageView(this.getClass().getResource("DisapproveIcon_64.png").toString()));
stage.getIcons().add(new Image(this.getClass().getResourceAsStream("Icon_32.png")));
alert.setTitle("Validator");
alert.setHeaderText(null);
alert.setContentText("Your Document has " + SBTabController.numErrors(doc) + " Errors");
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Exception Dialog");
alert.setHeaderText("You have " + SBTabController.numErrors(doc) + "Errors in your Document.");
alert.setContentText("List of all Errors");

Exception ex = new FileNotFoundException("Error");

// Create expandable Exception.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();

Label label = new Label("The exception stacktrace was:");

TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);

textArea.setSize((int)Double.MAX_VALUE, (int)Double.MAX_VALUE);
//Cannot be resolved to a field for unknown reason
//GridPane.setVgrow(textArea, Priority.ALWAYS);
//GridPane.setHgrow(textArea, Priority.ALWAYS);

GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
//despite all tutorials and Documentations the add functions states that it needs a node
//expContent.add(label, 0, 0);
//expContent.add(textArea, 0, 1);

// Set expandable Exception into the dialog pane.
alert.getDialogPane().setExpandableContent(expContent);

alert.showAndWait();
}

Expand Down

0 comments on commit cd883a3

Please sign in to comment.