BrightSide Workbench Full Report + Source Code
zul/dossier/ResolutionChart.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.IssueResolution;
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 
33 
38 public class ResolutionChart extends Chart {
39 
40  public void setDossierReport(final DossierDWReport dossierReport) {
41  Map<IssueResolution, Double> values = dossierReport.getIssuesByResolution();
42  setType(PIE);
43  SimplePieModel spm = new SimplePieModel();
44  for(IssueResolution is : values.keySet()) {
45  spm.setValue(I_.byKey(is.toString()),
46  values.get(is));
47  }
48  setModel(spm);
49  addEventListener(Events.ON_CLICK, new EventListener() {
50  @Override
51  public void onEvent(Event event) throws Exception {
52  Object obj = ((MouseEvent) event).getAreaComponent();
53  if(obj instanceof Area) {
54  Area area = (Area) obj;
55  if("DATA".equals(area.getAttribute("entity"))) {
56  EntityGrid.showEntities(dossierReport.getIssuesPathByResolution((String) area.getAttribute("category")));
57  }
58  }
59  }
60  });
61  }
62 
63 }
Map< IssueResolution, Double > getIssuesByResolution()
Collection< String > getIssuesPathByResolution(String resolution)
void setDossierReport(final DossierDWReport dossierReport)
static void showEntities(Collection< String > entitiesPath)
Definition: EntityGrid.java:73
static String byKey(String key)
Definition: I_.java:83