BrightSide Workbench Full Report + Source Code
PortfolioDisagreementsGrid.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.financials.portfolio;
19 
20 import java.util.logging.Level;
21 import java.util.logging.Logger;
22 import org.turro.elephant.context.ElephantContext;
23 import org.turro.financials.document.action.DocumentActionMenu;
24 import org.turro.financials.document.logic.DocumentWrapper;
25 import org.turro.financials.entity.Contract;
26 import org.turro.financials.menu.FinancialsMenu;
27 import org.turro.financials.model.document.PortfolioDisagreement;
28 import org.turro.financials.model.document.PortfolioDisagreementSet;
29 import org.turro.i18n.I_;
30 import org.turro.zkoss.grid.CollectionGrid;
31 import org.turro.zkoss.grid.EditableCell;
32 import org.zkoss.zk.ui.HtmlBasedComponent;
33 import org.zkoss.zk.ui.event.Event;
34 import org.zkoss.zk.ui.event.EventListener;
35 import org.zkoss.zk.ui.event.Events;
36 import org.zkoss.zul.A;
37 import org.zkoss.zul.Row;
38 
43 public class PortfolioDisagreementsGrid extends CollectionGrid<PortfolioDisagreement> {
44 
45  private DocumentActionMenu dam;
46 
48  super(new PortfolioDisagreementSet().values());
49  }
50 
52  super(new PortfolioDisagreementSet(contract).values());
53  }
54 
55  @Override
56  protected void initiateRow(Row row, PortfolioDisagreement value) {
57  row.setValue(value);
58  }
59 
60  @Override
61  protected boolean deleteRow(Row row) {
62  return false;
63  }
64 
65  @Override
66  protected boolean isValid(PortfolioDisagreement v) {
67  return true;
68  }
69 
70  @Override
71  protected HtmlBasedComponent createRenderer(EditableCell editableCell) {
72  if(editableCell.getCellIndex() == 0) {
73  final PortfolioDisagreement dr = (PortfolioDisagreement) editableCell.getRow().getValue();
74  A b = new A(new DocumentWrapper(dr.getDocument()).getDocDescription());
75  b.setImage("/_zul/images/document.png");
76  b.addEventListener(Events.ON_CLICK, new EventListener() {
77  @Override
78  public void onEvent(Event event) throws Exception {
80  }
81  });
82  b.setContext(dam);
83  b.setAttribute("document", dr.getDocument());
84  return b;
85  }
86  return super.createRenderer(editableCell);
87  }
88 
89  @Override
90  public void afterCompose() {
91  setReadOnly(true);
92  dam = new DocumentActionMenu();
93  getParent().appendChild(dam);
94  addColumns();
95  super.afterCompose();
96  }
97 
98  private void addColumns() {
99  try {
100  addColumn(I_.get("Document"), String.class, "document", null, 0, false, false).setWidth("80%");
101  addColumn(I_.get("Difference"), "double", "difference", null, 2, false, false).setWidth("20%");
102  } catch (ClassNotFoundException ex) {
103  Logger.getLogger(PortfolioDisagreementsGrid.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
104  }
105  }
106 
107 }
HtmlBasedComponent createRenderer(EditableCell editableCell)
static String get(String msg)
Definition: I_.java:41
EditableColumn addColumn(String label, Class javaClass, String property, String format, int scale, boolean onlyDate, boolean readOnly)
void setReadOnly(boolean readOnly)