BrightSide Workbench Full Report + Source Code
NewslettersComposer.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 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.newsletter;
20 
21 import org.turro.queue.zul.AllCategoriesListbox;
22 import org.zkoss.zk.ui.Component;
23 import org.zkoss.zk.ui.select.SelectorComposer;
24 import org.zkoss.zk.ui.select.annotation.Listen;
25 import org.zkoss.zk.ui.select.annotation.Wire;
26 import org.zkoss.zul.Checkbox;
27 import org.zkoss.zul.Textbox;
28 
33 public class NewslettersComposer extends SelectorComposer<Component> {
34 
35  @Wire("#catList")
36  private AllCategoriesListbox catList;
37 
38  @Wire("#accepted")
39  private Checkbox accepted;
40 
41  @Wire("#text")
42  private Textbox text;
43 
44  @Wire("#newsGrid")
45  private NewsletterGrid newsGrid;
46 
47  @Listen("onOK = #newsPanel")
48  public void onOK() {
49  updateGrid();
50  }
51 
52  @Listen("onSelect = #catList")
53  public void onSelectCategory() {
54  updateGrid();
55  }
56 
57  @Listen("onCheck = #accepted")
58  public void onCheckAccepted() {
59  updateGrid();
60  }
61 
62  @Listen("onClick = #doSearch")
63  public void onSearch() {
64  updateGrid();
65  }
66 
67  private void updateGrid() {
68  newsGrid.setValues(accepted.isChecked(), catList.getCategory(), text.getValue());
69  }
70 
71  @Override
72  public void doFinally() throws Exception {
73  super.doFinally();
74  }
75 
76 }
77 
void setValues(boolean accepted, NotificationCategory category, String text)