BrightSide Workbench Full Report + Source Code
SectionComposer.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.composer.EntityPathComposer;
22 import org.turro.publication.entity.NewsSection;
23 import org.zkoss.zk.ui.Component;
24 import org.zkoss.zk.ui.Executions;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.Events;
27 import org.zkoss.zk.ui.select.annotation.Listen;
28 import org.zkoss.zk.ui.select.annotation.Wire;
29 import org.zkoss.zul.Checkbox;
30 import org.zkoss.zul.Textbox;
31 
36 public class SectionComposer extends EntityPathComposer<NewsSection> {
37 
38  private SectionsGrid grid;
39 
40  @Wire("#column")
41  private Checkbox column;
42 
43  @Wire("#colWidth")
44  private Textbox colWidth;
45 
46  @Wire("#useAsTrigger")
47  private Checkbox useAsTrigger;
48 
49  @Wire("#hideIfEmpty")
50  private Checkbox hideIfEmpty;
51 
52  @Listen("onCheck = #column")
53  public void onColumn() {
54  entity.setNewColumn(column.isChecked());
55  colWidth.setReadonly(!column.isChecked());
56  Events.postEvent(new Event(Events.ON_CHANGE));
57  }
58 
59  @Listen("onChange = #colWidth")
60  public void onColWidth() {
61  entity.setWidth(colWidth.getValue());
62  Events.postEvent(new Event(Events.ON_CHANGE));
63  }
64 
65  @Listen("onCheck = #useAsTrigger")
66  public void onUseAsTrigger() {
67  entity.setUseAsTrigger(useAsTrigger.isChecked());
68  Events.postEvent(new Event(Events.ON_CHANGE));
69  }
70 
71  @Listen("onCheck = #hideIfEmpty")
72  public void onHideOfEmpty() {
73  entity.setHideIfEmpty(hideIfEmpty.isChecked());
74  Events.postEvent(new Event(Events.ON_CHANGE));
75  }
76 
77  @Listen("onClick = #mvup")
78  public void onMoveUp() {
79  grid.moveUp(entity);
80  Events.postEvent(new Event(Events.ON_CHANGE));
81  }
82 
83  @Listen("onClick = #mvdown")
84  public void onMoveDown() {
85  grid.moveDown(entity);
86  Events.postEvent(new Event(Events.ON_CHANGE));
87  }
88 
89  @Listen("onClick = #delete")
90  public void onDelete() {
91  grid.deleteSection(entity);
92  Events.postEvent(new Event(Events.ON_CHANGE));
93  }
94 
95  @Override
96  public void doAfterCompose(Component comp) throws Exception {
97  super.doAfterCompose(comp);
98  grid = (SectionsGrid) Executions.getCurrent().getAttribute("grid");
99  column.setChecked(entity.isNewColumn());
100  useAsTrigger.setChecked(entity.isUseAsTrigger());
101  hideIfEmpty.setChecked(entity.isHideIfEmpty());
102  colWidth.setReadonly(!column.isChecked());
103  }
104 
105 }
void moveDown(NewsSection newsSection)
void moveUp(NewsSection newsSection)
void deleteSection(NewsSection newsSection)