19 package org.turro.dossier.gantt;
21 import java.util.Objects;
22 import org.turro.dossier.entity.Dossier;
23 import org.turro.dossier.entity.Issue;
24 import org.turro.dossier.entity.IssuePredecessor;
25 import org.turro.dossier.entity.IssuePredecessorType;
26 import org.turro.zkoss.svg.Gantt;
27 import org.turro.zkoss.svg.GanttData;
28 import org.turro.zkoss.svg.GanttItem;
29 import org.turro.zkoss.svg.GanttPredecessor;
30 import org.zkoss.zk.ui.ext.AfterCompose;
38 private String selectItem;
40 private double scale = 1.0;
41 private boolean onlyPublishable =
false;
51 this.selectItem = selectItem;
59 this.dossier = dossier;
71 return onlyPublishable;
75 this.onlyPublishable = onlyPublishable;
91 getChildren().clear();
100 private void loadData() {
101 if(dossier !=
null) {
106 private GanttData getGanttData() {
107 GanttData gd =
new GanttData();
109 dgi.setMilestone(
false);
110 dgi.setFinished(
false);
111 for(Issue issue : dossier.
getAllIssues(onlyPublishable)) {
114 for(Issue issue : dossier.
getAllIssues(onlyPublishable)) {
115 solvePredecessors(issue, gd);
121 private void addIssue(Issue issue, GanttData gd) {
122 if (onlyPublishable && !issue.isPublishable()) {
125 GanttItem gi = gd.addGanttItem(issue.getDossier().getId(),
"" + issue.getId(),
126 issue.getDescription(),
127 issue.getHours() == 0.0 ? 1.0 : issue.getHours(),
128 issue.getSumHours());
129 gi.setMilestone(issue.isMilestone());
130 gi.setFinished(issue.getStatus().isFinished());
133 private void solvePredecessors(Issue issue, GanttData gd) {
134 for(IssuePredecessor predecessor : issue.getSources()) {
135 Issue source = predecessor.getSource();
136 boolean sameSpace = Objects.equals(source.getDossier().getId(), dossier.
getId());
137 GanttPredecessor gp =
new GanttPredecessor(
138 predecessor.getType().equals(IssuePredecessorType.START_WHEN_STARTS) ?
139 GanttPredecessor.GANTT_START_TO_START :
140 GanttPredecessor.GANTT_END_TO_START,
144 addIssue(source, gd);
146 gd.getItem(
"" + issue.getId()).getPredecessors().add(gp);
String getFullDescription()
Collection< Issue > getAllIssues()
void setDossier(Dossier dossier)
void setScale(double scale)
boolean isOnlyPublishable()
void setSelectItem(String selectItem)
void setOnlyPublishable(boolean onlyPublishable)
void setData(GanttData data)
void startComposing(String onUserEvent, String width, String height, double scale)
void generateContent(Map args)