BrightSide Workbench Full Report + Source Code
MonthBandbox.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.zkoss.input;
20 
21 import java.util.Collection;
22 import org.zkoss.zk.ui.event.Event;
23 import org.zkoss.zk.ui.event.EventListener;
24 import org.zkoss.zk.ui.event.Events;
25 
30 public class MonthBandbox extends GenericBandbox<Collection<Integer>> {
31 
32  private MonthListbox monthListbox = new MonthListbox();
33  private boolean typing = false;
34 
35  @Override
36  protected void fillPopup() {
37  if(!isFilled()) {
38  getBandPopup().setHeight("300px");
39  getBandPopup().setWidth("200px");
40  setAutodrop(true);
41  monthListbox.setVflex(true);
42  addEventListener(Events.ON_CHANGE, new EventListener() {
43  @Override
44  public void onEvent(Event event) throws Exception {
45  try {
46  typing = true;
47  monthListbox.selectItemByText(MonthBandbox.this.getValue());
48  } finally {
49  typing = false;
50  }
51  }
52  });
53  monthListbox.afterCompose();
54  monthListbox.addEventListener(Events.ON_SELECT, new EventListener() {
55  @Override
56  public void onEvent(Event event) {
57  if(!typing && getObjectValue() != null) {
58  Events.postEvent(new Event(Events.ON_CHANGE, MonthBandbox.this));
59  }
60  }
61  });
62  setPopupComponent(monthListbox);
63  }
64  }
65 
66  @Override
67  public Collection<Integer> getObjectValue() {
68  setBandText(monthListbox.getStringValues());
69  return monthListbox.getObjectValues();
70  }
71 
72  @Override
73  public void setObjectValue(Collection<Integer> v) {
74  monthListbox.setObjectValues(v);
75  setBandText(monthListbox.getStringValues());
76  }
77 
78 }
Collection< Integer > getObjectValue()
void setObjectValue(Collection< Integer > v)