BrightSide Workbench Full Report + Source Code
SocialGroupRenderer.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 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.contacts.social;
19 
20 import java.util.List;
21 import org.turro.html.Colors;
22 import org.turro.i18n.I_;
23 import org.zkoss.zul.Listcell;
24 import org.zkoss.zul.Listgroup;
25 import org.zkoss.zul.Listgroupfoot;
26 import org.zkoss.zul.Listitem;
27 import org.zkoss.zul.ListitemRenderer;
28 
33 public class SocialGroupRenderer implements ListitemRenderer<Object> {
34 
35  @Override
36  public void render(Listitem listitem, Object obj, int index) throws Exception {
37  if (listitem instanceof Listgroup) {
38  List list = (List) obj;
39  SocialGroupValue sg = (SocialGroupValue) list.iterator().next();
40  listitem.setLabel(I_.byKey(sg.getType().name()));
41  listitem.setValue(obj);
42  } else if (listitem instanceof Listgroupfoot) {
43  listitem.setLabel("Total " + obj + " items");
44  } else {
46  listitem.setLabel(data.getName());
47  ((Listcell) listitem.getChildren().iterator().next())
48  .setIconSclass("z-icon-" + data.getType().getIcon());
49  listitem.setStyle("color:" + Colors.cssByName(data.getType().getColor()));
50  listitem.setValue(data);
51  }
52  }
53 
54 }
void render(Listitem listitem, Object obj, int index)
static String byKey(String key)
Definition: I_.java:83