BrightSide Workbench Full Report + Source Code
RegisterSelfSummary.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.contacts.command;
20 
21 import java.util.Collection;
22 import org.turro.contacts.log.CrossTabRegisterByUser;
23 import org.turro.elephant.context.Application;
24 import org.turro.elephant.util.Images;
25 import org.turro.i18n.I_;
26 import org.turro.plugin.command.SelfSummaryPlugin;
27 import org.turro.plugin.log.ILogRegister;
28 import org.turro.plugin.log.LogUtil;
29 import org.turro.zkoss.label.LabelTypes;
30 import org.turro.zkoss.layout.GroupboxArrow;
31 import org.turro.zul.log.CrossTabRegisterByUserGrid;
32 import org.zkoss.zul.Hlayout;
33 import org.zkoss.zul.Image;
34 import org.zkoss.zul.Space;
35 
40 //@ElephantPlugin
41 public class RegisterSelfSummary extends SelfSummaryPlugin {
42 
43  private CrossTabRegisterByUser register;
44 
45  @Override
46  protected void executePlugin() {
48  if(app.isInRole("contact:log")) {
49  GroupboxArrow gba = new GroupboxArrow() {
50  @Override
51  protected void doFillContent() {
52  loadRegister();
54  appendChild(crossTab);
55  }
56  };
57  Hlayout hbox = new Hlayout();
58  gba.setCaption(hbox);
59  hbox.setSclass("z-valign-middle");
60  hbox.setValign("middle");
61  hbox.appendChild(new Image(Images.getImage("log")));
62  hbox.appendChild(LabelTypes.getSoftLabel(I_.get("Log")));
63  hbox.appendChild(new Space());
64  gba.setOpen(false);
65  addResult("register", gba);
66  }
67  }
68 
69  public void loadRegister() {
70  Collection<ILogRegister> regs = LogUtil.load(null, null, LogUtil.GROUP_USER, null);
71  regs.addAll(LogUtil.loadLogin());
72  register = new CrossTabRegisterByUser();
73  register.addRegisters(regs);
74  }
75 
76 }
Object addResult(String key, Object value)
static String getImage(String image)
Definition: Images.java:36
static String get(String msg)
Definition: I_.java:41
static Collection< ILogRegister > load(LogType type, String pathOrigin, int group, String comment)
static Label getSoftLabel(String value)
Definition: LabelTypes.java:28