fix of zero interval

This commit is contained in:
giavaphi 2022-11-28 00:50:41 +01:00
parent 6d24687f7b
commit e9258fb238
5 changed files with 26 additions and 16 deletions

View File

@ -22,6 +22,7 @@ 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.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -205,22 +206,28 @@ public class CropDetailController {
} }
private HBox createTaskHBox(Task task) { private HBox createTaskHBox(Task task) {
HBox hBox = new HBox(); HBox hBox = new HBox(10);
Label taskName = new Label(task.getName()+": "); Label taskName = new Label(task.getName()+": ");
taskName.setMinWidth(100);
taskName.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
taskName.setStyle("-fx-font-weight: bold"); taskName.setStyle("-fx-font-weight: bold");
Label taskDescription = new Label(task.getDescription()); Label taskDescription = new Label(task.getDescription());
taskDescription.setWrapText(true); taskDescription.setWrapText(true);
taskDescription.setMaxWidth(2000); taskDescription.setMaxSize(600, Double.MAX_VALUE);
HBox.setHgrow(taskDescription, Priority.ALWAYS); Pane puffer = new Pane();
HBox.setHgrow(puffer, Priority.ALWAYS);
Button edit = new Button(); Button edit = new Button();
Button delete = new Button(); Button delete = new Button();
HBox.setHgrow(edit, Priority.NEVER);
HBox.setHgrow(delete, Priority.NEVER);
setIconToButton(edit, "editIcon.png"); setIconToButton(edit, "editIcon.png");
setIconToButton(delete, "deleteIcon.png"); setIconToButton(delete, "deleteIcon.png");
edit.setOnAction(getEditTaskEvent(task)); edit.setOnAction(getEditTaskEvent(task));
delete.setOnAction(deleteTask(task)); delete.setOnAction(deleteTask(task));
hBox.getChildren().addAll(taskName, taskDescription, edit, delete); hBox.getChildren().addAll(taskName, taskDescription, puffer, edit, delete);
return hBox; return hBox;
} }
@ -229,12 +236,15 @@ public class CropDetailController {
label.setStyle("-fx-font-weight: bold"); label.setStyle("-fx-font-weight: bold");
HBox hBox = new HBox(); HBox hBox = new HBox();
hBox.fillHeightProperty(); hBox.fillHeightProperty();
Label label1 = new Label(pest.description()); Label description = new Label(pest.description());
label1.setAlignment(Pos.TOP_LEFT); description.setAlignment(Pos.TOP_LEFT);
label1.setWrapText(true); description.setWrapText(true);
label1.setMaxWidth(600); description.setMaxWidth(600);
Pane puffer = new Pane();
HBox.setHgrow(puffer, Priority.ALWAYS);
Button button = new Button("Get Counter Measures"); Button button = new Button("Get Counter Measures");
hBox.getChildren().addAll(label, label1, button); HBox.setHgrow(button, Priority.NEVER);
hBox.getChildren().addAll(label, description, puffer, button);
return hBox; return hBox;
} }

View File

@ -151,6 +151,7 @@ public class GardenSchedule {
if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) { if (date.equals(checkDate) && !date.isAfter(task.getEndDate().orElse(LocalDate.MIN))) {
dayTaskList.get(finalI).add(task); dayTaskList.get(finalI).add(task);
} }
if (task.getInterval().orElse(0) == 0) break;
checkDate = checkDate.plusDays(task.getInterval().orElse(0)); checkDate = checkDate.plusDays(task.getInterval().orElse(0));
} while (task.getInterval().isPresent() && checkDate.isBefore(LocalDate.now().plusDays(listLength))); } while (task.getInterval().isPresent() && checkDate.isBefore(LocalDate.now().plusDays(listLength)));
}); });

View File

@ -18,6 +18,7 @@ public class Task {
private LocalDate nextExecution; private LocalDate nextExecution;
private LocalDate nextNotification; private LocalDate nextNotification;
private long cropId; private long cropId;
private boolean done;
/** /**
* default constructor * default constructor
@ -69,7 +70,7 @@ public class Task {
} }
public void done(){ public void done(){
if(interval != null && !nextExecution.plusDays(interval).isAfter(endDate)){ if(interval != null && interval != 0 && !nextExecution.plusDays(interval).isAfter(endDate)){
nextExecution = nextExecution.plusDays(interval); nextExecution = nextExecution.plusDays(interval);
} else { } else {
nextExecution = null; nextExecution = null;

View File

@ -107,7 +107,7 @@
<Insets right="60.0" /> <Insets right="60.0" />
</HBox.margin> </HBox.margin>
</Label> </Label>
<Label fx:id="area_label" text="Label"> <Label fx:id="area_label" minWidth="-Infinity" prefWidth="50.0" text="Label">
<HBox.margin> <HBox.margin>
<Insets right="10.0" /> <Insets right="10.0" />
</HBox.margin> </HBox.margin>
@ -125,7 +125,7 @@
<Insets right="40.0" /> <Insets right="40.0" />
</HBox.margin> </HBox.margin>
</Label> </Label>
<Label fx:id="location_label" text="Label"> <Label fx:id="location_label" minHeight="-Infinity" prefWidth="50.0" text="Label">
<HBox.margin> <HBox.margin>
<Insets right="10.0" /> <Insets right="10.0" />
</HBox.margin> </HBox.margin>

View File

@ -9,9 +9,7 @@
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?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">
<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> <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"> <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> <padding>
@ -27,7 +25,7 @@
<HBox prefHeight="77.0" prefWidth="350.0"> <HBox prefHeight="77.0" prefWidth="350.0">
<children> <children>
<Label maxWidth="1.7976931348623157E308" text="Description:" HBox.hgrow="ALWAYS" /> <Label maxWidth="1.7976931348623157E308" text="Description:" HBox.hgrow="ALWAYS" />
<TextArea fx:id="description_area" prefHeight="73.0" prefWidth="206.0" promptText="Description" /> <TextArea fx:id="description_area" prefHeight="73.0" prefWidth="206.0" promptText="Description" wrapText="true" />
</children> </children>
</HBox> </HBox>
<HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0"> <HBox alignment="CENTER_LEFT" layoutX="30.0" layoutY="30.0" prefHeight="35.0" prefWidth="560.0">