summaryrefslogtreecommitdiffstats
path: root/src/de/fhswf/in/inf
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2016-01-12 20:35:59 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2016-01-12 21:19:27 +0100
commit13334f73d62fc3970a2dc0b70d81edade69a303d (patch)
tree403ccb016af9353b8cfcda8599cdb885fe8bc8e1 /src/de/fhswf/in/inf
parent83af27ca52e2c877c7a6749a09b16cc84b2dc85f (diff)
downloadProjektthemenvergabe-13334f73d62fc3970a2dc0b70d81edade69a303d.tar.gz
Projektthemenvergabe-13334f73d62fc3970a2dc0b70d81edade69a303d.zip
Allow a projektthema only once
Diffstat (limited to 'src/de/fhswf/in/inf')
-rw-r--r--src/de/fhswf/in/inf/se/projektthemenvergabe/view/ProjektHinzufuegenController.java103
1 files changed, 68 insertions, 35 deletions
diff --git a/src/de/fhswf/in/inf/se/projektthemenvergabe/view/ProjektHinzufuegenController.java b/src/de/fhswf/in/inf/se/projektthemenvergabe/view/ProjektHinzufuegenController.java
index a51a326..77608a1 100644
--- a/src/de/fhswf/in/inf/se/projektthemenvergabe/view/ProjektHinzufuegenController.java
+++ b/src/de/fhswf/in/inf/se/projektthemenvergabe/view/ProjektHinzufuegenController.java
@@ -239,54 +239,87 @@ public class ProjektHinzufuegenController
{
if (!projektthemaTextField.getText().trim().isEmpty())
{
- if (projekt == null)
- {
- projekt = new Projekt(projektthemaTextField.getText().trim(),
- student1ComboBox.getValue(), student2ComboBox.getValue(),
- student3ComboBox.getValue(),
- ansprechpartnerComboBox.getValue());
- }
- else
- {
- projekt.setProjektthema(projektthemaTextField.getText().trim());
- projekt.setAnsprechpartner(ansprechpartnerComboBox.getValue());
+ boolean projektthemaAlreadyExists = false;
- if (projekt.getStudent1() != null)
+ for (Projekt projekt : main.getProjekte())
+ {
+ if (projekt.getProjektthema()
+ .equals(projektthemaTextField.getText().trim()))
{
- projekt.removeStudent(projekt.getStudent1());
+ projektthemaAlreadyExists = true;
+ break;
}
- if (projekt.getStudent2() != null)
+ }
+
+ if ((projekt != null && projektthemaTextField.getText().trim()
+ .equals(projekt.getProjektthema()))
+ || !projektthemaAlreadyExists)
+ {
+ if (projekt == null)
{
- projekt.removeStudent(projekt.getStudent2());
+ projekt = new Projekt(projektthemaTextField.getText().trim(),
+ student1ComboBox.getValue(), student2ComboBox.getValue(),
+ student3ComboBox.getValue(),
+ ansprechpartnerComboBox.getValue());
}
- if (projekt.getStudent3() != null)
+ else
{
- projekt.removeStudent(projekt.getStudent3());
- }
+ projekt
+ .setProjektthema(projektthemaTextField.getText().trim());
+ projekt.setAnsprechpartner(ansprechpartnerComboBox.getValue());
- if (student1ComboBox.getValue() != null)
- {
- projekt.addStudent(student1ComboBox.getValue());
- }
+ if (projekt.getStudent1() != null)
+ {
+ projekt.removeStudent(projekt.getStudent1());
+ }
+ if (projekt.getStudent2() != null)
+ {
+ projekt.removeStudent(projekt.getStudent2());
+ }
+ if (projekt.getStudent3() != null)
+ {
+ projekt.removeStudent(projekt.getStudent3());
+ }
- if (student2ComboBox.getValue() != null)
- {
- projekt.addStudent(student2ComboBox.getValue());
- }
+ if (student1ComboBox.getValue() != null)
+ {
+ projekt.addStudent(student1ComboBox.getValue());
+ }
- if (student3ComboBox.getValue() != null)
- {
- projekt.addStudent(student3ComboBox.getValue());
+ if (student2ComboBox.getValue() != null)
+ {
+ projekt.addStudent(student2ComboBox.getValue());
+ }
+
+ if (student3ComboBox.getValue() != null)
+ {
+ projekt.addStudent(student3ComboBox.getValue());
+ }
}
+
+ projekt.setSkizze(projektskizzeTextField.getText().trim());
+ projekt.setProjektbeschreibung(
+ projekthintergrundTextField.getText().trim());
+ projekt.setProjekteinhalte(
+ projektinhalteTextField.getText().trim());
+
+ wasAborted = false;
+ projekthinzufuegenStage.close();
}
+ else
+ {
+ Alert alert = new Alert(AlertType.ERROR);
+ alert.setTitle("Projektthema ist bereits vorhanden");
+ alert.setHeaderText("Projekt wurde bereits angelegt.");
+ alert.setContentText(
+ "Bitte geben Sie ein neues Projektthema ein.");
- projekt.setSkizze(projektskizzeTextField.getText().trim());
- projekt.setProjektbeschreibung(
- projekthintergrundTextField.getText().trim());
- projekt.setProjekteinhalte(projektinhalteTextField.getText().trim());
+ alert.initOwner(main.getProjekthinzufuegenStage());
- wasAborted = false;
- projekthinzufuegenStage.close();
+ alert.showAndWait();
+
+ projektthemaTextField.requestFocus();
+ }
}
else
{