BrightSide Workbench Full Report + Source Code
ParticipationVM.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2017 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.activity;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.zkoss.bind.annotation.BindingParam;
24 import org.zkoss.bind.annotation.Command;
25 import org.zkoss.bind.annotation.ExecutionArgParam;
26 import org.zkoss.bind.annotation.Init;
27 import org.zkoss.bind.annotation.NotifyChange;
28 import org.zkoss.zk.ui.Executions;
29 import org.zkoss.zul.GroupsModel;
30 import org.zkoss.zul.SimpleGroupsModel;
31 
36 public class ParticipationVM {
37 
38  private String entityPath;
39 
40  @Init
41  public void init(@ExecutionArgParam("entityPath") String entityPath) {
42  if(entityPath != null) this.entityPath = entityPath;
43  if(this.entityPath == null) {
44  this.entityPath = (String) Executions.getCurrent().getAttribute("entityPath");
45  }
46  }
47 
48  public Object getEntityPath() {
49  return entityPath;
50  }
51 
52  @NotifyChange("model")
53  @Command("entityPath")
54  public void setEntityPath(@BindingParam("entityPath") String entityPath) {
55  this.entityPath = entityPath;
56  }
57 
58  public GroupsModel<IParticipation, Object, Object> getModel() {
59  List<List<IParticipation>> data = new ArrayList<>();
60  List<String> headers = new ArrayList<>();
61  List<IParticipation> loading = null;
62 
63  String group = null;
64 
66  String current = ia.getCatcher().getDescription();
67  if(!(current.equals(group))) {
68  group = current;
69  headers.add(group);
70  loading = new ArrayList<>();
71  data.add(loading);
72  }
73  if(loading != null) {
74  loading.add(ia);
75  }
76  }
77 
78  return new SimpleGroupsModel<>(data, headers);
79  }
80 
81 }
static ArrayList< IParticipation > getParticipations(String entityPath)
GroupsModel< IParticipation, Object, Object > getModel()
void setEntityPath(@BindingParam("entityPath") String entityPath)
void init(@ExecutionArgParam("entityPath") String entityPath)