BrightSide Workbench Full Report + Source Code
CrossTabRegisterByUserGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2013 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 
19 package org.turro.zul.log;
20 
21 import java.util.TreeMap;
22 import org.turro.string.ObjectString;
23 import org.turro.contacts.log.CrossTabRegisterByUser;
24 import org.turro.elephant.util.DateFormats;
25 import org.turro.i18n.I_;
26 import org.turro.plugin.log.ILogRegister;
27 import org.turro.zkoss.layout.GridLayout;
28 
33 public class CrossTabRegisterByUserGrid extends GridLayout {
34 
35  private CrossTabRegisterByUser register;
36 
38  this.register = register;
39  addColumns();
40  addRows();
41  }
42 
44  return register;
45  }
46 
47  private void addColumns() {
48  setColumns("1,min,right-min,right-min,right-min,right-min,right-min,right-min,right-min,right-min");
49  setColCaptions(new String[] {
50  I_.get("Name"),
51  I_.get("Last login"),
52  I_.get("Login"),
53  I_.get("Save"),
54  I_.get("Sent"),
55  I_.get("Delete"),
56  I_.get("Upload"),
57  I_.get("Download"),
58  I_.get("Subscribed"),
59  I_.get("Unsubscribed")
60  });
61  }
62 
63  private void addRows() {
64  for(String name : register.keySet()) {
65  addCaption(name);
66  TreeMap<String, ILogRegister> comment = register.get(name);
67  if(comment.containsKey("/log/in")) {
68  ILogRegister lr = comment.get("/log/in");
69  addValue(DateFormats.format(lr.getDateLog(), false));
70  addValue(ObjectString.formatObject(lr.getCount(), null, true));
71  } else {
72  addSpace();
73  addSpace();
74  }
75  if(comment.containsKey("saved")) {
76  ILogRegister lr = comment.get("saved");
77  addValue(ObjectString.formatObject(lr.getCount(), null, true));
78  } else {
79  addSpace();
80  }
81  if(comment.containsKey("sent")) {
82  ILogRegister lr = comment.get("sent");
83  addValue(ObjectString.formatObject(lr.getCount(), null, true));
84  } else {
85  addSpace();
86  }
87  if(comment.containsKey("deleted")) {
88  ILogRegister lr = comment.get("deleted");
89  addValue(ObjectString.formatObject(lr.getCount(), null, true));
90  } else {
91  addSpace();
92  }
93  if(comment.containsKey("uploaded")) {
94  ILogRegister lr = comment.get("uploaded");
95  addValue(ObjectString.formatObject(lr.getCount(), null, true));
96  } else {
97  addSpace();
98  }
99  if(comment.containsKey("downloaded")) {
100  ILogRegister lr = comment.get("downloaded");
101  addValue(ObjectString.formatObject(lr.getCount(), null, true));
102  } else {
103  addSpace();
104  }
105  if(comment.containsKey("subscribed")) {
106  ILogRegister lr = comment.get("subscribed");
107  addValue(ObjectString.formatObject(lr.getCount(), null, true));
108  } else {
109  addSpace();
110  }
111  if(comment.containsKey("unsubscribed")) {
112  ILogRegister lr = comment.get("unsubscribed");
113  addValue(ObjectString.formatObject(lr.getCount(), null, true));
114  } else {
115  addSpace();
116  }
117  addRow();
118  }
119  }
120 
121 }
static String get(String msg)
Definition: I_.java:41
void setColCaptions(String captions)
Definition: GridLayout.java:94
GridLayout addCaption(String label)
GridLayout addValue(String value)
CrossTabRegisterByUserGrid(CrossTabRegisterByUser register)