From 870d09d2722848f468a70281431bc5d0f7a30605 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Thu, 28 Sep 2023 00:16:33 +0200 Subject: [PATCH] fix: improve minor issues in Gantt --- src/net/sourceforge/plantuml/project/GanttDiagram.java | 2 +- .../plantuml/project/lang/SentenceTaskEndsAbsolute.java | 8 ++++---- .../plantuml/project/lang/SentenceTaskStarts.java | 4 ++-- .../plantuml/project/lang/SentenceTaskStartsAbsolute.java | 8 ++++---- .../sourceforge/plantuml/project/lang/SubjectProject.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/net/sourceforge/plantuml/project/GanttDiagram.java b/src/net/sourceforge/plantuml/project/GanttDiagram.java index 3690ed306..fdc8a18c0 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagram.java @@ -662,7 +662,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprit return colorSet; } - public void setStartingDate(Day start) { + public void setProjectStartingDate(Day start) { openClose.setStartingDay(start); this.min = start; } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java index 101c186de..484f7a41b 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java @@ -50,11 +50,11 @@ public class SentenceTaskEndsAbsolute extends SentenceSimple { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Task task = (Task) subject; final Day end = (Day) complement; -// final Day startingDate = project.getStartingDate(); -// if (startingDate == null) { -// return CommandExecutionResult.error("No starting date for the project"); -// } + final Day startingDate = project.getStartingDate(); + if (startingDate.getAbsoluteDayNum() == 0) + return CommandExecutionResult.error("No starting date for the project"); task.setEnd(end); + return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java index 029b7d625..8737f4020 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStarts.java @@ -56,10 +56,10 @@ public class SentenceTaskStarts extends SentenceSimple { HColor color = null; when = (TaskInstant) complement; task.setStart(when.getInstantPrecise()); - if (when.isTask()) { + if (when.isTask()) project.addContraint(new GanttConstraint(project.getIHtmlColorSet(), project.getCurrentStyleBuilder(), when, new TaskInstant(task, TaskAttribute.START), color)); - } + return CommandExecutionResult.ok(); }; diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java index daa316ebe..e535412e0 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java @@ -50,10 +50,10 @@ public class SentenceTaskStartsAbsolute extends SentenceSimple { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Task task = (Task) subject; final Day start = (Day) complement; -// final Day startingDate = project.getStartingDate(); -// if (startingDate == null) { -// return CommandExecutionResult.error("No starting date for the project"); -// } + final Day startingDate = project.getStartingDate(); + if (startingDate.getAbsoluteDayNum() == 0) + project.setProjectStartingDate(start); + task.setStart(start); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectProject.java b/src/net/sourceforge/plantuml/project/lang/SubjectProject.java index a31264131..7b7a29c4d 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectProject.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectProject.java @@ -75,7 +75,7 @@ public class SubjectProject implements Subject { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Day start = (Day) complement; assert project == subject; - project.setStartingDate(start); + project.setProjectStartingDate(start); return CommandExecutionResult.ok(); }