BrightSide Workbench Full Report + Source Code
org.turro.financials.document.DocumentLinesGrid Class Reference
Inheritance diagram for org.turro.financials.document.DocumentLinesGrid:
Collaboration diagram for org.turro.financials.document.DocumentLinesGrid:

Public Member Functions

 DocumentLinesGrid ()
 
Document getDocument ()
 
void setDocument (Document document)
 
void updateDocument (Document document)
 
void updateLines ()
 
Collection< ContractgetStores ()
 
void afterCompose ()
 
- Public Member Functions inherited from org.turro.zkoss.grid.CollectionGrid< V >
 CollectionGrid ()
 
 CollectionGrid (Collection< V > collection)
 
Collection< V > getCollection ()
 
void setCollection (Collection< V > collection)
 
void updateCollection (Collection< V > collection)
 
Row getDependingRow ()
 
void setDependingRow (Row dependingRow)
 
void clearTable ()
 
void deleteSelectedRow (Row row)
 
- Public Member Functions inherited from org.turro.zkoss.grid.EditableGrid< V >
 EditableGrid ()
 
boolean isAllowDeletions ()
 
void setAllowDeletions (boolean allowDeletions)
 
boolean isAllowInsertions ()
 
void setAllowInsertions (boolean allowInsertions)
 
EditableCell getCurrentCell ()
 
Row getLastRow ()
 
boolean isReadOnly ()
 
void setReadOnly (boolean readOnly)
 
boolean isSelectInput ()
 
void setSelectInput (boolean selectInput)
 
boolean isShowZeros ()
 
void setShowZeros (boolean showZeros)
 
void clearFoot ()
 
void clearRows ()
 
void clearValidRows ()
 
void clearColumns ()
 
List< V > getValues ()
 
List< V > getAllValues ()
 
EventListener getEditListener ()
 
EventListener getNextListener ()
 
EventListener getKeyListener ()
 
EventListener getBlurListener ()
 
EventListener getCancelListener ()
 
void processEdition (EditableCell editableCell)
 
void cancelEdition ()
 
HtmlBasedComponent getEditor (EditableCell editableCell)
 
Row appendValue ()
 
Row addNewRow ()
 
void insertInSelectedRow (Row row)
 
Column getEditableColumn (int cellIndex)
 
void updateRow (Row row)
 
void updateRows ()
 
EditableColumn addColumn (String label, Class javaClass, String property, String format, int scale, boolean onlyDate, boolean readOnly)
 
EditableColumn addColumn (String label, String javaClass, String property, String format, int scale, boolean onlyDate, boolean readOnly) throws ClassNotFoundException
 
EditableColumn addColumn (String image, String tooltip, Class javaClass, String property, String format, int scale, boolean onlyDate, boolean readOnly)
 
EditableColumn addColumn (String image, String tooltip, String javaClass, String property, String format, int scale, boolean onlyDate, boolean readOnly) throws ClassNotFoundException
 
- Public Member Functions inherited from org.turro.zkoss.grid.PagingGrid
void setColumns (int columns)
 
void setColumns (String hflexs)
 
void refine ()
 
boolean isDefaultBehavior ()
 
void setDefaultBehavior (boolean defaultBehavior)
 
String getRefineValue ()
 
void setRefineValue (String value)
 
int getMaxResults ()
 
void setMaxResults (int maxResults)
 
String getPagingMold ()
 
void setPagingMold (String pagingMold)
 
int getRowCount ()
 
void setRowCount (int rows)
 
void setHeadersVisible (boolean value)
 
boolean isHeadersVisible ()
 
String getVarColumns ()
 
void setVarColumns (String varColumns)
 
Collection< String > getVarColumnsList (String defaultCols)
 
void addDetailColumn ()
 
void addDetailColumn (HtmlBasedComponent caption)
 
void openDetails ()
 
boolean isEmpty ()
 
void clearEmptyGroups ()
 
Columns getColumns (boolean create)
 
Rows getRows (boolean create)
 
Foot getFoot (boolean create)
 
Foot createFoot ()
 
void exportToPdf ()
 

Protected Member Functions

void initiateRow (Row row, DocumentLine value)
 
boolean deleteRow (Row row)
 
boolean isValid (DocumentLine v)
 
Object getEditorValue (EditableCell editableCell)
 
String formatCell (EditableCell editableCell, Object value)
 
HtmlBasedComponent createEditor (EditableCell editableCell)
 
void cellChanged (EditableCell editableCell, Object value)
 
- Protected Member Functions inherited from org.turro.zkoss.grid.CollectionGrid< V >
void rowChanged (Row row)
 
boolean filterValue (V v)
 
- Protected Member Functions inherited from org.turro.zkoss.grid.EditableGrid< V >
Object getCellValue (EditableCell editableCell)
 
void setCellValue (EditableCell editableCell, Object value)
 
HtmlBasedComponent createRenderer (EditableCell editableCell)
 
boolean isCellValid (EditableCell editableCell, Object value)
 
boolean canDeleteRow (Row row)
 
boolean canEditRow (Row row)
 
abstract void initiateRow (Row row, V value)
 
abstract boolean isValid (V v)
 

Additional Inherited Members

- Public Attributes inherited from org.turro.zkoss.grid.EditableGrid< V >
EditEventListener editListener
 
NextEventListener nextListener
 
KeyEventListener keyListener
 
CancelEventListener cancelListener
 
BlurEventListener blurListener
 
boolean allowInsertions
 
- Protected Attributes inherited from org.turro.zkoss.grid.CollectionGrid< V >
Row dependingRow
 
- Protected Attributes inherited from org.turro.zkoss.grid.EditableGrid< V >
EditableCell currentCell
 
String ctrlKeys
 
Row lastRow
 

Detailed Description

Author
Lluis Turró Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 48 of file document/DocumentLinesGrid.java.

Constructor & Destructor Documentation

◆ DocumentLinesGrid()

org.turro.financials.document.DocumentLinesGrid.DocumentLinesGrid ( )

Definition at line 57 of file document/DocumentLinesGrid.java.

57  {
58  super();
59  hasProducts = ProductWrapper.hasAvailableProducts();
60  }
Here is the call graph for this function:

Member Function Documentation

◆ afterCompose()

void org.turro.financials.document.DocumentLinesGrid.afterCompose ( )

Reimplemented from org.turro.zkoss.grid.CollectionGrid< V >.

Definition at line 129 of file document/DocumentLinesGrid.java.

129  {
130  if(document != null && document.isValid()) {
131  setReadOnly(false);
132  try {
133  addColumns();
134  invalidate();
135  } catch (ClassNotFoundException ex) {
136  Logger.getLogger(DocumentLinesGrid.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
137  }
138  } else {
139  setReadOnly(true);
140  }
141  super.afterCompose();
142  }
void setReadOnly(boolean readOnly)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cellChanged()

void org.turro.financials.document.DocumentLinesGrid.cellChanged ( EditableCell  editableCell,
Object  value 
)
protected

Reimplemented from org.turro.zkoss.grid.CollectionGrid< V >.

Definition at line 293 of file document/DocumentLinesGrid.java.

293  {
294  super.cellChanged(editableCell, value);
295  updateRow(editableCell.getRow());
296  EditableColumn ec = (EditableColumn) editableCell.getColumn();
297  if(value instanceof Contract) {
298  lastStore = (Contract) value;
299  } else if("tax".equals(ec.getProperty())) {
300  lastTax = (Double) value;
301  } else if("equivalenceSurcharge".equals(ec.getProperty())) {
302  lastReq = (Double) value;
303  } else if("retention".equals(ec.getProperty())) {
304  lastRet = (Double) value;
305  }
306  }
Here is the call graph for this function:

◆ createEditor()

HtmlBasedComponent org.turro.financials.document.DocumentLinesGrid.createEditor ( EditableCell  editableCell)
protected

Reimplemented from org.turro.zkoss.grid.EditableGrid< V >.

Definition at line 192 of file document/DocumentLinesGrid.java.

192  {
193  if(editableCell.getColumn() instanceof EditableColumn) {
194  EditableColumn ec = (EditableColumn) editableCell.getColumn();
195  if(ec.getJavaClass().equals(Product.class)) {
196  Object value = getCellValue(editableCell);
197  DocumentLine dl = (DocumentLine) editableCell.getRow().getValue();
198  /*
199  ProductCombobox pc = new ProductCombobox();
200  if(value != null) pc.setObjectValue((Product) value);
201  return pc;
202  */
203  ProductExtendedCombobox pc = new ProductExtendedCombobox();
204  pc.setContractorId(document.getContract().getId());
205  IProduct prod = (IProduct) value;
206  if(prod == null && dl.getProductByContractor() != null) {
207  prod = dl.getProductByContractor().getProduct();
208  }
209  if(prod != null) {
211  pc.setObjectValue(prod);
212  }
213  return pc;
214 // } else if(ec.getJavaClass().equals(ProductByContractor.class)) {
215 // Object value = getCellValue(editableCell);
216 // ProductByContractorCombobox pbpc = new ProductByContractorCombobox(document.getContract());
217 // if(value != null) pbpc.setObjectValue((ProductByContractor) value);
218 // return pbpc;
219  } else if(ec.getJavaClass().equals(LineType.class)) {
220  DocumentLine dl = (DocumentLine) editableCell.getRow().getValue();
221  Object value = getCellValue(editableCell);
222  LineTypePreferenceListbox ltl = new LineTypePreferenceListbox(document);
223  //TODO: check whether is preferable to assign preferences from document line
224  //((LineType) value).setContractPreference(dl.getContractPreference());
225  if(value != null) ltl.setObjectValue((LineType) value);
226  ltl.setMold("select");
227  return ltl;
228  } else if(ec.getJavaClass().equals(Contract.class)) {
229  DocumentLine dl = (DocumentLine) editableCell.getRow().getValue();
230  Object value = getCellValue(editableCell);
231  ContractListbox slb = new ContractListbox(usualStores);
232  if(value != null) slb.setObjectValue((Contract) value);
233  slb.setMold("select");
234  return slb;
235  } else if(ec.getJavaClass().equals(String.class) && "concept".equals(ec.getProperty())) {
236  DocumentLine dl = (DocumentLine) editableCell.getRow().getValue();
237  Object value = getCellValue(editableCell);
238  ConceptCombobox slb = new ConceptCombobox();
239  slb.setDocumentDefinition(document.getDocumentDefinition());
240  if(value != null) {
241  slb.setObjectValue((String) value);
242  } else if(!hasProducts) {
243  slb.setObjectValue(UsualUsages.getMostUsedvalue(document.getUsualPath() + "cp:"));
244  }
245  return slb;
246  } else if("tax".equals(ec.getProperty())) {
247  HtmlBasedComponent hbc = new ContractWrapper(document.getContract()).getTaxCtrl();
248  Object value = getCellValue(editableCell);
249  if(hbc != null) {
250  if(hbc instanceof CollectionListbox) {
251  if(!Zero.near((double) value, 2)) {
252  ((CollectionListbox) hbc).setObjectValue(value);
253  } else {
254  ((CollectionListbox) hbc).setObjectValue(lastTax);
255  }
256  }
257  return hbc;
258  } else {
259  setCellValue(editableCell, !Zero.near((double) value, 2) ? value : lastTax);
260  }
261  } else if("equivalenceSurcharge".equals(ec.getProperty())) {
262  HtmlBasedComponent hbc = new ContractWrapper(document.getContract()).getReqCtrl();
263  Object value = getCellValue(editableCell);
264  if(hbc != null) {
265  if(hbc instanceof CollectionListbox) {
266  if(value != null) {
267  ((CollectionListbox) hbc).setObjectValue(value);
268  } else {
269  ((CollectionListbox) hbc).setObjectValue(lastReq);
270  }
271  }
272  return hbc;
273  } else {
274  setCellValue(editableCell, !Zero.near((double) value, 2) ? value : lastReq);
275  }
276  } else if("retention".equals(ec.getProperty())) {
277  HtmlBasedComponent hbc = new ContractWrapper(document.getContract()).getRetentionCtrl();
278  Object value = getCellValue(editableCell);
279  if(hbc != null) {
280  if(hbc instanceof CollectionListbox) {
281  if(value != null) ((CollectionListbox) hbc).setObjectValue(value);
282  }
283  return hbc;
284  } else {
285  setCellValue(editableCell, !Zero.near((double) value, 2) ? value : lastRet);
286  }
287  }
288  }
289  return super.createEditor(editableCell);
290  }
ProductByContractor getProductByContractor()
DocumentDefinition getDocumentDefinition()
Definition: Document.java:167
static boolean near(double value, int digits)
Definition: Zero.java:30
void setCellValue(EditableCell editableCell, Object value)
Object getCellValue(EditableCell editableCell)
void setProductByContractor(ProductByContractor pbc)
Here is the call graph for this function:

◆ deleteRow()

boolean org.turro.financials.document.DocumentLinesGrid.deleteRow ( Row  row)
protected

Reimplemented from org.turro.zkoss.grid.EditableGrid< V >.

Definition at line 118 of file document/DocumentLinesGrid.java.

118  {
119  document.getDocumentLines().remove((DocumentLine) row.getValue());
120  return true;
121  }
Set< DocumentLine > getDocumentLines()
Definition: Document.java:180
Here is the call graph for this function:

◆ formatCell()

String org.turro.financials.document.DocumentLinesGrid.formatCell ( EditableCell  editableCell,
Object  value 
)
protected

Reimplemented from org.turro.zkoss.grid.EditableGrid< V >.

Definition at line 166 of file document/DocumentLinesGrid.java.

166  {
167 // if(value instanceof Product) {
168 // Product p = ((Product) value);
169 // setValuesFrom(p, (DocumentLine) editableCell.getRow().getFieldValue());
170 // return "#" + p.getProductCodeStr() + " " + p.getDescription();
171 // } else if(value instanceof ProductByContractor) {
172 // ProductByContractor pbp = ((ProductByContractor) value);
173 // setValuesFrom(pbp, (DocumentLine) editableCell.getRow().getFieldValue());
174 // return "#" + pbp.getContractorCode() + " " + pbp.getProduct().getDescription();
175  if(value instanceof Product) {
176  Product p = ((Product) value);
177  DocumentLine dl = (DocumentLine) editableCell.getRow().getValue();
178  ProductFactory.setPriceTax(dl, p);
180  return p.getProductString();
181  } else if(value instanceof LineType) {
182  LineType lt = ((LineType) value);
183  return lt.getComposedName();
184  } else if(value instanceof Contract) {
185  Contract ctc = ((Contract) value);
186  return ctc.getPartialDescription();
187  }
188  return super.formatCell(editableCell, value);
189  }
void setProductByContractor(ProductByContractor productByContractor)
Definition: Product.java:213
Here is the call graph for this function:

◆ getDocument()

Document org.turro.financials.document.DocumentLinesGrid.getDocument ( )

Definition at line 62 of file document/DocumentLinesGrid.java.

62  {
63  return document;
64  }

◆ getEditorValue()

Object org.turro.financials.document.DocumentLinesGrid.getEditorValue ( EditableCell  editableCell)
protected

Reimplemented from org.turro.zkoss.grid.EditableGrid< V >.

Definition at line 145 of file document/DocumentLinesGrid.java.

145  {
146  HtmlBasedComponent hbc = (HtmlBasedComponent) editableCell.getEditor();
147  if(hbc instanceof ProductExtendedCombobox) {
148  DocumentLine dl = (DocumentLine) editableCell.getRow().getValue();
149  IProduct prod = ((ProductExtendedCombobox) hbc).getObjectValue();
150  if(prod != null) {
151  ProductFactory.setPriceTax(dl, prod);
152  if(prod.isUncoded()) {
153  dl.setConcept(prod.getProductString());
154  return null;
155  }
157  } else {
158  dl.setProductByContractor(null);
159  }
160  return prod;
161  }
162  return super.getEditorValue(editableCell);
163  }
void setProductByContractor(ProductByContractor productByContractor)
ProductByContractor getProductByContractor()
Here is the call graph for this function:

◆ getStores()

Collection<Contract> org.turro.financials.document.DocumentLinesGrid.getStores ( )

Definition at line 96 of file document/DocumentLinesGrid.java.

96  {
97  return stores;
98  }

◆ initiateRow()

void org.turro.financials.document.DocumentLinesGrid.initiateRow ( Row  row,
DocumentLine  value 
)
protected

Definition at line 101 of file document/DocumentLinesGrid.java.

101  {
102  if(value == null) {
103  value = new DocumentLine();
104  value.setDocument(document);
105  value.setLineType(document.getDefaultLineType());
106  if(value.getLineType() != null) {
108  }
109  value.setStore(lastStore);
110  // avoid equalities
111  value.setLineOrder(document.getDocumentLines().size() + 90001);
112  document.getDocumentLines().add(value);
113  }
114  row.setValue(value);
115  }
void setContractPreference(ContractPreference contractPreference)
ContractPreference getContractPreference()
Definition: LineType.java:77
Here is the call graph for this function:

◆ isValid()

boolean org.turro.financials.document.DocumentLinesGrid.isValid ( DocumentLine  v)
protected

Definition at line 124 of file document/DocumentLinesGrid.java.

124  {
125  return !v.isEmpty();
126  }
Here is the call graph for this function:

◆ setDocument()

void org.turro.financials.document.DocumentLinesGrid.setDocument ( Document  document)

Definition at line 66 of file document/DocumentLinesGrid.java.

66  {
67  this.document = document;
68  if(document == null || !document.isValid()) return;
69  document.clearEmpties();
70  setCollection(document.getDocumentLines());
71  stores = new DocumentDefinitionWrapper(document.getDocumentDefinition())
72  .getRelatedStores(document.getContract());
73  if(stores.isEmpty()) {
74  stores = new DocumentDefinitionWrapper(document.getDocumentDefinition())
76  }
78  usualStores = new ContractUsualSet(stores, true, document.getUsualPath() + "st:");
79 // if(!stores.isEmpty()) {
80 // lastStore = stores.iterator().next();
81 // }
82  }
void setCollection(Collection< V > collection)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateDocument()

void org.turro.financials.document.DocumentLinesGrid.updateDocument ( Document  document)

Definition at line 84 of file document/DocumentLinesGrid.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateLines()

void org.turro.financials.document.DocumentLinesGrid.updateLines ( )

Definition at line 90 of file document/DocumentLinesGrid.java.

90  {
91  clearRows();
92  setDocument(document);
93  super.afterCompose();
94  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: