BrightSide Workbench Full Report + Source Code
PubCategoryItem.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 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.publication.zul.tree;
20 
21 import java.util.Collection;
22 import org.turro.i18n.I_;
23 import org.turro.publication.entity.PublicationCategory;
24 import org.turro.publication.util.PublicationCategories;
25 import org.zkoss.zk.ui.ext.AfterCompose;
26 import org.zkoss.zul.Treechildren;
27 import org.zkoss.zul.Treeitem;
28 
33 public class PubCategoryItem extends Treeitem implements AfterCompose {
34 
35  private Treechildren children;
36 
38  super();
39  setValue(category);
40  setLabel(category == null ? I_.get("All") : category.getName());
41  setTooltiptext(getLabel());
42  }
43 
44  @Override
46  return (PubCategoryTree) super.getTree();
47  }
48 
50  return (PublicationCategory) getValue();
51  }
52 
53  public void showContents() {
54  fillCategory();
55  setOpen(true);
56  }
57 
58  public void reloadContents() {
59  if(children != null) {
60  children.getChildren().clear();
61  showContents();
62  }
63  }
64 
65  public boolean isLeaf() {
66  return getCategory() != null;
67  }
68 
70  PubCategoryItem cat = new PubCategoryItem(category);
71  children.appendChild(cat);
72  cat.afterCompose();
73  return cat;
74  }
75 
76  private void fillCategory() {
77  if(children != null && children.getChildren().isEmpty()) {
79  addCategory(cat);
80  }
81  }
82  }
83 
84  private void addChildrenSpace() {
85  if(!isLeaf()) {
86  children = new Treechildren();
87  appendChild(children);
88  fillCategory();
89  setOpen(true);
90  }
91  }
92 
93  public Collection<PublicationCategory> getCategoryChildren() {
95  }
96 
97  @Override
98  public void afterCompose() {
99  addChildrenSpace();
100  }
101 
102 }
static String get(String msg)
Definition: I_.java:41
static List< PublicationCategory > getPublicationCategories()
PubCategoryItem addCategory(PublicationCategory category)
PubCategoryItem(PublicationCategory category)
Collection< PublicationCategory > getCategoryChildren()