BrightSide Workbench Full Report + Source Code
ViewBandbox.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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.financials.view;
19 
20 import java.util.HashSet;
21 import org.turro.financials.entity.RegisterView;
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 import org.zkoss.zul.Hbox;
27 
32 public class ViewBandbox extends GenericBandbox<ViewSets> {
33 
34  private ViewSets sets;
35  private ViewListbox viewA, viewB;
36 
37  @Override
38  protected void fillPopup() {
39  if(!isFilled()) {
40  viewA = new ViewListbox();
41  viewA.setHflex("1");
42  viewA.setSelectFirst(false);
43  viewA.setMultiple(true);
44  viewA.setCheckmark(true);
45  viewA.addEventListener(Events.ON_SELECT, new EventListener() {
46  @Override
47  public void onEvent(Event event) throws Exception {
48  updateSets();
49  }
50  });
51  viewB = new ViewListbox();
52  viewB.setHflex("1");
53  viewB.setSelectFirst(false);
54  viewB.setMultiple(true);
55  viewB.setCheckmark(true);
56  viewB.addEventListener(Events.ON_SELECT, new EventListener() {
57  @Override
58  public void onEvent(Event event) throws Exception {
59  updateSets();
60  }
61  });
62  Hbox hbox = new Hbox();
63  hbox.setWidth("100%");
64  hbox.appendChild(viewA);
65  hbox.appendChild(viewB);
66  setPopupComponent(hbox);
67  viewA.afterCompose();
68  viewB.afterCompose();
69  viewA.setObjectValues(sets.getGroupA());
70  viewB.setObjectValues(sets.getGroupB());
71  }
72  }
73 
74  @Override
77  return sets;
78  }
79 
80  @Override
81  public void setObjectValue(ViewSets v) {
82  sets = v;
84  }
85 
86  private void updateSets() {
87  sets.setGroupA(new HashSet<RegisterView>(viewA.getObjectValues()));
88  sets.setGroupB(new HashSet<RegisterView>(viewB.getObjectValues()));
89  setObjectValue(sets);
90  }
91 }
void setGroupB(Set< RegisterView > groupB)
Definition: ViewSets.java:53
Set< RegisterView > getGroupA()
Definition: ViewSets.java:40
Set< RegisterView > getGroupB()
Definition: ViewSets.java:49
void setGroupA(Set< RegisterView > groupA)
Definition: ViewSets.java:44
void setPopupComponent(Component component)
void setObjectValues(Collection< V > collection)
void setSelectFirst(boolean selectFirst)