-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduleHtmlFileCreator.java
More file actions
141 lines (111 loc) · 4.1 KB
/
Copy pathScheduleHtmlFileCreator.java
File metadata and controls
141 lines (111 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import java.io.File;
import java.io.FileWriter;
public class ScheduleHtmlFileCreator {
TaskModel taskModel;
String content = "";
ScheduleTableCreator stc;
int lengthOfGrid;
ScheduleHtmlFileCreator(TaskModel taskModel, String projectName) throws Exception{
this.taskModel = taskModel;
stc = new ScheduleTableCreator(taskModel);
lengthOfGrid = stc.getMaxDays();
createHtmlFile(projectName);
}
public void createHtmlFile(String projectName) throws Exception{
content = "<!DOCTYPE html>\n" +
"<html>\n" +
"<head>\n" +
"<style>\n" +
"table {\n" +
" font-family: arial, sans-serif;\n" +
" border-collapse: collapse;\n" +
" width: 100%;\n" +
"}\n" +
"\n" +
"td, th {\n" +
" border: 1px solid #dddddd;\n" +
" text-align: left;\n" +
" padding: 8px;\n" +
"}\n" +
"\n" +
// "tr:nth-child(even) {\n" +
// " background-color: #dddddd;\n" +
// "}\n" +
"#selected {\n" +
" background-color: green;\n" +
"}\n" +
"</style>\n" +
"</head>\n" +
"<body>\n" +
"<table>";
printHeader();
for (int i = 0; i < taskModel.getTaskUnits().size(); i++){
printRow(i);
}
content += "</table>\n" +
"</body>\n" +
"</html>";
//..............print to file
File file = new File(Finals.PRINT_PATH + projectName + "/" +projectName+ "_grafic_de_executie.html");
file.getParentFile().mkdirs();
FileWriter fw = new FileWriter(Finals.PRINT_PATH + projectName + "/" +projectName+ "_grafic_de_executie.html");
fw.write(content);
fw.close();
}
public void printHeader(){
content += "<tr>\n";
content += "<th colspan=\"" + Finals.LENGTH_OF_TASKS_TABLE +"\"> Articole </th>\n";
for (int i = 0; i < (stc.getMaxDays() + 1) / 7; i++){ // +1 mert 0-tol van inexelve
content += "<th colspan=\"7\"> Spt. " + i + "</th>\n";
}
if ((stc.getMaxDays() + 1) % 7 != 0) // utolso, nem teljes het // +1 mert 0-tol van inexelve
{
content += "<th colspan=\"" + ((stc.getMaxDays() + 1) % 7) + "\"> Spt. " + ((stc.getMaxDays() + 1) / 7 + 1) + "</th>\n";// +1 mert 0-tol van inexelve
}
content += "</tr>\n";
content += "<tr>\n";
for (String str : Finals.TASKS_TABLE_HEADER){
content += "<th>" + str + "</th>\n";
}
for(int i = 0; i < (stc.getMaxDays() + 1) / 7; i++)
{
for (String str : Finals.WEEK_HEADER){
content += "<th>" + str + "</th>\n";
}
}
for (int i = 0; i < (stc.getMaxDays() + 1) % 7; i++){
content += "<th>" + Finals.WEEK_HEADER[i] + "</th>\n";
}
content += "</tr>\n";
}
public void printRow(int i){
TaskUnit tu = taskModel.getTaskUnits().get(i);
content += "<tr>\n";
content += "<th>";
content += "" + (i + 1); // index
content += "</th>\n";
content += "<th>";
content += tu.getUnitTitle();
content += "</th>\n";
content += "<th>";
content += tu.getUnitateMetric();
content += "</th>\n";
content += "<th>";
content += tu.getCantitate();
content += "</th>\n";
content += "<th>";
content += tu.getOre();
content += "</th>\n";
//--------------------------------------------------------tasks resz
for (int j = 0; j <= stc.getMaxDays(); j++){
if (stc.getWeeksTable()[i][j]){ // ha zold
content += "<th id=\"selected\"></th>\n";
}
else // not seleted
{
content += "<th></th>\n";
}
}
content += "</tr>\n";
}
}