BrightSide Workbench Full Report + Source Code
ProductOrderFilterGrid.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.erp.workorder;
20 
21 import org.turro.elephant.db.WhereClause;
22 import org.turro.financials.db.FinancialsPU;
23 import org.turro.financials.entity.Product;
24 import org.turro.financials.product.ProductCombobox;
25 import org.turro.zkoss.filter.FilterField;
26 import org.turro.zkoss.filter.FilterFieldOperator;
27 import org.turro.zkoss.filter.FilterGrid;
28 import org.zkoss.zk.ui.HtmlBasedComponent;
29 
34 public class ProductOrderFilterGrid extends FilterGrid {
35 
37  super();
38  addField(new FilterField("lProduct") {
39  @Override
40  protected HtmlBasedComponent createEditor() {
41  ProductCombobox pcb = new ProductCombobox();
42  if(value instanceof Long) {
43  pcb.setObjectValue(new FinancialsPU().find(Product.class, value));
44  }
45  return pcb;
46  }
47 
48  @Override
49  protected Object getEditorValue() {
50  Product product = (Product) super.getEditorValue();
51  if(product != null) {
52  return product.getId();
53  }
54  return 0L;
55  }
56  @Override
57  public void addConstraint(WhereClause wc) {
58  doAddConstraint(wc, "wo.productId");
59  }
60  });
61  addField(new FilterField("lInternalId", 0L, FilterFieldOperator.FILTER_EQUAL) {
62  @Override
63  public void addConstraint(WhereClause wc) {
64  doAddConstraint(wc, "wo.id");
65  }
66  });
67  addField(new FilterField("lDate", new java.util.Date(new java.util.Date().getTime() - (1L * 30L * 24L * 60L * 60L * 1000L))) {
68  @Override
69  public void addConstraint(WhereClause wc) {
70  doAddConstraint(wc, "wo.workOrderDate");
71  }
72  });
73  addField(new FilterField("lDescription", "", FilterFieldOperator.FILTER_CONTAINS) {
74  @Override
75  public void addConstraint(WhereClause wc) {
76  doAddConstraint(wc, new String[] { "wo.description", "r.description" });
77  }
78  });
79  if(!loadPreferences(this.getClass().getName()+"_filter")) {
80  addCurrentField("lProduct");
81  }
82  }
83 
84 }
85 
FilterField addField(FilterField filterField)
Definition: FilterGrid.java:62