BrightSide Workbench Full Report + Source Code
DossierActivityGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.dossier.zul.dossier;
19 
20 import org.turro.dossier.dossier.DossierActivitySet;
21 import org.turro.dossier.entity.Dossier;
22 import org.turro.dossier.entity.Issue;
23 import org.turro.dossier.entity.IssueComment;
24 import org.turro.dossier.zul.issue.IssueDetailRow;
25 import org.turro.i18n.I_;
26 import org.turro.zkoss.grid.GroupExtended;
27 import org.turro.zkoss.grid.PagingGrid;
28 import org.zkoss.zul.Column;
29 import org.zkoss.zul.Columns;
30 import org.zkoss.zul.Group;
31 import org.zkoss.zul.Rows;
32 
37 public class DossierActivityGrid extends PagingGrid {
38 
39  private Rows rows;
40 
42  addColumns();
43  }
44 
45  public void setDossier(Dossier dossier) {
46  addRows(dossier);
47  }
48 
49  private void addColumns() {
50  Columns cols = new Columns();
51  cols.setSizable(true);
52  cols.setMenupopup("auto");
53  appendChild(cols);
54 
55  Column col = new Column(I_.get("Modification"));
56  col.setWidth("180px");
57  cols.appendChild(col);
58  col = new Column(I_.get("Comment"));
59  cols.appendChild(col);
60  }
61 
62  private void addRows(Dossier dossier) {
63 
64  if(rows != null) removeChild(rows);
65 
66  rows = new Rows();
67  appendChild(rows);
68 
69  DossierActivitySet ids = new DossierActivitySet(dossier);
70 
71  setRowCount(ids.size());
72 
73  Issue lastIssue = null;
74 
75  for(Object obj : ids) {
76  if(obj instanceof IssueComment) {
77  IssueComment c = (IssueComment) obj;
78  if(lastIssue == null || !c.getIssue().getId().equals(lastIssue.getId())) {
79  lastIssue = c.getIssue();
80  Group group = new GroupExtended("#" + lastIssue.getId() + " " + lastIssue.getDescription());
81  rows.appendChild(group);
82  }
83  }
84  IssueDetailRow row = new IssueDetailRow(lastIssue);
85  row.setValue(obj);
86  rows.appendChild(row);
87  }
88  }
89 
90 }
91 
static String get(String msg)
Definition: I_.java:41