BrightSide Workbench Full Report + Source Code
ContractFilterGrid.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.contract.filter;
19 
20 import org.turro.contacts.Contact;
21 import org.turro.contacts.filter.CityFilterField;
22 import org.turro.contacts.filter.GlobalIdentifierFilterField;
23 import org.turro.contacts.filter.ProvinceFilterField;
24 import org.turro.contacts.filter.ZipCodeFilterField;
25 import org.turro.contacts.util.ContactCombobox;
26 import org.turro.elephant.db.WhereClause;
27 import org.turro.financials.contract.ContractDefinitionCombobox;
28 import org.turro.zkoss.filter.FilterField;
29 import org.turro.zkoss.filter.FilterFieldOperator;
30 import org.turro.zkoss.filter.FilterGrid;
31 import org.zkoss.zk.ui.HtmlBasedComponent;
32 
37 public class ContractFilterGrid extends FilterGrid {
38 
39  public ContractFilterGrid() {
40  super();
41  addField(new FilterField("Name", "") {
42  @Override
43  public void addConstraint(WhereClause wc) {
44  doAddConstraint(wc, "ctc.name");
45  }
46  });
47  addField(new FilterField("Internal ID", 0L, FilterFieldOperator.FILTER_EQUAL) {
48  @Override
49  public void addConstraint(WhereClause wc) {
50  doAddConstraint(wc, "ctc.id");
51  }
52  });
53  addField(new FilterField("Active", true) {
54  @Override
55  public void addConstraint(WhereClause wc) {
56  doAddConstraint(wc, "ctc.active");
57  }
58  });
59  addField(new FilterField("Contract model") {
60  @Override
61  protected HtmlBasedComponent createEditor() {
62  return new ContractDefinitionCombobox();
63  }
64  @Override
65  public void addConstraint(WhereClause wc) {
66  doAddConstraint(wc, "ctc.contractDefinition");
67  }
68  });
69  addField(new FilterField("Contact") {
70  @Override
71  protected HtmlBasedComponent createEditor() {
72  return new ContactCombobox();
73  }
74  @Override
75  protected Object getEditorValue() {
76  Contact c = ((ContactCombobox) editor).getContact();
77  return c == null ? null : c.getId();
78  }
79  @Override
80  public void addConstraint(WhereClause wc) {
81  doAddConstraint(wc, "ctc.contractor");
82  }
83  });
84  addField(new CityFilterField() {
85  @Override
86  public String getContactField() {
87  return "ctc.contractor";
88  }
89  });
90  addField(new ProvinceFilterField() {
91  @Override
92  public String getContactField() {
93  return "ctc.contractor";
94  }
95  });
96  addField(new ZipCodeFilterField() {
97  @Override
98  public String getContactField() {
99  return "ctc.contractor";
100  }
101  });
102  addField(new GlobalIdentifierFilterField() {
103  @Override
104  public String getContactField() {
105  return "ctc.contractor";
106  }
107  });
108  addField(new FilterField("Contract alias", "", FilterFieldOperator.FILTER_EQUAL) {
109  @Override
110  public void addConstraint(WhereClause wc) {
111  doAddConstraint(wc, "ctc.globalId");
112  }
113  });
114  addField(new FilterField("Notes", "") {
115  @Override
116  public void addConstraint(WhereClause wc) {
117  doAddConstraint(wc, "ctc.notes");
118  }
119  });
120  if(!loadPreferences(this.getClass().getName()+"_filter")) {
121  addCurrentField("Name");
122  }
123  }
124 
125 }
FilterField addField(FilterField filterField)
Definition: FilterGrid.java:62