BrightSide Workbench Full Report + Source Code
GroupItBandbox.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2014 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.groupit;
20 
21 import org.turro.contacts.GroupIt;
22 import org.turro.zkoss.input.GenericBandbox;
23 import org.zkoss.zk.ui.event.Event;
24 import org.zkoss.zk.ui.event.EventListener;
25 import org.zkoss.zk.ui.event.Events;
26 
31 public class GroupItBandbox extends GenericBandbox<GroupIt> {
32 
33  private String category;
34  private GroupItTree tree;
35 
36  public void setCategory(String category) {
37  this.category = category;
38  if(tree != null) {
39  tree.setCategory(category);
41  }
42  }
43 
44  @Override
45  protected void fillPopup() {
46  if(!isFilled()) {
47  getBandPopup().setHeight("350px");
48  getBandPopup().setWidth("600px");
49  setAutodrop(true);
50  tree = new GroupItTree();
51  tree.setCategory(category);
52  tree.setVflex(true);
53  tree.setHflex("1");
54  tree.addEventListener(Events.ON_SELECT, new EventListener<Event>() {
55  @Override
56  public void onEvent(Event event) {
57  getObjectValue();
58  Events.postEvent(new Event(Events.ON_CHANGE, GroupItBandbox.this));
59  GroupItBandbox.this.close();
60  }
61  });
62  setPopupComponent(tree);
63  if(value != null) {
65  }
66  }
67  }
68 
69  @Override
71  if(tree == null) {
72  return value;
73  } else {
74  GroupIt v = tree.getSelectedGroup();
75  if(v != null) {
76  setBandText(v.getPathName());
77  } else {
78  setBandText("");
79  }
80  return v;
81  }
82  }
83 
84  @Override
85  public void setObjectValue(GroupIt v) {
86  if(tree == null) {
87  value = v;
88  } else {
89  tree.setSelectedGroup(v);
90  }
91  getObjectValue();
92  }
93 
94 }
void setPopupComponent(Component component)
void setCategory(String category)