BrightSide Workbench Full Report + Source Code
FixedAssetFilterGrid.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 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.financials.assets.filter;
20 
21 import org.turro.elephant.db.WhereClause;
22 import org.turro.financials.assets.InvestmentListbox;
23 import org.turro.financials.contract.ContractCombobox;
24 import org.turro.financials.linetype.LineTypeListbox;
25 import org.turro.financials.view.ViewListbox;
26 import org.turro.zkoss.filter.FilterField;
27 import org.turro.zkoss.filter.FilterFieldOperator;
28 import org.turro.zkoss.filter.FilterGrid;
29 import org.zkoss.zk.ui.HtmlBasedComponent;
30 
35 public class FixedAssetFilterGrid extends FilterGrid {
36 
38  super();
40  @Override
41  public void addConstraint(WhereClause wc) {
42  doAddConstraint(wc, "fa.id");
43  }
44  });
45  addField(new FilterField("Name", "") {
46  @Override
47  public void addConstraint(WhereClause wc) {
48  doAddConstraint(wc, "fa.name");
49  }
50  });
51  addField(new FilterField("Unsubscribed", true) {
52  @Override
53  public void addConstraint(WhereClause wc) {
54  doAddConstraint(wc, "fa.unsubscribed");
55  }
56  });
57  addField(new FilterField("Investment") {
58  @Override
59  protected HtmlBasedComponent createEditor() {
60  InvestmentListbox il = new InvestmentListbox();
61  il.setMold("select");
62  il.setAllowNull(true);
63  return il;
64  }
65  @Override
66  public void addConstraint(WhereClause wc) {
67  doAddConstraint(wc, "fa.investmentPreference");
68  }
69  });
70  addField(new FilterField("Depreciation") {
71  @Override
72  protected HtmlBasedComponent createEditor() {
73  LineTypeListbox ltl = new LineTypeListbox();
74  ltl.setMold("select");
75  ltl.setAllowNull(true);
76  ltl.setRegexp(".*\\(A\\)");
77  return ltl;
78  }
79  @Override
80  public void addConstraint(WhereClause wc) {
81  doAddConstraint(wc, "fa.depreciationLineType");
82  }
83  });
84  addField(new FilterField("Store") {
85  @Override
86  protected HtmlBasedComponent createEditor() {
87  ContractCombobox cb = new ContractCombobox();
88  cb.setOnlyStores(true);
89  return cb;
90  }
91  @Override
92  public void addConstraint(WhereClause wc) {
93  doAddConstraint(wc, "fa.store");
94  }
95  });
96  addField(new FilterField("View") {
97  @Override
98  protected HtmlBasedComponent createEditor() {
99  ViewListbox vl = new ViewListbox();
100  vl.setMold("select");
101  vl.setAllowNull(true);
102  return vl;
103  }
104  @Override
105  public void addConstraint(WhereClause wc) {
106  doAddConstraint(wc, "ifnull(fa.view, 0)");
107  }
108  });
109  if(!loadPreferences(this.getClass().getName()+"_filter")) {
110  addCurrentField("Name");
111  }
112  }
113 
114 }
FilterField addField(FilterField filterField)
Definition: FilterGrid.java:62
boolean loadPreferences(String preference)
FilterField addCurrentField(String label)
Definition: FilterGrid.java:67