BrightSide Workbench Full Report + Source Code
zul/dossier/TypeChart.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.dossier.zul.dossier;
19 
20 import java.util.Map;
21 import org.turro.dossier.dw.DossierDWReport;
22 import org.turro.dossier.entity.IssueType;
23 import org.turro.elephant.zkoss.EntityGrid;
24 import org.turro.i18n.I_;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.EventListener;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zk.ui.event.MouseEvent;
29 import org.zkoss.zul.Area;
30 import org.zkoss.zul.Chart;
31 import org.zkoss.zul.SimplePieModel;
32 
37 public class TypeChart extends Chart {
38 
39  public void setDossierReport(final DossierDWReport dossierReport) {
40  Map<IssueType, Double> values = dossierReport.getIssuesByType();
41  setType(PIE);
42  SimplePieModel spm = new SimplePieModel();
43  for(IssueType is : values.keySet()) {
44  spm.setValue(I_.byKey(is.toString()),
45  values.get(is));
46  }
47  setModel(spm);
48  addEventListener(Events.ON_CLICK, new EventListener() {
49  @Override
50  public void onEvent(Event event) throws Exception {
51  Object obj = ((MouseEvent) event).getAreaComponent();
52  if(obj instanceof Area) {
53  Area area = (Area) obj;
54  if("DATA".equals(area.getAttribute("entity"))) {
55  EntityGrid.showEntities(dossierReport.getIssuesPathByType((String) area.getAttribute("category")));
56  }
57  }
58  }
59  });
60  }
61 
62 }
Collection< String > getIssuesPathByType(String type)
Map< IssueType, Double > getIssuesByType()
void setDossierReport(final DossierDWReport dossierReport)
static void showEntities(Collection< String > entitiesPath)
Definition: EntityGrid.java:73
static String byKey(String key)
Definition: I_.java:83