Compare commits
No commits in common. "main" and "feature_cropsAndTaskGUI_M2" have entirely different histories.
main
...
feature_cr
|
@ -1,27 +0,0 @@
|
||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to document bugs.
|
|
||||||
title: "[BUG]"
|
|
||||||
labels: bug
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Class / Methods**
|
|
||||||
List of classes or methods which contains the bug. (If known)
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Features to implement
|
|
||||||
title: "[FEATURE]"
|
|
||||||
labels: feature
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Description of Usecase**
|
|
||||||
A clear and concise description of what the feature allows to do.
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**List of Classes and Methods to implement**
|
|
||||||
List all Classes and Methods which have to be implemented.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
name: Tests
|
|
||||||
about: Tests to implement
|
|
||||||
title: "[TEST]"
|
|
||||||
labels: Tests
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Feature description**
|
|
||||||
A clear and concise description of the functionality which have to be tested.
|
|
||||||
|
|
||||||
**Test cases**
|
|
||||||
A list of cases which have to be tested.
|
|
||||||
|
|
||||||
**List of affected Classes and Methods**
|
|
||||||
A clear and concise list of the classes and methods which have to be tested.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
43
README.md
|
@ -1,19 +1,32 @@
|
||||||
# GardenPlanner
|
# PM3-HS22-IT21b_WIN-Team1
|
||||||
|
PM3 FivePlants Gartenverwaltung
|
||||||
|
|
||||||
## Installations- und Gebrauchsanweisung
|
## Class Diagram
|
||||||
### Vorbedingungen
|
Umletino: https://www.umletino.com/umletino.html
|
||||||
- Das Java Runtime Environment (JRE) muss in der Version 17 auf Ihrem Computer installiert sein.
|
|
||||||
- Das Java Development Kit (JDK) muss in der Version 17 auf Ihrem Computer installiert sein.
|
|
||||||
|
|
||||||
### Installation und Starten der Applikation
|
Draft File: doc/ClassDiagramDraft.uxf
|
||||||
1. Laden sie die neuste Version der Applikation herunter. Sie finden die Applikation hier:
|
|
||||||
https://github.zhaw.ch/schrom01/PM3-HS22-IT21b_WIN-Team1/tags
|
|
||||||
2. Extrahieren sie die heruntergeladene ZIP-Datei
|
|
||||||
3. Öffnen sie ein Kommandozeilenfenster und navigieren sie an den Speicherort der Entpack-ten Applikation.
|
|
||||||
4. Führen sie den Befehl: «./gradlew.bat run» (auf Windows) oder «./gradlew run» (auf ma-cOS und Linux) aus.
|
|
||||||
|
|
||||||
### Anwendung
|
## Branch model
|
||||||
Eine Bedienungsanleitung finden Sie im Dokument ["Technischer Bericht II"](doc/PM3-HS22-IT21b_WIN-Technischer_Bericht_II-Team1.pdf) im Kapitel 6.3.3.
|
- production branch: `main`
|
||||||
|
|
||||||
## Projektdokumentation
|
This branch has a working version of the code.
|
||||||
Die gesamte Projektdokumentation ist im Dokument ["Technischer Bericht II"](doc/PM3-HS22-IT21b_WIN-Technischer_Bericht_II-Team1.pdf) zu finden.
|
|
||||||
|
- development branch: `dev`
|
||||||
|
|
||||||
|
This branch should contain a running (although not necessarily working) version of the code. Working states are to be merged into the `main` branch regularly.
|
||||||
|
|
||||||
|
- feature: `feature_xy_<Milestone>`
|
||||||
|
|
||||||
|
These branches contain features in active development. When the code is ready it will be merged into the `dev` branch.
|
||||||
|
|
||||||
|
- bugfix: `bugfix_xy_<Milestone>`
|
||||||
|
|
||||||
|
These branches are for bugfixes.
|
||||||
|
|
||||||
|
- documentation: `doc_xy_<Milestone>`
|
||||||
|
|
||||||
|
These branches are for javadoc and project documentation (such as the readme, class diagrams etc.).
|
||||||
|
|
||||||
|
|
||||||
|
## User Manual
|
||||||
|
- Search Plant List: if first Char is '#': only exact match in ID.
|
||||||
|
|
14
build.gradle
|
@ -3,7 +3,6 @@ plugins {
|
||||||
id 'application'
|
id 'application'
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.13'
|
id 'org.openjfx.javafxplugin' version '0.0.13'
|
||||||
id 'org.beryx.jlink' version '2.25.0'
|
id 'org.beryx.jlink' version '2.25.0'
|
||||||
id 'jacoco'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'ch.zhaw.gartenverwaltung'
|
group 'ch.zhaw.gartenverwaltung'
|
||||||
|
@ -26,7 +25,7 @@ tasks.withType(JavaCompile) {
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainModule = 'ch.zhaw.gartenverwaltung'
|
mainModule = 'ch.zhaw.gartenverwaltung'
|
||||||
mainClass = 'ch.zhaw.gartenverwaltung.Main'
|
mainClass = 'ch.zhaw.gartenverwaltung.HelloApplication'
|
||||||
}
|
}
|
||||||
|
|
||||||
javafx {
|
javafx {
|
||||||
|
@ -42,21 +41,10 @@ dependencies {
|
||||||
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4'
|
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4'
|
||||||
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4'
|
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4'
|
||||||
testImplementation 'org.mockito:mockito-core:4.3.+'
|
testImplementation 'org.mockito:mockito-core:4.3.+'
|
||||||
implementation 'com.sun.mail:javax.mail:1.6.2'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
finalizedBy jacocoTestReport
|
|
||||||
}
|
|
||||||
|
|
||||||
jacocoTestReport {
|
|
||||||
dependsOn test
|
|
||||||
}
|
|
||||||
|
|
||||||
jacoco {
|
|
||||||
toolVersion = "0.8.8"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jlink {
|
jlink {
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
<diagram program="umletino" version="15.0.0"><zoom_level>10</zoom_level><element><id>UMLClass</id><coordinates><x>720</x><y>30</y><w>100</w><h>30</h></coordinates><panel_attributes>Main</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1240</x><y>250</y><w>300</w><h>140</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
PlantDatabase
|
||||||
|
--
|
||||||
|
+ getPlantList(zone: HardinessZone): List<Plant>
|
||||||
|
+ getPlant(id: long): Optional<Plant></panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>940</x><y>580</y><w>220</w><h>40</h></coordinates><panel_attributes>TaskListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1240</x><y>10</y><w>300</w><h>180</h></coordinates><panel_attributes><<Record>>
|
||||||
|
Plant
|
||||||
|
--
|
||||||
|
+ id: long
|
||||||
|
+ name: String
|
||||||
|
+ description: String
|
||||||
|
+ spacing: int
|
||||||
|
+ lifecycle: List<GrowthPhase>
|
||||||
|
--
|
||||||
|
+ calculateStartDate(harvestDate: Date): Date
|
||||||
|
+ generateTasks()
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1210</x><y>580</y><w>210</w><h>120</h></coordinates><panel_attributes>TaskListModel
|
||||||
|
--
|
||||||
|
- tasks: ListProperty<Task>
|
||||||
|
- taskDb: TaskDatabase
|
||||||
|
--
|
||||||
|
+ getTask(id: long): Optional<Task>
|
||||||
|
+ saveTask(task: Task)
|
||||||
|
+ removeTask(task: Task)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>590</x><y>560</y><w>250</w><h>110</h></coordinates><panel_attributes>GardenPlanModel
|
||||||
|
--
|
||||||
|
- tasks: ListProperty<Task>
|
||||||
|
- gardenPlan: GardenPlan
|
||||||
|
--
|
||||||
|
+ savePlanting(planting: UserPlanting)
|
||||||
|
+ removePlanting(planting: UserPlanting)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>340</x><y>550</y><w>180</w><h>80</h></coordinates><panel_attributes>GardenPlanController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1660</x><y>720</y><w>490</w><h>240</h></coordinates><panel_attributes>Task
|
||||||
|
--
|
||||||
|
+ id: long
|
||||||
|
+ name: String {readOnly}
|
||||||
|
+ description: String {readOnly}
|
||||||
|
+ startDate: Date {readOnly}
|
||||||
|
+ isReadOnly: boolean {readOnly}
|
||||||
|
- interval: int
|
||||||
|
- endDate: Date
|
||||||
|
--
|
||||||
|
+ Task(name: String, description: String, startDate: String, isReadOnly: boolean): Task
|
||||||
|
+ withInterval(interval: int): Task
|
||||||
|
+ withEndDate(endDate: Date): Task
|
||||||
|
+ withId(id: long): Task
|
||||||
|
--
|
||||||
|
+ getInterval(): Optional<int>
|
||||||
|
+ getEndDate(): Optional<Date></panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1170</x><y>760</y><w>280</w><h>140</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
TaskDatabase
|
||||||
|
--
|
||||||
|
+ getTaskList(start: Date, end: Date): List<Task>
|
||||||
|
+ saveTask(Task task) throws ??Exception
|
||||||
|
+ removeTask(Task task) throws ??Exception</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>780</x><y>310</y><w>100</w><h>100</h></coordinates><panel_attributes>MainWindow</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>440</x><y>180</y><w>180</w><h>130</h></coordinates><panel_attributes>MainWindowController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1340</x><y>1070</y><w>210</w><h>70</h></coordinates><panel_attributes>NotificationService
|
||||||
|
--
|
||||||
|
- taskDb: TaskDatabase
|
||||||
|
--
|
||||||
|
+ tick()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1640</x><y>1210</y><w>240</w><h>140</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
WeatherProvider
|
||||||
|
--
|
||||||
|
+ getWeatherForecast: WeatherForecast</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1620</x><y>1040</y><w>400</w><h>100</h></coordinates><panel_attributes>WeatherService
|
||||||
|
--
|
||||||
|
- weatherPovider: WeatherProvider
|
||||||
|
- taskDb: TaskDatabase
|
||||||
|
--
|
||||||
|
+ WeatherService(provider: WeatherProvider, taskDb: TaskDatabase)
|
||||||
|
- updateTasks()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1620</x><y>10</y><w>260</w><h>150</h></coordinates><panel_attributes><<Record>>
|
||||||
|
GrowthPhase
|
||||||
|
--
|
||||||
|
+ startDate: Date
|
||||||
|
+ endDate: Date
|
||||||
|
+ type: GrowthPhaseType
|
||||||
|
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1530</x><y>80</y><w>110</w><h>30</h></coordinates><panel_attributes>lt=<->>>>></panel_attributes><additional_attributes>90;10;10;10</additional_attributes></element><element><id>Text</id><coordinates><x>420</x><y>0</y><w>190</w><h>70</h></coordinates><panel_attributes>Note:
|
||||||
|
--
|
||||||
|
{final, readOnly} omitted on public data fields in <<Record>> Entities for clarity
|
||||||
|
style=wordwrap</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1440</x><y>820</y><w>240</w><h>30</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>220;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1300</x><y>690</y><w>30</w><h>90</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;70;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>600</x><y>980</y><w>210</w><h>120</h></coordinates><panel_attributes><<Record>>
|
||||||
|
UserPlanting
|
||||||
|
--
|
||||||
|
+ plantId: long
|
||||||
|
+ asSowing: boolean
|
||||||
|
+ startDate: Date
|
||||||
|
+ area: int</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1380</x><y>180</y><w>30</w><h>90</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;10;10;70</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1950</x><y>10</y><w>140</w><h>120</h></coordinates><panel_attributes><<Enumeration>>
|
||||||
|
GrowthPhaseType
|
||||||
|
--
|
||||||
|
SOW
|
||||||
|
PLANT
|
||||||
|
HARVEST</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1870</x><y>70</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=<->>>></panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1150</x><y>590</y><w>80</w><h>30</h></coordinates><panel_attributes>lt=<->>>></panel_attributes><additional_attributes>60;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>700</x><y>890</y><w>30</w><h>110</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;90;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>510</x><y>580</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=<->>>></panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>570</x><y>760</y><w>280</w><h>140</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
GardenPlan
|
||||||
|
--
|
||||||
|
+ getPlantings(): List<UserPlanting>
|
||||||
|
+ addPlanting(plantId: long, startDate)
|
||||||
|
+ savePlanting(planting: UserPlanting)
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>690</x><y>660</y><w>30</w><h>120</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;100;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>60</x><y>390</y><w>180</w><h>80</h></coordinates><panel_attributes>PlantingCell
|
||||||
|
{extends ListCell<>}</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>0</x><y>540</y><w>290</w><h>80</h></coordinates><panel_attributes>PlantingCellFactory
|
||||||
|
{implements Callback<ListView<UserPlanting> >}</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>140</x><y>460</y><w>30</w><h>100</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;10;10;80</additional_attributes></element><element><id>Relation</id><coordinates><x>1750</x><y>1130</y><w>30</w><h>100</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;80;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1350</x><y>890</y><w>120</w><h>200</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;10;100;180</additional_attributes></element><element><id>Relation</id><coordinates><x>1380</x><y>890</y><w>260</w><h>220</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;10;240;200</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1090</x><y>1060</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonTaskDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1180</x><y>890</y><w>30</w><h>190</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>10;10;10;170</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1620</x><y>310</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonPlantDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1530</x><y>320</y><w>110</w><h>30</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>10;10;90;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>300</x><y>800</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonGardenPlan</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>490</x><y>810</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>280</x><y>570</y><w>80</w><h>30</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;10;60;10</additional_attributes></element><element><id>Relation</id><coordinates><x>850</x><y>400</y><w>220</w><h>200</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>200;180;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>440</x><y>400</y><w>390</w><h>170</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;150;370;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>850</x><y>120</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>760</x><y>50</y><w>90</w><h>280</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>70;260;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>610</x><y>230</y><w>190</w><h>140</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;10;170;120</additional_attributes></element><element><id>Relation</id><coordinates><x>870</x><y>170</y><w>80</w><h>210</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>60;10;10;190</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1020</x><y>290</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListModel</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1000</x><y>150</y><w>110</w><h>160</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>90;140;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1170</x><y>310</y><w>90</w><h>30</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>70;10;10;10</additional_attributes></element></diagram>
|
After Width: | Height: | Size: 25 KiB |
|
@ -0,0 +1,7 @@
|
||||||
|
<diagram program="umletino" version="15.0.0"><zoom_level>10</zoom_level><element><id>UMLPackage</id><coordinates><x>390</x><y>60</y><w>340</w><h>100</h></coordinates><panel_attributes>UI</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>390</x><y>180</y><w>460</w><h>120</h></coordinates><panel_attributes>Domain</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>390</x><y>330</y><w>460</w><h>120</h></coordinates><panel_attributes>Technical Services</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>400</x><y>90</y><w>100</w><h>60</h></coordinates><panel_attributes>Views (JFX)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>400</x><y>220</y><w>100</w><h>60</h></coordinates><panel_attributes>IO</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>400</x><y>370</y><w>100</w><h>60</h></coordinates><panel_attributes>Jackson</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>510</x><y>220</y><w>100</w><h>60</h></coordinates><panel_attributes>Types</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>620</x><y>220</y><w>100</w><h>60</h></coordinates><panel_attributes>Models</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>510</x><y>90</y><w>110</w><h>60</h></coordinates><panel_attributes>Controllers (JFX)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>510</x><y>370</y><w>100</w><h>60</h></coordinates><panel_attributes>Logging</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>620</x><y>370</y><w>100</w><h>60</h></coordinates><panel_attributes>JavaFX</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>730</x><y>220</y><w>110</w><h>60</h></coordinates><panel_attributes>Services</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLPackage</id><coordinates><x>730</x><y>370</y><w>110</w><h>60</h></coordinates><panel_attributes>HTTP/API</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>570</x><y>150</y><w>90</w><h>70</h></coordinates><panel_attributes>lt=.>
|
||||||
|
</panel_attributes><additional_attributes>70;10;10;50</additional_attributes></element><element><id>Relation</id><coordinates><x>570</x><y>290</y><w>110</w><h>80</h></coordinates><panel_attributes>lt=.>
|
||||||
|
</panel_attributes><additional_attributes>90;10;10;60</additional_attributes></element><element><id>Relation</id><coordinates><x>340</x><y>120</y><w>350</w><h>400</h></coordinates><panel_attributes>lt=.>
|
||||||
|
</panel_attributes><additional_attributes>60;10;10;10;10;380;330;380;330;310</additional_attributes></element><element><id>Relation</id><coordinates><x>770</x><y>270</y><w>30</w><h>120</h></coordinates><panel_attributes>lt=.>
|
||||||
|
</panel_attributes><additional_attributes>10;10;10;100</additional_attributes></element><element><id>Relation</id><coordinates><x>360</x><y>250</y><w>60</w><h>180</h></coordinates><panel_attributes>lt=.>
|
||||||
|
</panel_attributes><additional_attributes>40;10;10;10;10;160;40;160</additional_attributes></element><element><id>Relation</id><coordinates><x>610</x><y>120</y><w>70</w><h>120</h></coordinates><panel_attributes>lt=.>
|
||||||
|
</panel_attributes><additional_attributes>10;10;50;10;50;100</additional_attributes></element></diagram>
|
After Width: | Height: | Size: 286 KiB |
|
@ -0,0 +1,144 @@
|
||||||
|
<diagram program="umletino" version="15.0.0"><zoom_level>10</zoom_level><element><id>UMLClass</id><coordinates><x>482</x><y>360</y><w>100</w><h>30</h></coordinates><panel_attributes>Main</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1082</x><y>380</y><w>370</w><h>100</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
PlantDatabase
|
||||||
|
--
|
||||||
|
+ getPlantList(zone: HardinessZone): List<Plant>
|
||||||
|
+ getPlantById(zone: HardinessZone id: long): Optional<Plant></panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>672</x><y>710</y><w>220</w><h>40</h></coordinates><panel_attributes>TaskListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1132</x><y>110</y><w>300</w><h>180</h></coordinates><panel_attributes><<Record>>
|
||||||
|
Plant
|
||||||
|
--
|
||||||
|
+ id: long
|
||||||
|
+ name: String
|
||||||
|
+ description: String
|
||||||
|
+ spacing: int
|
||||||
|
+ lifecycle: List<GrowthPhase>
|
||||||
|
--
|
||||||
|
+ calculateStartDate(harvestDate: Date): Date
|
||||||
|
+ generateTasks()
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>942</x><y>710</y><w>210</w><h>120</h></coordinates><panel_attributes>TaskListModel
|
||||||
|
--
|
||||||
|
- tasks: ListProperty<Task>
|
||||||
|
- taskDb: TaskDatabase
|
||||||
|
--
|
||||||
|
+ getTask(id: long): Optional<Task>
|
||||||
|
+ saveTask(task: Task)
|
||||||
|
+ removeTask(task: Task)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>322</x><y>690</y><w>250</w><h>120</h></coordinates><panel_attributes>GardenPlanModel
|
||||||
|
--
|
||||||
|
- tasks: ListProperty<Crop>
|
||||||
|
- gardenPlan: GardenPlan
|
||||||
|
--
|
||||||
|
+ plantAsCrop(planting: UserPlanting)
|
||||||
|
+ removePlanting(planting: UserPlanting)</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>72</x><y>680</y><w>180</w><h>80</h></coordinates><panel_attributes>GardenPlanController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1362</x><y>830</y><w>490</w><h>240</h></coordinates><panel_attributes>Task
|
||||||
|
--
|
||||||
|
+ id: long
|
||||||
|
+ name: String {readOnly}
|
||||||
|
+ description: String {readOnly}
|
||||||
|
+ startDate: Date {readOnly}
|
||||||
|
+ isOptional: boolean {readOnly}
|
||||||
|
- interval: int
|
||||||
|
- endDate: Date
|
||||||
|
--
|
||||||
|
+ Task(name: String, description: String, startDate: String, isReadOnly: boolean): Task
|
||||||
|
+ withInterval(interval: int): Task
|
||||||
|
+ withEndDate(endDate: Date): Task
|
||||||
|
+ withId(id: long): Task
|
||||||
|
--
|
||||||
|
+ getInterval(): Optional<int>
|
||||||
|
+ getEndDate(): Optional<Date></panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>902</x><y>930</y><w>280</w><h>140</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
TaskDatabase
|
||||||
|
--
|
||||||
|
+ getTaskList(start: Date, end: Date): List<Task>
|
||||||
|
+ saveTask(Task task) throws ??Exception
|
||||||
|
+ removeTask(Task task) throws ??Exception</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>442</x><y>440</y><w>170</w><h>80</h></coordinates><panel_attributes>MainWindowController</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>962</x><y>1310</y><w>210</w><h>70</h></coordinates><panel_attributes>NotificationService
|
||||||
|
--
|
||||||
|
- taskDb: TaskDatabase
|
||||||
|
--
|
||||||
|
+ tick()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1412</x><y>1310</y><w>240</w><h>90</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
WeatherProvider
|
||||||
|
--
|
||||||
|
+ getWeatherForecast: WeatherForecast</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1392</x><y>1150</y><w>400</w><h>100</h></coordinates><panel_attributes>WeatherService
|
||||||
|
--
|
||||||
|
- weatherPovider: WeatherProvider
|
||||||
|
- taskDb: TaskDatabase
|
||||||
|
--
|
||||||
|
+ WeatherService(provider: WeatherProvider, taskDb: TaskDatabase)
|
||||||
|
- updateTasks()</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1502</x><y>110</y><w>260</w><h>150</h></coordinates><panel_attributes><<Record>>
|
||||||
|
GrowthPhase
|
||||||
|
--
|
||||||
|
+ startDate: MonthDay
|
||||||
|
+ endDate: MonthDay
|
||||||
|
+ type: GrowthPhaseType
|
||||||
|
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1422</x><y>180</y><w>100</w><h>40</h></coordinates><panel_attributes>lt=<->>>>>
|
||||||
|
m1=*
|
||||||
|
m2=1</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Text</id><coordinates><x>152</x><y>130</y><w>190</w><h>70</h></coordinates><panel_attributes>Note:
|
||||||
|
--
|
||||||
|
{final, readOnly} omitted on public data fields in <<Record>> Entities for clarity
|
||||||
|
style=wordwrap</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1172</x><y>970</y><w>210</w><h>50</h></coordinates><panel_attributes>lt=<.
|
||||||
|
m1=*
|
||||||
|
m2=1
|
||||||
|
returns ></panel_attributes><additional_attributes>190;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>1032</x><y>820</y><w>140</w><h>130</h></coordinates><panel_attributes>lt=<-
|
||||||
|
m1=1 external database
|
||||||
|
m2=1 internal list
|
||||||
|
accesses</panel_attributes><additional_attributes>10;110;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>322</x><y>1120</y><w>240</w><h>150</h></coordinates><panel_attributes>Crop
|
||||||
|
--
|
||||||
|
- cropId: Long
|
||||||
|
+ plantId: long {final, readOnly}
|
||||||
|
+ startDate: LocalDate {final, readOnly}
|
||||||
|
+ area: Double
|
||||||
|
--
|
||||||
|
+ withId(long): Crop
|
||||||
|
+ withArea(double): Crop
|
||||||
|
--
|
||||||
|
+ getCropId(): Optional<Long></panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1262</x><y>280</y><w>70</w><h>120</h></coordinates><panel_attributes>lt=<.
|
||||||
|
m1=*
|
||||||
|
m2=1
|
||||||
|
returns</panel_attributes><additional_attributes>10;10;10;100</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1632</x><y>290</y><w>130</w><h>100</h></coordinates><panel_attributes><<Enumeration>>
|
||||||
|
GrowthPhaseType
|
||||||
|
--
|
||||||
|
SOW
|
||||||
|
PLANT
|
||||||
|
HARVEST</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1582</x><y>250</y><w>70</w><h>120</h></coordinates><panel_attributes>lt=<->>>>
|
||||||
|
m1=1
|
||||||
|
m2=*</panel_attributes><additional_attributes>50;90;10;90;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>882</x><y>720</y><w>80</w><h>30</h></coordinates><panel_attributes>lt=<->>>></panel_attributes><additional_attributes>60;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>432</x><y>1020</y><w>110</w><h>120</h></coordinates><panel_attributes>lt=<.
|
||||||
|
m1=*
|
||||||
|
m2=1
|
||||||
|
returns / saves</panel_attributes><additional_attributes>10;100;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>242</x><y>710</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=<->>>></panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>302</x><y>890</y><w>280</w><h>140</h></coordinates><panel_attributes><<Interface>>
|
||||||
|
GardenPlan
|
||||||
|
--
|
||||||
|
+ getPlantings(): List<UserPlanting>
|
||||||
|
+ addPlanting(plantId: long, startDate)
|
||||||
|
+ savePlanting(planting: UserPlanting)
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>422</x><y>800</y><w>80</w><h>110</h></coordinates><panel_attributes>lt=<.
|
||||||
|
m1=1
|
||||||
|
m2=1
|
||||||
|
accesses</panel_attributes><additional_attributes>10;90;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1522</x><y>1240</y><w>30</w><h>90</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;70;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1062</x><y>1060</y><w>80</w><h>270</h></coordinates><panel_attributes>lt=<-
|
||||||
|
m1=1
|
||||||
|
m2=1
|
||||||
|
accesses</panel_attributes><additional_attributes>10;10;10;250</additional_attributes></element><element><id>Relation</id><coordinates><x>1142</x><y>1060</y><w>270</w><h>170</h></coordinates><panel_attributes>lt=<-
|
||||||
|
m1=1
|
||||||
|
m2=1
|
||||||
|
adds Tasks</panel_attributes><additional_attributes>10;10;10;140;250;140</additional_attributes></element><element><id>UMLClass</id><coordinates><x>822</x><y>1140</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonTaskDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>912</x><y>1060</y><w>30</w><h>100</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>10;10;10;80</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1562</x><y>430</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonPlantDatabase</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1442</x><y>440</y><w>140</w><h>30</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>10;10;120;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>32</x><y>930</y><w>200</w><h>50</h></coordinates><panel_attributes>JsonGardenPlan</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>222</x><y>940</y><w>100</w><h>30</h></coordinates><panel_attributes>lt=<<-</panel_attributes><additional_attributes>80;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>582</x><y>510</y><w>220</w><h>220</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>200;200;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>172</x><y>510</y><w>340</w><h>190</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;170;320;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>582</x><y>250</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListController</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>522</x><y>380</y><w>30</w><h>80</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>10;60;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>602</x><y>300</y><w>80</w><h>210</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>60;10;10;190</additional_attributes></element><element><id>UMLClass</id><coordinates><x>732</x><y>390</y><w>160</w><h>60</h></coordinates><panel_attributes>PlantListModel</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>732</x><y>280</y><w>90</w><h>130</h></coordinates><panel_attributes>lt=<.</panel_attributes><additional_attributes>70;110;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>882</x><y>400</y><w>220</w><h>70</h></coordinates><panel_attributes>lt=<-
|
||||||
|
m1=1\nexternal\ndatabase
|
||||||
|
m2=1\ninternal\nlist
|
||||||
|
accesses ></panel_attributes><additional_attributes>200;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>582</x><y>0</y><w>190</w><h>50</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=0..n
|
||||||
|
m2=0..1
|
||||||
|
teaches to ></panel_attributes><additional_attributes>10;20;170;20</additional_attributes></element><element><id>UMLClass</id><coordinates><x>1412</x><y>530</y><w>420</w><h>200</h></coordinates><panel_attributes>TaskTemplate
|
||||||
|
--
|
||||||
|
+ name: String {readOnly}
|
||||||
|
+ description: String {readOnly}
|
||||||
|
+ relativeStartDate: int {readOnly}
|
||||||
|
- interval: Integer
|
||||||
|
- relativeEndDate: Integer
|
||||||
|
- isOptional: boolean
|
||||||
|
--
|
||||||
|
+ Task(name: String, description: String, startDate: String): TaskTemplate
|
||||||
|
+ setRelativeEndDate(relativeEndDate: int)
|
||||||
|
+ setInterval(interval: Integer)
|
||||||
|
+ generateTask(realStartDate: LocalDate): Task
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>1752</x><y>180</y><w>130</w><h>490</h></coordinates><panel_attributes>lt=<->>>>>
|
||||||
|
m1=*
|
||||||
|
m2=1</panel_attributes><additional_attributes>80;460;110;460;110;10;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>1602</x><y>720</y><w>90</w><h>130</h></coordinates><panel_attributes>lt=<.
|
||||||
|
m1=*
|
||||||
|
m2=1
|
||||||
|
generates</panel_attributes><additional_attributes>10;110;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>562</x><y>770</y><w>400</w><h>40</h></coordinates><panel_attributes>lt=<-
|
||||||
|
delegates generating Tasks</panel_attributes><additional_attributes>380;20;10;20</additional_attributes></element></diagram>
|
|
@ -0,0 +1,70 @@
|
||||||
|
<diagram program="umletino" version="15.0.0"><zoom_level>12</zoom_level><element><id>UMLClass</id><coordinates><x>852</x><y>372</y><w>120</w><h>72</h></coordinates><panel_attributes>Gardener
|
||||||
|
--
|
||||||
|
Name
|
||||||
|
Type</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>144</x><y>372</y><w>120</w><h>120</h></coordinates><panel_attributes>Plant
|
||||||
|
--
|
||||||
|
name
|
||||||
|
description</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>600</x><y>372</y><w>120</w><h>84</h></coordinates><panel_attributes>Garden
|
||||||
|
--
|
||||||
|
Location
|
||||||
|
hardiness zone</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>384</x><y>372</y><w>120</w><h>72</h></coordinates><panel_attributes>Bed
|
||||||
|
--
|
||||||
|
Area</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>1152</x><y>624</y><w>120</w><h>36</h></coordinates><panel_attributes>Weather</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>852</x><y>816</y><w>120</w><h>36</h></coordinates><panel_attributes>Calendar</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>852</x><y>96</y><w>144</w><h>72</h></coordinates><panel_attributes>Community
|
||||||
|
--
|
||||||
|
Plant Information
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>288</x><y>636</y><w>120</w><h>72</h></coordinates><panel_attributes>Growth phase
|
||||||
|
--
|
||||||
|
duration</panel_attributes><additional_attributes></additional_attributes></element><element><id>UMLClass</id><coordinates><x>852</x><y>624</y><w>120</w><h>84</h></coordinates><panel_attributes>Gardening task
|
||||||
|
--
|
||||||
|
start date
|
||||||
|
end date
|
||||||
|
interval</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>852</x><y>156</y><w>120</w><h>240</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=0..*
|
||||||
|
m2=1..*
|
||||||
|
< is part of </panel_attributes><additional_attributes>10;180;10;10</additional_attributes></element><element><id>Relation</id><coordinates><x>708</x><y>372</y><w>168</w><h>60</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1..*
|
||||||
|
< has </panel_attributes><additional_attributes>120;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>252</x><y>372</y><w>156</w><h>60</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=0..*
|
||||||
|
< contains </panel_attributes><additional_attributes>110;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>252</x><y>444</y><w>156</w><h>216</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1..*
|
||||||
|
has ></panel_attributes><additional_attributes>10;10;80;10;80;160</additional_attributes></element><element><id>Relation</id><coordinates><x>492</x><y>372</y><w>132</w><h>60</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1..*
|
||||||
|
< contains </panel_attributes><additional_attributes>90;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>900</x><y>432</y><w>120</w><h>216</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1..*
|
||||||
|
< manages </panel_attributes><additional_attributes>10;10;10;160</additional_attributes></element><element><id>Relation</id><coordinates><x>960</x><y>624</y><w>216</w><h>60</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1..*
|
||||||
|
< manipulates</panel_attributes><additional_attributes>160;20;10;20</additional_attributes></element><element><id>Relation</id><coordinates><x>900</x><y>696</y><w>108</w><h>144</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=0..*
|
||||||
|
< contains</panel_attributes><additional_attributes>10;10;10;100</additional_attributes></element><element><id>Relation</id><coordinates><x>960</x><y>408</y><w>468</w><h>468</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1
|
||||||
|
< informs </panel_attributes><additional_attributes>10;360;310;360;310;10;10;10</additional_attributes></element><element><id>UMLClass</id><coordinates><x>12</x><y>636</y><w>120</w><h>84</h></coordinates><panel_attributes>Need
|
||||||
|
--
|
||||||
|
start date
|
||||||
|
end date</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>60</x><y>432</y><w>108</w><h>228</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1..*
|
||||||
|
m2=1..*
|
||||||
|
has ></panel_attributes><additional_attributes>10;170;10;10;70;10</additional_attributes></element><element><id>Relation</id><coordinates><x>60</x><y>672</y><w>816</w><h>120</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1
|
||||||
|
requires ></panel_attributes><additional_attributes>660;10;520;10;520;80;10;80;10;40</additional_attributes></element><element><id>UMLClass</id><coordinates><x>456</x><y>588</y><w>120</w><h>36</h></coordinates><panel_attributes>Team
|
||||||
|
</panel_attributes><additional_attributes></additional_attributes></element><element><id>Relation</id><coordinates><x>564</x><y>432</y><w>312</w><h>180</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=1..*
|
||||||
|
contains of ></panel_attributes><additional_attributes>10;130;240;10</additional_attributes></element><element><id>Relation</id><coordinates><x>564</x><y>600</y><w>312</w><h>60</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=1
|
||||||
|
m2=0..*
|
||||||
|
manages ></panel_attributes><additional_attributes>10;20;240;20</additional_attributes></element><element><id>Relation</id><coordinates><x>960</x><y>156</y><w>216</w><h>240</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=0..n
|
||||||
|
m2=1..n
|
||||||
|
exchanges Informatione ></panel_attributes><additional_attributes>10;10;10;180</additional_attributes></element><element><id>Relation</id><coordinates><x>120</x><y>648</y><w>192</w><h>60</h></coordinates><panel_attributes>lt=-
|
||||||
|
m1=0..n
|
||||||
|
m2=1
|
||||||
|
< contains </panel_attributes><additional_attributes>10;20;140;20</additional_attributes></element></diagram>
|
After Width: | Height: | Size: 44 KiB |
|
@ -0,0 +1,19 @@
|
||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
private static HardinessZone currentHardinessZone;
|
||||||
|
|
||||||
|
static {
|
||||||
|
currentHardinessZone = HardinessZone.ZONE_8A;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HardinessZone getCurrentHardinessZone() {
|
||||||
|
return currentHardinessZone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
|
||||||
|
Config.currentHardinessZone = currentHardinessZone;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,58 +1,31 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.TaskList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
|
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||||
import ch.zhaw.gartenverwaltung.types.Pest;
|
import ch.zhaw.gartenverwaltung.types.Pest;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.beans.property.ListProperty;
|
|
||||||
import javafx.beans.property.SimpleListProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.layout.Priority;
|
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the CropDetail.fxml file
|
|
||||||
*/
|
|
||||||
public class CropDetailController {
|
public class CropDetailController {
|
||||||
private Crop crop;
|
private Crop crop = null;
|
||||||
|
private final PlantListModel plantListModel = new PlantListModel();
|
||||||
@Inject
|
private final TaskListModel taskListModel = new TaskListModel();
|
||||||
private PlantList plantList;
|
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
||||||
@Inject
|
|
||||||
private GardenSchedule gardenSchedule;
|
|
||||||
@Inject
|
|
||||||
private Garden garden;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
AppLoader appLoader;
|
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
|
|
||||||
private final ListProperty<Task> taskListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
|
||||||
private final ListProperty<Pest> pestListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
|
@ -69,361 +42,91 @@ public class CropDetailController {
|
||||||
@FXML
|
@FXML
|
||||||
private Label description_label;
|
private Label description_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private VBox growthPhases_vbox;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label location_label;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label light_label;
|
private Label light_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button location_button;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private VBox pests_vbox;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label soil_label;
|
private Label soil_label;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label spacing_label;
|
private Label spacing_label;
|
||||||
|
|
||||||
@FXML
|
public CropDetailController() throws IOException {
|
||||||
private Button addTask_button;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ListView<Task> taskList_listView;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ListView<Pest> pests_listView;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
void addTask() throws IOException, HardinessZoneNotSetException {
|
|
||||||
createTaskDialog(true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* close Window
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void goBack() {
|
void editTaskList(ActionEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void goBack(ActionEvent event) {
|
||||||
Stage stage = (Stage) imageView.getScene().getWindow();
|
Stage stage = (Stage) imageView.getScene().getWindow();
|
||||||
stage.close();
|
stage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* open dialog to set area
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void setArea() throws IOException {
|
void setArea(ActionEvent event) {
|
||||||
openTextFieldDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@FXML
|
||||||
* set labels and image from selected {@link Crop}
|
void setLocation(ActionEvent event) {
|
||||||
* set icons for buttons
|
|
||||||
* @param crop {@link Crop} which will be displayed
|
}
|
||||||
* @throws PlantNotFoundException exception
|
|
||||||
*/
|
public void setPlantFromCrop(Crop crop) throws HardinessZoneNotSetException, IOException {
|
||||||
public void setPlantFromCrop(Crop crop) throws PlantNotFoundException {
|
|
||||||
this.crop = crop;
|
this.crop = crop;
|
||||||
try {
|
Plant plant = plantListModel.getFilteredPlantListById(Config.getCurrentHardinessZone(), crop.getPlantId()).get(0);
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId())
|
cropName_label.setText(plant.name());
|
||||||
.orElseThrow(PlantNotFoundException::new);
|
description_label.setText(plant.description());
|
||||||
|
light_label.setText(String.valueOf(plant.light()));
|
||||||
cropName_label.setText(plant.name());
|
soil_label.setText(plant.soil());
|
||||||
description_label.setText(plant.description());
|
spacing_label.setText(plant.spacing());
|
||||||
light_label.setText(String.valueOf(plant.light()));
|
if (plant.image() != null) {
|
||||||
soil_label.setText(plant.soil());
|
imageView.setImage(plant.image());
|
||||||
spacing_label.setText(plant.spacing());
|
|
||||||
if (plant.image() != null) {
|
|
||||||
imageView.setImage(plant.image());
|
|
||||||
}
|
|
||||||
area_label.setText(String.valueOf(crop.getArea()));
|
|
||||||
|
|
||||||
initializeTaskListProperty(crop);
|
|
||||||
|
|
||||||
TaskList.TaskListObserver taskListObserver = newTaskList -> {
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
taskListProperty.clear();
|
|
||||||
try {
|
|
||||||
taskListProperty.addAll(gardenSchedule.getTaskListForCrop(crop.getCropId().get()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
gardenSchedule.setTaskListObserver(taskListObserver);
|
|
||||||
|
|
||||||
taskList_listView.itemsProperty().bind(taskListProperty);
|
|
||||||
|
|
||||||
pestListProperty.addAll(plant.pests());
|
|
||||||
pests_listView.itemsProperty().bind(pestListProperty);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
|
||||||
throw new PlantNotFoundException();
|
|
||||||
}
|
}
|
||||||
setIconToButton(addTask_button, "addIcon.png");
|
area_label.setText("");
|
||||||
setIconToButton(area_button, "areaIcon.png");
|
location_label.setText("");
|
||||||
setCellFactoryPests();
|
createTaskLists(crop);
|
||||||
setCellFactoryTasks();
|
createPestList(plant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void createTaskLists(Crop crop) throws IOException {
|
||||||
* cell Factory for TaskListView
|
List<Task> taskList = taskListModel.getTaskListForCrop(crop.getCropId().get());
|
||||||
*/
|
for (Task task : taskList) {
|
||||||
private void setCellFactoryTasks() {
|
Label label = new Label(task.getDescription());
|
||||||
taskList_listView.setCellFactory(param -> new ListCell<>() {
|
growthPhases_vbox.getChildren().add(label);
|
||||||
@Override
|
|
||||||
protected void updateItem(Task task, boolean empty) {
|
|
||||||
super.updateItem(task, empty);
|
|
||||||
|
|
||||||
if (empty || task == null) {
|
|
||||||
setText(null);
|
|
||||||
setGraphic(null);
|
|
||||||
} else {
|
|
||||||
setText("");
|
|
||||||
setGraphic(createTaskHBox(task));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cell Factory for PestListView
|
|
||||||
*/
|
|
||||||
private void setCellFactoryPests() {
|
|
||||||
pests_listView.setCellFactory(param -> new ListCell<>() {
|
|
||||||
@Override
|
|
||||||
protected void updateItem(Pest pest, boolean empty) {
|
|
||||||
super.updateItem(pest, empty);
|
|
||||||
|
|
||||||
if (empty || pest == null) {
|
|
||||||
setText(null);
|
|
||||||
setGraphic(null);
|
|
||||||
} else {
|
|
||||||
setText("");
|
|
||||||
setGraphic(createPestHBox(pest));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize task list
|
|
||||||
* @param crop {@link Crop} that is selected
|
|
||||||
*/
|
|
||||||
private void initializeTaskListProperty(Crop crop) {
|
|
||||||
crop.getCropId().ifPresent(id -> {
|
|
||||||
List<Task> taskList;
|
|
||||||
try {
|
|
||||||
taskList = gardenSchedule.getTaskListForCrop(id);
|
|
||||||
taskListProperty.clear();
|
|
||||||
taskListProperty.addAll(taskList);
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not get task list for crop", e.getCause());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link HBox} for the given {@link Task}.
|
|
||||||
* @param task {@link Task} which is selected
|
|
||||||
* @return {@link HBox} that was created
|
|
||||||
*/
|
|
||||||
private HBox createTaskHBox(Task task) {
|
|
||||||
HBox hBox = new HBox(10);
|
|
||||||
Label taskName = new Label(task.getName()+": ");
|
|
||||||
taskName.setMinWidth(100);
|
|
||||||
taskName.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
|
||||||
taskName.setStyle("-fx-font-weight: bold");
|
|
||||||
Label taskDescription = new Label(task.getDescription());
|
|
||||||
taskDescription.setWrapText(true);
|
|
||||||
taskDescription.setMaxSize(600, Double.MAX_VALUE);
|
|
||||||
Pane puffer = new Pane();
|
|
||||||
HBox.setHgrow(puffer, Priority.ALWAYS);
|
|
||||||
|
|
||||||
|
|
||||||
Button edit = new Button();
|
|
||||||
Button delete = new Button();
|
|
||||||
edit.getStyleClass().add("button-class");
|
|
||||||
delete.getStyleClass().add("button-class");
|
|
||||||
HBox.setHgrow(edit, Priority.NEVER);
|
|
||||||
HBox.setHgrow(delete, Priority.NEVER);
|
|
||||||
setIconToButton(edit, "editIcon.png");
|
|
||||||
setIconToButton(delete, "deleteIcon.png");
|
|
||||||
edit.setOnAction(getEditTaskEvent(task));
|
|
||||||
delete.setOnAction(deleteTask(task));
|
|
||||||
|
|
||||||
hBox.getChildren().addAll(taskName, taskDescription, puffer, edit, delete);
|
|
||||||
return hBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link HBox} for the given {@link Pest}.
|
|
||||||
* @param pest {@link Pest} which is selected
|
|
||||||
* @return {@link HBox} that was created
|
|
||||||
*/
|
|
||||||
private HBox createPestHBox(Pest pest) {
|
|
||||||
Label label = new Label(pest.name() + ": ");
|
|
||||||
label.setStyle("-fx-font-weight: bold");
|
|
||||||
HBox hBox = new HBox();
|
|
||||||
hBox.fillHeightProperty();
|
|
||||||
Label description = new Label(pest.description());
|
|
||||||
description.setAlignment(Pos.TOP_LEFT);
|
|
||||||
description.setWrapText(true);
|
|
||||||
description.setMaxWidth(800);
|
|
||||||
hBox.getChildren().addAll(label, description);
|
|
||||||
return hBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* adds icon to button
|
|
||||||
* @param button the button which get the icon
|
|
||||||
* @param iconFileName file name of icon
|
|
||||||
*/
|
|
||||||
private void setIconToButton(Button button, String iconFileName) {
|
|
||||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
|
||||||
ImageView imageView = new ImageView(img);
|
|
||||||
imageView.setFitHeight(20);
|
|
||||||
imageView.setPreserveRatio(true);
|
|
||||||
button.setGraphic(imageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* opens dialog of {@link Task} edit.
|
|
||||||
* @param task {@link Task}
|
|
||||||
* @return {@link EventHandler} for the case of editing a {@link Task}
|
|
||||||
*/
|
|
||||||
private EventHandler<ActionEvent> getEditTaskEvent(Task task) {
|
|
||||||
return (event) -> {
|
|
||||||
try {
|
|
||||||
createTaskDialog(false, task);
|
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* opens alert of {@link Task} deletion.
|
|
||||||
* @param task {@link Task}
|
|
||||||
* @return {@link EventHandler} for the case of deleting a {@link Task}
|
|
||||||
*/
|
|
||||||
private EventHandler<ActionEvent> deleteTask(Task task) {
|
|
||||||
return (event) -> {
|
|
||||||
showDeleteTask(task);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* opens a dialog to create a new Task or edit the given Task
|
|
||||||
* @param newTask boolean if it is a new Task
|
|
||||||
* @param givenTask {@link Task} which was selected
|
|
||||||
* @throws IOException Exception
|
|
||||||
* @throws HardinessZoneNotSetException Exception
|
|
||||||
*/
|
|
||||||
private void createTaskDialog(boolean newTask, Task givenTask) throws IOException, HardinessZoneNotSetException {
|
|
||||||
Dialog<Task> dialog = new Dialog<>();
|
|
||||||
dialog.setTitle("Set Task");
|
|
||||||
dialog.setHeaderText("Add/Edit Task:");
|
|
||||||
dialog.setResizable(false);
|
|
||||||
|
|
||||||
DialogPane dialogPane = dialog.getDialogPane();
|
|
||||||
|
|
||||||
dialogPane.getStylesheets().add(
|
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
|
||||||
|
|
||||||
ButtonType saveTask;
|
|
||||||
if(newTask) {
|
|
||||||
saveTask = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
|
|
||||||
} else {
|
|
||||||
saveTask = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
|
||||||
}
|
|
||||||
dialogPane.getButtonTypes().addAll(saveTask, ButtonType.CANCEL);
|
|
||||||
|
|
||||||
if (appLoader.loadPaneToDialog("TaskFormular.fxml", dialogPane) instanceof TaskFormularController controller) {
|
|
||||||
controller.setCorp(this.crop);
|
|
||||||
controller.initSaveButton((Button) dialogPane.lookupButton(saveTask));
|
|
||||||
if (!newTask) {
|
|
||||||
controller.setTaskValue(givenTask);
|
|
||||||
}
|
|
||||||
dialog.setResultConverter(button -> button.equals(saveTask) ? controller.returnResult(this.crop) : null);
|
|
||||||
|
|
||||||
dialog.showAndWait()
|
|
||||||
.ifPresent(task -> {
|
|
||||||
if (newTask) {
|
|
||||||
try {
|
|
||||||
gardenSchedule.addTask(task);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
gardenSchedule.addTask(givenTask.updateTask(task));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* opens TextField Dialog to enter the plant area.
|
|
||||||
* @throws IOException Exception
|
|
||||||
*/
|
|
||||||
private void openTextFieldDialog() throws IOException {
|
|
||||||
Dialog<String> dialog = new Dialog<>();
|
|
||||||
dialog.setTitle("set Text Area");
|
|
||||||
dialog.setHeaderText("set Text Area");
|
|
||||||
dialog.setResizable(false);
|
|
||||||
|
|
||||||
DialogPane dialogPane = dialog.getDialogPane();
|
|
||||||
|
|
||||||
dialogPane.getStylesheets().add(
|
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
|
||||||
|
|
||||||
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
|
||||||
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);
|
|
||||||
|
|
||||||
if (appLoader.loadPaneToDialog("TextFieldFormular.fxml", dialogPane) instanceof TextFieldFormularController controller) {
|
|
||||||
controller.setDescription_label("Text Area");
|
|
||||||
controller.setValueTextArea(area_label.getText());
|
|
||||||
controller.initSaveButton((Button) dialogPane.lookupButton(save));
|
|
||||||
|
|
||||||
dialog.setResultConverter(button -> button.equals(save) ? controller.getValue() : null);
|
|
||||||
|
|
||||||
dialog.showAndWait()
|
|
||||||
.ifPresent(string -> {
|
|
||||||
try {
|
|
||||||
garden.updateCrop(this.crop.withArea(Double.parseDouble(string)));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
area_label.setText(string);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void createPestList(Plant plant) {
|
||||||
* Alert to delete Task.
|
List<Pest> pests = plant.pests();
|
||||||
* @param task {@link Task} which is being deleted
|
for (Pest pest : pests) {
|
||||||
*/
|
Label label = new Label(pest.name() + ":");
|
||||||
private void showDeleteTask(Task task) {
|
label.setStyle("-fx-font-weight: bold");
|
||||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
HBox hBox = new HBox();
|
||||||
alert.setTitle("Delete " + task.getName());
|
hBox.fillHeightProperty();
|
||||||
alert.setHeaderText("Are you sure want to delete this Task?");
|
Label label1 = new Label(pest.description());
|
||||||
|
label1.setAlignment(Pos.TOP_LEFT);
|
||||||
DialogPane dialogPane = alert.getDialogPane();
|
label1.setWrapText(true);
|
||||||
|
label1.setMaxWidth(600);
|
||||||
dialogPane.getStylesheets().add(
|
label1.setMaxHeight(100);
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
Button button = new Button("Get Counter Measures");
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
hBox.getChildren().addAll(label1, button);
|
||||||
|
pests_vbox.getChildren().addAll(label, hBox);
|
||||||
alert.showAndWait()
|
}
|
||||||
.ifPresent(buttonType -> {
|
|
||||||
if (buttonType == ButtonType.OK) {
|
|
||||||
try {
|
|
||||||
gardenSchedule.removeTask(task);
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not remove crop.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class HelloApplication extends Application {
|
||||||
|
@Override
|
||||||
|
public void start(Stage stage) throws IOException {
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("MainFXML.fxml"));
|
||||||
|
Scene scene = new Scene(fxmlLoader.load());
|
||||||
|
stage.setTitle("Gartenverwaltung");
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
|
||||||
|
public class HelloController {
|
||||||
|
@FXML
|
||||||
|
private Label welcomeText;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void onHelloButtonClick() {
|
||||||
|
welcomeText.setText("Welcome to JavaFX Application!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,55 +1,5 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
public class HomeController
|
||||||
import javafx.fxml.Initializable;
|
{
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the Home.fxml file
|
|
||||||
*/
|
|
||||||
public class HomeController implements Initializable {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ImageView imageViewDavid;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ImageView imageViewElias;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ImageView imageViewGian;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ImageView imageViewPhilippe;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ImageView imageViewRoman;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
|
||||||
setImages(imageViewDavid, "");
|
|
||||||
setImages(imageViewElias, "");
|
|
||||||
setImages(imageViewGian, "");
|
|
||||||
setImages(imageViewRoman, "");
|
|
||||||
setImages(imageViewPhilippe, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set image to image view
|
|
||||||
* @param imageView the imageView to update
|
|
||||||
* @param photoName the file name of the photo
|
|
||||||
*/
|
|
||||||
private void setImages(ImageView imageView, String photoName) {
|
|
||||||
Image img;
|
|
||||||
if (photoName.equals("")) {
|
|
||||||
img = new Image(String.valueOf(getClass().getResource("icons/userIcon.png")));
|
|
||||||
} else {
|
|
||||||
img = new Image(String.valueOf(getClass().getResource("icons/" + photoName)));
|
|
||||||
}
|
|
||||||
imageView.setImage(img);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
|
||||||
import ch.zhaw.gartenverwaltung.backgroundtasks.BackgroundTasks;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.CropList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.TaskList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Timer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main class of the Application
|
|
||||||
*/
|
|
||||||
public class Main extends Application {
|
|
||||||
Timer backGroundTaskTimer = new Timer();
|
|
||||||
BackgroundTasks backgroundTasks;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method which is automatically called if Application is starting. It loads the scenes to stage and shows the stage.
|
|
||||||
* It creates a new Instance of BackgroundTasks and schedules them with a Timer instance to execute them every minute.
|
|
||||||
* @param stage Stage to show
|
|
||||||
* @throws IOException If loading Scenes can not access the fxml Resource File
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void start(Stage stage) throws IOException {
|
|
||||||
AppLoader appLoader = new AppLoader();
|
|
||||||
|
|
||||||
appLoader.loadSceneToStage("MainFXML.fxml", stage);
|
|
||||||
|
|
||||||
stage.setTitle("Gartenverwaltung");
|
|
||||||
stage.show();
|
|
||||||
|
|
||||||
backgroundTasks = new BackgroundTasks((TaskList) appLoader.getAppDependency(TaskList.class),(CropList) appLoader.getAppDependency(CropList.class), (PlantList) appLoader.getAppDependency(PlantList.class));
|
|
||||||
backGroundTaskTimer.scheduleAtFixedRate(backgroundTasks, 0, 60000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method which is automatically called when application is stopped.
|
|
||||||
* It cancels the timer to not execute the background tasks anymore.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void stop(){
|
|
||||||
backGroundTaskTimer.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Main method launches the application
|
|
||||||
* @param args There are no arguments needed.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
launch();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +1,28 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
import javafx.event.ActionEvent;
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.image.Image;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.stage.Modality;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import javafx.stage.WindowEvent;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
public class MainFXMLController implements Initializable {
|
||||||
* Controller class for the MainFXML.fxml file
|
/**
|
||||||
*/
|
* Caching the panes
|
||||||
public class MainFXMLController {
|
*/
|
||||||
|
private final Map<String, AnchorPane> panes = new HashMap<>();
|
||||||
private static final Logger LOG = Logger.getLogger(MainFXMLController.class.getName());
|
private static final Logger LOG = Logger.getLogger(MainFXMLController.class.getName());
|
||||||
|
|
||||||
@Inject
|
|
||||||
AppLoader appLoader;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button home_button;
|
private Button home_button;
|
||||||
|
|
||||||
|
@ -36,93 +30,36 @@ public class MainFXMLController {
|
||||||
private AnchorPane mainPane;
|
private AnchorPane mainPane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button myGarden_button;
|
private Button myPlants_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button mySchedule_button;
|
private Button mySchedule_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button settings_button;
|
private Button plants_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button tutorial_button;
|
void goToHome(ActionEvent event) throws IOException {
|
||||||
|
loadPane("Home.fxml");
|
||||||
private final Stage tutorialModal = new Stage();
|
styleChangeButton(home_button);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* go to home pane
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
void goToHome() {
|
|
||||||
showPaneAsMainView("Home.fxml");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* go to my garden pane
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void goToMyPlants() {
|
void goToMyPlants(ActionEvent event) throws IOException {
|
||||||
showPaneAsMainView("MyGarden.fxml");
|
loadPane("MyPlants.fxml");
|
||||||
|
styleChangeButton(myPlants_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* go to the schedule pane
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void goToMySchedule() {
|
void goToMySchedule(ActionEvent event) throws IOException {
|
||||||
showPaneAsMainView("MySchedule.fxml");
|
loadPane("MySchedule.fxml");
|
||||||
|
styleChangeButton(mySchedule_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* open dialog of the settings
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void openSettings() throws IOException {
|
void goToPlants(ActionEvent event) throws IOException {
|
||||||
Dialog<ButtonType> dialog = new Dialog<>();
|
loadPane("Plants.fxml");
|
||||||
dialog.setTitle("Settings");
|
styleChangeButton(plants_button);
|
||||||
dialog.setHeaderText("Settings");
|
|
||||||
dialog.setResizable(false);
|
|
||||||
|
|
||||||
DialogPane dialogPane = dialog.getDialogPane();
|
|
||||||
|
|
||||||
dialogPane.getStylesheets().add(
|
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
|
||||||
|
|
||||||
ButtonType saveSettings = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
|
||||||
dialogPane.getButtonTypes().addAll(saveSettings, ButtonType.CANCEL);
|
|
||||||
|
|
||||||
if (appLoader.loadPaneToDialog("Settings.fxml", dialogPane) instanceof SettingsController controller) {
|
|
||||||
|
|
||||||
dialog.showAndWait()
|
|
||||||
.ifPresent(button -> {
|
|
||||||
if (button.equals(saveSettings)) {
|
|
||||||
controller.saveSettings();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the tutorial window
|
|
||||||
*/
|
|
||||||
public void showTutorial() {
|
|
||||||
if (!tutorialModal.isShowing()) {
|
|
||||||
if (tutorialModal.getScene() == null) {
|
|
||||||
try {
|
|
||||||
appLoader.loadSceneToStage("Tutorial.fxml", tutorialModal);
|
|
||||||
tutorialModal.initModality(Modality.NONE);
|
|
||||||
tutorialModal.setResizable(false);
|
|
||||||
tutorialModal.sizeToScene();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not load Tutorial");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tutorialModal.show();
|
|
||||||
}
|
|
||||||
tutorialModal.requestFocus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,70 +67,43 @@ public class MainFXMLController {
|
||||||
* set HGrow and VGrow to parent AnchorPane.
|
* set HGrow and VGrow to parent AnchorPane.
|
||||||
* Sends MainController to other Controllers.
|
* Sends MainController to other Controllers.
|
||||||
* @param fxmlFile string of fxml file
|
* @param fxmlFile string of fxml file
|
||||||
|
* @throws IOException exception when file does not exist
|
||||||
*/
|
*/
|
||||||
public void showPaneAsMainView(String fxmlFile) {
|
public void loadPane(String fxmlFile) throws IOException {
|
||||||
try {
|
|
||||||
Pane anchorPane = appLoader.loadPane(fxmlFile);
|
|
||||||
mainPane.getChildren().setAll(anchorPane);
|
|
||||||
anchorPane.prefWidthProperty().bind(mainPane.widthProperty());
|
|
||||||
anchorPane.prefHeightProperty().bind(mainPane.heightProperty());
|
|
||||||
|
|
||||||
anchorPane.removeEventHandler(ChangeViewEvent.CHANGE_MAIN_VIEW, changeMainViewHandler);
|
AnchorPane anchorPane = panes.get(fxmlFile);
|
||||||
anchorPane.addEventHandler(ChangeViewEvent.CHANGE_MAIN_VIEW, changeMainViewHandler);
|
if (anchorPane == null) {
|
||||||
} catch (IOException e) {
|
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(HelloApplication.class.getResource(fxmlFile)));
|
||||||
LOG.log(Level.SEVERE, "Could not load pane.", e);
|
anchorPane = loader.load();
|
||||||
|
panes.put(fxmlFile, anchorPane);
|
||||||
|
|
||||||
|
if(fxmlFile.equals("MyPlants.fxml")) {
|
||||||
|
MyPlantsController myPlantsController = loader.getController();
|
||||||
|
myPlantsController.getMainController(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mainPane.getChildren().setAll(anchorPane);
|
||||||
|
anchorPane.prefWidthProperty().bind(mainPane.widthProperty());
|
||||||
|
anchorPane.prefHeightProperty().bind(mainPane.heightProperty());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final EventHandler<ChangeViewEvent> changeMainViewHandler = (ChangeViewEvent event) -> showPaneAsMainView(event.view());
|
private void styleChangeButton(Button button) {
|
||||||
|
//ToDo changeStyle of the menu buttons
|
||||||
/**
|
|
||||||
* preload all menu bar panes
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
private void preloadPanes() throws IOException {
|
|
||||||
appLoader.loadAndCacheFxml("MyGarden.fxml");
|
|
||||||
appLoader.loadAndCacheFxml("MySchedule.fxml");
|
|
||||||
appLoader.loadAndCacheFxml("Plants.fxml");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loads the default FXML File
|
* loads the default FXML File
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@AfterInject
|
@Override
|
||||||
@SuppressWarnings("unused")
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
public void init() {
|
|
||||||
try {
|
try {
|
||||||
preloadPanes();
|
loadPane("Home.fxml");
|
||||||
showPaneAsMainView("MyGarden.fxml");
|
styleChangeButton(home_button);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
|
LOG.log(Level.SEVERE, "Failed to load FXML-Pane!", e);
|
||||||
}
|
}
|
||||||
mainPane.getScene().getWindow().setOnCloseRequest(this::closeWindowHandler);
|
|
||||||
setIconToButton(home_button, "homeIcon.png");
|
|
||||||
setIconToButton(settings_button, "settingsIcon.png");
|
|
||||||
tutorial_button.visibleProperty().bind(Settings.getInstance().getShowTutorialProperty());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* close Tutorial Window
|
|
||||||
* @param windowEvent event
|
|
||||||
*/
|
|
||||||
private void closeWindowHandler(WindowEvent windowEvent) {
|
|
||||||
tutorialModal.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* adds icon to given button
|
|
||||||
* @param button the button which get the icon
|
|
||||||
* @param iconFileName file name of icon
|
|
||||||
*/
|
|
||||||
private void setIconToButton(Button button, String iconFileName) {
|
|
||||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
|
||||||
ImageView imageView = new ImageView(img);
|
|
||||||
imageView.setFitHeight(20);
|
|
||||||
imageView.setPreserveRatio(true);
|
|
||||||
button.setGraphic(imageView);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,226 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.*;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.layout.Priority;
|
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import javafx.stage.Modality;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the MyGarden.fxml file
|
|
||||||
*/
|
|
||||||
public class MyGardenController {
|
|
||||||
private static final Logger LOG = Logger.getLogger(MyGardenController.class.getName());
|
|
||||||
@Inject
|
|
||||||
AppLoader appLoader;
|
|
||||||
@Inject
|
|
||||||
private Garden garden;
|
|
||||||
@Inject
|
|
||||||
private PlantList plantList;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public AnchorPane myGardenRoot;
|
|
||||||
@FXML
|
|
||||||
private Button addPlant_button;
|
|
||||||
@FXML
|
|
||||||
private ListView<Crop> myGarden_listView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize crop list
|
|
||||||
* add listener for crop list
|
|
||||||
* set icon for button
|
|
||||||
*/
|
|
||||||
@AfterInject
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void init() {
|
|
||||||
setIconToButton(addPlant_button, "addIcon.png");
|
|
||||||
myGarden_listView.itemsProperty().bind(garden.getPlantedCrops());
|
|
||||||
setCellFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* redirect to plant fxml file
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
void addPlant() {
|
|
||||||
myGardenRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "Plants.fxml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set cell factory to load {@link HBox} as list view content
|
|
||||||
*/
|
|
||||||
private void setCellFactory() {
|
|
||||||
myGarden_listView.setCellFactory(param -> new ListCell<>() {
|
|
||||||
@Override
|
|
||||||
protected void updateItem(Crop crop, boolean empty) {
|
|
||||||
super.updateItem(crop, empty);
|
|
||||||
|
|
||||||
if (empty || crop == null) {
|
|
||||||
setText(null);
|
|
||||||
setGraphic(null);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
setText("");
|
|
||||||
setGraphic(createHBoxForListView(crop));
|
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
|
||||||
LOG.log(Level.WARNING, "Could not get plant for Cell", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and returns HBox of the crop
|
|
||||||
* @param crop {@link Crop} which is selected
|
|
||||||
* @return {@link HBox} of the {@link Crop}
|
|
||||||
* @throws HardinessZoneNotSetException exception
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
private HBox createHBoxForListView(Crop crop) throws HardinessZoneNotSetException, IOException {
|
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
|
||||||
HBox hBox = new HBox(10);
|
|
||||||
ImageView imageView = new ImageView();
|
|
||||||
imageView.setPreserveRatio(false);
|
|
||||||
imageView.setFitHeight(100);
|
|
||||||
imageView.setFitWidth(100);
|
|
||||||
imageView.maxHeight(100);
|
|
||||||
if (plant.image() != null) {
|
|
||||||
imageView.setImage(plant.image());
|
|
||||||
}
|
|
||||||
hBox.setMinHeight(100);
|
|
||||||
Label label = new Label(plant.name());
|
|
||||||
label.setMinWidth(100);
|
|
||||||
|
|
||||||
VBox vbox = new VBox(10);
|
|
||||||
HBox startDateHBox = new HBox(10);
|
|
||||||
Label startDateDescription = new Label("Start Date:");
|
|
||||||
startDateDescription.setMinWidth(75);
|
|
||||||
Label startDate = new Label(crop.getStartDate().toString());
|
|
||||||
startDateHBox.getChildren().addAll(startDateDescription, startDate);
|
|
||||||
HBox endDateHBox = new HBox(10);
|
|
||||||
Label endDateDescription = new Label("End Date:");
|
|
||||||
endDateDescription.setMinWidth(75);
|
|
||||||
Label endDate = new Label(crop.getStartDate().plusDays(plant.timeToHarvest(0)).toString());
|
|
||||||
endDateHBox.getChildren().addAll(endDateDescription, endDate);
|
|
||||||
vbox.getChildren().addAll(startDateHBox, endDateHBox);
|
|
||||||
|
|
||||||
vbox.setMaxWidth(2000);
|
|
||||||
HBox.setHgrow(vbox, Priority.ALWAYS);
|
|
||||||
|
|
||||||
Button details = new Button();
|
|
||||||
Button delete = new Button();
|
|
||||||
details.getStyleClass().add("button-class");
|
|
||||||
delete.getStyleClass().add("button-class");
|
|
||||||
|
|
||||||
setIconToButton(details, "detailsIcon.png");
|
|
||||||
setIconToButton(delete, "deleteIcon.png");
|
|
||||||
details.setOnAction(getGoToCropDetailEvent(crop));
|
|
||||||
delete.setOnAction(getDeleteCropEvent(crop));
|
|
||||||
|
|
||||||
hBox.getChildren().addAll(imageView, label, vbox, details, delete);
|
|
||||||
return hBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* adds icon to button
|
|
||||||
* @param button the button which get the icon
|
|
||||||
* @param iconFileName file name of icon
|
|
||||||
*/
|
|
||||||
private void setIconToButton(Button button, String iconFileName) {
|
|
||||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
|
||||||
ImageView imageView = new ImageView(img);
|
|
||||||
imageView.setFitHeight(20);
|
|
||||||
imageView.setPreserveRatio(true);
|
|
||||||
button.setGraphic(imageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* open detail window of the selected {@link Crop}
|
|
||||||
* @param crop {@link Crop} which is selected
|
|
||||||
* @return {@link EventHandler} for button
|
|
||||||
*/
|
|
||||||
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
|
|
||||||
return (event) -> {
|
|
||||||
try {
|
|
||||||
Stage stage = new Stage();
|
|
||||||
if (appLoader.loadSceneToStage("CropDetail.fxml", stage) instanceof CropDetailController controller) {
|
|
||||||
controller.setPlantFromCrop(crop);
|
|
||||||
}
|
|
||||||
stage.initModality(Modality.APPLICATION_MODAL);
|
|
||||||
stage.setResizable(true);
|
|
||||||
stage.showAndWait();
|
|
||||||
} catch (IOException | PlantNotFoundException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not load plant details.", e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* open alert for deleting the selected {@link Crop}
|
|
||||||
* @param crop {@link Crop} which is selected
|
|
||||||
* @return {@link EventHandler} for button
|
|
||||||
*/
|
|
||||||
private EventHandler<ActionEvent> getDeleteCropEvent(Crop crop) {
|
|
||||||
return (event) -> {
|
|
||||||
try {
|
|
||||||
showConfirmation(crop);
|
|
||||||
} catch (IOException | HardinessZoneNotSetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alert to confirm that the crop can be deleted.
|
|
||||||
* @param crop {@link Crop} which is selected
|
|
||||||
* @throws IOException exception
|
|
||||||
* @throws HardinessZoneNotSetException exception
|
|
||||||
*/
|
|
||||||
private void showConfirmation(Crop crop) throws IOException, HardinessZoneNotSetException {
|
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
|
||||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
|
||||||
alert.setTitle("Delete " + plant.name());
|
|
||||||
DialogPane dialogPane = alert.getDialogPane();
|
|
||||||
|
|
||||||
dialogPane.getStylesheets().add(
|
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
|
||||||
|
|
||||||
alert.setHeaderText("Are you sure want to delete this Crop?");
|
|
||||||
alert.setContentText("Deleting this crop will remove all associated tasks from your schedule.");
|
|
||||||
|
|
||||||
alert.showAndWait()
|
|
||||||
.ifPresent(buttonType -> {
|
|
||||||
if (buttonType == ButtonType.OK) {
|
|
||||||
try {
|
|
||||||
garden.removeCrop(crop);
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not remove crop.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
|
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
||||||
|
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
||||||
|
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||||
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Modality;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class MyPlantsController implements Initializable {
|
||||||
|
MainFXMLController mainController;
|
||||||
|
private final TaskListModel taskListModel = new TaskListModel();
|
||||||
|
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
||||||
|
private final PlantListModel plantListModel = new PlantListModel();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private VBox myPlants_vbox;
|
||||||
|
|
||||||
|
public MyPlantsController() throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void addPlant(ActionEvent event) throws IOException {
|
||||||
|
mainController.loadPane("Plants.fxml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
|
//ToDo update, when new crops are added
|
||||||
|
try {
|
||||||
|
loadCropList();
|
||||||
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCropList() throws HardinessZoneNotSetException, IOException {
|
||||||
|
List<Crop> cropList = new LinkedList<>();
|
||||||
|
try {
|
||||||
|
cropList = getCropList();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
createPlantView(cropList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createPlantView(List<Crop> crops) throws HardinessZoneNotSetException, IOException {
|
||||||
|
myPlants_vbox.getChildren().clear();
|
||||||
|
for(Crop crop : crops) {
|
||||||
|
HBox hBox = createPlantView(crop);
|
||||||
|
myPlants_vbox.getChildren().add(hBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getMainController(MainFXMLController controller) {
|
||||||
|
mainController = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Crop> getCropList() throws IOException {
|
||||||
|
List<Crop> cropList;
|
||||||
|
cropList = gardenplanmodel.getCrops();
|
||||||
|
return cropList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HBox createPlantView(Crop crop) throws HardinessZoneNotSetException, IOException {
|
||||||
|
//ToDo add better design
|
||||||
|
Plant plant = plantListModel.getFilteredPlantListById(Config.getCurrentHardinessZone(), crop.getPlantId()).get(0);
|
||||||
|
HBox hBox = new HBox(10);
|
||||||
|
ImageView imageView = new ImageView();
|
||||||
|
imageView.setPreserveRatio(false);
|
||||||
|
imageView.setFitHeight(100);
|
||||||
|
imageView.setFitWidth(100);
|
||||||
|
imageView.maxHeight(100);
|
||||||
|
if (plant.image() != null) {
|
||||||
|
imageView.setImage(plant.image());
|
||||||
|
}
|
||||||
|
hBox.setMinHeight(100);
|
||||||
|
Label label = new Label(plant.name());
|
||||||
|
label.setMaxWidth(2000);
|
||||||
|
HBox.setHgrow(label, Priority.ALWAYS);
|
||||||
|
Button details = new Button("Details");
|
||||||
|
Button delete = new Button("delete");
|
||||||
|
details.setOnAction(getGoToCropDetailEvent(crop));
|
||||||
|
delete.setOnAction(getDeleteCropEvent(crop));
|
||||||
|
hBox.getChildren().addAll(imageView, label, details, delete);
|
||||||
|
return hBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler<ActionEvent> getGoToCropDetailEvent(Crop crop) {
|
||||||
|
EventHandler<ActionEvent> event = new EventHandler<ActionEvent>() {
|
||||||
|
@Override
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
Parent root;
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("CropDetail.fxml")));
|
||||||
|
try {
|
||||||
|
root = fxmlLoader.load();
|
||||||
|
CropDetailController controller = fxmlLoader.getController();
|
||||||
|
controller.setPlantFromCrop(crop);
|
||||||
|
Stage stage = new Stage();
|
||||||
|
stage.setScene(new Scene(root));
|
||||||
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
stage.setResizable(true);
|
||||||
|
stage.showAndWait();
|
||||||
|
} catch (IOException | HardinessZoneNotSetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler<ActionEvent> getDeleteCropEvent(Crop crop) {
|
||||||
|
EventHandler<ActionEvent> event = new EventHandler<ActionEvent>() {
|
||||||
|
@Override
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
try {
|
||||||
|
showConfirmation(crop);
|
||||||
|
} catch (IOException | HardinessZoneNotSetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showConfirmation(Crop crop) throws IOException, HardinessZoneNotSetException {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||||
|
alert.setTitle("Delete Crop");
|
||||||
|
alert.setHeaderText("Are you sure want to delete this Crop?");
|
||||||
|
alert.setContentText("placeholder");
|
||||||
|
|
||||||
|
Optional<ButtonType> option = alert.showAndWait();
|
||||||
|
|
||||||
|
if (option.get() == ButtonType.OK) {
|
||||||
|
gardenplanmodel.removeCrop(crop);
|
||||||
|
loadCropList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,50 +1,80 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.TaskList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
||||||
|
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.beans.property.ListProperty;
|
import javafx.beans.property.ListProperty;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.beans.property.SimpleListProperty;
|
||||||
import javafx.event.EventHandler;
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.ListCell;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.Priority;
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the MySchedule.fxml file
|
|
||||||
*/
|
|
||||||
public class MyScheduleController {
|
|
||||||
private static final Logger LOG = Logger.getLogger(MyScheduleController.class.getName());
|
|
||||||
|
|
||||||
|
public class MyScheduleController implements Initializable {
|
||||||
private Crop selectedCrop = null;
|
private Crop selectedCrop = null;
|
||||||
|
private final TaskListModel taskListModel = new TaskListModel();
|
||||||
|
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
||||||
|
private final PlantListModel plantListModel = new PlantListModel();
|
||||||
|
|
||||||
@Inject
|
private final ListProperty<Crop> cropListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
private GardenSchedule gardenSchedule;
|
|
||||||
@Inject
|
|
||||||
private Garden garden;
|
|
||||||
@Inject
|
|
||||||
private PlantList plantList;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<List<Task>> week_listView;
|
private Label day1_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day1_pane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label day2_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day2_pane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label day3_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day3_pane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label day4_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day4_pane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label day5_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day5_pane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label day6_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day6_pane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label day7_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Pane day7_pane;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Label information_label;
|
private Label information_label;
|
||||||
|
@ -52,58 +82,57 @@ public class MyScheduleController {
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<Crop> scheduledPlants_listview;
|
private ListView<Crop> scheduledPlants_listview;
|
||||||
|
|
||||||
@FXML
|
public MyScheduleController() throws IOException {
|
||||||
private void showAllTasks(ActionEvent actionEvent) throws IOException {
|
|
||||||
gardenSchedule.getTasksUpcomingWeek();
|
|
||||||
scheduledPlants_listview.getSelectionModel().clearSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterInject
|
@Override
|
||||||
@SuppressWarnings("unused")
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
public void init() throws IOException {
|
List<Crop> cropList;
|
||||||
setCellFactoryCropListView();
|
try {
|
||||||
setCellFactoryTaskListView();
|
cropList = gardenplanmodel.getCrops();
|
||||||
scheduledPlants_listview.itemsProperty().bind(garden.getPlantedCrops());
|
cropListProperty.addAll(cropList);
|
||||||
ListProperty<List<Task>> taskListProperty = gardenSchedule.getWeeklyTaskListProperty();
|
} catch (IOException e) {
|
||||||
week_listView.itemsProperty().bind(taskListProperty);
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
setCellFactoryListView();
|
||||||
|
scheduledPlants_listview.itemsProperty().bind(cropListProperty);
|
||||||
lookForSelectedListEntries();
|
lookForSelectedListEntries();
|
||||||
|
setDayLabels();
|
||||||
information_label.setText("");
|
information_label.setText("");
|
||||||
|
try {
|
||||||
gardenSchedule.getTasksUpcomingWeek();
|
loadTaskList();
|
||||||
TaskList.TaskListObserver taskListObserver = newTaskList -> {
|
} catch (IOException e) {
|
||||||
Platform.runLater(() -> {
|
e.printStackTrace();
|
||||||
try {
|
}
|
||||||
gardenSchedule.getTasksUpcomingWeek();
|
|
||||||
scheduledPlants_listview.getSelectionModel().clearSelection();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
gardenSchedule.setTaskListObserver(taskListObserver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* sort scheduler to selected crop
|
|
||||||
*/
|
|
||||||
private void lookForSelectedListEntries() {
|
private void lookForSelectedListEntries() {
|
||||||
scheduledPlants_listview.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
scheduledPlants_listview.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Crop>() {
|
||||||
selectedCrop = newValue;
|
@Override
|
||||||
try {
|
public void changed(ObservableValue<? extends Crop> observable, Crop oldValue, Crop newValue) {
|
||||||
loadTaskList();
|
selectedCrop = newValue;
|
||||||
} catch (IOException e) {
|
try {
|
||||||
e.printStackTrace();
|
loadTaskList();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void setDayLabels() {
|
||||||
* set cellFactory for the crops.
|
LocalDate today = LocalDate.now();
|
||||||
*/
|
day1_label.setText(today.getDayOfWeek().toString());
|
||||||
private void setCellFactoryCropListView() {
|
day2_label.setText(today.plusDays(1).getDayOfWeek().toString());
|
||||||
MultipleSelectionModel<Crop> selectionModel = scheduledPlants_listview.getSelectionModel();
|
day3_label.setText(today.plusDays(2).getDayOfWeek().toString());
|
||||||
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
|
day4_label.setText(today.plusDays(3).getDayOfWeek().toString());
|
||||||
scheduledPlants_listview.setCellFactory(param -> new ListCell<>() {
|
day5_label.setText(today.plusDays(4).getDayOfWeek().toString());
|
||||||
|
day6_label.setText(today.plusDays(5).getDayOfWeek().toString());
|
||||||
|
day7_label.setText(today.plusDays(6).getDayOfWeek().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCellFactoryListView() {
|
||||||
|
scheduledPlants_listview.setCellFactory(param -> new ListCell<Crop>() {
|
||||||
@Override
|
@Override
|
||||||
protected void updateItem(Crop crop, boolean empty) {
|
protected void updateItem(Crop crop, boolean empty) {
|
||||||
super.updateItem(crop, empty);
|
super.updateItem(crop, empty);
|
||||||
|
@ -112,120 +141,42 @@ public class MyScheduleController {
|
||||||
setText(null);
|
setText(null);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
String text = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId())
|
setText(plantListModel.getFilteredPlantListById(Config.getCurrentHardinessZone(), crop.getPlantId()).get(0).name());
|
||||||
.map(Plant::name)
|
|
||||||
.orElse("");
|
|
||||||
setText(text);
|
|
||||||
} catch (HardinessZoneNotSetException | IOException e) {
|
} catch (HardinessZoneNotSetException | IOException e) {
|
||||||
LOG.log(Level.WARNING, "Could not get plant for Cell", e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set CallFactory for the given Tasks
|
|
||||||
*/
|
|
||||||
private void setCellFactoryTaskListView() {
|
|
||||||
week_listView.setCellFactory(param -> new ListCell<>() {
|
|
||||||
@Override
|
|
||||||
protected void updateItem(List<Task> taskList, boolean empty) {
|
|
||||||
super.updateItem(taskList, empty);
|
|
||||||
|
|
||||||
if (empty || taskList == null) {
|
|
||||||
setText(null);
|
|
||||||
setGraphic(null);
|
|
||||||
} else {
|
|
||||||
setText("");
|
|
||||||
setGraphic(weekTaskVBox(taskList, this.getIndex()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update task list
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
private void loadTaskList() throws IOException {
|
private void loadTaskList() throws IOException {
|
||||||
List<List<Task>> taskLists;
|
List<List<Task>> taskLists = new LinkedList<>();
|
||||||
if (selectedCrop != null) {
|
if (selectedCrop != null) {
|
||||||
gardenSchedule.getTasksUpcomingWeekForCrop(selectedCrop.getCropId().get());
|
taskLists = taskListModel.getTasksUpcomingWeekForCrop(selectedCrop.getCropId().get());
|
||||||
} else {
|
} else {
|
||||||
gardenSchedule.getTasksUpcomingWeek();
|
taskLists = taskListModel.getTasksUpcomingWeek();
|
||||||
|
}
|
||||||
|
if (!taskLists.isEmpty()) {
|
||||||
|
viewTaskListOfDay(day1_pane, taskLists.get(0));
|
||||||
|
viewTaskListOfDay(day2_pane, taskLists.get(1));
|
||||||
|
viewTaskListOfDay(day3_pane, taskLists.get(2));
|
||||||
|
viewTaskListOfDay(day4_pane, taskLists.get(3));
|
||||||
|
viewTaskListOfDay(day5_pane, taskLists.get(4));
|
||||||
|
viewTaskListOfDay(day6_pane, taskLists.get(5));
|
||||||
|
viewTaskListOfDay(day7_pane, taskLists.get(6));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void viewTaskListOfDay(Pane pane, List<Task> tasks) {
|
||||||
* Create a {@link VBox} of the given TaskList.
|
//ToDo update pane with task list
|
||||||
* @param tasks List of {@link Task}s
|
VBox vBox = new VBox();
|
||||||
* @param dayIndex index of the day
|
|
||||||
* @return {@link VBox} of the given Task of the day
|
|
||||||
*/
|
|
||||||
private VBox weekTaskVBox(List<Task> tasks, int dayIndex) {
|
|
||||||
VBox vBox = new VBox(10);
|
|
||||||
LocalDate today = LocalDate.now();
|
|
||||||
Label weekDay = new Label(today.plusDays(dayIndex).getDayOfWeek().toString());
|
|
||||||
weekDay.setStyle("-fx-font-weight: bold; -fx-underline: true");
|
|
||||||
vBox.getChildren().add(weekDay);
|
|
||||||
for (Task task : tasks) {
|
for (Task task : tasks) {
|
||||||
HBox hBox = new HBox(10);
|
Label label = new Label(task.getDescription());
|
||||||
Label taskName = new Label(task.getName() + ":");
|
vBox.getChildren().add(label);
|
||||||
taskName.setStyle("-fx-font-weight: bold");
|
|
||||||
taskName.setMinWidth(100);
|
|
||||||
taskName.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
|
|
||||||
hBox.getChildren().addAll(taskName);
|
|
||||||
|
|
||||||
HBox hBoxDescription = new HBox();
|
|
||||||
Label taskDescription = new Label(task.getDescription());
|
|
||||||
taskDescription.setWrapText(true);
|
|
||||||
taskDescription.setMaxSize(600, Double.MAX_VALUE);
|
|
||||||
Pane puffer = new Pane();
|
|
||||||
HBox.setHgrow(puffer, Priority.ALWAYS);
|
|
||||||
Button button = new Button("Task completed!");
|
|
||||||
button.getStyleClass().add("button-class");
|
|
||||||
|
|
||||||
button.setOnAction(new EventHandler<ActionEvent>() {
|
|
||||||
@Override
|
|
||||||
public void handle(ActionEvent event) {
|
|
||||||
showConfirmation(task);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
HBox.setHgrow(button, Priority.NEVER);
|
|
||||||
hBoxDescription.getChildren().addAll(taskDescription, puffer, button);
|
|
||||||
vBox.getChildren().addAll(hBox, hBoxDescription);
|
|
||||||
}
|
}
|
||||||
return vBox;
|
pane.getChildren().add(vBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Alert to confirm that task has been completed.
|
|
||||||
* @param task {@link Task} which is selected
|
|
||||||
*/
|
|
||||||
private void showConfirmation(Task task) {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
|
||||||
alert.setTitle("Task Completed?");
|
|
||||||
alert.setHeaderText("Are you sure you have completed this task?");
|
|
||||||
alert.setContentText("Confirming that you have completed the task will remove it from the schedule.");
|
|
||||||
|
|
||||||
DialogPane dialogPane = alert.getDialogPane();
|
|
||||||
|
|
||||||
dialogPane.getStylesheets().add(
|
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
|
||||||
|
|
||||||
alert.showAndWait()
|
|
||||||
.ifPresent(buttonType -> {
|
|
||||||
if (buttonType == ButtonType.OK) {
|
|
||||||
task.done();
|
|
||||||
try {
|
|
||||||
loadTaskList();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +1,44 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.ChangeViewEvent;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
import ch.zhaw.gartenverwaltung.plantList.PlantListModel;
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantListModel;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.types.Seasons;
|
import ch.zhaw.gartenverwaltung.types.Seasons;
|
||||||
import javafx.beans.property.ListProperty;
|
import javafx.beans.property.ListProperty;
|
||||||
import javafx.beans.property.SimpleListProperty;
|
import javafx.beans.property.SimpleListProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Modality;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
public class PlantsController implements Initializable {
|
||||||
* Controller class for the Plants.fxml file
|
|
||||||
*/
|
|
||||||
public class PlantsController {
|
|
||||||
private static final Logger LOG = Logger.getLogger(PlantsController.class.getName());
|
private static final Logger LOG = Logger.getLogger(PlantsController.class.getName());
|
||||||
|
private final PlantListModel plantListModel = new PlantListModel();
|
||||||
@Inject
|
|
||||||
private PlantListModel plantListModel;
|
|
||||||
@Inject
|
|
||||||
private AppLoader appLoader;
|
|
||||||
@Inject
|
|
||||||
private Garden garden;
|
|
||||||
|
|
||||||
private Plant selectedPlant = null;
|
private Plant selectedPlant = null;
|
||||||
private final HardinessZone DEFAULT_HARDINESS_ZONE = HardinessZone.ZONE_8A;
|
private final HardinessZone DEFAULT_HARDINESS_ZONE = HardinessZone.ZONE_8A;
|
||||||
|
|
||||||
|
// TODO: move to model
|
||||||
private final ListProperty<Plant> plantListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
private final ListProperty<Plant> plantListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
||||||
|
|
||||||
@FXML
|
|
||||||
public AnchorPane plantsRoot;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private VBox seasons;
|
private VBox seasons;
|
||||||
|
|
||||||
|
@ -73,38 +62,20 @@ public class PlantsController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* open new window to select sow or harvest day to save the crop
|
* open new window to select sow or harvest day to save the crop
|
||||||
|
* @param event event
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
void selectSowDate() throws IOException {
|
void selectSowDate(ActionEvent event) throws IOException {
|
||||||
Dialog<LocalDate> dateSelection = new Dialog<>();
|
Parent root;
|
||||||
dateSelection.setTitle("Select Date");
|
FXMLLoader fxmlLoader = new FXMLLoader(Objects.requireNonNull(getClass().getResource("SelectSowDay.fxml")));
|
||||||
dateSelection.setHeaderText(String.format("Select Harvest/Sow Date for %s:", selectedPlant.name()));
|
root = fxmlLoader.load();
|
||||||
dateSelection.setResizable(false);
|
SelectSowDayController controller = fxmlLoader.getController();
|
||||||
|
controller.getSelectedPlant(selectedPlant);
|
||||||
DialogPane dialogPane = dateSelection.getDialogPane();
|
Stage stage = new Stage();
|
||||||
|
stage.setScene(new Scene(root));
|
||||||
dialogPane.getStylesheets().add(
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
stage.setResizable(false);
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
stage.showAndWait();
|
||||||
|
|
||||||
ButtonType sowButton = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
|
||||||
dialogPane.getButtonTypes().addAll(sowButton, ButtonType.CANCEL);
|
|
||||||
|
|
||||||
if (appLoader.loadPaneToDialog("SelectSowDay.fxml", dialogPane) instanceof SelectSowDayController controller) {
|
|
||||||
controller.initSaveButton((Button) dialogPane.lookupButton(sowButton));
|
|
||||||
controller.setSelectedPlant(selectedPlant);
|
|
||||||
dateSelection.setResultConverter(button -> button.equals(sowButton) ? controller.retrieveResult() : null);
|
|
||||||
|
|
||||||
dateSelection.showAndWait()
|
|
||||||
.ifPresent(date -> {
|
|
||||||
try {
|
|
||||||
garden.plantAsCrop(selectedPlant, date);
|
|
||||||
} catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Couldn't save Crop", e);
|
|
||||||
}
|
|
||||||
plantsRoot.fireEvent(new ChangeViewEvent(ChangeViewEvent.CHANGE_MAIN_VIEW, "MyGarden.fxml"));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,9 +85,8 @@ public class PlantsController {
|
||||||
* create event listener for selected list entry and search by query
|
* create event listener for selected list entry and search by query
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@AfterInject
|
@Override
|
||||||
@SuppressWarnings("unused")
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
public void init() {
|
|
||||||
setListCellFactory();
|
setListCellFactory();
|
||||||
fillPlantListWithHardinessZone();
|
fillPlantListWithHardinessZone();
|
||||||
list_plants.itemsProperty().bind(plantListProperty);
|
list_plants.itemsProperty().bind(plantListProperty);
|
||||||
|
@ -127,7 +97,6 @@ public class PlantsController {
|
||||||
createFilterSeasons();
|
createFilterSeasons();
|
||||||
createFilterHardinessZone();
|
createFilterHardinessZone();
|
||||||
lookForSelectedListEntry();
|
lookForSelectedListEntry();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
viewFilteredListBySearch();
|
viewFilteredListBySearch();
|
||||||
} catch (HardinessZoneNotSetException e) {
|
} catch (HardinessZoneNotSetException e) {
|
||||||
|
@ -138,7 +107,7 @@ public class PlantsController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set text of list view to plant name
|
* set text of list view to plant name
|
||||||
*/
|
*/
|
||||||
private void setListCellFactory() {
|
private void setListCellFactory() {
|
||||||
list_plants.setCellFactory(param -> new ListCell<>() {
|
list_plants.setCellFactory(param -> new ListCell<>() {
|
||||||
|
@ -158,10 +127,9 @@ public class PlantsController {
|
||||||
/**
|
/**
|
||||||
* get plant list according to param season and hardiness zone
|
* get plant list according to param season and hardiness zone
|
||||||
* fill list view with plant list
|
* fill list view with plant list
|
||||||
*
|
|
||||||
* @param season enum of seasons
|
* @param season enum of seasons
|
||||||
* @throws HardinessZoneNotSetException throws exception
|
* @throws HardinessZoneNotSetException throws exception
|
||||||
* @throws IOException throws exception
|
* @throws IOException throws exception
|
||||||
*/
|
*/
|
||||||
private void viewFilteredListBySeason(Seasons season) throws HardinessZoneNotSetException, IOException {
|
private void viewFilteredListBySeason(Seasons season) throws HardinessZoneNotSetException, IOException {
|
||||||
clearListView();
|
clearListView();
|
||||||
|
@ -171,9 +139,8 @@ public class PlantsController {
|
||||||
/**
|
/**
|
||||||
* get plant list filtered by search plant entry and hardiness zone
|
* get plant list filtered by search plant entry and hardiness zone
|
||||||
* fill list view with plant list
|
* fill list view with plant list
|
||||||
*
|
|
||||||
* @throws HardinessZoneNotSetException throws exception when no hardiness zone is defined
|
* @throws HardinessZoneNotSetException throws exception when no hardiness zone is defined
|
||||||
* @throws IOException throws exception
|
* @throws IOException throws exception
|
||||||
*/
|
*/
|
||||||
private void viewFilteredListBySearch() throws HardinessZoneNotSetException, IOException {
|
private void viewFilteredListBySearch() throws HardinessZoneNotSetException, IOException {
|
||||||
search_plants.textProperty().addListener((observable, oldValue, newValue) -> {
|
search_plants.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
@ -218,7 +185,7 @@ public class PlantsController {
|
||||||
for (HardinessZone zone : HardinessZone.values()) {
|
for (HardinessZone zone : HardinessZone.values()) {
|
||||||
RadioButton radioButton = new RadioButton(zone.name());
|
RadioButton radioButton = new RadioButton(zone.name());
|
||||||
radioButton.setToggleGroup(hardinessGroup);
|
radioButton.setToggleGroup(hardinessGroup);
|
||||||
radioButton.setPadding(new Insets(0, 0, 10, 0));
|
radioButton.setPadding(new Insets(0,0,10,0));
|
||||||
if (zone.equals(DEFAULT_HARDINESS_ZONE)) {
|
if (zone.equals(DEFAULT_HARDINESS_ZONE)) {
|
||||||
radioButton.setSelected(true);
|
radioButton.setSelected(true);
|
||||||
}
|
}
|
||||||
|
@ -240,12 +207,12 @@ public class PlantsController {
|
||||||
for (Seasons season : Seasons.values()) {
|
for (Seasons season : Seasons.values()) {
|
||||||
RadioButton radioButton = new RadioButton(season.getName());
|
RadioButton radioButton = new RadioButton(season.getName());
|
||||||
radioButton.setToggleGroup(seasonGroup);
|
radioButton.setToggleGroup(seasonGroup);
|
||||||
radioButton.setPadding(new Insets(0, 0, 10, 0));
|
radioButton.setPadding(new Insets(0,0,10,0));
|
||||||
if (season.equals(Seasons.ALLSEASONS)) {
|
if (season.equals(Seasons.AllSEASONS)) {
|
||||||
radioButton.setSelected(true);
|
radioButton.setSelected(true);
|
||||||
}
|
}
|
||||||
radioButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
radioButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
if (season.equals(Seasons.ALLSEASONS)) {
|
if (season.equals(Seasons.AllSEASONS)) {
|
||||||
fillPlantListWithHardinessZone();
|
fillPlantListWithHardinessZone();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -274,12 +241,12 @@ public class PlantsController {
|
||||||
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
Image img = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
img_plant.setImage(img);
|
img_plant.setImage(img);
|
||||||
list_plants.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
list_plants.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
if (newValue != null) {
|
if(newValue != null) {
|
||||||
selectedPlant = newValue;
|
selectedPlant = newValue;
|
||||||
description_plant.setText(getPlantDescription());
|
description_plant.setText(selectedPlant.description());
|
||||||
selectSowDay_button.setDisable(false);
|
selectSowDay_button.setDisable(false);
|
||||||
Image img1;
|
Image img1;
|
||||||
if (selectedPlant.image() != null) {
|
if(selectedPlant.image() != null) {
|
||||||
img1 = selectedPlant.image();
|
img1 = selectedPlant.image();
|
||||||
} else {
|
} else {
|
||||||
img1 = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
img1 = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
||||||
|
@ -295,20 +262,6 @@ public class PlantsController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* creates {@link String} of the plant information.
|
|
||||||
* @return return {@link Plant} description
|
|
||||||
*/
|
|
||||||
private String getPlantDescription() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("Name: ").append(selectedPlant.name())
|
|
||||||
.append("\nDescription:\n").append(selectedPlant.description())
|
|
||||||
.append("\nLight Level: ").append(selectedPlant.light())
|
|
||||||
.append("\nSoil: ").append(selectedPlant.soil())
|
|
||||||
.append("\nSpacing: ").append(selectedPlant.spacing());
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clears the ListView of entries
|
* clears the ListView of entries
|
||||||
|
|
|
@ -1,107 +1,174 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
package ch.zhaw.gartenverwaltung;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.gardenplan.Gardenplanmodel;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
|
import ch.zhaw.gartenverwaltung.taskList.PlantNotFoundException;
|
||||||
|
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
||||||
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
|
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.stage.Stage;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
public class SelectSowDayController implements Initializable {
|
||||||
* Controller class for the SelectSowDay.fxml file
|
private Plant selectedPlant = null;
|
||||||
* Gets opened with a dialog.
|
private final TaskListModel taskListModel = new TaskListModel();
|
||||||
*/
|
private final Gardenplanmodel gardenplanmodel = new Gardenplanmodel(taskListModel);
|
||||||
public class SelectSowDayController {
|
|
||||||
private Plant selectedPlant;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private DatePicker datepicker;
|
private DatePicker datepicker;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private RadioButton harvest_radio;
|
private Label popup_label;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button save_button;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private RadioButton sow_radio;
|
private RadioButton sow_radio;
|
||||||
@FXML
|
|
||||||
public ToggleGroup phase_group;
|
public SelectSowDayController() throws IOException {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if sow date radio button was selected return sow date
|
* close the date selector window
|
||||||
* if sow date was not selected get sow from harvest day and return sow date
|
* @param event event
|
||||||
* @return {@link LocalDate} of the sow date
|
|
||||||
*/
|
*/
|
||||||
public LocalDate retrieveResult() {
|
@FXML
|
||||||
LocalDate sowDate = datepicker.getValue();
|
void cancel(ActionEvent event) {
|
||||||
if (harvest_radio.isSelected()) {
|
closeWindow();
|
||||||
sowDate = selectedPlant.sowDateFromHarvestDate(sowDate);
|
|
||||||
}
|
|
||||||
return sowDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@link Plant} for which a date should be selected.
|
* get sow date from datePicker or calculate sow date from harvest date
|
||||||
*
|
* save selected plant and sow date
|
||||||
|
* @param event event
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
void save(ActionEvent event) throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
|
||||||
|
LocalDate sowDate;
|
||||||
|
if (sow_radio.isSelected()) {
|
||||||
|
sowDate = datepicker.getValue();
|
||||||
|
} else {
|
||||||
|
//ToDo method to get current lifecycle group in plant
|
||||||
|
sowDate = selectedPlant.sowDateFromHarvestDate(datepicker.getValue(), 0);
|
||||||
|
}
|
||||||
|
gardenplanmodel.plantAsCrop(selectedPlant, sowDate);
|
||||||
|
closeWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save the plant which will be planted and update label
|
||||||
* @param plant Plant
|
* @param plant Plant
|
||||||
*/
|
*/
|
||||||
public void setSelectedPlant(Plant plant) {
|
public void getSelectedPlant(Plant plant) {
|
||||||
selectedPlant = plant;
|
selectedPlant = plant;
|
||||||
|
popup_label.setText("Select Harvest/Sow Date for" + selectedPlant.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add listener and set default values
|
* add listener and set default values
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @param location location
|
||||||
|
* @param resources resources
|
||||||
*/
|
*/
|
||||||
@FXML
|
@Override
|
||||||
public void initialize() {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
clearDatePickerEntries();
|
clearDatePickerEntries();
|
||||||
|
|
||||||
Callback<DatePicker, DateCell> dayCellFactory = getDayCellFactory();
|
Callback<DatePicker, DateCell> dayCellFactory= getDayCellFactory();
|
||||||
datepicker.setDayCellFactory(dayCellFactory);
|
datepicker.setDayCellFactory(dayCellFactory);
|
||||||
datepicker.setEditable(false);
|
datepicker.getEditor().setEditable(false);
|
||||||
|
|
||||||
sow_radio.setUserData(GrowthPhaseType.SOW);
|
enableDisableSaveButton();
|
||||||
harvest_radio.setUserData(GrowthPhaseType.HARVEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable save button when date picker is empty
|
|
||||||
* @param saveButton {@link Button} to be disabled
|
|
||||||
*/
|
|
||||||
public void initSaveButton(Button saveButton) {
|
|
||||||
saveButton.disableProperty().bind(datepicker.valueProperty().isNull());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear date picker editor when radio button is changed
|
* clear date picker editor when radio button is changed
|
||||||
*/
|
*/
|
||||||
private void clearDatePickerEntries() {
|
private void clearDatePickerEntries() {
|
||||||
harvest_radio.selectedProperty().addListener((observable, oldValue, isNowSelected) -> datepicker.setValue(null));
|
sow_radio.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean isNowSelected) {
|
||||||
|
datepicker.getEditor().clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* date picker disable/enable dates according to selected plant: sow or harvest day
|
* date picker disable/enable dates according to selected plant: sow or harvest day
|
||||||
*
|
|
||||||
* @return cellFactory of datePicker
|
* @return cellFactory of datePicker
|
||||||
*/
|
*/
|
||||||
private Callback<DatePicker, DateCell> getDayCellFactory() {
|
private Callback<DatePicker, DateCell> getDayCellFactory() {
|
||||||
|
|
||||||
return (datePicker) -> new DateCell() {
|
final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
|
||||||
private final LocalDate today = LocalDate.now();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(LocalDate item, boolean empty) {
|
public DateCell call(final DatePicker datePicker) {
|
||||||
super.updateItem(item, empty);
|
return new DateCell() {
|
||||||
setDisable(true);
|
@Override
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
public void updateItem(LocalDate item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
if (item.compareTo(today) > 0 && (!harvest_radio.isSelected() || selectedPlant.sowDateFromHarvestDate(item).compareTo(today) >= 0)) {
|
setDisable(true);
|
||||||
GrowthPhaseType selectedPhase = (GrowthPhaseType) phase_group.getSelectedToggle().getUserData();
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
|
List<LocalDate> dates;
|
||||||
if (selectedPlant.isDateInPhase(item, selectedPhase)) {
|
LocalDate today = LocalDate.now();
|
||||||
setDisable(false);
|
if (sow_radio.isSelected()) {
|
||||||
setStyle("-fx-background-color: #32CD32;");
|
dates = selectedPlant.getDateListOfGrowthPhase(GrowthPhaseType.SOW);
|
||||||
|
} else {
|
||||||
|
dates = selectedPlant.getDateListOfGrowthPhase(GrowthPhaseType.HARVEST);
|
||||||
|
}
|
||||||
|
for (LocalDate date : dates) {
|
||||||
|
if (item.getMonth() == date.getMonth()
|
||||||
|
&& item.getDayOfMonth() == date.getDayOfMonth()
|
||||||
|
&& item.compareTo(today) > 0) {
|
||||||
|
setDisable(false);
|
||||||
|
setStyle("-fx-background-color: #32CD32;");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((!sow_radio.isSelected() && selectedPlant.sowDateFromHarvestDate(item, 0).compareTo(today) < 0)) {
|
||||||
|
setDisable(true);
|
||||||
|
setStyle("-fx-background-color: #ffc0cb;");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return dayCellFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* close date picker window
|
||||||
|
*/
|
||||||
|
private void closeWindow() {
|
||||||
|
Stage stage = (Stage) save_button.getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* disable save button, when there is no date selected in date picker
|
||||||
|
*/
|
||||||
|
private void enableDisableSaveButton() {
|
||||||
|
save_button.setDisable(true);
|
||||||
|
datepicker.getEditor().textProperty().addListener(new ChangeListener<String>() {
|
||||||
|
@Override
|
||||||
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||||
|
if (newValue == null || newValue.equals("")) {
|
||||||
|
save_button.setDisable(true);
|
||||||
|
} else {
|
||||||
|
save_button.setDisable(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.backgroundtasks.email.SmtpCredentials;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Class to store default Settings and User Settings
|
|
||||||
*/
|
|
||||||
public class Settings {
|
|
||||||
/*
|
|
||||||
* The Class instance to use everywhere
|
|
||||||
*/
|
|
||||||
|
|
||||||
private static final Settings instance;
|
|
||||||
/**
|
|
||||||
* The current Hardiness zone initialized as default value Zone_8A
|
|
||||||
*/
|
|
||||||
private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A;
|
|
||||||
/**
|
|
||||||
* Setting to show or hide the Tutorial in Main Menu
|
|
||||||
*/
|
|
||||||
private final BooleanProperty showTutorial = new SimpleBooleanProperty(false);
|
|
||||||
/**
|
|
||||||
* The SMTP Credentials which are used to send E-Mail Notifications
|
|
||||||
* The following Google Account is created for Testing:
|
|
||||||
* E-Mail Address: pm3.hs22.it21b.win.team1@gmail.com
|
|
||||||
* Account Password: Gartenverwaltung.PM3.2022
|
|
||||||
* SMTP Password: bisefhhjtrrhtoqr
|
|
||||||
*/
|
|
||||||
private SmtpCredentials smtpCredentials = new SmtpCredentials("imap.gmail.com", "587", "pm3.hs22.it21b.win.team1@gmail.com", "pm3.hs22.it21b.win.team1@gmail.com", "bisefhhjtrrhtoqr", true);
|
|
||||||
/**
|
|
||||||
* List of Receivers for E-Mailnotifications. Multiple E-Mailadresses can be separated by ";"
|
|
||||||
* Following Public E-mail address was used for Testing: pm3.hs22.it21b.win.team1@mailinator.com
|
|
||||||
* The E-Mail inbox of this address can be found here: https://www.mailinator.com/v4/public/inboxes.jsp?to=pm3.hs22.it21b.win.team1
|
|
||||||
*/
|
|
||||||
private String mailNotificationReceivers = "pm3.hs22.it21b.win.team1@mailinator.com";
|
|
||||||
/**
|
|
||||||
* String Template to create E-Mail Subject for Notifications
|
|
||||||
* Variables: Task Name
|
|
||||||
*/
|
|
||||||
private String mailNotificationSubjectTemplate = "Task %s is due!";
|
|
||||||
/**
|
|
||||||
* String Template to create E-Mail Text for Notifications
|
|
||||||
* Variables: Task Name, plant Name, nextExecution, Task description
|
|
||||||
*/
|
|
||||||
private String mailNotificationTextTemplate = "Dear user\nYour gardentask %s for plant %s is due at %tF. Don't forget to confirm in your application if the task is done.\nTask description:\n%s";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location of the garden can be set by user (Used for Weather Service)
|
|
||||||
*/
|
|
||||||
private String location = "";
|
|
||||||
|
|
||||||
/*
|
|
||||||
Create Instance of Settings
|
|
||||||
*/
|
|
||||||
static {
|
|
||||||
instance = new Settings();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Settings getInstance() {
|
|
||||||
return Settings.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private constructor to prevent Classes from creating more instances
|
|
||||||
*/
|
|
||||||
private Settings() {}
|
|
||||||
|
|
||||||
public HardinessZone getCurrentHardinessZone() {
|
|
||||||
return currentHardinessZone;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to set the current Hardiness Zone. If no Hardiness Zone is given the default zone (ZONE_8A) will be used.
|
|
||||||
* @param currentHardinessZone the new Hardiness Zone
|
|
||||||
*/
|
|
||||||
public void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
|
|
||||||
this.currentHardinessZone = Objects.requireNonNullElse(currentHardinessZone, HardinessZone.ZONE_8A);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShowTutorial (boolean showTutorial) {
|
|
||||||
this.showTutorial.setValue(showTutorial);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanProperty getShowTutorialProperty() {
|
|
||||||
return this.showTutorial;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getShowTutorial() {
|
|
||||||
return this.showTutorial.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(String location) {
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLocation() {
|
|
||||||
return this.location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SmtpCredentials getSmtpCredentials() {
|
|
||||||
return smtpCredentials;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMailNotificationReceivers() {
|
|
||||||
return mailNotificationReceivers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMailNotificationSubjectTemplate() {
|
|
||||||
return mailNotificationSubjectTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMailNotificationTextTemplate() {
|
|
||||||
return mailNotificationTextTemplate;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,116 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AppLoader;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.*;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the Settings.fxml file
|
|
||||||
*/
|
|
||||||
public class SettingsController implements Initializable {
|
|
||||||
Settings settings = Settings.getInstance();
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
AppLoader appLoader;
|
|
||||||
@FXML
|
|
||||||
private ComboBox<HardinessZone> selectHardinessZone_comboBox;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private CheckBox showTutorial_checkBox;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button location_button;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label location_label;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* open dialog to set location
|
|
||||||
* @param event event
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
@FXML
|
|
||||||
void setLocation(ActionEvent event) throws IOException {
|
|
||||||
openTextFieldDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* save selected values to {@link Settings}
|
|
||||||
*/
|
|
||||||
public void saveSettings() {
|
|
||||||
settings.setShowTutorial(showTutorial_checkBox.isSelected());
|
|
||||||
settings.setCurrentHardinessZone(selectHardinessZone_comboBox.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* save default values form {@link Settings}
|
|
||||||
* @param location location
|
|
||||||
* @param resources resources
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
|
||||||
showTutorial_checkBox.setSelected(settings.getShowTutorial());
|
|
||||||
selectHardinessZone_comboBox.getItems().addAll(HardinessZone.values());
|
|
||||||
selectHardinessZone_comboBox.setValue(settings.getCurrentHardinessZone());
|
|
||||||
setIconToButton(location_button, "locationIcon.png");
|
|
||||||
location_label.setText(settings.getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* adds icon to button
|
|
||||||
* @param button the button which get the icon
|
|
||||||
* @param iconFileName file name of icon
|
|
||||||
*/
|
|
||||||
private void setIconToButton(Button button, String iconFileName) {
|
|
||||||
Image img = new Image(String.valueOf(getClass().getResource("icons/" + iconFileName)));
|
|
||||||
ImageView imageView = new ImageView(img);
|
|
||||||
imageView.setFitHeight(20);
|
|
||||||
imageView.setPreserveRatio(true);
|
|
||||||
button.setGraphic(imageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* opens Dialog to set exception
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
private void openTextFieldDialog() throws IOException {
|
|
||||||
Dialog<String> dialog = new Dialog<>();
|
|
||||||
dialog.setTitle("Set Location of your Garden");
|
|
||||||
dialog.setHeaderText("set Location of your Garden!");
|
|
||||||
dialog.setResizable(false);
|
|
||||||
|
|
||||||
DialogPane dialogPane = dialog.getDialogPane();
|
|
||||||
|
|
||||||
dialogPane.getStylesheets().add(
|
|
||||||
Objects.requireNonNull(getClass().getResource("bootstrap/dialogStyle.css")).toExternalForm());
|
|
||||||
dialogPane.getStyleClass().add("myDialog");
|
|
||||||
|
|
||||||
ButtonType save = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
|
|
||||||
dialogPane.getButtonTypes().addAll(save, ButtonType.CANCEL);
|
|
||||||
|
|
||||||
if (appLoader.loadPaneToDialog("TextFieldFormular.fxml", dialogPane) instanceof TextFieldFormularController controller) {
|
|
||||||
controller.setDescription_label("Set");
|
|
||||||
controller.setValueTextArea(settings.getLocation());
|
|
||||||
controller.initSaveButton((Button) dialogPane.lookupButton(save));
|
|
||||||
|
|
||||||
dialog.setResultConverter(button -> button.equals(save) ? controller.getValue() : null);
|
|
||||||
|
|
||||||
dialog.showAndWait()
|
|
||||||
.ifPresent(string -> {
|
|
||||||
settings.setLocation(string);
|
|
||||||
location_label.setText(settings.getLocation());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,190 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.AfterInject;
|
|
||||||
import ch.zhaw.gartenverwaltung.bootstrap.Inject;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.*;
|
|
||||||
import javafx.util.Callback;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the TaskFormular.fxml file
|
|
||||||
*/
|
|
||||||
public class TaskFormularController implements Initializable {
|
|
||||||
private Crop crop;
|
|
||||||
private Plant plant;
|
|
||||||
private Task task = null;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private GardenSchedule gardenSchedule;
|
|
||||||
@Inject
|
|
||||||
private Garden garden;
|
|
||||||
@Inject
|
|
||||||
private PlantList plantList;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TextArea description_area;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private DatePicker end_datePicker;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TextField interval_field;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private DatePicker start_datePicker;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TextField taskName_field;
|
|
||||||
|
|
||||||
@AfterInject
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the edited or added {@link Task}
|
|
||||||
* @param crop {@link Crop} which was selected
|
|
||||||
* @return {@link Task} which was edited or added
|
|
||||||
*/
|
|
||||||
public Task returnResult(Crop crop) {
|
|
||||||
int interval = 0;
|
|
||||||
if (interval_field.getText() != null && !(interval_field.getText().isEmpty() || interval_field.getText().equals(""))) {
|
|
||||||
interval = Integer.parseInt(interval_field.getText());
|
|
||||||
}
|
|
||||||
Task task = new Task(taskName_field.getText(), description_area.getText(),
|
|
||||||
start_datePicker.getValue(), end_datePicker.getValue(),
|
|
||||||
interval, crop.getCropId().get());
|
|
||||||
if (this.task != null) return this.task.updateTask(task);
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set selected crop and get the plant from the crop.
|
|
||||||
* @param crop {@link Crop} which was selected
|
|
||||||
* @throws HardinessZoneNotSetException exception
|
|
||||||
* @throws IOException exception
|
|
||||||
*/
|
|
||||||
public void setCorp(Crop crop) throws HardinessZoneNotSetException, IOException {
|
|
||||||
this.crop = crop;
|
|
||||||
this.plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set the values of task into the labels and datePicker.
|
|
||||||
* @param task {@link Task} which was given
|
|
||||||
*/
|
|
||||||
public void setTaskValue(Task task) {
|
|
||||||
this.task = task;
|
|
||||||
taskName_field.setText(task.getName());
|
|
||||||
description_area.setText(task.getDescription());
|
|
||||||
start_datePicker.setValue(task.getStartDate());
|
|
||||||
end_datePicker.setValue(task.getEndDate().orElse(null));
|
|
||||||
if(task.getInterval().orElse(null)!=null) {
|
|
||||||
interval_field.setText(task.getInterval().get().toString());
|
|
||||||
} else {
|
|
||||||
interval_field.setText(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dayCellFactory of the start date
|
|
||||||
* @return {@link Callback} of the dayCellFactory
|
|
||||||
*/
|
|
||||||
private Callback<DatePicker, DateCell> getDayCellFactoryStartDate() {
|
|
||||||
|
|
||||||
return (datePicker) -> new DateCell() {
|
|
||||||
private final LocalDate today = LocalDate.now();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateItem(LocalDate item, boolean empty) {
|
|
||||||
super.updateItem(item, empty);
|
|
||||||
setDisable(true);
|
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
|
||||||
|
|
||||||
if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0 && item.compareTo(crop.getStartDate().plusDays(plant.timeToHarvest(0))) < 0) {
|
|
||||||
setDisable(false);
|
|
||||||
setStyle("-fx-background-color: #32CD32;");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end_datePicker.getValue() != null && item.compareTo(end_datePicker.getValue()) > 0) {
|
|
||||||
setDisable(true);
|
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dayCellFactory of the end date
|
|
||||||
* @return {@link Callback} of the dayCellFactory
|
|
||||||
*/
|
|
||||||
private Callback<DatePicker, DateCell> getDayCellFactoryEndDate() {
|
|
||||||
|
|
||||||
return (datePicker) -> new DateCell() {
|
|
||||||
private final LocalDate today = LocalDate.now();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateItem(LocalDate item, boolean empty) {
|
|
||||||
super.updateItem(item, empty);
|
|
||||||
setDisable(true);
|
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
|
||||||
|
|
||||||
if (item.compareTo(today) > 0 && item.compareTo(crop.getStartDate()) > 0 && item.compareTo(crop.getStartDate().plusDays(plant.timeToHarvest(0))) < 0) {
|
|
||||||
setDisable(false);
|
|
||||||
setStyle("-fx-background-color: #32CD32;");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (start_datePicker.getValue() != null && item.compareTo(start_datePicker.getValue()) < 0) {
|
|
||||||
setDisable(true);
|
|
||||||
setStyle("-fx-background-color: #ffc0cb;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* disable button until condition meet.
|
|
||||||
* @param button {@link Button} which was given
|
|
||||||
*/
|
|
||||||
public void initSaveButton(Button button) {
|
|
||||||
interval_field.textProperty().addListener((observable, oldValue, newValue) -> {
|
|
||||||
if (newValue != null && !newValue.matches("\\d*")) {
|
|
||||||
interval_field.setText(newValue.replaceAll("[^\\d]", ""));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
button.disableProperty().bind(start_datePicker.valueProperty().isNull()
|
|
||||||
.or(taskName_field.textProperty().isEmpty())
|
|
||||||
.or(description_area.textProperty().isEmpty()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize dayCellFactories
|
|
||||||
* @param location
|
|
||||||
* The location used to resolve relative paths for the root object, or
|
|
||||||
* {@code null} if the location is not known.
|
|
||||||
*
|
|
||||||
* @param resources
|
|
||||||
* The resources used to localize the root object, or {@code null} if
|
|
||||||
* the root object was not localized.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
|
||||||
start_datePicker.setDayCellFactory(getDayCellFactoryStartDate());
|
|
||||||
start_datePicker.setEditable(false);
|
|
||||||
|
|
||||||
end_datePicker.setDayCellFactory(getDayCellFactoryEndDate());
|
|
||||||
end_datePicker.setEditable(false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.Label;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the TexFieldFormular.fxml file
|
|
||||||
*/
|
|
||||||
public class TextFieldFormularController {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Label description_label;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TextField text_area;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set description label
|
|
||||||
* @param string string of the description
|
|
||||||
*/
|
|
||||||
public void setDescription_label(String string) {
|
|
||||||
description_label.setText(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* set text area value
|
|
||||||
* @param string string of text area value
|
|
||||||
*/
|
|
||||||
public void setValueTextArea(String string) {
|
|
||||||
text_area.setText(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return value of text area
|
|
||||||
* @return string of the tex area
|
|
||||||
*/
|
|
||||||
public String getValue() {
|
|
||||||
return text_area.getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable Button until condition meet
|
|
||||||
* @param button {@link Button} which is gets dissabled
|
|
||||||
*/
|
|
||||||
public void initSaveButton(Button button) {
|
|
||||||
text_area.textProperty().addListener((observable, oldValue, newValue) -> {
|
|
||||||
if (newValue.matches("\\d*\\.?\\d*")) {
|
|
||||||
text_area.setText(newValue);
|
|
||||||
} else {
|
|
||||||
text_area.setText(oldValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
button.disableProperty().bind(text_area.textProperty().isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung;
|
|
||||||
|
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.layout.StackPane;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller class for the Tutorial.fxml file
|
|
||||||
*/
|
|
||||||
public class TutorialController {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public Button previousPageButton;
|
|
||||||
@FXML
|
|
||||||
public Button nextPageButton;
|
|
||||||
@FXML
|
|
||||||
public StackPane tourPages;
|
|
||||||
public ImageView imgAddNewPlant;
|
|
||||||
public ImageView imgTaskList;
|
|
||||||
public ImageView imgSelectDate;
|
|
||||||
public ImageView imgAddTaskButton;
|
|
||||||
public ImageView imgDetailDeleteButtons;
|
|
||||||
|
|
||||||
private int page = 0;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void initialize() {
|
|
||||||
switchViews();
|
|
||||||
setButtonAbilities();
|
|
||||||
|
|
||||||
setImageView(imgAddNewPlant, "add-new-plant.png");
|
|
||||||
setImageView(imgSelectDate, "select-sow-harvest.png");
|
|
||||||
setImageView(imgDetailDeleteButtons, "details-delete.png");
|
|
||||||
setImageView(imgTaskList, "schedule.png");
|
|
||||||
setImageView(imgAddTaskButton, "add-task.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* update the given image view with screenshot or placeholder image.
|
|
||||||
* @param imageView the image view to update
|
|
||||||
* @param fileName the file name of the source
|
|
||||||
*/
|
|
||||||
private void setImageView(ImageView imageView, String fileName) {
|
|
||||||
InputStream is = PlantsController.class.getResourceAsStream("screenshots/" + fileName);
|
|
||||||
Image image;
|
|
||||||
if (is != null) {
|
|
||||||
image = new Image(String.valueOf(PlantsController.class.getResource("screenshots/" + fileName)));
|
|
||||||
} else {
|
|
||||||
image = new Image(String.valueOf(PlantsController.class.getResource("placeholder.png")));
|
|
||||||
}
|
|
||||||
imageView.setImage(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void viewNextPage() {
|
|
||||||
page++;
|
|
||||||
switchViews();
|
|
||||||
setButtonAbilities();
|
|
||||||
}
|
|
||||||
public void viewPreviousPage() {
|
|
||||||
page--;
|
|
||||||
switchViews();
|
|
||||||
setButtonAbilities();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* disable next or close button according to the location of button
|
|
||||||
*/
|
|
||||||
private void setButtonAbilities() {
|
|
||||||
previousPageButton.setDisable(page <= 0);
|
|
||||||
nextPageButton.setDisable(page >= tourPages.getChildren().size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* switch to next view
|
|
||||||
*/
|
|
||||||
private void switchViews() {
|
|
||||||
tourPages.getChildren().forEach(node -> node.setOpacity(0));
|
|
||||||
tourPages.getChildren().get(page).setOpacity(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* close Tutorial
|
|
||||||
*/
|
|
||||||
public void closeTutorial() {
|
|
||||||
Stage root = (Stage) tourPages.getScene().getWindow();
|
|
||||||
root.close();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.CropDetailController;
|
|
||||||
import ch.zhaw.gartenverwaltung.backgroundtasks.weather.WeatherGradenTaskPlanner;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.CropList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.TaskList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class with tasks which must be executed periodic and not triggered by user. Method run must be called in a fix interval.
|
|
||||||
*/
|
|
||||||
public class BackgroundTasks extends TimerTask {
|
|
||||||
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
|
|
||||||
private final TaskList taskList;
|
|
||||||
private final Notifier notifier;
|
|
||||||
private final WeatherGradenTaskPlanner weatherGardenTaskPlaner;
|
|
||||||
|
|
||||||
public BackgroundTasks(TaskList taskList, CropList cropList, PlantList plantList) {
|
|
||||||
this.taskList = taskList;
|
|
||||||
notifier = new Notifier(taskList, plantList, cropList);
|
|
||||||
weatherGardenTaskPlaner = new WeatherGradenTaskPlanner(taskList, plantList, cropList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the field "nextExecution" of all tasks if it's in the past to the actual date as long as they are not done.
|
|
||||||
* @throws IOException if the taskList can't be read.
|
|
||||||
*/
|
|
||||||
private void movePastTasks() throws IOException {
|
|
||||||
List<Task> taskList = this.taskList.getTaskList(LocalDate.MIN.plusDays(1), LocalDate.now().minusDays(1));
|
|
||||||
for (Task task : taskList) {
|
|
||||||
if (!task.isDone()) {
|
|
||||||
task.setNextExecution(LocalDate.now());
|
|
||||||
this.taskList.saveTask(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to call if Tasks should be executed. It calls all Background tasks after each other.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
movePastTasks();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOG.log(Level.WARNING, "Could not execute Background Task: move past Tasks ", e.getCause());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
weatherGardenTaskPlaner.refreshTasks();
|
|
||||||
} catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOG.log(Level.WARNING, "Could not execute Background Task: Refresh Tasks by WeatherGardenTaskPlaner ", e.getCause());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
notifier.sendNotifications();
|
|
||||||
} catch (IOException | MessagingException | HardinessZoneNotSetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOG.log(Level.WARNING, "Could not execute Background Task: send Notification for due Tasks", e.getCause());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.Settings;
|
|
||||||
import ch.zhaw.gartenverwaltung.backgroundtasks.email.EMailSender;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.CropList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.TaskList;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
|
||||||
|
|
||||||
import javax.mail.MessagingException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to send Notifications to the user
|
|
||||||
*/
|
|
||||||
public class Notifier {
|
|
||||||
private final TaskList taskList;
|
|
||||||
private final CropList cropList;
|
|
||||||
private final PlantList plantList;
|
|
||||||
private final EMailSender eMailSender = new EMailSender();
|
|
||||||
|
|
||||||
public Notifier(TaskList taskList, PlantList plantList, CropList cropList) {
|
|
||||||
this.taskList = taskList;
|
|
||||||
this.cropList = cropList;
|
|
||||||
this.plantList = plantList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to send a Notification to the user for e specific Task
|
|
||||||
* @param task The task to use for notification
|
|
||||||
* @throws IOException if tasklist can not be read
|
|
||||||
* @throws MessagingException if E-Mail can not be sent for any reason
|
|
||||||
* @throws HardinessZoneNotSetException if hardiness zone is not set in plant list.
|
|
||||||
*/
|
|
||||||
private void sendNotification(Task task) throws IOException, MessagingException, HardinessZoneNotSetException {
|
|
||||||
String plantName = "unkown plant";
|
|
||||||
if(cropList.getCropById((task.getCropId())).isPresent()){
|
|
||||||
Crop crop = cropList.getCropById(task.getCropId()).get();
|
|
||||||
if(plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).isPresent()) {
|
|
||||||
plantName = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).get().name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String messageSubject = String.format(Settings.getInstance().getMailNotificationSubjectTemplate(), task.getName());
|
|
||||||
String messageText = String.format(Settings.getInstance().getMailNotificationTextTemplate(), task.getName(), plantName, task.getNextExecution(), task.getDescription());
|
|
||||||
eMailSender.sendMails(Settings.getInstance().getMailNotificationReceivers(), messageSubject, messageText);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a notification to the user for each task which is due and not done every day as long as it's not done.
|
|
||||||
* @throws IOException if tasklist can not be read
|
|
||||||
* @throws MessagingException if E-Mail can not be sent for any reason
|
|
||||||
* @throws HardinessZoneNotSetException if hardiness zone is not set in plant list.
|
|
||||||
*/
|
|
||||||
public void sendNotifications() throws IOException, MessagingException, HardinessZoneNotSetException {
|
|
||||||
for (Task task : taskList.getTaskList(LocalDate.MIN, LocalDate.MAX)) {
|
|
||||||
if (task.getNextNotification() != null && task.getNextNotification().isBefore(LocalDate.now().minusDays(1))) {
|
|
||||||
sendNotification(task);
|
|
||||||
task.setNextNotification(LocalDate.now().plusDays(1));
|
|
||||||
taskList.saveTask(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks.email;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.Settings;
|
|
||||||
|
|
||||||
import javax.mail.*;
|
|
||||||
import javax.mail.internet.InternetAddress;
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to send E-Mails
|
|
||||||
*/
|
|
||||||
public class EMailSender {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to send E-Mail to one or multiple recipients
|
|
||||||
* @param recipients recipients E-Mail addresses separated by ";"
|
|
||||||
* @param subject Subject of the E-Mail
|
|
||||||
* @param text E-Mail message Text as rear text or html
|
|
||||||
* @throws MessagingException If sending the E-Mail fails for any reason
|
|
||||||
*/
|
|
||||||
public void sendMails(String recipients, String subject, String text) throws MessagingException {
|
|
||||||
printMail(recipients, subject, text);
|
|
||||||
MimeMessage message = new MimeMessage(Settings.getInstance().getSmtpCredentials().getSession());
|
|
||||||
message.addHeader("Content-type", "text/HTML; charset=UTF-8");
|
|
||||||
message.addHeader("format", "flowed");
|
|
||||||
message.addHeader("Content-Transfer-Encoding", "8bit");
|
|
||||||
message.setFrom(new InternetAddress(Settings.getInstance().getSmtpCredentials().fromAddress()));
|
|
||||||
message.setReplyTo(InternetAddress.parse(Settings.getInstance().getSmtpCredentials().fromAddress(), false));
|
|
||||||
message.setSubject(subject);
|
|
||||||
message.setText(text);
|
|
||||||
message.setSentDate(new Date());
|
|
||||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
|
|
||||||
Transport.send(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printMail(String receiver, String subject, String text){
|
|
||||||
System.out.printf("\nSending E-Mail:\nTo: %s\nSubject: %s\nMessage:\n%s\n", receiver, subject, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks.email;
|
|
||||||
|
|
||||||
import javax.mail.PasswordAuthentication;
|
|
||||||
import javax.mail.Session;
|
|
||||||
import java.net.Authenticator;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class to store SMTP Credentials to send E-Mails and create
|
|
||||||
* corresponding Session Object
|
|
||||||
*/
|
|
||||||
public record SmtpCredentials(
|
|
||||||
String host,
|
|
||||||
String port,
|
|
||||||
String fromAddress,
|
|
||||||
String username,
|
|
||||||
String password,
|
|
||||||
boolean startTLS
|
|
||||||
) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Properties Object with SMTP Server Information
|
|
||||||
* @return the created Properties Object
|
|
||||||
*/
|
|
||||||
private Properties getProperties() {
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.put("mail.smtp.host", host);
|
|
||||||
properties.put("mail.smtp.port", port);
|
|
||||||
properties.put("mail.smtp.auth", "true");
|
|
||||||
properties.put("mail.smtp.starttls.enable", startTLS ? "true" : "false");
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a javax.mail.Authenticator Object with username and password for SMTP Server
|
|
||||||
* @return the created javax.mail.Authenticator Object
|
|
||||||
*/
|
|
||||||
private javax.mail.Authenticator getAuthenticator() {
|
|
||||||
return new javax.mail.Authenticator() {
|
|
||||||
@Override
|
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
|
||||||
return new PasswordAuthentication(username, password);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to get the Session Instance with the given SMTP Credentials
|
|
||||||
* @return the Session Instance
|
|
||||||
*/
|
|
||||||
public Session getSession() {
|
|
||||||
return Session.getInstance(getProperties(), getAuthenticator());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum of possible Weather events
|
|
||||||
*/
|
|
||||||
public enum SevereWeather {
|
|
||||||
FROST,SNOW,HAIL,NO_SEVERE_WEATHER,RAIN
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.io.CropList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.TaskList;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantNotFoundException;
|
|
||||||
import ch.zhaw.gartenverwaltung.types.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The WeatherGardenTaskPlanner creates Tasks based on weather events and the rain amount from the last days
|
|
||||||
*/
|
|
||||||
public class WeatherGradenTaskPlanner {
|
|
||||||
private final TaskList taskList;
|
|
||||||
private final PlantList plantList;
|
|
||||||
private final CropList cropList;
|
|
||||||
WeatherService weatherService;
|
|
||||||
private final LocalDate dateSevereWeather = LocalDate.now();
|
|
||||||
|
|
||||||
public WeatherGradenTaskPlanner(TaskList taskList, PlantList plantList, CropList cropList) {
|
|
||||||
this.taskList = taskList;
|
|
||||||
this.plantList = plantList;
|
|
||||||
this.cropList = cropList;
|
|
||||||
weatherService = new WeatherService();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to refresh watering tasks and severe weather tasks
|
|
||||||
* @throws IOException If the database cannot be accessed
|
|
||||||
* @throws HardinessZoneNotSetException If the hardiness zone is not available
|
|
||||||
* @throws PlantNotFoundException if the plant is not available for the watering task
|
|
||||||
*/
|
|
||||||
public void refreshTasks() throws IOException, HardinessZoneNotSetException, PlantNotFoundException {
|
|
||||||
getSevereWeatherEvents();
|
|
||||||
getRainAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getSevereWeatherEvents() throws IOException {
|
|
||||||
SevereWeather actualWeather = weatherService.causeSevereWeather(1);
|
|
||||||
|
|
||||||
List<Crop> actualCrops = cropList.getCrops();
|
|
||||||
for (Crop crop : actualCrops) {
|
|
||||||
|
|
||||||
List<Task> actualCropTasks = taskList.getTaskForCrop(crop.getCropId().orElse(-1L));
|
|
||||||
|
|
||||||
if (SevereWeather.HAIL.equals(actualWeather)) {
|
|
||||||
createPreHailTask(crop, actualCropTasks);
|
|
||||||
} else if (SevereWeather.FROST.equals(actualWeather)) {
|
|
||||||
createPreFrostTask(crop, actualCropTasks);
|
|
||||||
} else if (SevereWeather.SNOW.equals(actualWeather)) {
|
|
||||||
createPreSnowTask(crop, actualCropTasks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getRainAmount() throws IOException, HardinessZoneNotSetException, PlantNotFoundException {
|
|
||||||
int rainAmount = weatherService.causeRainAmount(3);
|
|
||||||
adjustWateringTask(rainAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create a PreHailTask and saves it in the tasklist
|
|
||||||
* @throws IOException If the database cannot be accessed
|
|
||||||
*/
|
|
||||||
private void createPreHailTask(Crop crop, List<Task> actualTasksForCrop) throws IOException {
|
|
||||||
Task preHailTask = new Task("Hail",
|
|
||||||
"During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin",
|
|
||||||
dateSevereWeather,dateSevereWeather.plusDays(1L),crop.getCropId().orElse(-1L));
|
|
||||||
|
|
||||||
List<Task> hailTasks = actualTasksForCrop.stream().filter(task -> task.getName().equals("Hail")).toList();
|
|
||||||
|
|
||||||
if(isNoSevereWeatherTaskAtDate(preHailTask, hailTasks) && hailTasks.isEmpty()){
|
|
||||||
taskList.saveTask(preHailTask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create a PreFrosttask and saves it in the tasklist
|
|
||||||
* @throws IOException If the database cannot be accessed
|
|
||||||
*/
|
|
||||||
private void createPreFrostTask(Crop crop, List<Task> actualTasksForCrop) throws IOException {
|
|
||||||
Task preFrostTask = new Task("Frost",
|
|
||||||
"The temperatur falls below zero degrees, cover especially the root with wool",
|
|
||||||
dateSevereWeather,dateSevereWeather.plusDays(1L),crop.getCropId().orElse(-1L));
|
|
||||||
|
|
||||||
List<Task> frostTasks = actualTasksForCrop.stream().filter(task -> task.getName().equals("Frost")).toList();
|
|
||||||
|
|
||||||
if(isNoSevereWeatherTaskAtDate(preFrostTask, frostTasks) && frostTasks.isEmpty()){
|
|
||||||
taskList.saveTask(preFrostTask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create a PreSnowTask and saves it in the tasklist
|
|
||||||
* @throws IOException If the database cannot be accessed
|
|
||||||
*/
|
|
||||||
private void createPreSnowTask(Crop crop, List<Task> actualTasksForCrop) throws IOException {
|
|
||||||
Task preSnowTask = new Task("Snow",
|
|
||||||
"The weather brings little snowfall. Cover your crops",
|
|
||||||
dateSevereWeather, dateSevereWeather.plusDays(1L), crop.getCropId().orElse(-1L));
|
|
||||||
|
|
||||||
List<Task> snowTasklist = actualTasksForCrop.stream().filter(task -> task.getName().equals("Snow")).toList();
|
|
||||||
|
|
||||||
if(isNoSevereWeatherTaskAtDate(preSnowTask, snowTasklist) && snowTasklist.isEmpty()){
|
|
||||||
taskList.saveTask(preSnowTask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create a PreSnowTask and saves it in the tasklist
|
|
||||||
* @param preSevereWeatherTask the Task which would be added if there is not already
|
|
||||||
* the same Type of severe weather task
|
|
||||||
* @param severeWeatherTasks List of severe weather tasks from e specific severe weather
|
|
||||||
* @return true If there is not already a severe weather task of the same type of preSevereWeatherTask
|
|
||||||
* task at the date of the preSevereWeatherTask
|
|
||||||
*/
|
|
||||||
private boolean isNoSevereWeatherTaskAtDate(Task preSevereWeatherTask, List<Task> severeWeatherTasks) {
|
|
||||||
List<Task> severeWeatherTasksAtDate = new ArrayList<>();
|
|
||||||
for (Task task : severeWeatherTasks) {
|
|
||||||
if (task.getStartDate() == preSevereWeatherTask.getStartDate()) {
|
|
||||||
severeWeatherTasksAtDate.add(task);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return severeWeatherTasksAtDate.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to adjust the water plant tasks
|
|
||||||
* @param rainAmount Amount of rain from the last 7 days
|
|
||||||
* @throws IOException If the database cannot be accessed
|
|
||||||
* @throws HardinessZoneNotSetException If the hardiness zone is not available
|
|
||||||
* @throws PlantNotFoundException if the plant is not available for the watering task
|
|
||||||
*/
|
|
||||||
private void adjustWateringTask(int rainAmount) throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
|
|
||||||
|
|
||||||
for (Crop crop : cropList.getCrops()) {
|
|
||||||
Plant plant = plantList.getPlantById(HardinessZone.ZONE_8A,crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
|
|
||||||
|
|
||||||
if(plant.wateringCycle().litersPerSqM() < rainAmount){
|
|
||||||
adjustNextExecutionOfWateringTasks(taskList.getTaskList(LocalDate.now(), LocalDate.now().plusDays(7)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to set next execution date of the water plant tasks
|
|
||||||
* @param cropTaskList List with tasks from crops
|
|
||||||
*/
|
|
||||||
private void adjustNextExecutionOfWateringTasks(List<Task> cropTaskList){
|
|
||||||
for(Task task : cropTaskList){
|
|
||||||
if(task.getName().equals("water plant")){
|
|
||||||
task.setNextExecution(task.getNextExecution().plusDays(task.getInterval().orElse(1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.backgroundtasks.weather;
|
|
||||||
/**
|
|
||||||
* The WeatherService is a class to cause weather events for the WeatherGardenTaskPlanner
|
|
||||||
*/
|
|
||||||
public class WeatherService {
|
|
||||||
private static final int NO_RAIN = 0;
|
|
||||||
private static final int LITTLE_RAIN = 15;
|
|
||||||
private static final int RAIN = 25;
|
|
||||||
private static final int HEAVY_RAIN = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to simmulate a Weather Service for testing
|
|
||||||
* @param randomWeather random int. Range: 1-3
|
|
||||||
* @return the selected SevereWeather
|
|
||||||
*/
|
|
||||||
public SevereWeather causeSevereWeather(int randomWeather) {
|
|
||||||
return switch (randomWeather) {
|
|
||||||
case 1 -> SevereWeather.HAIL;
|
|
||||||
case 2 -> SevereWeather.SNOW;
|
|
||||||
case 3 -> SevereWeather.FROST;
|
|
||||||
default -> null;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to simulate a Weather Service for testing
|
|
||||||
* @param randomRainAmount random int. Range: 1-4
|
|
||||||
* @return the selected rain amount
|
|
||||||
*/
|
|
||||||
public int causeRainAmount(int randomRainAmount) {
|
|
||||||
return switch (randomRainAmount) {
|
|
||||||
case 1 -> NO_RAIN;
|
|
||||||
case 2 -> LITTLE_RAIN;
|
|
||||||
case 3 -> RAIN;
|
|
||||||
case 4 -> HEAVY_RAIN;
|
|
||||||
default -> -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.bootstrap;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotates a method to be executed after all dependencies annotated with {@link Inject}
|
|
||||||
* have been injected.
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface AfterInject { }
|
|
|
@ -1,167 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.bootstrap;
|
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.CropDetailController;
|
|
||||||
import ch.zhaw.gartenverwaltung.Main;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.*;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.Garden;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.GardenSchedule;
|
|
||||||
import ch.zhaw.gartenverwaltung.models.PlantListModel;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.DialogPane;
|
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class responsible for bootstrapping the application wide dependencies
|
|
||||||
* and injecting them into JavaFX Controllers.
|
|
||||||
*/
|
|
||||||
public class AppLoader {
|
|
||||||
private static final Logger LOG = Logger.getLogger(CropDetailController.class.getName());
|
|
||||||
/**
|
|
||||||
* Caching the panes
|
|
||||||
*/
|
|
||||||
private final Map<String, Pane> panes = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Application-wide dependencies
|
|
||||||
*/
|
|
||||||
private final Map<String, Object> dependencies = new HashMap<>();
|
|
||||||
|
|
||||||
public AppLoader() throws IOException {
|
|
||||||
PlantList plantList = new JsonPlantList();
|
|
||||||
CropList cropList = new JsonCropList();
|
|
||||||
TaskList taskList = new JsonTaskList();
|
|
||||||
GardenSchedule gardenSchedule = new GardenSchedule(taskList, plantList);
|
|
||||||
|
|
||||||
dependencies.put(PlantList.class.getSimpleName(), plantList);
|
|
||||||
dependencies.put(CropList.class.getSimpleName(), cropList);
|
|
||||||
dependencies.put(TaskList.class.getSimpleName(), taskList);
|
|
||||||
|
|
||||||
dependencies.put(PlantListModel.class.getSimpleName(), new PlantListModel(plantList));
|
|
||||||
|
|
||||||
dependencies.put(GardenSchedule.class.getSimpleName(), gardenSchedule);
|
|
||||||
dependencies.put(Garden.class.getSimpleName(), new Garden(gardenSchedule, cropList));
|
|
||||||
dependencies.put(AppLoader.class.getSimpleName(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads and returns a {@link Pane} (cached).
|
|
||||||
*
|
|
||||||
* @param fxmlFile The file name to be loaded
|
|
||||||
* @return The loaded Pane
|
|
||||||
* @throws IOException if the file could not be loaded
|
|
||||||
*/
|
|
||||||
public Pane loadPane(String fxmlFile) throws IOException {
|
|
||||||
Pane pane = panes.get(fxmlFile);
|
|
||||||
if (pane == null) {
|
|
||||||
loadAndCacheFxml(fxmlFile);
|
|
||||||
pane = panes.get(fxmlFile);
|
|
||||||
}
|
|
||||||
return pane;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given fxml-file from resources (no caching) and creates a new {@link Scene},
|
|
||||||
* which is then appended to the given {@link Stage}.
|
|
||||||
* Performs dependency-injection.
|
|
||||||
*
|
|
||||||
* @param fxmlFile The file name to be loaded
|
|
||||||
* @param appendee The {@link Stage} to which the new {@link Scene} is appended.
|
|
||||||
* @return The controller of the loaded scene.
|
|
||||||
* @throws IOException if the file could not be loaded
|
|
||||||
*/
|
|
||||||
public Object loadSceneToStage(String fxmlFile, Stage appendee) throws IOException {
|
|
||||||
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(Main.class.getResource(fxmlFile)));
|
|
||||||
Pane root = loader.load();
|
|
||||||
Scene scene = new Scene(root);
|
|
||||||
String css = Objects.requireNonNull(this.getClass().getResource("styles.css")).toExternalForm();
|
|
||||||
appendee.setScene(scene);
|
|
||||||
scene.getStylesheets().add(css);
|
|
||||||
Object controller = loader.getController();
|
|
||||||
annotationInject(controller);
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given fxml-file from resources (no caching) and appendeds it's
|
|
||||||
* contents to the given {@link DialogPane}.
|
|
||||||
* Performs dependency-injection.
|
|
||||||
*
|
|
||||||
* @param fxmlFile The file name to be loaded
|
|
||||||
* @param appendee The {@link DialogPane} to which the FXML contents are to be appended.
|
|
||||||
* @return The controller of the loaded scene.
|
|
||||||
* @throws IOException if the file could not be loaded
|
|
||||||
*/
|
|
||||||
public Object loadPaneToDialog(String fxmlFile, DialogPane appendee) throws IOException {
|
|
||||||
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(Main.class.getResource(fxmlFile)));
|
|
||||||
appendee.setContent(loader.load());
|
|
||||||
Object controller = loader.getController();
|
|
||||||
annotationInject(controller);
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given fxml-file from resources and caches the pane.
|
|
||||||
* Performs dependency-injection.
|
|
||||||
*
|
|
||||||
* @param fxmlFile The file name to be loaded
|
|
||||||
* @throws IOException if the file could not be loaded
|
|
||||||
*/
|
|
||||||
public void loadAndCacheFxml(String fxmlFile) throws IOException {
|
|
||||||
FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(Main.class.getResource(fxmlFile)));
|
|
||||||
Pane pane = loader.load();
|
|
||||||
panes.put(fxmlFile, pane);
|
|
||||||
annotationInject(loader.getController());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Injects the applications dependencies into the given object's fields annotated with {@link Inject}.
|
|
||||||
* Afterwards, all methods on the objects annotated with {@link AfterInject} are executed.
|
|
||||||
* (Success of the injections is not guaranteed!)
|
|
||||||
*
|
|
||||||
* @param controller The class containing the injectable fields
|
|
||||||
*/
|
|
||||||
public void annotationInject(Object controller) {
|
|
||||||
Arrays.stream(controller.getClass().getDeclaredFields())
|
|
||||||
.filter(field -> field.isAnnotationPresent(Inject.class))
|
|
||||||
.forEach(field -> {
|
|
||||||
field.setAccessible(true);
|
|
||||||
try {
|
|
||||||
field.set(controller, getAppDependency(field.getType()));
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
field.setAccessible(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
Arrays.stream(controller.getClass().getMethods())
|
|
||||||
.filter(method -> method.isAnnotationPresent(AfterInject.class) && method.getParameterCount() == 0)
|
|
||||||
.forEach(afterInjectMethod -> {
|
|
||||||
try {
|
|
||||||
afterInjectMethod.invoke(controller);
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
||||||
LOG.log(Level.SEVERE, "Could not invoke afterInjectMethod", e.getCause());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to get any AppDependency
|
|
||||||
* @param type Class of Dependency
|
|
||||||
* @return the App dependency
|
|
||||||
*/
|
|
||||||
public Object getAppDependency(Class<?> type) {
|
|
||||||
return dependencies.get(type.getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.bootstrap;
|
|
||||||
|
|
||||||
import javafx.event.Event;
|
|
||||||
import javafx.event.EventType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an event that should lead to a view being changed.
|
|
||||||
*/
|
|
||||||
public class ChangeViewEvent extends Event {
|
|
||||||
private final String view;
|
|
||||||
|
|
||||||
public static final EventType<ChangeViewEvent> CHANGE_MAIN_VIEW = new EventType<>("CHANGE_MAIN_VIEW");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an Event that should lead to the main view being changed.
|
|
||||||
*
|
|
||||||
* @param eventType The {@link EventType<ChangeViewEvent>} specifying which view should be changed.
|
|
||||||
* @param view The filename of the View to be changed to
|
|
||||||
*/
|
|
||||||
public ChangeViewEvent(EventType<? extends Event> eventType, String view) {
|
|
||||||
super(eventType);
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String view() {
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package ch.zhaw.gartenverwaltung.bootstrap;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Annotates a Field to be injected from the application-dependencies.
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
public @interface Inject { }
|
|
|
@ -1,41 +1,41 @@
|
||||||
package ch.zhaw.gartenverwaltung.models;
|
package ch.zhaw.gartenverwaltung.gardenplan;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.io.CropList;
|
import ch.zhaw.gartenverwaltung.io.GardenPlan;
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.JsonGardenPlan;
|
||||||
|
import ch.zhaw.gartenverwaltung.taskList.PlantNotFoundException;
|
||||||
|
import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
|
||||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
import javafx.beans.property.ListProperty;
|
|
||||||
import javafx.beans.property.SimpleListProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Gardenplan model manages the crops in the gardenplan.
|
* The Gardenplan model manages the crops in the gardenplan.
|
||||||
*/
|
*/
|
||||||
public class Garden {
|
public class Gardenplanmodel {
|
||||||
private final CropList cropList;
|
private GardenPlan gardenPlan;
|
||||||
private final ListProperty<Crop> plantedCrops = new SimpleListProperty<>(FXCollections.observableArrayList());
|
private List<Crop> cropList;
|
||||||
private final GardenSchedule gardenSchedule;
|
private TaskListModel taskListModel;
|
||||||
|
private Object IllegalArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of Gardenplan model
|
* Constructor of Gardenplan model
|
||||||
*
|
*
|
||||||
* @param gardenSchedule holds a reference to the task list object.
|
* @param taskListModel holds a reference to the task list object.
|
||||||
*/
|
*/
|
||||||
public Garden(GardenSchedule gardenSchedule, CropList cropList) throws IOException {
|
public Gardenplanmodel(TaskListModel taskListModel) throws IOException {
|
||||||
this.gardenSchedule = gardenSchedule;
|
this.taskListModel = taskListModel;
|
||||||
this.cropList = cropList;
|
gardenPlan = new JsonGardenPlan();
|
||||||
plantedCrops.addAll(cropList.getCrops());
|
cropList = new ArrayList<>();
|
||||||
}
|
cropList = gardenPlan.getCrops();
|
||||||
|
|
||||||
public ListProperty<Crop> getPlantedCrops() {
|
|
||||||
return plantedCrops;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,10 +50,11 @@ public class Garden {
|
||||||
*/
|
*/
|
||||||
public void plantAsCrop(Plant plant, LocalDate plantingDate) throws IOException, HardinessZoneNotSetException, PlantNotFoundException {
|
public void plantAsCrop(Plant plant, LocalDate plantingDate) throws IOException, HardinessZoneNotSetException, PlantNotFoundException {
|
||||||
Crop crop = new Crop(plant.id(), plantingDate);
|
Crop crop = new Crop(plant.id(), plantingDate);
|
||||||
cropList.saveCrop(crop);
|
//TODO Add Area to Plant
|
||||||
gardenSchedule.planTasksForCrop(crop);
|
//crop.withArea(0);
|
||||||
plantedCrops.clear();
|
gardenPlan.saveCrop(crop);
|
||||||
plantedCrops.addAll(cropList.getCrops());
|
taskListModel.planTasksForCrop(crop);
|
||||||
|
cropList = gardenPlan.getCrops();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,31 +64,20 @@ public class Garden {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void removeCrop(Crop crop) throws IOException {
|
public void removeCrop(Crop crop) throws IOException {
|
||||||
cropList.removeCrop(crop);
|
gardenPlan.removeCrop(crop);
|
||||||
gardenSchedule.removeTasksForCrop(crop.getCropId().orElseThrow(IllegalArgumentException::new));
|
taskListModel.removeTasksForCrop(crop.getCropId().orElseThrow(IllegalArgumentException::new));
|
||||||
plantedCrops.clear();
|
cropList = gardenPlan.getCrops();
|
||||||
plantedCrops.addAll(cropList.getCrops());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the {@link Crop} from the file and the cache
|
|
||||||
*
|
|
||||||
* @param crop The crop which is being updated
|
|
||||||
* @throws IOException If the database cannot be accessed
|
|
||||||
*/
|
|
||||||
public void updateCrop(Crop crop) throws IOException {
|
|
||||||
cropList.saveCrop(crop);
|
|
||||||
plantedCrops.clear();
|
|
||||||
plantedCrops.addAll(cropList.getCrops());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of {@link Crop}s which are currently in the gardenplan.
|
* Returns a list of {@link Crop}s which are currently in the gardenplan.
|
||||||
*
|
*
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<Crop> getCrops() throws IOException {
|
public List<Crop> getCrops() throws IOException {
|
||||||
return cropList.getCrops();
|
if(!cropList.isEmpty()){
|
||||||
|
cropList = gardenPlan.getCrops();
|
||||||
|
}
|
||||||
|
return cropList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,6 +87,6 @@ public class Garden {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public Optional<Crop> getCrop(Long cropId) throws IOException {
|
public Optional<Crop> getCrop(Long cropId) throws IOException {
|
||||||
return cropList.getCropById(cropId);
|
return gardenPlan.getCropById(cropId);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,11 +6,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
public interface GardenPlan {
|
||||||
* Represents a List of {@link Crop}s.
|
|
||||||
* The interface specifies the operations to add/update and remove entries.
|
|
||||||
*/
|
|
||||||
public interface CropList {
|
|
||||||
/**
|
/**
|
||||||
* Yields a list of all {@link Crop}s in the database.
|
* Yields a list of all {@link Crop}s in the database.
|
||||||
*
|
*
|
|
@ -1,8 +1,5 @@
|
||||||
package ch.zhaw.gartenverwaltung.io;
|
package ch.zhaw.gartenverwaltung.io;
|
||||||
|
|
||||||
/**
|
|
||||||
* Exceptionm which is thrown if Hardiness zone is not set in plant list.
|
|
||||||
*/
|
|
||||||
public class HardinessZoneNotSetException extends Exception {
|
public class HardinessZoneNotSetException extends Exception {
|
||||||
public HardinessZoneNotSetException() {
|
public HardinessZoneNotSetException() {
|
||||||
super("HardinessZone must be set to retrieve plants!");
|
super("HardinessZone must be set to retrieve plants!");
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
package ch.zhaw.gartenverwaltung.io;
|
package ch.zhaw.gartenverwaltung.io;
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides an sequential ID starting from the given initial Value.
|
|
||||||
*/
|
|
||||||
public class IdProvider {
|
public class IdProvider {
|
||||||
private long currentId;
|
private long currentId;
|
||||||
public IdProvider(long initialValue) {
|
public IdProvider(long initialValue) {
|
||||||
currentId = initialValue;
|
currentId = initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Yields the next ID in the sequence.
|
|
||||||
* @return The next ID
|
|
||||||
*/
|
|
||||||
public long incrementAndGet() {
|
public long incrementAndGet() {
|
||||||
return ++currentId;
|
return ++currentId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,6 @@ package ch.zhaw.gartenverwaltung.io;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Excption which is thrown if a JSON file has a invalid File format.
|
|
||||||
*/
|
|
||||||
class InvalidJsonException extends IOException {
|
class InvalidJsonException extends IOException {
|
||||||
public InvalidJsonException(String reason) {
|
public InvalidJsonException(String reason) {
|
||||||
super(reason);
|
super(reason);
|
||||||
|
|
|
@ -19,12 +19,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
public class JsonGardenPlan implements GardenPlan {
|
||||||
* Implements the {@link CropList} interface for reading and writing {@link Crop} objects
|
|
||||||
* from and to a local JSON file.
|
|
||||||
* The reads are cached to minimize file-io operations.
|
|
||||||
*/
|
|
||||||
public class JsonCropList implements CropList {
|
|
||||||
private final URL dataSource;
|
private final URL dataSource;
|
||||||
|
|
||||||
private IdProvider idProvider;
|
private IdProvider idProvider;
|
||||||
|
@ -45,9 +40,9 @@ public class JsonCropList implements CropList {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. Uses a file from the app resources.
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
public JsonCropList() {
|
public JsonGardenPlan() {
|
||||||
this.dataSource = getClass().getResource("user-crops.json");
|
this.dataSource = getClass().getResource("user-crops.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +50,9 @@ public class JsonCropList implements CropList {
|
||||||
* Constructor to use a specified {@link URL} as a {@link #dataSource}
|
* Constructor to use a specified {@link URL} as a {@link #dataSource}
|
||||||
* @param dataSource A {@link URL} to the file to be used as a data source
|
* @param dataSource A {@link URL} to the file to be used as a data source
|
||||||
*/
|
*/
|
||||||
public JsonCropList(URL dataSource) {
|
public JsonGardenPlan(URL dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
|
@ -20,12 +20,12 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the {@link PlantList} interface for reading {@link Plant} objects
|
* Implements the {@link PlantDatabase} interface for loading {@link Plant} objects
|
||||||
* from a local JSON file.
|
* from a JSON file.
|
||||||
* The reads are cached to minimize file-io operations.
|
* The reads are cached to minimize file-io operations.
|
||||||
*/
|
*/
|
||||||
public class JsonPlantList implements PlantList {
|
public class JsonPlantDatabase implements PlantDatabase {
|
||||||
private final URL dataSource;
|
private final URL dataSource = getClass().getResource("plantdb.json");
|
||||||
|
|
||||||
private HardinessZone currentZone;
|
private HardinessZone currentZone;
|
||||||
private Map<Long, Plant> plantMap = Collections.emptyMap();
|
private Map<Long, Plant> plantMap = Collections.emptyMap();
|
||||||
|
@ -44,27 +44,12 @@ public class JsonPlantList implements PlantList {
|
||||||
imageModule.addDeserializer(Image.class, new PlantImageDeserializer());
|
imageModule.addDeserializer(Image.class, new PlantImageDeserializer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor. Uses a file from the app resources.
|
|
||||||
*/
|
|
||||||
public JsonPlantList() {
|
|
||||||
this.dataSource = getClass().getResource("plantdb.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor to use a specified {@link URL} as a {@link #dataSource}
|
|
||||||
* @param dataSource A {@link URL} to the file to be used as a data source
|
|
||||||
*/
|
|
||||||
public JsonPlantList(URL dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no data is currently loaded, or the specified zone differs
|
* If no data is currently loaded, or the specified zone differs
|
||||||
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
|
* from the {@link #currentZone}, data is loaded from {@link #dataSource}.
|
||||||
* In any case, the values of {@link #plantMap} are returned.
|
* In any case, the values of {@link #plantMap} are returned.
|
||||||
*
|
*
|
||||||
* @see PlantList#getPlantList(HardinessZone)
|
* @see PlantDatabase#getPlantList(HardinessZone)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Plant> getPlantList(HardinessZone zone) throws IOException, HardinessZoneNotSetException {
|
public List<Plant> getPlantList(HardinessZone zone) throws IOException, HardinessZoneNotSetException {
|
||||||
|
@ -75,7 +60,7 @@ public class JsonPlantList implements PlantList {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PlantList#getPlantById(HardinessZone, long)
|
* @see PlantDatabase#getPlantById(long)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Optional<Plant> getPlantById(HardinessZone zone, long id) throws HardinessZoneNotSetException, IOException {
|
public Optional<Plant> getPlantById(HardinessZone zone, long id) throws HardinessZoneNotSetException, IOException {
|
|
@ -1,5 +1,6 @@
|
||||||
package ch.zhaw.gartenverwaltung.io;
|
package ch.zhaw.gartenverwaltung.io;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||||
|
@ -13,24 +14,22 @@ import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the {@link TaskList} interface for reading and writing {@link Task} objects
|
* Implements the {@link TaskDatabase} interface for loading and writing {@link Task} objects
|
||||||
* from and to a local JSON file.
|
* from and to a JSON file.
|
||||||
* The reads are cached to minimize file-io operations.
|
* The reads are cached to minimize file-io operations.
|
||||||
*/
|
*/
|
||||||
public class JsonTaskList implements TaskList {
|
public class JsonTaskDatabase implements TaskDatabase{
|
||||||
IdProvider idProvider;
|
IdProvider idProvider;
|
||||||
private final URL dataSource;
|
private final URL dataSource = getClass().getResource("taskdb.json");
|
||||||
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
|
private final static String INVALID_DATASOURCE_MSG = "Invalid datasource specified!";
|
||||||
|
|
||||||
private Map<Long, Task> taskMap = Collections.emptyMap();
|
private Map<Long, Task> taskMap = Collections.emptyMap();
|
||||||
private final List<TaskListObserver> subscribers = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creating constant objects required to deserialize the {@link LocalDate} classes
|
* Creating constant objects required to deserialize the {@link LocalDate} classes
|
||||||
|
@ -45,33 +44,18 @@ public class JsonTaskList implements TaskList {
|
||||||
timeModule.addSerializer(LocalDate.class, dateSerializer);
|
timeModule.addSerializer(LocalDate.class, dateSerializer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor. Uses a file from the app resources.
|
|
||||||
*/
|
|
||||||
public JsonTaskList() {
|
|
||||||
this.dataSource = getClass().getResource("taskdb.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor to use a specified {@link URL} as a {@link #dataSource}
|
|
||||||
* @param dataSource A {@link URL} to the file to be used as a data source
|
|
||||||
*/
|
|
||||||
public JsonTaskList(URL dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no data is currently loaded, data is loaded from {@link #dataSource}.
|
* If no data is currently loaded, data is loaded from {@link #dataSource}.
|
||||||
* In any case, the values of {@link #taskMap} are returned.
|
* In any case, the values of {@link #taskMap} are returned.
|
||||||
*
|
*
|
||||||
* @see TaskList#getTaskList(LocalDate, LocalDate)
|
* @see TaskDatabase#getTaskList(LocalDate, LocalDate)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException{
|
public List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException{
|
||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
return taskMap.values().stream().filter(task -> task.isInTimePeriod(start, end)).toList();
|
return taskMap.values().stream().filter(task -> task.isInTimePeriode(start, end)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,7 +64,7 @@ public class JsonTaskList implements TaskList {
|
||||||
* @return List of Tasks for given Crop
|
* @return List of Tasks for given Crop
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<Task> getTaskForCrop(long cropId) throws IOException {
|
public List<Task> getTaskForCrop(long cropId) throws IOException {
|
||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
|
@ -96,9 +80,7 @@ public class JsonTaskList implements TaskList {
|
||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
taskMap.entrySet().removeIf(entry -> entry.getValue().getCropId() == cropId);
|
taskMap.values().removeIf(task -> task.getCropId() == cropId);
|
||||||
writeTaskListToFile();
|
|
||||||
notifySubscribers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,18 +90,17 @@ public class JsonTaskList implements TaskList {
|
||||||
* it to the {@link #taskMap}. In any case, the {@link #taskMap} is written
|
* it to the {@link #taskMap}. In any case, the {@link #taskMap} is written
|
||||||
* to the {@link #dataSource}.
|
* to the {@link #dataSource}.
|
||||||
*
|
*
|
||||||
* @see TaskList#saveTask(Task)
|
* @see TaskDatabase#saveTask(Task)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void saveTask(Task task) throws IOException {
|
public void saveTask(Task task) throws IOException {
|
||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
long id = task.getId().orElse(idProvider.incrementAndGet());
|
if(task.getId() == 0) {
|
||||||
|
task.withId(idProvider.incrementAndGet());
|
||||||
taskMap.put(id, task.withId(id));
|
}
|
||||||
writeTaskListToFile();
|
writeTaskListToFile();
|
||||||
notifySubscribers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,37 +108,17 @@ public class JsonTaskList implements TaskList {
|
||||||
* If the {@link Task}s id is found in the {@link #taskMap}, the Task is removed
|
* If the {@link Task}s id is found in the {@link #taskMap}, the Task is removed
|
||||||
* from the {@link #taskMap}. Then the Task are written to the {@link #dataSource}.
|
* from the {@link #taskMap}. Then the Task are written to the {@link #dataSource}.
|
||||||
*
|
*
|
||||||
* @see TaskList#removeTask(Task)
|
* @see TaskDatabase#removeTask(Task)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeTask(Task task) throws IOException {
|
public void removeTask(Task task) throws IOException {
|
||||||
if(taskMap.isEmpty()) {
|
if(taskMap.isEmpty()) {
|
||||||
loadTaskListFromFile();
|
loadTaskListFromFile();
|
||||||
}
|
}
|
||||||
Long taskId = task.getId().orElseThrow(IOException::new);
|
if(taskMap.containsKey(task.getId())){
|
||||||
if(taskMap.containsKey(taskId)){
|
taskMap.remove(task.getId());
|
||||||
taskMap.remove(taskId);
|
|
||||||
writeTaskListToFile();
|
writeTaskListToFile();
|
||||||
}
|
}
|
||||||
notifySubscribers();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
* @param observer The change handler
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void subscribe(TaskListObserver observer) {
|
|
||||||
subscribers.add(observer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the change handler method on all registered observers.
|
|
||||||
*/
|
|
||||||
private void notifySubscribers() throws IOException {
|
|
||||||
for (TaskListObserver subscriber : subscribers) {
|
|
||||||
subscriber.onChange(taskMap.values().stream().toList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,7 +156,7 @@ public class JsonTaskList implements TaskList {
|
||||||
|
|
||||||
taskMap = result.stream()
|
taskMap = result.stream()
|
||||||
.collect(HashMap::new,
|
.collect(HashMap::new,
|
||||||
(res, task) -> res.put(task.getId().orElse(0L), task),
|
(res, task) -> res.put(task.getId(), task),
|
||||||
(existing, replacement) -> {});
|
(existing, replacement) -> {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A List of {@link Plant}s.
|
* A database of {@link Plant}s.
|
||||||
* The interface specifies the minimal required operations.
|
* The interface specifies the minimal required operations.
|
||||||
*/
|
*/
|
||||||
public interface PlantList {
|
public interface PlantDatabase {
|
||||||
/**
|
/**
|
||||||
* Yields a list of all {@link Plant}s in the database with only data relevant to the specfied {@link HardinessZone}
|
* Yields a list of all {@link Plant}s in the database with only data relevant to the specfied {@link HardinessZone}
|
||||||
*
|
*
|
|
@ -1,16 +1,20 @@
|
||||||
package ch.zhaw.gartenverwaltung.io;
|
package ch.zhaw.gartenverwaltung.io;
|
||||||
|
|
||||||
|
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||||
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||||
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
import ch.zhaw.gartenverwaltung.types.Task;
|
import ch.zhaw.gartenverwaltung.types.Task;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a List of {@link Task}s.
|
* A database of {@link Task}s.
|
||||||
* The interface specifies the operations to add/update and remove entries.
|
* The interface specifies the minimal required operations.
|
||||||
*/
|
*/
|
||||||
public interface TaskList {
|
public interface TaskDatabase {
|
||||||
/**
|
/**
|
||||||
* Yields a list of all {@link Task}s in the database with the start and end date of a period of time.
|
* Yields a list of all {@link Task}s in the database with the start and end date of a period of time.
|
||||||
*
|
*
|
||||||
|
@ -51,22 +55,4 @@ public interface TaskList {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
void removeTask(Task task) throws IOException;
|
void removeTask(Task task) throws IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an observer to be notified of Changes in the TaskList
|
|
||||||
* @param observer The change handler
|
|
||||||
*/
|
|
||||||
void subscribe(TaskListObserver observer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies an observer for a TaskList
|
|
||||||
*/
|
|
||||||
@FunctionalInterface
|
|
||||||
interface TaskListObserver {
|
|
||||||
/**
|
|
||||||
* Method which will be called when changes occur.
|
|
||||||
* @param newTaskList The new values
|
|
||||||
*/
|
|
||||||
void onChange(List<Task> newTaskList) throws IOException;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -7,9 +7,6 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by the Jackson Library to deserialize a String to a {@link GrowthPhaseType}
|
|
||||||
*/
|
|
||||||
public class GrowthPhaseTypeDeserializer extends StdDeserializer<GrowthPhaseType> {
|
public class GrowthPhaseTypeDeserializer extends StdDeserializer<GrowthPhaseType> {
|
||||||
public GrowthPhaseTypeDeserializer(Class<?> vc) {
|
public GrowthPhaseTypeDeserializer(Class<?> vc) {
|
||||||
super(vc);
|
super(vc);
|
||||||
|
|
|
@ -7,9 +7,6 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by the Jackson Library to deserialize a String to a {@link HardinessZone}
|
|
||||||
*/
|
|
||||||
public class HardinessZoneDeserializer extends StdDeserializer<HardinessZone> {
|
public class HardinessZoneDeserializer extends StdDeserializer<HardinessZone> {
|
||||||
public HardinessZoneDeserializer(Class<?> vc) {
|
public HardinessZoneDeserializer(Class<?> vc) {
|
||||||
super(vc);
|
super(vc);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package ch.zhaw.gartenverwaltung.json;
|
package ch.zhaw.gartenverwaltung.json;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
import ch.zhaw.gartenverwaltung.io.PlantDatabase;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
@ -13,17 +13,18 @@ import java.io.InputStream;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by the Jackson Library to deserialize a String to a {@link Image}
|
|
||||||
*/
|
|
||||||
public class PlantImageDeserializer extends JsonDeserializer<Image> {
|
public class PlantImageDeserializer extends JsonDeserializer<Image> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
public Image deserialize(JsonParser parser, DeserializationContext context) throws IOException {
|
||||||
Image result = null;
|
Image result = null;
|
||||||
InputStream is = PlantList.class.getResourceAsStream(String.format("images/%s", parser.getText()));
|
URL imageUrl = PlantDatabase.class.getResource(String.format("images/%s", parser.getText()));
|
||||||
if (is != null) {
|
if (imageUrl != null) {
|
||||||
result = new Image(is);
|
try (InputStream is = new FileInputStream(new File(imageUrl.toURI()))) {
|
||||||
|
result = new Image(is);
|
||||||
|
} catch (IllegalArgumentException | URISyntaxException e) {
|
||||||
|
throw new IOException(String.format("Cannot find Image \"%s\"\n", imageUrl.getFile()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package ch.zhaw.gartenverwaltung.models;
|
package ch.zhaw.gartenverwaltung.plantList;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.Settings;
|
|
||||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||||
import ch.zhaw.gartenverwaltung.io.PlantList;
|
import ch.zhaw.gartenverwaltung.io.JsonPlantDatabase;
|
||||||
|
import ch.zhaw.gartenverwaltung.io.PlantDatabase;
|
||||||
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
|
import ch.zhaw.gartenverwaltung.types.GrowthPhaseType;
|
||||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||||
|
@ -16,7 +16,8 @@ import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PlantListModel {
|
public class PlantListModel {
|
||||||
private final PlantList plantList;
|
private PlantDatabase plantDatabase;
|
||||||
|
private HardinessZone currentZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparators to create sorted Plant List
|
* Comparators to create sorted Plant List
|
||||||
|
@ -27,21 +28,26 @@ public class PlantListModel {
|
||||||
/**
|
/**
|
||||||
* Constructor to create Database Object.
|
* Constructor to create Database Object.
|
||||||
*/
|
*/
|
||||||
public PlantListModel(PlantList plantList) {
|
public PlantListModel() {
|
||||||
this.plantList = plantList;
|
plantDatabase = new JsonPlantDatabase();
|
||||||
|
setDefaultZone();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlantListModel(PlantDatabase plantDatabase) {
|
||||||
|
this.plantDatabase = plantDatabase;
|
||||||
setDefaultZone();
|
setDefaultZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultZone() {
|
private void setDefaultZone() {
|
||||||
Settings.getInstance().setCurrentHardinessZone(null);
|
currentZone = HardinessZone.ZONE_8A; // TODO: get Default Zone from Config
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentZone(HardinessZone currentZone) {
|
public void setCurrentZone(HardinessZone currentZone) {
|
||||||
Settings.getInstance().setCurrentHardinessZone(currentZone);
|
this.currentZone = currentZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HardinessZone getCurrentZone() {
|
public HardinessZone getCurrentZone() {
|
||||||
return Settings.getInstance().getCurrentHardinessZone();
|
return currentZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +72,7 @@ public class PlantListModel {
|
||||||
*/
|
*/
|
||||||
public List<Plant> getSortedPlantList(HardinessZone zone, Comparator<Plant> comparator) throws HardinessZoneNotSetException, IOException {
|
public List<Plant> getSortedPlantList(HardinessZone zone, Comparator<Plant> comparator) throws HardinessZoneNotSetException, IOException {
|
||||||
setCurrentZone(zone);
|
setCurrentZone(zone);
|
||||||
return plantList.getPlantList(zone).stream().sorted(comparator).collect(Collectors.toList());
|
return plantDatabase.getPlantList(zone).stream().sorted(comparator).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +101,7 @@ public class PlantListModel {
|
||||||
public List<Plant> getFilteredPlantListById(HardinessZone zone, Long id) throws HardinessZoneNotSetException, IOException {
|
public List<Plant> getFilteredPlantListById(HardinessZone zone, Long id) throws HardinessZoneNotSetException, IOException {
|
||||||
setCurrentZone(zone);
|
setCurrentZone(zone);
|
||||||
List<Plant> plantList = new ArrayList<>();
|
List<Plant> plantList = new ArrayList<>();
|
||||||
this.plantList.getPlantById(zone, id).ifPresent(plantList::add);
|
plantDatabase.getPlantById(zone, id).ifPresent(plantList::add);
|
||||||
return plantList;
|
return plantList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package ch.zhaw.gartenverwaltung.models;
|
package ch.zhaw.gartenverwaltung.taskList;
|
||||||
|
|
||||||
/**
|
|
||||||
* Exception which is thrown if there is no plant in plant Database with the given id.
|
|
||||||
*/
|
|
||||||
public class PlantNotFoundException extends Exception {
|
public class PlantNotFoundException extends Exception {
|
||||||
public PlantNotFoundException() {
|
public PlantNotFoundException() {
|
||||||
super("The selected Plant was not found in Database!");
|
super("The selected Plant was not found in Database!");
|
|
@ -1,49 +1,37 @@
|
||||||
package ch.zhaw.gartenverwaltung.models;
|
package ch.zhaw.gartenverwaltung.taskList;
|
||||||
|
|
||||||
import ch.zhaw.gartenverwaltung.Settings;
|
import ch.zhaw.gartenverwaltung.Config;
|
||||||
import ch.zhaw.gartenverwaltung.io.*;
|
import ch.zhaw.gartenverwaltung.io.*;
|
||||||
import ch.zhaw.gartenverwaltung.types.*;
|
import ch.zhaw.gartenverwaltung.types.*;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.beans.property.ListProperty;
|
|
||||||
import javafx.beans.property.SimpleListProperty;
|
|
||||||
import javafx.collections.FXCollections;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class GardenSchedule {
|
public class TaskListModel {
|
||||||
private final TaskList taskList;
|
private TaskDatabase taskDatabase;
|
||||||
private final PlantList plantList;
|
private PlantDatabase plantDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparators to create sorted Task List
|
* Comparators to create sorted Task List
|
||||||
*/
|
*/
|
||||||
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
|
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
|
||||||
static final Comparator<Task> sortByNextExecution = Comparator.comparing(Task::getNextExecution);
|
|
||||||
private final ListProperty<List<Task>> weeklyTaskListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
|
public TaskListModel(){
|
||||||
|
taskDatabase = new JsonTaskDatabase();
|
||||||
|
plantDatabase = new JsonPlantDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to create Database Objects.
|
* Constructor to create Database Objects.
|
||||||
*/
|
*/
|
||||||
public GardenSchedule(TaskList taskList, PlantList plantList) throws IOException {
|
public TaskListModel(TaskDatabase taskDatabase, PlantDatabase plantDatabase) {
|
||||||
this.taskList = taskList;
|
this.taskDatabase = taskDatabase;
|
||||||
this.plantList = plantList;
|
this.plantDatabase = plantDatabase;
|
||||||
}
|
|
||||||
|
|
||||||
public ListProperty<List<Task>> getWeeklyTaskListProperty() {
|
|
||||||
return weeklyTaskListProperty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* subscribe task list observer to get notifications
|
|
||||||
* @param observer the task list which will be ovserved
|
|
||||||
*/
|
|
||||||
public void setTaskListObserver(TaskList.TaskListObserver observer) {
|
|
||||||
taskList.subscribe(observer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +40,7 @@ public class GardenSchedule {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void addTask(Task task) throws IOException {
|
public void addTask(Task task) throws IOException {
|
||||||
taskList.saveTask(task);
|
taskDatabase.saveTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,13 +51,8 @@ public class GardenSchedule {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException {
|
public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException {
|
||||||
Plant plant = plantList.getPlantById(Settings.getInstance().getCurrentHardinessZone(), crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
|
Plant plant = plantDatabase.getPlantById(Config.getCurrentHardinessZone(), crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
|
||||||
int growPhaseGroup = plant.getGrowphaseGroupForDate(crop.getStartDate());
|
for (GrowthPhase growthPhase : plant.lifecycle()) {
|
||||||
addTask(new Task("watering Task", "pour water over the plant circa : "+ plant.wateringCycle().litersPerSqM() +" per square meter",
|
|
||||||
crop.getStartDate(), crop.getStartDate().plusDays(plant.timeToHarvest(0)),
|
|
||||||
plant.wateringCycle().interval(), crop.getCropId().orElse(0L)));
|
|
||||||
|
|
||||||
for (GrowthPhase growthPhase : plant.lifecycleForGroup(growPhaseGroup)) {
|
|
||||||
for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) {
|
for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) {
|
||||||
addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L)));
|
addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L)));
|
||||||
}
|
}
|
||||||
|
@ -82,7 +65,7 @@ public class GardenSchedule {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void removeTasksForCrop(long cropId) throws IOException {
|
public void removeTasksForCrop(long cropId) throws IOException {
|
||||||
taskList.removeTasksForCrop(cropId);
|
taskDatabase.removeTasksForCrop(cropId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +74,7 @@ public class GardenSchedule {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void removeTask(Task task) throws IOException {
|
public void removeTask(Task task) throws IOException {
|
||||||
taskList.removeTask(task);
|
taskDatabase.removeTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Task> filterListByCrop(List<Task> taskList, Long cropId) {
|
private List<Task> filterListByCrop(List<Task> taskList, Long cropId) {
|
||||||
|
@ -158,40 +141,26 @@ public class GardenSchedule {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<List<Task>> getTasksUpcomingWeek() throws IOException {
|
public List<List<Task>> getTasksUpcomingWeek() throws IOException {
|
||||||
final int listLength = 7;
|
|
||||||
List<Task> weekTasks = taskList.getTaskList(LocalDate.now(), LocalDate.now().plusDays(listLength - 1));
|
|
||||||
List<List<Task>> dayTaskList = new ArrayList<>();
|
List<List<Task>> dayTaskList = new ArrayList<>();
|
||||||
for(int i = 0; i < listLength; i++) {
|
for(int i = 0; i < 7; i++) {
|
||||||
LocalDate date = LocalDate.now().plusDays(i);
|
LocalDate date = LocalDate.now().plusDays(i);
|
||||||
dayTaskList.add(new ArrayList<>());
|
dayTaskList.add(taskDatabase.getTaskList(date, date));
|
||||||
final int finalI = i;
|
|
||||||
weekTasks.forEach(task -> {
|
|
||||||
if(task.getNextExecution() != null) {
|
|
||||||
LocalDate checkDate = task.getNextExecution();
|
|
||||||
do {
|
|
||||||
if (date.equals(task.getNextExecution()) || (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN)))) {
|
|
||||||
dayTaskList.get(finalI).add(task);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
checkDate = checkDate.plusDays(task.getInterval().orElse(0));
|
|
||||||
} while (!(task.getInterval().orElse(0) == 0) && checkDate.isBefore(LocalDate.now().plusDays(listLength)));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
weeklyTaskListProperty.clear();
|
|
||||||
weeklyTaskListProperty.addAll(dayTaskList);
|
|
||||||
return dayTaskList;
|
return dayTaskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to get an List of 7 Tasklists for the next 7 days. (Filtered Index 0 is Tasklist for Today.
|
* Method to get an List of 7 Tasklists for the next 7 days. (Filtered Index 0 is Tasklist for Today.
|
||||||
|
* @return List with length 7 (List<List<Task>>)
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void getTasksUpcomingWeekForCrop(Long cropId) throws IOException {
|
public List<List<Task>> getTasksUpcomingWeekForCrop(Long cropId) throws IOException {
|
||||||
List<List<Task>> dayTaskList = getTasksUpcomingWeek();
|
List<List<Task>> dayTaskList = new ArrayList<>();
|
||||||
dayTaskList.forEach(taskList -> taskList.removeIf(task -> task.getCropId() != cropId));
|
for(int i = 0; i < 7; i++) {
|
||||||
weeklyTaskListProperty.clear();
|
LocalDate date = LocalDate.now().plusDays(i);
|
||||||
weeklyTaskListProperty.addAll(dayTaskList);
|
dayTaskList.add(filterListByCrop(taskDatabase.getTaskList(date, date), cropId));
|
||||||
|
}
|
||||||
|
return dayTaskList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +171,7 @@ public class GardenSchedule {
|
||||||
* @throws IOException If the database cannot be accessed
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public List<Task> getFilteredTaskList(LocalDate start, LocalDate end) throws IOException {
|
public List<Task> getFilteredTaskList(LocalDate start, LocalDate end) throws IOException {
|
||||||
return getSortedTaskList(taskList.getTaskList(start, end), sortByNextExecution);
|
return getSortedTaskList(taskDatabase.getTaskList(start, end), sortByStartDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,6 +181,6 @@ public class GardenSchedule {
|
||||||
* @return a sorted coppy of the given Tasklist
|
* @return a sorted coppy of the given Tasklist
|
||||||
*/
|
*/
|
||||||
private List<Task> getSortedTaskList(List<Task> taskList, Comparator<Task> comparator) {
|
private List<Task> getSortedTaskList(List<Task> taskList, Comparator<Task> comparator) {
|
||||||
return taskList.stream().filter(task -> task.getNextExecution() != null).sorted(comparator).collect(Collectors.toList());
|
return taskList.stream().sorted(comparator).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,9 +4,6 @@ import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a crop, meaning a specific plant growing at a specific time.
|
|
||||||
*/
|
|
||||||
public class Crop {
|
public class Crop {
|
||||||
private Long cropId = null;
|
private Long cropId = null;
|
||||||
private final long plantId;
|
private final long plantId;
|
||||||
|
@ -40,6 +37,7 @@ public class Crop {
|
||||||
public Optional<Long> getCropId() {
|
public Optional<Long> getCropId() {
|
||||||
return Optional.ofNullable(cropId);
|
return Optional.ofNullable(cropId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getPlantId() { return plantId; }
|
public long getPlantId() { return plantId; }
|
||||||
public LocalDate getStartDate() { return startDate; }
|
public LocalDate getStartDate() { return startDate; }
|
||||||
public double getArea() { return area; }
|
public double getArea() { return area; }
|
||||||
|
|
|
@ -7,23 +7,12 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import java.time.MonthDay;
|
import java.time.MonthDay;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a growth phase of a plant.
|
|
||||||
* Plants go through several phases during their life (sowing, germinating, growing, ..., harvest).
|
|
||||||
* These phases are characterized by what kinds of tasks need to be executed by the gardener to stay alive.
|
|
||||||
* This class represents one such phase.
|
|
||||||
*
|
|
||||||
* @param startDate The earliest date on which this phase can start
|
|
||||||
* @param endDate The latest date on which this phase can start
|
|
||||||
* @param group Which group this phase belongs to (if the growth phase can occur multiple times a year, default: 0)
|
|
||||||
* @param type What {@link GrowthPhaseType} this represents
|
|
||||||
* @param zone The hardiness zone for which this growth phase is valid
|
|
||||||
* @param taskTemplates The (undated) tasks required to be performed by the gardener
|
|
||||||
*/
|
|
||||||
public record GrowthPhase(
|
public record GrowthPhase(
|
||||||
MonthDay startDate,
|
MonthDay startDate,
|
||||||
MonthDay endDate,
|
MonthDay endDate,
|
||||||
int group,
|
int group,
|
||||||
|
WateringCycle wateringCycle,
|
||||||
@JsonDeserialize(using = GrowthPhaseTypeDeserializer.class) GrowthPhaseType type,
|
@JsonDeserialize(using = GrowthPhaseTypeDeserializer.class) GrowthPhaseType type,
|
||||||
@JsonDeserialize(using = HardinessZoneDeserializer.class) HardinessZone zone,
|
@JsonDeserialize(using = HardinessZoneDeserializer.class) HardinessZone zone,
|
||||||
List<TaskTemplate> taskTemplates) {
|
List<TaskTemplate> taskTemplates) {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package ch.zhaw.gartenverwaltung.types;
|
package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
/**
|
|
||||||
* Enumerates the different possible types of {@link GrowthPhase}.
|
|
||||||
* (Subject to later expansion)
|
|
||||||
*/
|
|
||||||
public enum GrowthPhaseType {
|
public enum GrowthPhaseType {
|
||||||
SOW, PLANT, REPLANT, HARVEST
|
SOW, PLANT, REPLANT, HARVEST
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
package ch.zhaw.gartenverwaltung.types;
|
package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a pest or pathogen which may afflict a plant.
|
|
||||||
*
|
|
||||||
* @param name The name of the pest
|
|
||||||
* @param description A description of the pest
|
|
||||||
* @param measures Measures that can be taken against the pest.
|
|
||||||
*/
|
|
||||||
public record Pest(String name, String description, String measures) {
|
public record Pest(String name, String description, String measures) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,12 @@ package ch.zhaw.gartenverwaltung.types;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.MonthDay;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.time.temporal.ChronoUnit.DAYS;
|
import static java.time.temporal.ChronoUnit.DAYS;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a plant
|
|
||||||
*
|
|
||||||
* @param id A unique identifier
|
|
||||||
* @param name The name of the plant
|
|
||||||
* @param description A description of the plant
|
|
||||||
* @param image An image representing the plant
|
|
||||||
* @param spacing The amount of space needed between individual plants of this type
|
|
||||||
* @param light The amount of light preferred by the plant (h/d)
|
|
||||||
* @param soil The type of soil required for the plant
|
|
||||||
* @param pests {@link Pest}s that may afflict the plant
|
|
||||||
* @param wateringCycle The {@link WateringCycle} required by the plant
|
|
||||||
* @param lifecycle A list of {@link GrowthPhase}s constituting the plants lifecycle
|
|
||||||
*/
|
|
||||||
public record Plant(
|
public record Plant(
|
||||||
long id,
|
long id,
|
||||||
String name,
|
String name,
|
||||||
|
@ -32,7 +18,6 @@ public record Plant(
|
||||||
int light,
|
int light,
|
||||||
String soil,
|
String soil,
|
||||||
List<Pest> pests,
|
List<Pest> pests,
|
||||||
WateringCycle wateringCycle,
|
|
||||||
List<GrowthPhase> lifecycle) {
|
List<GrowthPhase> lifecycle) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,10 +29,9 @@ public record Plant(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all {@link GrowthPhase}s of a lifecycle group
|
* get all growthPhases of lifecycle group
|
||||||
*
|
* @param group lifecycle group
|
||||||
* @param group The lifecycle group
|
* @return list of growthPhases
|
||||||
* @return A list of {@link GrowthPhase}s
|
|
||||||
*/
|
*/
|
||||||
public List<GrowthPhase> lifecycleForGroup(int group) {
|
public List<GrowthPhase> lifecycleForGroup(int group) {
|
||||||
return lifecycle.stream()
|
return lifecycle.stream()
|
||||||
|
@ -56,95 +40,66 @@ public record Plant(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a {@link LocalDate}, determines which lifecycle group contains it.
|
* get sow date from given harvest day from lifecycle group
|
||||||
*
|
|
||||||
* @param date The date to look for
|
|
||||||
* @return Which lifecycle group the date is in
|
|
||||||
*/
|
|
||||||
public int getGrowphaseGroupForDate(LocalDate date) {
|
|
||||||
for(GrowthPhase growthPhase : lifecycle){
|
|
||||||
MonthDay plantingDate = MonthDay.of(date.getMonth().getValue(), date.getDayOfMonth());
|
|
||||||
if(plantingDate.isAfter(growthPhase.startDate()) && plantingDate.isBefore(growthPhase.endDate())){
|
|
||||||
return growthPhase.group();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get sow date from given harvest date from lifecycle group
|
|
||||||
*
|
|
||||||
* @param harvestDate date of the harvest
|
* @param harvestDate date of the harvest
|
||||||
* @return {@link LocalDate} of sow date
|
* @param group lifecycle group
|
||||||
|
* @return LocaleDate of sow date
|
||||||
*/
|
*/
|
||||||
public LocalDate sowDateFromHarvestDate(LocalDate harvestDate) {
|
public LocalDate sowDateFromHarvestDate(LocalDate harvestDate, int group) {
|
||||||
return harvestDate.minusDays(timeToHarvest(lifecycleGroupFromHarvestDate(harvestDate)));
|
return harvestDate.minusDays(timeToHarvest(group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the number of days between sow and harvest date for lifecycle group
|
* calculate the days between sow and harvest day for lifecycle group
|
||||||
*
|
|
||||||
* @param group the lifecycle group
|
* @param group the lifecycle group
|
||||||
* @return Integer number of dates between sow and harvest day
|
* @return Integer number of dates between sow and harvest day
|
||||||
*/
|
*/
|
||||||
public int timeToHarvest(int group) {
|
public int timeToHarvest(int group) {
|
||||||
List<GrowthPhase> activeLifecycle = lifecycleForGroup(group);
|
List<GrowthPhase> activeLifecycle = lifecycleForGroup(group);
|
||||||
GrowthPhase sow = activeLifecycle.stream()
|
GrowthPhase sow = activeLifecycle.stream()
|
||||||
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.SOW))
|
.filter(growthPhase -> !growthPhase.type().equals(GrowthPhaseType.SOW))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
GrowthPhase harvest = activeLifecycle.stream()
|
GrowthPhase harvest = activeLifecycle.stream()
|
||||||
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.HARVEST))
|
.filter(growthPhase -> !growthPhase.type().equals(GrowthPhaseType.HARVEST))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
int currentYear = LocalDate.now().getYear();
|
int currentYear = LocalDate.now().getYear();
|
||||||
return (int) DAYS.between(sow.startDate().atYear(currentYear),harvest.startDate().atYear(currentYear));
|
return (int) DAYS.between(harvest.startDate().atYear(currentYear), sow.startDate().atYear(currentYear));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a harvest date, determines which lifecycle group it belongs to.
|
* filter out the given growthPhase out of the lifecycle
|
||||||
*
|
* create list of dates for this growthPhase and return it
|
||||||
* @param harvestDate The harvest date
|
* @param growthPhase the wanted growthPhase
|
||||||
* @return Which lifecycle group the harvest date is in
|
* @return a list of dates of the current year
|
||||||
*/
|
*/
|
||||||
public int lifecycleGroupFromHarvestDate(LocalDate harvestDate) {
|
public List<LocalDate> getDateListOfGrowthPhase(GrowthPhaseType growthPhase) {
|
||||||
return lifecycle.stream()
|
List<LocalDate> dates = new LinkedList<>();
|
||||||
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.HARVEST) &&
|
for (GrowthPhase growth : lifecycle) {
|
||||||
dateInRange(harvestDate, growthPhase.startDate(), growthPhase.endDate()))
|
if (growth.type().equals(growthPhase)) {
|
||||||
.map(GrowthPhase::group)
|
dates = addDatesFromMonthDay(growth);
|
||||||
.findFirst()
|
}
|
||||||
.orElse(0);
|
}
|
||||||
|
return dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given {@link LocalDate} is within a {@link GrowthPhase} of the given {@link GrowthPhaseType}
|
* transform monthDay value of the given growthPhase to localDate
|
||||||
*
|
* return a list of dates from start to end of growth phase
|
||||||
* @param date The date to check.
|
* @param growthPhase the current growthPhase
|
||||||
* @param phase The {@link GrowthPhaseType} to match against
|
* @return a list of dates of the current year
|
||||||
* @return Whether the date is within the given {@link GrowthPhaseType}
|
|
||||||
*/
|
*/
|
||||||
public boolean isDateInPhase(LocalDate date, GrowthPhaseType phase) {
|
private List<LocalDate> addDatesFromMonthDay(GrowthPhase growthPhase) {
|
||||||
return lifecycle.stream()
|
List<LocalDate> dates = new LinkedList<>();
|
||||||
.filter(growthPhase -> growthPhase.type().equals(phase))
|
LocalDate today = LocalDate.now();
|
||||||
.anyMatch(growthPhase -> dateInRange(date, growthPhase.startDate(), growthPhase.endDate()));
|
LocalDate start = growthPhase.startDate().atYear(today.getYear());
|
||||||
}
|
LocalDate end = growthPhase.endDate().atYear(today.getYear());
|
||||||
|
while (!start.isAfter(end)) {
|
||||||
/**
|
dates.add(start);
|
||||||
* Checks if the given {@link LocalDate} is within the given {@link MonthDay} range.
|
start = start.plusDays(1);
|
||||||
* (regardless of year)
|
}
|
||||||
*
|
return dates;
|
||||||
* @param subject The date to check
|
|
||||||
* @param min The start of the date-range
|
|
||||||
* @param max The end of the date-range
|
|
||||||
* @return Whether the subject is within the range.
|
|
||||||
*/
|
|
||||||
private boolean dateInRange(LocalDate subject, MonthDay min, MonthDay max) {
|
|
||||||
return subject.getMonth().compareTo(min.getMonth()) >= 0 &&
|
|
||||||
subject.getMonth().compareTo(max.getMonth()) <= 0 &&
|
|
||||||
// if the day is less than the minimum day, the minimum month must not be equal
|
|
||||||
(subject.getDayOfMonth() >= min.getDayOfMonth() || !subject.getMonth().equals(min.getMonth())) &&
|
|
||||||
// if the day is greater than the maximum day, the maximum month must not be equal
|
|
||||||
(subject.getDayOfMonth() <= max.getDayOfMonth() || !subject.getMonth().equals(max.getMonth()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,8 @@ package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
import java.time.MonthDay;
|
import java.time.MonthDay;
|
||||||
|
|
||||||
/**
|
|
||||||
* Describes the 4 Seasons in terms of {@link java.time.LocalDate}s
|
|
||||||
* Also describes "All Seasons" as the full year.
|
|
||||||
*/
|
|
||||||
public enum Seasons {
|
public enum Seasons {
|
||||||
ALLSEASONS("--01-01", "--12-31", "All Seasons"),
|
AllSEASONS("--01-01", "--12-31", "All Seasons"),
|
||||||
SPRING("--03-01", "--05-30", "Spring"),
|
SPRING("--03-01", "--05-30", "Spring"),
|
||||||
SUMMER("--06-01", "--08-30", "Summer"),
|
SUMMER("--06-01", "--08-30", "Summer"),
|
||||||
AUTUMN("--09-01", "--11-30", "Autumn"),
|
AUTUMN("--09-01", "--11-30", "Autumn"),
|
||||||
|
|
|
@ -1,86 +1,43 @@
|
||||||
package ch.zhaw.gartenverwaltung.types;
|
package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Task
|
* Models a Task
|
||||||
* May be created using the builder pattern.
|
* May be created using the builder pattern.
|
||||||
*/
|
*/
|
||||||
public class Task {
|
public class Task {
|
||||||
private Long id;
|
private long id;
|
||||||
private String name;
|
private final String name;
|
||||||
private String description;
|
private final String description;
|
||||||
private LocalDate startDate;
|
private final LocalDate startDate;
|
||||||
private Integer interval;
|
private Integer interval;
|
||||||
private LocalDate endDate;
|
private LocalDate endDate;
|
||||||
private LocalDate nextExecution;
|
|
||||||
private LocalDate nextNotification;
|
|
||||||
private long cropId;
|
private long cropId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* default constructor
|
||||||
* (used by Json deserializer)
|
* (used by Json deserializer)
|
||||||
*/
|
*/
|
||||||
public Task(){
|
public Task(){
|
||||||
name= "";
|
name= "";
|
||||||
description= "";
|
description= "";
|
||||||
startDate = LocalDate.now();
|
startDate = LocalDate.now();
|
||||||
endDate = startDate;
|
|
||||||
nextExecution = startDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for a non-repeating task related to a {@link Crop}
|
|
||||||
*
|
|
||||||
* @param name The name of the task
|
|
||||||
* @param description A description of the task
|
|
||||||
* @param startDate The start date of the task
|
|
||||||
* @param cropId The id of the crop to which the task belongs
|
|
||||||
*/
|
|
||||||
public Task(String name, String description, LocalDate startDate, long cropId) {
|
public Task(String name, String description, LocalDate startDate, long cropId) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
this.endDate = startDate;
|
|
||||||
nextExecution = startDate;
|
|
||||||
this.cropId = cropId;
|
this.cropId = cropId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for weather events
|
|
||||||
*
|
|
||||||
* @param name The name of the task
|
|
||||||
* @param description A description of the task
|
|
||||||
* @param startDate The start date of the task
|
|
||||||
* @param endDate The maximum date on which the task should be executed
|
|
||||||
*/
|
|
||||||
public Task(String name, String description, LocalDate startDate, LocalDate endDate, long cropId) {
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.startDate = startDate;
|
|
||||||
nextExecution = startDate;
|
|
||||||
this.endDate = endDate;
|
|
||||||
this.cropId = cropId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Full constructor (without id)
|
|
||||||
*
|
|
||||||
* @param name The name of the task
|
|
||||||
* @param description A description of the task
|
|
||||||
* @param startDate The start date of the task
|
|
||||||
* @param endDate The maximum date on which the task should be executed
|
|
||||||
* @param interval The number of days between executions
|
|
||||||
* @param cropId The id of the crop to which the task belongs
|
|
||||||
*/
|
|
||||||
public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval, long cropId) {
|
public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval, long cropId) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.startDate = startDate;
|
this.startDate = startDate;
|
||||||
nextExecution = startDate;
|
|
||||||
this.endDate = endDate;
|
this.endDate = endDate;
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
this.cropId = cropId;
|
this.cropId = cropId;
|
||||||
|
@ -100,47 +57,12 @@ public class Task {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isInTimePeriode(LocalDate searchStartDate, LocalDate searchEndDate){
|
||||||
* Checks if the Task is within a specific date range.
|
return startDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate);
|
||||||
*
|
|
||||||
* @param searchStartDate The minimum date
|
|
||||||
* @param searchEndDate The maximum date
|
|
||||||
* @return Whether the Task is within the given range
|
|
||||||
*/
|
|
||||||
public boolean isInTimePeriod(LocalDate searchStartDate, LocalDate searchEndDate) {
|
|
||||||
return (endDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate)) || ((nextExecution != null && nextExecution.isBefore(searchEndDate.plusDays(1)) && nextExecution.isAfter(searchStartDate.minusDays(1))));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks a specific execution of a Task as done.
|
|
||||||
*/
|
|
||||||
public void done(){
|
|
||||||
if(interval != null && interval != 0 && !nextExecution.plusDays(interval).isAfter(endDate)){
|
|
||||||
nextExecution = nextExecution.plusDays(interval);
|
|
||||||
nextNotification = nextExecution;
|
|
||||||
} else {
|
|
||||||
nextExecution = null;
|
|
||||||
nextNotification = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public boolean isDone(){
|
|
||||||
return nextExecution == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNextExecution(LocalDate nextExecution) {
|
|
||||||
this.nextExecution = nextExecution;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNextNotification(LocalDate nextNotification) {
|
|
||||||
this.nextNotification = nextNotification;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
public LocalDate getNextNotification() { return nextNotification; }
|
public long getId() { return id; }
|
||||||
public LocalDate getNextExecution() { return nextExecution; }
|
|
||||||
public Optional<Long> getId() { return Optional.ofNullable(id); }
|
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
public String getDescription() { return description; }
|
public String getDescription() { return description; }
|
||||||
public LocalDate getStartDate() { return startDate; }
|
public LocalDate getStartDate() { return startDate; }
|
||||||
|
@ -152,20 +74,4 @@ public class Task {
|
||||||
public Optional<LocalDate> getEndDate() {
|
public Optional<LocalDate> getEndDate() {
|
||||||
return Optional.ofNullable(endDate);
|
return Optional.ofNullable(endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the fields of this Task using the values of the given Task
|
|
||||||
*
|
|
||||||
* @param task The task whose fields to copy
|
|
||||||
* @return This task with the fields already updated
|
|
||||||
*/
|
|
||||||
public Task updateTask(Task task) {
|
|
||||||
this.name = task.getName();
|
|
||||||
this.description = task.getDescription();
|
|
||||||
this.startDate = task.getStartDate();
|
|
||||||
this.endDate = task.getEndDate().orElse(null);
|
|
||||||
this.interval = task.getInterval().orElse(0);
|
|
||||||
this.cropId = task.getCropId();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class which represents a Task if the start and enddate is not known yet.
|
|
||||||
*/
|
|
||||||
public class TaskTemplate {
|
public class TaskTemplate {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -19,6 +16,10 @@ public class TaskTemplate {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private Integer interval;
|
private Integer interval;
|
||||||
|
|
||||||
|
// TODO: reconsider if we need this
|
||||||
|
@JsonProperty
|
||||||
|
private boolean isOptional = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
* (Used by deserializer)
|
* (Used by deserializer)
|
||||||
|
@ -33,7 +34,6 @@ public class TaskTemplate {
|
||||||
public void setRelativeEndDate(Integer relativeEndDate) {
|
public void setRelativeEndDate(Integer relativeEndDate) {
|
||||||
this.relativeEndDate = relativeEndDate;
|
this.relativeEndDate = relativeEndDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInterval(Integer interval) {
|
public void setInterval(Integer interval) {
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
}
|
}
|
||||||
|
@ -44,22 +44,14 @@ public class TaskTemplate {
|
||||||
this.relativeStartDate = relativeStartDate;
|
this.relativeStartDate = relativeStartDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a concrete {@link Task} given a concrete start date
|
|
||||||
*
|
|
||||||
* @param realStartDate The start date of the {@link GrowthPhase} to which the {@link #relativeStartDate} is relative.
|
|
||||||
* @param cropId The crop for which the task should be generated.
|
|
||||||
* @return The created {@link Task}
|
|
||||||
*/
|
|
||||||
public Task generateTask(LocalDate realStartDate, long cropId) {
|
public Task generateTask(LocalDate realStartDate, long cropId) {
|
||||||
LocalDate endDate = relativeEndDate != null ? realStartDate.plusDays(relativeEndDate) : realStartDate;
|
Task task = new Task(name, description, realStartDate.plusDays(relativeStartDate), cropId);
|
||||||
|
if (relativeEndDate != null) {
|
||||||
if (interval == null) {
|
task.withEndDate(realStartDate.plusDays(relativeEndDate));
|
||||||
this.interval = 0;
|
|
||||||
}
|
}
|
||||||
|
if (interval != null) {
|
||||||
return new Task(name, description, realStartDate.plusDays(relativeStartDate), cropId)
|
task.withInterval(interval);
|
||||||
.withInterval(interval)
|
}
|
||||||
.withEndDate(endDate);
|
return task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package ch.zhaw.gartenverwaltung.types;
|
package ch.zhaw.gartenverwaltung.types;
|
||||||
|
|
||||||
/**
|
|
||||||
* Describes the cycle in which a {@link Plant} should be watered
|
|
||||||
*
|
|
||||||
* @param litersPerSqM How many litres of water per square metre of ground
|
|
||||||
* @param interval The interval (days)
|
|
||||||
* @param notes Notes on the cycle
|
|
||||||
*/
|
|
||||||
public record WateringCycle(
|
public record WateringCycle(
|
||||||
int litersPerSqM,
|
int litersPerSqM,
|
||||||
int interval,
|
int interval,
|
||||||
|
|
|
@ -5,18 +5,10 @@ module ch.zhaw.gartenverwaltung {
|
||||||
requires com.fasterxml.jackson.datatype.jsr310;
|
requires com.fasterxml.jackson.datatype.jsr310;
|
||||||
requires com.fasterxml.jackson.datatype.jdk8;
|
requires com.fasterxml.jackson.datatype.jdk8;
|
||||||
requires java.logging;
|
requires java.logging;
|
||||||
requires java.mail;
|
|
||||||
|
|
||||||
|
|
||||||
opens ch.zhaw.gartenverwaltung to javafx.fxml;
|
opens ch.zhaw.gartenverwaltung to javafx.fxml;
|
||||||
opens ch.zhaw.gartenverwaltung.types to com.fasterxml.jackson.databind;
|
opens ch.zhaw.gartenverwaltung.types to com.fasterxml.jackson.databind;
|
||||||
exports ch.zhaw.gartenverwaltung;
|
exports ch.zhaw.gartenverwaltung;
|
||||||
exports ch.zhaw.gartenverwaltung.io;
|
|
||||||
exports ch.zhaw.gartenverwaltung.types;
|
exports ch.zhaw.gartenverwaltung.types;
|
||||||
exports ch.zhaw.gartenverwaltung.models;
|
|
||||||
exports ch.zhaw.gartenverwaltung.json;
|
exports ch.zhaw.gartenverwaltung.json;
|
||||||
exports ch.zhaw.gartenverwaltung.backgroundtasks;
|
|
||||||
opens ch.zhaw.gartenverwaltung.backgroundtasks to javafx.fxml;
|
|
||||||
exports ch.zhaw.gartenverwaltung.backgroundtasks.email;
|
|
||||||
opens ch.zhaw.gartenverwaltung.backgroundtasks.email to javafx.fxml;
|
|
||||||
}
|
}
|
|
@ -3,7 +3,6 @@
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ListView?>
|
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
@ -13,34 +12,39 @@
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="785.0" prefWidth="899.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.CropDetailController">
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="785.0" prefWidth="899.0"
|
||||||
|
xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.CropDetailController">
|
||||||
<children>
|
<children>
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true" prefHeight="759.0" prefWidth="664.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<ScrollPane fitToWidth="true" prefHeight="759.0" prefWidth="664.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<content>
|
<content>
|
||||||
<VBox fx:id="cropDetailVBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="781.0" prefWidth="897.0" spacing="5.0">
|
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="503.0" prefWidth="897.0">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
<children>
|
<children>
|
||||||
<Button styleClass="button-class" mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
|
<Button mnemonicParsing="false" onAction="#goBack" prefHeight="25.0" prefWidth="91.0" text="Go Back">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Label styleClass="page-title" fx:id="cropName_label" text="Label">
|
<Label fx:id="cropName_label" text="Label">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<HBox maxHeight="1.7976931348623157E308" prefHeight="268.0" prefWidth="855.0" spacing="10.0" VBox.vgrow="NEVER">
|
<HBox prefHeight="265.0" prefWidth="879.0">
|
||||||
<children>
|
<children>
|
||||||
<GridPane styleClass="custom-container" maxWidth="1.7976931348623157E308" prefHeight="231.0" prefWidth="555.0" HBox.hgrow="ALWAYS">
|
<GridPane maxWidth="1.7976931348623157E308" prefHeight="296.0" prefWidth="577.0" HBox.hgrow="ALWAYS">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" maxWidth="284.0" minWidth="10.0" prefWidth="97.33334350585938" />
|
<ColumnConstraints halignment="LEFT" hgrow="SOMETIMES" maxWidth="284.0" minWidth="10.0" prefWidth="97.33334350585938" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.99999237060547" minWidth="10.0" prefWidth="481.9999898274739" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="488.99999237060547" minWidth="10.0" prefWidth="481.9999898274739" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="149.66665903727215" minHeight="10.0" prefHeight="126.33328501383463" valignment="TOP" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="149.66665903727215" minHeight="10.0" prefHeight="149.66665903727215" valignment="TOP" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="187.9999647140503" minHeight="10.0" prefHeight="45.00002034505208" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="187.9999647140503" minHeight="10.0" prefHeight="51.00000762939453" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="105.66662597656247" minHeight="10.0" prefHeight="46.33331298828125" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="105.66662597656247" minHeight="10.0" prefHeight="54.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="105.66662597656247" minHeight="10.0" prefHeight="45.66668701171875" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="105.66662597656247" minHeight="10.0" prefHeight="46.66666666666666" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label prefHeight="17.0" prefWidth="65.0" text="Description:">
|
<Label prefHeight="17.0" prefWidth="65.0" text="Description:">
|
||||||
|
@ -72,58 +76,67 @@
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Label>
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
|
||||||
<Insets bottom="5.0" left="10.0" right="5.0" top="5.0" />
|
|
||||||
</padding>
|
|
||||||
</GridPane>
|
</GridPane>
|
||||||
<ImageView fx:id="imageView" fitHeight="250.0" fitWidth="250.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
<ImageView fx:id="imageView" fitHeight="300.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label text="Tasks:">
|
<Label text="Growth Phases:">
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<ListView fx:id="taskList_listView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" prefHeight="100.0" prefWidth="869.0" VBox.vgrow="ALWAYS">
|
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</ListView>
|
</Label>
|
||||||
<Button styleClass="button-class" fx:id="addTask_button" mnemonicParsing="false" onAction="#addTask" prefHeight="25.0" prefWidth="120.0" VBox.vgrow="NEVER" text="Add Task">
|
<VBox fx:id="growthPhases_vbox" prefHeight="135.0" prefWidth="879.0">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets />
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</VBox>
|
||||||
|
<Button mnemonicParsing="false" onAction="#editTaskList" prefHeight="25.0" prefWidth="92.0" text="Edit Tasklist">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</Button>
|
</Button>
|
||||||
<Label text="Pests:" VBox.vgrow="NEVER" />
|
<Label text="Pests:" />
|
||||||
<ListView fx:id="pests_listView" maxHeight="1.7976931348623157E308" minHeight="-Infinity" prefHeight="100.0" prefWidth="855.0" VBox.vgrow="SOMETIMES">
|
<VBox fx:id="pests_vbox" prefHeight="200.0" prefWidth="100.0">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</ListView>
|
</VBox>
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="27.0" prefWidth="869.0" VBox.vgrow="NEVER">
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" VBox.vgrow="NEVER">
|
||||||
<children>
|
<children>
|
||||||
<Label text="Area:">
|
<Label text="Area:">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="60.0" />
|
<Insets right="60.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Label fx:id="area_label" minWidth="-Infinity" prefWidth="50.0" text="Label">
|
<Label fx:id="area_label" text="Label">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="10.0" />
|
<Insets right="10.0" />
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<Button styleClass="button-class" fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Set Area" />
|
<Button fx:id="area_button" mnemonicParsing="false" onAction="#setArea" prefHeight="25.0" prefWidth="116.0" text="Add Area" />
|
||||||
</children>
|
</children>
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
<HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="719.0" prefHeight="100.0" prefWidth="200.0" VBox.vgrow="NEVER">
|
||||||
|
<children>
|
||||||
|
<Label text="Location:">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="40.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Label fx:id="location_label" text="Label">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="10.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</Label>
|
||||||
|
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" prefHeight="25.0" prefWidth="115.0" text="Add Location" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
</content>
|
</content>
|
||||||
<padding>
|
|
||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
|
||||||
</padding>
|
|
||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
|
@ -2,251 +2,42 @@
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
|
||||||
<?import javafx.scene.image.ImageView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="1091.0" prefWidth="1060.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.HomeController">
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="729.0" prefWidth="1060.0"
|
||||||
|
xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.HomeController">
|
||||||
<children>
|
<children>
|
||||||
<ScrollPane fitToWidth="true" prefHeight="1157.0" prefWidth="1060.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<VBox layoutX="75.0" layoutY="73.0" prefHeight="729.0" prefWidth="1060.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<padding>
|
<children>
|
||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
<Label text="Gartenverwaltung">
|
||||||
</padding>
|
<font>
|
||||||
<content>
|
<Font size="34.0" />
|
||||||
<VBox fx:id="homeVBox" prefHeight="1047.0" prefWidth="1019.0" spacing="10.0">
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Label prefHeight="106.0" prefWidth="1040.0" text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." wrapText="true" />
|
||||||
|
<Label text="Tutorial">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="18.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<Pane prefHeight="200.0" prefWidth="200.0">
|
||||||
<children>
|
<children>
|
||||||
<Label styleClass="page-title" text="Garden Management">
|
<VBox prefHeight="200.0" prefWidth="1040.0">
|
||||||
<font>
|
|
||||||
<Font size="34.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<Label alignment="TOP_LEFT" prefHeight="22.0" prefWidth="1039.0" text="This Application was created to help the user manage his or her garden. For this the Application has many functionalities:" wrapText="true">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
|
|
||||||
<children>
|
<children>
|
||||||
<Label text="Base Functionalities:">
|
<Label text="Task 1" wrapText="true" />
|
||||||
<font>
|
<Label text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." wrapText="true" />
|
||||||
<Font name="System Bold" size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can select a plant he wants to cultivate.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can filter the plants according to seasons, hardiness zone and search query">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can select the harverst or sow date. ">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can get a detailed information of the plant he wants to harvest.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can get view the task list of the given plant.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can get the tasks of the next seven days in the scheduler.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
|
||||||
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
|
|
||||||
<children>
|
|
||||||
<Label text="Advanced Functionalities:">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can edit the task list and add custom tasks.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can set the area (sqare meter) for the plants.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can set the location (PLZ) for the plants.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user can set the pesticide which will be used, which will create additonal tasks.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
|
||||||
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
|
|
||||||
<children>
|
|
||||||
<Label text="Weather Forcast:">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- According to the location the weather forcast will crate or delete tasks.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label text="- The user receives notifications that aditional tasks werde created or some tasks were deleted.">
|
|
||||||
<font>
|
|
||||||
<Font size="14.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
|
||||||
<VBox styleClass="vbox" prefHeight="200.0" prefWidth="100.0" spacing="15.0">
|
|
||||||
<children>
|
|
||||||
<Label text="Created by:">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="14.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<ImageView fx:id="imageViewElias" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="30.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</ImageView>
|
|
||||||
<Label minWidth="150.0" text="Elias Csomor" />
|
|
||||||
<Label minWidth="200.0" text="csomoeli@students.zhaw.ch" />
|
|
||||||
<Label text="Assistent Project Lead/Developer" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets left="50.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<ImageView fx:id="imageViewPhilippe" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="30.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</ImageView>
|
|
||||||
<Label minWidth="150.0" text="Philippe Giavarini" />
|
|
||||||
<Label minWidth="200.0" text="giavaphi@students.zhaw.ch" />
|
|
||||||
<Label text="Project Lead/Developer" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets left="50.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<ImageView fx:id="imageViewDavid" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="30.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</ImageView>
|
|
||||||
<Label minWidth="150.0" text="David Guler" />
|
|
||||||
<Label minWidth="200.0" text="gulerdav@students.zhaw.ch" />
|
|
||||||
<Label text="Developer" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets left="50.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<ImageView fx:id="imageViewGian" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="30.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</ImageView>
|
|
||||||
<Label minWidth="150.0" text="Gian-Andrea Hutter" />
|
|
||||||
<Label minWidth="200.0" text="huttergia@students.zhaw.ch" />
|
|
||||||
<Label text="Developer" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets left="50.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<ImageView fx:id="imageViewRoman" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets right="30.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</ImageView>
|
|
||||||
<Label minWidth="150.0" text="Roman Schenk" />
|
|
||||||
<Label minWidth="200.0" text="schrom01@students.zhaw.ch" />
|
|
||||||
<Label text="Developer" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets left="50.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</Pane>
|
||||||
</content>
|
</children>
|
||||||
</ScrollPane>
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
|
@ -7,14 +7,13 @@
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="938.0" prefWidth="1110.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MainFXMLController">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="938.0" prefWidth="1110.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MainFXMLController">
|
||||||
<children>
|
<children>
|
||||||
<HBox fx:id="menubar" maxWidth="35.0" minHeight="40.0" prefHeight="38.0" prefWidth="1110.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<HBox maxWidth="35.0" minHeight="35.0" prefHeight="38.0" prefWidth="1110.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="38.0" HBox.hgrow="NEVER" />
|
<Button fx:id="home_button" mnemonicParsing="false" onAction="#goToHome" prefHeight="38.0" prefWidth="121.0" text="Home" HBox.hgrow="NEVER" />
|
||||||
<Button fx:id="myGarden_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMyPlants" prefHeight="38.0" prefWidth="121.0" text="My Garden" />
|
<Button fx:id="plants_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToPlants" prefHeight="38.0" prefWidth="121.0" text="Plants" />
|
||||||
<Button fx:id="mySchedule_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMySchedule" prefHeight="38.0" prefWidth="121.0" text="My Schedule" />
|
<Button fx:id="myPlants_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMyPlants" prefHeight="38.0" prefWidth="121.0" text="MyPlants" />
|
||||||
<Button fx:id="tutorial_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#showTutorial" prefHeight="38.0" prefWidth="121.0" text="Tutorial" />
|
<Button fx:id="mySchedule_button" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#goToMySchedule" prefHeight="38.0" prefWidth="121.0" text="MySchedule" />
|
||||||
<Pane fx:id="menu_pane" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
|
<Pane maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
|
||||||
<Button fx:id="settings_button" mnemonicParsing="false" onAction="#openSettings" prefHeight="38.0" prefWidth="38.0" HBox.hgrow="NEVER" />
|
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<AnchorPane fx:id="mainPane" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="35.0" />
|
<AnchorPane fx:id="mainPane" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="35.0" />
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.ListView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
|
||||||
|
|
||||||
<AnchorPane fx:id="myGardenRoot" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="655.0" prefWidth="1175.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyGardenController">
|
|
||||||
<children>
|
|
||||||
<VBox layoutY="49.0" prefHeight="655.0" prefWidth="1175.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<children>
|
|
||||||
<Label styleClass="page-title" text="My Garden">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="28.0" />
|
|
||||||
</font>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<ListView fx:id="myGarden_listView" maxHeight="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS" />
|
|
||||||
<Button styleClass="button-class" fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</Button>
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
|
||||||
</padding>
|
|
||||||
</AnchorPane>
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="655.0" prefWidth="1175.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyPlantsController">
|
||||||
|
<children>
|
||||||
|
<VBox layoutY="49.0" prefHeight="655.0" prefWidth="1175.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<Label text="MyPlants">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="28.0" />
|
||||||
|
</font>
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets bottom="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Label>
|
||||||
|
<VBox fx:id="myPlants_vbox" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="100.0" VBox.vgrow="ALWAYS" />
|
||||||
|
<Button fx:id="addPlant_button" mnemonicParsing="false" onAction="#addPlant" prefHeight="45.0" prefWidth="155.0" text="Add new Plant">
|
||||||
|
<VBox.margin>
|
||||||
|
<Insets top="10.0" />
|
||||||
|
</VBox.margin>
|
||||||
|
</Button>
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||||
|
</padding>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
|
@ -1,62 +1,74 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ListView?>
|
<?import javafx.scene.control.ListView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="572.0" prefWidth="867.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyScheduleController">
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="572.0" prefWidth="867.0"
|
||||||
|
xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.MyScheduleController">
|
||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<Label layoutX="14.0" layoutY="14.0" text="MySchedule">
|
||||||
|
<font>
|
||||||
|
<Font size="24.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<HBox layoutY="31.0" prefHeight="541.0" prefWidth="867.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
|
||||||
<children>
|
<children>
|
||||||
<Label styleClass="page-title" text="MySchedule" VBox.vgrow="NEVER">
|
<ListView fx:id="scheduledPlants_listview" maxWidth="1.7976931348623157E308" prefHeight="522.0" prefWidth="365.0" HBox.hgrow="NEVER" />
|
||||||
<font>
|
<VBox maxWidth="1.7976931348623157E308" prefHeight="537.0" prefWidth="650.0" HBox.hgrow="ALWAYS">
|
||||||
<Font size="24.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="541.0" prefWidth="867.0" spacing="10.0" VBox.vgrow="ALWAYS">
|
|
||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="497.0" prefWidth="237.0" spacing="10.0" HBox.hgrow="NEVER">
|
<GridPane alignment="CENTER_LEFT" gridLinesVisible="true" maxWidth="1.7976931348623157E308" prefHeight="403.0" prefWidth="575.0" VBox.vgrow="ALWAYS">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints fillWidth="false" hgrow="NEVER" maxWidth="278.0" minWidth="100.0" prefWidth="173.0" />
|
||||||
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="402.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<ListView fx:id="scheduledPlants_listview" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="522.0" prefWidth="271.0" VBox.vgrow="ALWAYS" />
|
<Label fx:id="day1_label" alignment="CENTER" prefHeight="32.0" prefWidth="173.0" text="Label" />
|
||||||
<Button maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#showAllTasks" styleClass="button-class" text="Show All Tasks" VBox.vgrow="NEVER" />
|
<Label fx:id="day2_label" alignment="CENTER" prefHeight="29.0" prefWidth="173.0" text="Label" GridPane.rowIndex="1" />
|
||||||
|
<Label fx:id="day3_label" alignment="CENTER" prefHeight="32.0" prefWidth="172.0" text="Label" GridPane.rowIndex="2" />
|
||||||
|
<Label fx:id="day4_label" alignment="CENTER" prefHeight="35.0" prefWidth="173.0" text="Label" GridPane.rowIndex="3" />
|
||||||
|
<Label fx:id="day5_label" alignment="CENTER" prefHeight="31.0" prefWidth="173.0" text="Label" GridPane.rowIndex="4" />
|
||||||
|
<Label fx:id="day6_label" alignment="CENTER" prefHeight="31.0" prefWidth="173.0" text="Label" GridPane.rowIndex="5" />
|
||||||
|
<Label fx:id="day7_label" alignment="CENTER" prefHeight="35.0" prefWidth="173.0" text="Label" GridPane.rowIndex="6" />
|
||||||
|
<Pane fx:id="day1_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" />
|
||||||
|
<Pane fx:id="day2_pane" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<Pane fx:id="day3_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
<Pane fx:id="day4_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
|
<Pane fx:id="day5_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
|
<Pane fx:id="day6_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.rowIndex="5" />
|
||||||
|
<Pane fx:id="day7_pane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</GridPane>
|
||||||
<VBox maxWidth="1.7976931348623157E308" prefHeight="537.0" prefWidth="650.0" spacing="10.0" HBox.hgrow="ALWAYS">
|
<Pane prefHeight="119.0" prefWidth="575.0" VBox.vgrow="NEVER">
|
||||||
<children>
|
<children>
|
||||||
<ListView fx:id="week_listView" maxWidth="1.7976931348623157E308" prefHeight="200.0" prefWidth="200.0" VBox.vgrow="ALWAYS">
|
<Label alignment="TOP_LEFT" layoutX="14.0" layoutY="14.0" prefHeight="17.0" prefWidth="550.0" text="Importants Information:" wrapText="true">
|
||||||
<VBox.margin>
|
<font>
|
||||||
<Insets />
|
<Font name="System Bold" size="12.0" />
|
||||||
</VBox.margin>
|
</font>
|
||||||
</ListView>
|
</Label>
|
||||||
<VBox styleClass="custom-container" prefHeight="131.0" prefWidth="603.0" spacing="5.0" VBox.vgrow="NEVER">
|
<Label fx:id="information_label" alignment="TOP_LEFT" layoutX="14.0" layoutY="31.0" maxWidth="1.7976931348623157E308" prefHeight="82.0" prefWidth="550.0" text="Label" wrapText="true" />
|
||||||
<children>
|
|
||||||
<Label alignment="TOP_LEFT" maxWidth="1.7976931348623157E308" prefHeight="17.0" prefWidth="558.0" text="Importants Information:" wrapText="true" VBox.vgrow="NEVER">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="12.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="information_label" alignment="TOP_LEFT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="73.0" prefWidth="550.0" text="Label" wrapText="true" VBox.vgrow="ALWAYS" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</Pane>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</VBox>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</HBox>
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
|
||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
|
||||||
</padding>
|
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
|
@ -4,109 +4,90 @@
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.ListView?>
|
<?import javafx.scene.control.ListView?>
|
||||||
|
<?import javafx.scene.control.SplitPane?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
<?import javafx.scene.control.TitledPane?>
|
<?import javafx.scene.control.TitledPane?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.Pane?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane fx:id="plantsRoot" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="1000.0" prefHeight="853.0" prefWidth="1219.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.PlantsController">
|
<AnchorPane maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="1000.0" prefHeight="853.0"
|
||||||
|
prefWidth="1219.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="ch.zhaw.gartenverwaltung.PlantsController">
|
||||||
<children>
|
<children>
|
||||||
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<SplitPane dividerPositions="0.7377363661277062" layoutX="539.0" layoutY="266.0" prefHeight="853.0" prefWidth="1219.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<items>
|
||||||
<Label styleClass="page-title" prefHeight="45.0" prefWidth="903.0" text="Plants" VBox.vgrow="NEVER">
|
<AnchorPane maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="30.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="100.0" prefWidth="200.0" spacing="10.0" VBox.vgrow="ALWAYS">
|
|
||||||
<children>
|
<children>
|
||||||
<AnchorPane maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
|
<VBox maxWidth="1.7976931348623157E308" prefHeight="850.6666666666666" prefWidth="894.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
<VBox maxWidth="1.7976931348623157E308" prefHeight="850.6666666666666" prefWidth="894.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<Label prefHeight="45.0" prefWidth="903.0" text="Plants">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="30.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<TextField fx:id="search_plants" promptText="Search for Plant Name" />
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="480.0" prefWidth="881.0" VBox.vgrow="ALWAYS">
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="search_plants" promptText="Search for Plant Name" VBox.vgrow="NEVER" />
|
<ListView fx:id="list_plants" maxWidth="1.7976931348623157E308" prefHeight="497.0" prefWidth="400.0" HBox.hgrow="ALWAYS" />
|
||||||
<HBox alignment="CENTER_LEFT" minHeight="300.0" prefHeight="480.0" prefWidth="881.0" spacing="10.0" VBox.vgrow="ALWAYS">
|
<ImageView fx:id="img_plant" fitWidth="300" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER" />
|
||||||
<children>
|
|
||||||
<ListView fx:id="list_plants" maxWidth="1.7976931348623157E308" prefHeight="497.0" prefWidth="400.0" HBox.hgrow="ALWAYS" />
|
|
||||||
<Pane styleClass="custom-container" maxHeight="1.7976931348623157E308" maxWidth="300.0" minWidth="300.0" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="NEVER">
|
|
||||||
<children>
|
|
||||||
<ImageView fx:id="img_plant" fitWidth="300" pickOnBounds="true" preserveRatio="true" />
|
|
||||||
</children>
|
|
||||||
</Pane>
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<VBox styleClass="vbox" maxHeight="1.7976931348623157E308" prefHeight="237.0" prefWidth="879.0" VBox.vgrow="ALWAYS">
|
|
||||||
<children>
|
|
||||||
<Label maxHeight="1.7976931348623157E308" prefHeight="33.0" prefWidth="919.0" text="Plant Information:" VBox.vgrow="NEVER">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="12.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<Label fx:id="description_plant" alignment="TOP_LEFT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="96.0" prefWidth="879.0" text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." textAlignment="JUSTIFY" wrapText="true" VBox.vgrow="ALWAYS">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</Label>
|
|
||||||
<Button styleClass="button-class" fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" VBox.vgrow="NEVER" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</HBox>
|
||||||
|
<Label prefHeight="33.0" prefWidth="919.0" text="Plant Information:">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="12.0" />
|
||||||
|
</font>
|
||||||
|
<padding>
|
||||||
|
<Insets top="15.0" />
|
||||||
|
</padding>
|
||||||
|
</Label>
|
||||||
|
<Label fx:id="description_plant" alignment="TOP_LEFT" maxWidth="1.7976931348623157E308" prefHeight="194.0" prefWidth="893.0" text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." textAlignment="JUSTIFY" wrapText="true">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</Label>
|
||||||
|
<Button fx:id="selectSowDay_button" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#selectSowDate" prefHeight="38.0" prefWidth="917.0" text="Select Harvest/Sow Day" />
|
||||||
</children>
|
</children>
|
||||||
<HBox.margin>
|
</VBox>
|
||||||
<Insets />
|
|
||||||
</HBox.margin>
|
|
||||||
</AnchorPane>
|
|
||||||
<AnchorPane styleClass="custom-container" maxWidth="300.0" minHeight="0.0" minWidth="300.0" prefHeight="160.0" prefWidth="100.0">
|
|
||||||
<children>
|
|
||||||
<VBox layoutX="38.0" layoutY="100.0" prefHeight="850.6666666666666" prefWidth="316.6666666666667" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<children>
|
|
||||||
<Label text="Filter">
|
|
||||||
<font>
|
|
||||||
<Font name="System Bold" size="17.0" />
|
|
||||||
</font>
|
|
||||||
</Label>
|
|
||||||
<TitledPane animated="false" text="Seasons">
|
|
||||||
<content>
|
|
||||||
<AnchorPane styleClass="custom-container" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<VBox fx:id="seasons" layoutX="37.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</content>
|
|
||||||
</TitledPane>
|
|
||||||
<TitledPane animated="false" text="Climate Zones">
|
|
||||||
<content>
|
|
||||||
<AnchorPane styleClass="custom-container" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<VBox fx:id="climate_zones" layoutX="36.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
||||||
</content>
|
|
||||||
</TitledPane>
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</AnchorPane>
|
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</AnchorPane>
|
||||||
</children>
|
<AnchorPane maxWidth="300.0" minHeight="0.0" minWidth="300.0" prefHeight="160.0" prefWidth="100.0">
|
||||||
</VBox>
|
<children>
|
||||||
|
<VBox layoutX="38.0" layoutY="100.0" prefHeight="850.6666666666666" prefWidth="316.6666666666667" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<Label text="Filter">
|
||||||
|
<font>
|
||||||
|
<Font name="System Bold" size="17.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
<TitledPane animated="false" text="Saison">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<VBox fx:id="seasons" layoutX="37.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</TitledPane>
|
||||||
|
<TitledPane animated="false" text="Climate Zones">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<VBox fx:id="climate_zones" layoutX="36.0" layoutY="-19.0" prefHeight="180.66666666666666" prefWidth="310.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</content>
|
||||||
|
</TitledPane>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</items>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
</SplitPane>
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
|
||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
|
||||||
</padding>
|
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.DatePicker?>
|
<?import javafx.scene.control.DatePicker?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.RadioButton?>
|
<?import javafx.scene.control.RadioButton?>
|
||||||
<?import javafx.scene.control.ToggleGroup?>
|
<?import javafx.scene.control.ToggleGroup?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
@ -14,19 +16,20 @@
|
||||||
<children>
|
<children>
|
||||||
<VBox maxWidth="1.7976931348623157E308" prefHeight="408.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<VBox maxWidth="1.7976931348623157E308" prefHeight="408.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
|
<Label fx:id="popup_label" text="Label" />
|
||||||
<HBox alignment="CENTER" prefHeight="293.0" prefWidth="631.0">
|
<HBox alignment="CENTER" prefHeight="293.0" prefWidth="631.0">
|
||||||
<children>
|
<children>
|
||||||
<VBox alignment="CENTER_LEFT" prefHeight="88.0" prefWidth="155.0">
|
<VBox alignment="CENTER_LEFT" prefHeight="88.0" prefWidth="155.0">
|
||||||
<children>
|
<children>
|
||||||
<RadioButton fx:id="sow_radio" mnemonicParsing="false" selected="true" text="Sow" toggleGroup="$phase_group">
|
<RadioButton fx:id="sow_radio" mnemonicParsing="false" selected="true" text="Sow">
|
||||||
<VBox.margin>
|
<VBox.margin>
|
||||||
<Insets bottom="10.0" />
|
<Insets bottom="10.0" />
|
||||||
</VBox.margin>
|
</VBox.margin>
|
||||||
<toggleGroup>
|
<toggleGroup>
|
||||||
<ToggleGroup fx:id="phase_group" />
|
<ToggleGroup fx:id="group" />
|
||||||
</toggleGroup>
|
</toggleGroup>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton fx:id="harvest_radio" mnemonicParsing="false" text="Harvest" toggleGroup="$phase_group" />
|
<RadioButton fx:id="harvest_radio" mnemonicParsing="false" text="Harvest" toggleGroup="$group" />
|
||||||
</children>
|
</children>
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets top="10.0" />
|
<Insets top="10.0" />
|
||||||
|
@ -35,6 +38,16 @@
|
||||||
<DatePicker fx:id="datepicker" />
|
<DatePicker fx:id="datepicker" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
<HBox fillHeight="false" prefHeight="54.0" prefWidth="631.0" VBox.vgrow="NEVER">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="save_button" mnemonicParsing="false" onAction="#save" prefHeight="25.0" prefWidth="53.0" text="Save">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="10.0" />
|
||||||
|
</HBox.margin>
|
||||||
|
</Button>
|
||||||
|
<Button fx:id="cancel_button" mnemonicParsing="false" onAction="#cancel" text="Cancel" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.CheckBox?>
|
|
||||||
<?import javafx.scene.control.ComboBox?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="117.0" prefWidth="374.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.SettingsController">
|
|
||||||
<children>
|
|
||||||
<VBox layoutX="14.0" layoutY="14.0" prefHeight="73.0" prefWidth="374.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<children>
|
|
||||||
<HBox prefHeight="23.0" prefWidth="334.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Show Tutorial Menu" HBox.hgrow="ALWAYS" />
|
|
||||||
<CheckBox fx:id="showTutorial_checkBox" mnemonicParsing="false" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="20.0" prefHeight="23.0" prefWidth="334.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Select Default Hardiness Zone" HBox.hgrow="ALWAYS" />
|
|
||||||
<ComboBox fx:id="selectHardinessZone_comboBox" prefWidth="150.0" promptText="Hardniness Zone" />
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets />
|
|
||||||
</VBox.margin>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="53.0" prefHeight="23.0" prefWidth="334.0" spacing="5.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Set Location" HBox.hgrow="ALWAYS" />
|
|
||||||
<Label fx:id="location_label" />
|
|
||||||
<Button fx:id="location_button" mnemonicParsing="false" onAction="#setLocation" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
|
@ -1,52 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.DatePicker?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.TextArea?>
|
|
||||||
<?import javafx.scene.control.TextField?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="259.0" prefWidth="390.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.TaskFormularController">
|
|
||||||
<children>
|
|
||||||
<VBox layoutX="14.0" layoutY="14.0" prefHeight="272.0" prefWidth="390.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
|
||||||
</padding>
|
|
||||||
<children>
|
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="35.0" prefWidth="560.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Task name:" HBox.hgrow="ALWAYS" />
|
|
||||||
<TextField fx:id="taskName_field" promptText="Task Name" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<HBox prefHeight="77.0" prefWidth="350.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Description:" HBox.hgrow="ALWAYS" />
|
|
||||||
<TextArea fx:id="description_area" prefHeight="73.0" prefWidth="206.0" promptText="Description" wrapText="true" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Start Date:" HBox.hgrow="ALWAYS" />
|
|
||||||
<DatePicker fx:id="start_datePicker" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="143.0" prefHeight="35.0" prefWidth="560.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="End Date:" HBox.hgrow="ALWAYS" />
|
|
||||||
<DatePicker fx:id="end_datePicker" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0">
|
|
||||||
<children>
|
|
||||||
<Label maxWidth="1.7976931348623157E308" text="Interval:" HBox.hgrow="ALWAYS" />
|
|
||||||
<TextField fx:id="interval_field" promptText="Interval (e.g. 0, 1, 3 ...)" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.TextField?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="64.0" prefWidth="298.0" xmlns="http://javafx.com/javafx/17"
|
|
||||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.TextFieldFormularController">
|
|
||||||
<children>
|
|
||||||
<HBox alignment="CENTER" layoutX="153.0" layoutY="33.0" prefHeight="100.0" prefWidth="200.0" spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<children>
|
|
||||||
<Label fx:id="description_label" maxWidth="1.7976931348623157E308" text="Label" HBox.hgrow="ALWAYS" />
|
|
||||||
<TextField fx:id="text_area" HBox.hgrow="NEVER" />
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
|
@ -1,174 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.Insets?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.ButtonBar?>
|
|
||||||
<?import javafx.scene.control.CheckBox?>
|
|
||||||
<?import javafx.scene.control.Separator?>
|
|
||||||
<?import javafx.scene.image.ImageView?>
|
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.StackPane?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
|
||||||
<?import javafx.scene.text.Text?>
|
|
||||||
<?import javafx.scene.text.TextFlow?>
|
|
||||||
|
|
||||||
<BorderPane maxHeight="470.0" maxWidth="724.0" minHeight="470.0" minWidth="724.0" prefHeight="470.0" prefWidth="724.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.gartenverwaltung.TutorialController">
|
|
||||||
<bottom>
|
|
||||||
<HBox alignment="CENTER" prefHeight="0.0" prefWidth="724.0" BorderPane.alignment="CENTER">
|
|
||||||
<children>
|
|
||||||
<CheckBox mnemonicParsing="false" text="Don't show again" />
|
|
||||||
<Separator prefWidth="50.0" visible="false" HBox.hgrow="ALWAYS" />
|
|
||||||
<ButtonBar prefHeight="40.0" prefWidth="200.0">
|
|
||||||
<buttons>
|
|
||||||
<Button cancelButton="true" contentDisplay="CENTER" graphicTextGap="5.0" mnemonicParsing="false" onAction="#closeTutorial" styleClass="button-class" text="Close" />
|
|
||||||
<Button fx:id="previousPageButton" mnemonicParsing="false" onAction="#viewPreviousPage" styleClass="button-class" text="Previous" />
|
|
||||||
<Button fx:id="nextPageButton" defaultButton="true" mnemonicParsing="false" onAction="#viewNextPage" styleClass="button-class" text="Next" />
|
|
||||||
</buttons>
|
|
||||||
</ButtonBar>
|
|
||||||
</children>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
|
|
||||||
</padding>
|
|
||||||
</HBox>
|
|
||||||
</bottom>
|
|
||||||
<center>
|
|
||||||
<StackPane fx:id="tourPages" prefHeight="150.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
|
||||||
<children>
|
|
||||||
<VBox layoutX="30.0" layoutY="26.0" opacity="0.0" prefHeight="200.0" prefWidth="100.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Adding Crops">
|
|
||||||
<font>
|
|
||||||
<Font size="24.0" />
|
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Separator prefWidth="200.0">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="15.0" top="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Separator>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="In the "My Garden" tab, you can see all of the plants you're planning on growing.">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="20.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Text>
|
|
||||||
<HBox prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<TextFlow lineSpacing="4.0" prefHeight="90.0" prefWidth="500.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="To get started, click on the "Add new Plant" button in the bottom left. This will open a list of all the plants you can grow. Use the search bar at the top, the filters on the left, or simply browse the list until you've found a plant you want to grow in your garden." wrappingWidth="345.80316162109375" />
|
|
||||||
</children>
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets bottom="20.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</TextFlow>
|
|
||||||
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
|
||||||
<ImageView fx:id="imgAddNewPlant" fitHeight="98.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
<HBox prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Once you've found what you're looking for, click the "Select Sow/Harvest Date" button at the bottom of the window. In the subsequently shown dialog, you can select the date you'd like to sow or harvest the crop. The date selector shows possible dates in green. Confirm your selection with the "Save" button." />
|
|
||||||
</children>
|
|
||||||
</TextFlow>
|
|
||||||
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
|
||||||
<ImageView fx:id="imgSelectDate" fitHeight="150.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
<opaqueInsets>
|
|
||||||
<Insets />
|
|
||||||
</opaqueInsets>
|
|
||||||
</VBox>
|
|
||||||
<VBox layoutX="30.0" layoutY="30.0" prefHeight="200.0" prefWidth="100.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Crops">
|
|
||||||
<font>
|
|
||||||
<Font size="24.0" />
|
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Separator prefWidth="200.0">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="15.0" top="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Separator>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Once you've added a crop to your garden, it will be displayed in the "My Garden" tab.">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="20.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Text>
|
|
||||||
<HBox prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="On the right hand side of the listing, you'll see two buttons. Button with the "trash can" icon lets you remove a crop from your garden plan. This will also delete all associated tasks. The button on the left will display the details of the crop in a new window." />
|
|
||||||
</children>
|
|
||||||
</TextFlow>
|
|
||||||
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
|
||||||
<ImageView fitHeight="70.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true" fx:id="imgDetailDeleteButtons"/>
|
|
||||||
</children></HBox>
|
|
||||||
<HBox layoutX="10.0" layoutY="105.0" prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<TextFlow lineSpacing="4.0" prefHeight="200.0" prefWidth="500.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Here, you can also add your own custom tasks, by clicking the "Add Task" button. In the subsequently shown dialog, you can enter the corresponding details. Note: If you want to make a task recurring, you need to set both an interval (in days) AND an end date, so the task won't repeat for all eternity." />
|
|
||||||
</children>
|
|
||||||
</TextFlow>
|
|
||||||
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
|
||||||
<ImageView fitHeight="150.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" fx:id="imgAddTaskButton"/>
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
<opaqueInsets>
|
|
||||||
<Insets />
|
|
||||||
</opaqueInsets>
|
|
||||||
</VBox>
|
|
||||||
<VBox opacity="0.0" prefHeight="200.0" prefWidth="100.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Managing Your Tasks">
|
|
||||||
<font>
|
|
||||||
<Font size="24.0" />
|
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Separator prefWidth="200.0">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="15.0" top="10.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Separator>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="In the "My Schedule" tab, you can see all of the tasks you need to complete for a successful harvest.">
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="20.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</Text>
|
|
||||||
<HBox prefHeight="100.0" prefWidth="200.0">
|
|
||||||
<children>
|
|
||||||
<TextFlow lineSpacing="4.0" prefHeight="90.0" prefWidth="500.0">
|
|
||||||
<children>
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="You can view the tasks for a specific crop by selecting it from the left sidebar. To see all tasks again, click the "Clear Filter" button at the bottom." wrappingWidth="345.80316162109375" />
|
|
||||||
</children>
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets bottom="20.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</TextFlow>
|
|
||||||
<Separator prefWidth="200.0" visible="false" HBox.hgrow="ALWAYS" />
|
|
||||||
<ImageView fx:id="imgTaskList" fitHeight="200.0" fitWidth="400.0" pickOnBounds="true" preserveRatio="true" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
<opaqueInsets>
|
|
||||||
<Insets />
|
|
||||||
</opaqueInsets>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
<BorderPane.margin>
|
|
||||||
<Insets />
|
|
||||||
</BorderPane.margin>
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
|
||||||
</padding>
|
|
||||||
</StackPane>
|
|
||||||
</center>
|
|
||||||
</BorderPane>
|
|
|
@ -1,86 +0,0 @@
|
||||||
.myDialog *.header-panel,
|
|
||||||
.myDialog *.header-panel .label {
|
|
||||||
-fx-background-color: #D3FFB5;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
}
|
|
||||||
.myDialog {
|
|
||||||
-fx-background-color: #EAFFE2;
|
|
||||||
-fx-border-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .button {
|
|
||||||
-fx-border-color: darkgreen;
|
|
||||||
-fx-border-radius: 4;
|
|
||||||
-fx-border-width: 1.5;
|
|
||||||
-fx-background-color: #D1FFB7;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
-fx-font-size: 13
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .check-box .box {
|
|
||||||
-fx-background-color: #D3FFB5;
|
|
||||||
-fx-border-color:grey;
|
|
||||||
-fx-border-radius: 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box .list-cell
|
|
||||||
{
|
|
||||||
-fx-background-color: #D1FFB7;
|
|
||||||
-fx-text-fill: -fx-text-base-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box-popup .list-view
|
|
||||||
{
|
|
||||||
-fx-background-color: darkgreen, darkgreen;
|
|
||||||
-fx-background-insets: 0, 1;
|
|
||||||
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 8, 0.0 , 0 , 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box-popup .list-view .list-cell
|
|
||||||
{
|
|
||||||
-fx-padding: 4 0 4 5;
|
|
||||||
|
|
||||||
/* No alternate highlighting */
|
|
||||||
-fx-background-color: #EAFFE2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box-popup .list-view .list-cell:filled:selected, .combo-box-popup .list-view .list-cell:filled:selected:hover
|
|
||||||
{
|
|
||||||
-fx-background: -fx-accent;
|
|
||||||
-fx-text-fill: black;
|
|
||||||
-fx-background-color: #D1FFB7;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box-popup .list-view .list-cell:filled:hover
|
|
||||||
{
|
|
||||||
-fx-text-fill: black;
|
|
||||||
-fx-background-color: #54B91C;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box-base {
|
|
||||||
-fx-border-color: grey;
|
|
||||||
-fx-background-color: #D1FFB7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .combo-box-base:hover
|
|
||||||
{
|
|
||||||
-fx-color: #54B91C;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .radio-button .radio {
|
|
||||||
-fx-background-color: #D3FFB5;
|
|
||||||
-fx-border-color:grey;
|
|
||||||
-fx-border-radius: 25;
|
|
||||||
}
|
|
||||||
|
|
||||||
.myDialog .date-picker .button {
|
|
||||||
-fx-border-color: none;
|
|
||||||
-fx-background-color: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
.button-class {
|
|
||||||
-fx-border-color: darkgreen;
|
|
||||||
-fx-border-radius: 4;
|
|
||||||
-fx-border-width: 1.5;
|
|
||||||
-fx-background-color: #D1FFB7;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
-fx-font-size: 13
|
|
||||||
}
|
|
||||||
|
|
||||||
#home_button, #myGarden_button,
|
|
||||||
#mySchedule_button, #settings_button,
|
|
||||||
#tutorial_button, #menu_pane {
|
|
||||||
-fx-text-fill: white;
|
|
||||||
-fx-background-color: rgb(0,128,0);
|
|
||||||
-fx-border-color: rgb(0,128,0);
|
|
||||||
-fx-border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#menubar {
|
|
||||||
-fx-background-color: rgb(0,128,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#home_button:hover, #myGarden_button:hover,
|
|
||||||
#mySchedule_button:hover, #settings_button:hover,
|
|
||||||
#tutorial_button:hover {
|
|
||||||
-fx-background-color: darkgreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
.root, .scroll-pane, #homeVBox, #cropDetailVBox {
|
|
||||||
-fx-background-color: #F3FFEC;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view {
|
|
||||||
-fx-border-color: black;
|
|
||||||
-fx-background-color: #EAFFE2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-cell:even:filled:selected:focused .label,
|
|
||||||
.list-cell:even:filled:selected .label,
|
|
||||||
.list-cell:even {
|
|
||||||
-fx-background-color: #EAFFE2;
|
|
||||||
-fx-text-fill: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-cell:odd:filled:selected:focused .label,
|
|
||||||
.list-cell:odd:filled:selected .label,
|
|
||||||
.list-cell:odd {
|
|
||||||
-fx-background-color: #D3FFB5;
|
|
||||||
-fx-text-fill: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
#list_plants .list-cell:even:filled:selected:focused,
|
|
||||||
#list_plants .list-cell:even:filled:selected,
|
|
||||||
#list_plants .list-cell:odd:filled:selected:focused,
|
|
||||||
#list_plants .list-cell:odd:filled:selected,
|
|
||||||
#scheduledPlants_listview .list-cell:even:filled:selected:focused,
|
|
||||||
#scheduledPlants_listview .list-cell:even:filled:selected,
|
|
||||||
#scheduledPlants_listview .list-cell:odd:filled:selected:focused,
|
|
||||||
#scheduledPlants_listview .list-cell:odd:filled:selected{
|
|
||||||
-fx-background-color: #7CD14B;
|
|
||||||
-fx-text-fill: white;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vbox, .custom-container {
|
|
||||||
-fx-background-color: #EAFFE2;
|
|
||||||
-fx-border-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.titled-pane > .title {
|
|
||||||
-fx-background-color: #D3FFB5;
|
|
||||||
-fx-border-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-title {
|
|
||||||
-fx-font-size: 20;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-button .radio {
|
|
||||||
-fx-background-color: #D3FFB5;
|
|
||||||
-fx-border-color:grey;
|
|
||||||
-fx-border-radius: 25;
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
|
||||||
|
fx:controller="ch.zhaw.gartenverwaltung.HelloController">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||||
|
</padding>
|
||||||
|
|
||||||
|
<Label fx:id="welcomeText"/>
|
||||||
|
<Button text="Hello!" onAction="#onHelloButtonClick"/>
|
||||||
|
</VBox>
|
Before Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 26 KiB |
|
@ -14,11 +14,6 @@
|
||||||
"measures": "Less water."
|
"measures": "Less water."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 25,
|
|
||||||
"interval": null,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"lifecycle": [
|
"lifecycle": [
|
||||||
{
|
{
|
||||||
"startDate": "03-10",
|
"startDate": "03-10",
|
||||||
|
@ -26,13 +21,19 @@
|
||||||
"type": "SOW",
|
"type": "SOW",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 0,
|
||||||
|
"interval": null,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "Germinate",
|
"name": "Germinate",
|
||||||
"relativeStartDate": -14,
|
"relativeStartDate": -14,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
||||||
"interval": null
|
"interval": null,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -42,13 +43,19 @@
|
||||||
"type": "PLANT",
|
"type": "PLANT",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 25,
|
||||||
|
"interval": 7,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "hilling",
|
"name": "hilling",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
||||||
"interval": 21
|
"interval": 21,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -58,13 +65,19 @@
|
||||||
"type": "HARVEST",
|
"type": "HARVEST",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 0,
|
||||||
|
"interval": null,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "Harvest",
|
"name": "Harvest",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
||||||
"interval": null
|
"interval": null,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -75,11 +88,6 @@
|
||||||
"name": "Early Carrot",
|
"name": "Early Carrot",
|
||||||
"description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.",
|
"description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.",
|
||||||
"image": "carrot.jpg",
|
"image": "carrot.jpg",
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 15,
|
|
||||||
"interval": 3,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"lifecycle": [
|
"lifecycle": [
|
||||||
{
|
{
|
||||||
"startDate": "02-20",
|
"startDate": "02-20",
|
||||||
|
@ -87,14 +95,19 @@
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"type": "SOW",
|
"type": "SOW",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 15,
|
||||||
|
"interval": 3,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "hilling",
|
"name": "hilling",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 0,
|
"relativeEndDate": 0,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": null
|
"interval": null,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -104,13 +117,21 @@
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"type": "PLANT",
|
"type": "PLANT",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 25,
|
||||||
|
"interval": 3,
|
||||||
|
"notes": [
|
||||||
|
"Be careful not to pour water over the leaves, as this will lead to sunburn."
|
||||||
|
]
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "hilling",
|
"name": "hilling",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": 15
|
"interval": 15,
|
||||||
|
"isOptional": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -120,13 +141,19 @@
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"type": "HARVEST",
|
"type": "HARVEST",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 0,
|
||||||
|
"interval": null,
|
||||||
|
"notes": []
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "Harvesting",
|
"name": "Harvesting",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 14,
|
"relativeEndDate": 14,
|
||||||
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
|
||||||
"interval": null
|
"interval": null,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -146,12 +173,6 @@
|
||||||
"name": "Summertime Onion",
|
"name": "Summertime Onion",
|
||||||
"description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
|
"description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
|
||||||
"image": "onion.jpg",
|
"image": "onion.jpg",
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 15,
|
|
||||||
"interval": 4,
|
|
||||||
"notes": [
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"lifecycle": [
|
"lifecycle": [
|
||||||
{
|
{
|
||||||
"startDate": "03-15",
|
"startDate": "03-15",
|
||||||
|
@ -159,13 +180,21 @@
|
||||||
"type": "SOW",
|
"type": "SOW",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 15,
|
||||||
|
"interval": 4,
|
||||||
|
"notes": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "Plant Sets",
|
"name": "hilling",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 0,
|
"relativeEndDate": 0,
|
||||||
"description": "Plant the sets about 5cm deep into the soil.",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": null
|
"interval": null,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -175,13 +204,21 @@
|
||||||
"type": "PLANT",
|
"type": "PLANT",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 25,
|
||||||
|
"interval": 3,
|
||||||
|
"notes": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "hilling",
|
"name": "hilling",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": null,
|
"relativeEndDate": null,
|
||||||
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
|
||||||
"interval": 15
|
"interval": 15,
|
||||||
|
"isOptional": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -191,13 +228,21 @@
|
||||||
"type": "HARVEST",
|
"type": "HARVEST",
|
||||||
"zone": "ZONE_8A",
|
"zone": "ZONE_8A",
|
||||||
"group": 0,
|
"group": 0,
|
||||||
|
"wateringCycle": {
|
||||||
|
"litersPerSqM": 0,
|
||||||
|
"interval": null,
|
||||||
|
"notes": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
"taskTemplates": [
|
"taskTemplates": [
|
||||||
{
|
{
|
||||||
"name": "Harvesting",
|
"name": "Harvesting",
|
||||||
"relativeStartDate": 0,
|
"relativeStartDate": 0,
|
||||||
"relativeEndDate": 14,
|
"relativeEndDate": 14,
|
||||||
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
|
||||||
"interval": null
|
"interval": null,
|
||||||
|
"isOptional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -211,77 +256,5 @@
|
||||||
"measures": "less water"
|
"measures": "less water"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 3,
|
|
||||||
"name": "Test Potato",
|
|
||||||
"description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.",
|
|
||||||
"light": 6,
|
|
||||||
"spacing": "35",
|
|
||||||
"soil": "sandy",
|
|
||||||
"image": "potato.jpg",
|
|
||||||
"pests": [
|
|
||||||
{
|
|
||||||
"name": "Rot",
|
|
||||||
"description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
|
|
||||||
"measures": "Less water."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"wateringCycle": {
|
|
||||||
"litersPerSqM": 0,
|
|
||||||
"interval": null,
|
|
||||||
"notes": []
|
|
||||||
},
|
|
||||||
"lifecycle": [
|
|
||||||
{
|
|
||||||
"startDate": "12-01",
|
|
||||||
"endDate": "12-19",
|
|
||||||
"type": "SOW",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "Germinate",
|
|
||||||
"relativeStartDate": -3,
|
|
||||||
"relativeEndDate": 0,
|
|
||||||
"description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.",
|
|
||||||
"interval": null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "12-03",
|
|
||||||
"endDate": "12-22",
|
|
||||||
"type": "PLANT",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "hilling",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": 10,
|
|
||||||
"description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.",
|
|
||||||
"interval": 1
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"startDate": "12-16",
|
|
||||||
"endDate": "12-30",
|
|
||||||
"type": "HARVEST",
|
|
||||||
"zone": "ZONE_8A",
|
|
||||||
"group": 0,
|
|
||||||
"taskTemplates": [
|
|
||||||
{
|
|
||||||
"name": "Harvest",
|
|
||||||
"relativeStartDate": 0,
|
|
||||||
"relativeEndDate": 4,
|
|
||||||
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
|
|
||||||
"interval": null
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,68 +1,56 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id" : 1,
|
||||||
"name": "sow plant",
|
"name" : "sow plant",
|
||||||
"description": "Plant the seeds, crops in de bed.",
|
"description": "Plant the seeds, crops in de bed.",
|
||||||
"startDate": "2022-05-01",
|
"startDate" : "2022-05-01",
|
||||||
"nextExecution": "2022-05-01",
|
"endDate" : "2022-05-01",
|
||||||
"nextNotification": "2022-05-01",
|
"interval" : 0,
|
||||||
"endDate": "2022-05-01",
|
"cropId" : 0
|
||||||
"interval": null,
|
|
||||||
"cropId": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id" : 2,
|
||||||
"name": "water plant",
|
"name" : "water plant",
|
||||||
"description": "water the plant, so that the soil is wet around the plant.",
|
"description": "water the plant, so that the soil is wet around the plant.",
|
||||||
"startDate": "2022-10-29",
|
"startDate" : "2022-05-01",
|
||||||
"nextExecution": "2022-11-30",
|
"endDate" : "2022-09-01",
|
||||||
"nextNotification": "2022-05-01",
|
"interval" : 2,
|
||||||
"endDate": "2022-12-31",
|
"cropId" : 0
|
||||||
"interval": 2,
|
|
||||||
"cropId": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id" : 3,
|
||||||
"name": "fertilize plant",
|
"name" : "fertilize plant",
|
||||||
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
||||||
"startDate": "2022-06-01",
|
"startDate" : "2022-06-01",
|
||||||
"nextExecution": "2022-06-01",
|
"endDate" : "2022-08-01",
|
||||||
"nextNotification": "2022-06-01",
|
"interval" : 28,
|
||||||
"endDate": "2022-08-01",
|
"cropId" : 0
|
||||||
"interval": 28,
|
|
||||||
"cropId": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 4,
|
"id" : 4,
|
||||||
"name": "covering plant",
|
"name" : "covering plant",
|
||||||
"description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage",
|
"description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage",
|
||||||
"startDate": "2022-07-01",
|
"startDate" : "2022-07-01",
|
||||||
"nextExecution": "2022-07-01",
|
"endDate" : "2022-07-01",
|
||||||
"nextNotification": "2022-07-01",
|
"interval" : 0,
|
||||||
"endDate": "2022-07-01",
|
"cropId" : 0
|
||||||
"interval": null,
|
|
||||||
"cropId": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 5,
|
"id" : 5,
|
||||||
"name": "look after plant",
|
"name" : "look after plant",
|
||||||
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
||||||
"startDate": "2022-05-01",
|
"startDate" : "2022-05-01",
|
||||||
"nextExecution": "2022-05-01",
|
"endDate" : "2022-09-01",
|
||||||
"nextNotification": "2022-05-01",
|
"interval" : 5,
|
||||||
"endDate": "2022-09-01",
|
"cropId" : 0
|
||||||
"interval": 5,
|
|
||||||
"cropId": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 6,
|
"id" : 6,
|
||||||
"name": "harvest plant",
|
"name" : "harvest plant",
|
||||||
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
||||||
"startDate": "2022-09-01",
|
"startDate" : "2022-09-01",
|
||||||
"nextExecution": "2022-09-01",
|
"endDate" : "2022-09-01",
|
||||||
"nextNotification": "2022-09-01",
|
"interval" : 0,
|
||||||
"endDate": "2022-09-01",
|
"cropId" : 0
|
||||||
"interval": null,
|
|
||||||
"cropId": 0
|
|
||||||
}
|
}
|
||||||
]
|
]
|
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 34 KiB |