summaryrefslogtreecommitdiffstats
path: root/src/de
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-11-30 20:36:13 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-11-30 20:36:13 +0100
commitfde59dfae9ccf9767193c7a8ce67ae27371f9638 (patch)
tree6f50d541164e6eec73a40ad61c2bcd1a3a67b371 /src/de
parent7fcb4b7cbd70d55c6c97e2eb4a8a0f9cd500a006 (diff)
downloadNotepad---fde59dfae9ccf9767193c7a8ce67ae27371f9638.tar.gz
Notepad---fde59dfae9ccf9767193c7a8ce67ae27371f9638.zip
Put gradeList into grades
Diffstat (limited to 'src/de')
-rw-r--r--src/de/fhswf/in/inf/se/notepadMinusMinus/Main.java15
-rw-r--r--src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java27
2 files changed, 22 insertions, 20 deletions
diff --git a/src/de/fhswf/in/inf/se/notepadMinusMinus/Main.java b/src/de/fhswf/in/inf/se/notepadMinusMinus/Main.java
index 3a72d6b..eb22eb5 100644
--- a/src/de/fhswf/in/inf/se/notepadMinusMinus/Main.java
+++ b/src/de/fhswf/in/inf/se/notepadMinusMinus/Main.java
@@ -11,7 +11,6 @@ import de.fhswf.in.inf.se.notepadMinusMinus.model.Grade;
import de.fhswf.in.inf.se.notepadMinusMinus.model.Grades;
import de.fhswf.in.inf.se.notepadMinusMinus.view.MainViewController;
import javafx.application.Application;
-import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
@@ -28,8 +27,7 @@ import javafx.stage.Stage;
*/
public class Main extends Application
{
- private ObservableList<Grade> gradeList = FXCollections
- .observableArrayList(Grade.extractor());
+ private Grades grades = new Grades();
private Stage primaryStage;
@@ -83,7 +81,7 @@ public class Main extends Application
*/
public ObservableList<Grade> getGradeList()
{
- return gradeList;
+ return grades.gradesProperty();
}
/**
@@ -174,8 +172,7 @@ public class Main extends Application
// Reading XML from the file and unmarshalling.
Grades wrapper = (Grades) um.unmarshal(file);
- gradeList.clear();
- gradeList.addAll(wrapper.getGrades());
+ grades.setGrades(wrapper.getGrades());
// Save the file path to the registry.
setGradesFilePath(file);
@@ -210,12 +207,8 @@ public class Main extends Application
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- // Wrapping our grades data.
- Grades wrapper = new Grades();
- wrapper.setGrades(gradeList);
-
// Marshalling and saving XML to the file.
- m.marshal(wrapper, file);
+ m.marshal(grades, file);
// Save the file path to the registry.
setGradesFilePath(file);
diff --git a/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java b/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java
index 631097e..aafc1e6 100644
--- a/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java
+++ b/src/de/fhswf/in/inf/se/notepadMinusMinus/model/Grades.java
@@ -1,7 +1,6 @@
package de.fhswf.in.inf.se.notepadMinusMinus.model;
import java.math.BigDecimal;
-import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
@@ -10,6 +9,8 @@ import javax.xml.bind.annotation.XmlRootElement;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
/**
* TODO Add comment here
@@ -20,7 +21,8 @@ import javafx.beans.property.SimpleObjectProperty;
@XmlRootElement(name = "grades")
public class Grades
{
- protected List<Grade> grades;
+ ObservableList<Grade> grades = FXCollections
+ .observableArrayList(Grade.extractor());
private ObjectProperty<BigDecimal> thesis = new SimpleObjectProperty<>(
new BigDecimal("0.0"));
@@ -36,21 +38,28 @@ public class Grades
@XmlElement(name = "grade", required = true)
public List<Grade> getGrades()
{
- if (grades == null)
- {
- grades = new ArrayList<>();
- }
return this.grades;
}
/**
* TODO Add method comment here
*
- * @param consumption
+ * @param grades
*/
- public void setGrades(List<Grade> consumption)
+ public void setGrades(List<Grade> grades)
{
- this.grades = consumption;
+ this.grades.clear();
+ this.grades.setAll(grades);
+ }
+
+ /**
+ * TODO Add method comment here
+ *
+ * @return
+ */
+ public ObservableList<Grade> gradesProperty()
+ {
+ return grades;
}
/**