From 98832daff21d115f66ff4707a4506ee12add055e Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Thu, 11 Jun 2009 06:57:15 +0000 Subject: [PATCH] FR [ 2804629 ] AbstractExcelExporter getters should be public https://sourceforge.net/tracker/?func=detail&aid=2804629&group_id=176962&atid=879335 --- .../impexp/AbstractExcelExporter.java | 70 ++++++++++++++++--- .../adempiere/impexp/ArrayExcelExporter.java | 16 ++--- .../impexp/GridTabExcelExporter.java | 16 ++--- .../print/export/PrintDataExcelExporter.java | 16 ++--- .../report/core/RModelExcelExporter.java | 16 ++--- 5 files changed, 93 insertions(+), 41 deletions(-) diff --git a/base/src/org/adempiere/impexp/AbstractExcelExporter.java b/base/src/org/adempiere/impexp/AbstractExcelExporter.java index 922eb315b1..10f7983a1a 100644 --- a/base/src/org/adempiere/impexp/AbstractExcelExporter.java +++ b/base/src/org/adempiere/impexp/AbstractExcelExporter.java @@ -50,18 +50,70 @@ import org.compiere.util.Util; */ public abstract class AbstractExcelExporter { - protected abstract boolean isFunctionRow(); - protected abstract int getColumnCount(); - protected abstract int getRowCount(); + /** + * Is the current Row a Function Row + * @return true if function row + */ + public abstract boolean isFunctionRow(); + + /** + * Get Columns Count + * @return number of columns + */ + public abstract int getColumnCount(); + + /** + * Get Rows Count + * @return number of rows + */ + public abstract int getRowCount(); + + /** + * Set current row + * @param row row index + */ protected abstract void setCurrentRow(int row); - protected abstract boolean isColumnPrinted(int col); - protected abstract String getHeaderName(int col); - protected abstract int getDisplayType(int row, int col); - protected abstract Object getValueAt(int row, int col); - protected abstract boolean isPageBreak(int row, int col); + + /** + * Check if column is printed (displayed) + * @param col column index + * @return true if is visible + */ + public abstract boolean isColumnPrinted(int col); + + /** + * Get column header name + * @param col column index + * @return header name + */ + public abstract String getHeaderName(int col); + + /** + * Get cell display type (see {@link DisplayType}) + * @param row row index + * @param col column index + * @return display type + */ + public abstract int getDisplayType(int row, int col); + + /** + * Get cell value + * @param row row index + * @param col column index + * @return cell value + */ + public abstract Object getValueAt(int row, int col); + + /** + * Check if there is a page break on given cell + * @param row row index + * @param col column index + * @return true if there is a page break + */ + public abstract boolean isPageBreak(int row, int col); /** Logger */ - protected CLogger log = CLogger.getCLogger(getClass()); + protected final CLogger log = CLogger.getCLogger(getClass()); // private HSSFWorkbook m_workbook; private HSSFDataFormat m_dataFormat; diff --git a/base/src/org/adempiere/impexp/ArrayExcelExporter.java b/base/src/org/adempiere/impexp/ArrayExcelExporter.java index 0416b9286b..44c72c843e 100644 --- a/base/src/org/adempiere/impexp/ArrayExcelExporter.java +++ b/base/src/org/adempiere/impexp/ArrayExcelExporter.java @@ -42,12 +42,12 @@ public class ArrayExcelExporter extends AbstractExcelExporter { } @Override - protected int getColumnCount() { + public int getColumnCount() { return m_data.get(0).size(); } @Override - protected int getDisplayType(int row, int col) { + public int getDisplayType(int row, int col) { ArrayList dataRow = m_data.get(row+1); Object value = dataRow.get(col); if (value == null) @@ -74,7 +74,7 @@ public class ArrayExcelExporter extends AbstractExcelExporter { } @Override - protected String getHeaderName(int col) { + public String getHeaderName(int col) { Object o = m_data.get(0).get(col); String name = o != null ? o.toString() : null; String nameTrl = Msg.translate(getLanguage(), name); @@ -84,29 +84,29 @@ public class ArrayExcelExporter extends AbstractExcelExporter { } @Override - protected int getRowCount() { + public int getRowCount() { return m_data.size() - 1; } @Override - protected Object getValueAt(int row, int col) { + public Object getValueAt(int row, int col) { ArrayList dataRow = m_data.get(row+1); Object value = dataRow.get(col); return value; } @Override - protected boolean isColumnPrinted(int col) { + public boolean isColumnPrinted(int col) { return true; } @Override - protected boolean isFunctionRow() { + public boolean isFunctionRow() { return false; } @Override - protected boolean isPageBreak(int row, int col) { + public boolean isPageBreak(int row, int col) { return false; } diff --git a/base/src/org/adempiere/impexp/GridTabExcelExporter.java b/base/src/org/adempiere/impexp/GridTabExcelExporter.java index c2eb2a6887..d24e5f71b9 100644 --- a/base/src/org/adempiere/impexp/GridTabExcelExporter.java +++ b/base/src/org/adempiere/impexp/GridTabExcelExporter.java @@ -40,31 +40,31 @@ public class GridTabExcelExporter extends AbstractExcelExporter } @Override - protected int getColumnCount() + public int getColumnCount() { return m_tab.getFieldCount(); } @Override - protected int getDisplayType(int row, int col) + public int getDisplayType(int row, int col) { return m_tab.getField(col).getDisplayType(); } @Override - protected String getHeaderName(int col) + public String getHeaderName(int col) { return m_tab.getField(col).getHeader(); } @Override - protected int getRowCount() + public int getRowCount() { return m_tab.getRowCount(); } @Override - protected Object getValueAt(int row, int col) + public Object getValueAt(int row, int col) { GridField f = m_tab.getField(col); Object key = m_tab.getValue(row, f.getColumnName()); @@ -87,7 +87,7 @@ public class GridTabExcelExporter extends AbstractExcelExporter } @Override - protected boolean isColumnPrinted(int col) + public boolean isColumnPrinted(int col) { GridField f = m_tab.getField(col); // Hide not displayed fields @@ -103,13 +103,13 @@ public class GridTabExcelExporter extends AbstractExcelExporter } @Override - protected boolean isFunctionRow() + public boolean isFunctionRow() { return false; } @Override - protected boolean isPageBreak(int row, int col) + public boolean isPageBreak(int row, int col) { return false; } diff --git a/base/src/org/adempiere/print/export/PrintDataExcelExporter.java b/base/src/org/adempiere/print/export/PrintDataExcelExporter.java index 23d6cbe87e..80c5aff7b0 100644 --- a/base/src/org/adempiere/print/export/PrintDataExcelExporter.java +++ b/base/src/org/adempiere/print/export/PrintDataExcelExporter.java @@ -46,7 +46,7 @@ extends AbstractExcelExporter } @Override - protected int getColumnCount() { + public int getColumnCount() { return m_printFormat.getItemCount(); } @@ -65,7 +65,7 @@ extends AbstractExcelExporter return null; } @Override - protected int getDisplayType(int row, int col) { + public int getDisplayType(int row, int col) { PrintDataElement pde = getPDE(row, col); if (pde != null) { return pde.getDisplayType(); @@ -75,7 +75,7 @@ extends AbstractExcelExporter } @Override - protected Object getValueAt(int row, int col) { + public Object getValueAt(int row, int col) { PrintDataElement pde = getPDE(row, col); Object value = null; if (pde == null) @@ -107,23 +107,23 @@ extends AbstractExcelExporter } @Override - protected String getHeaderName(int col) { + public String getHeaderName(int col) { return m_printFormat.getItem(col).getPrintName(getLanguage()); } @Override - protected int getRowCount() { + public int getRowCount() { return m_printData.getRowCount(); } @Override - protected boolean isColumnPrinted(int col) { + public boolean isColumnPrinted(int col) { MPrintFormatItem item = m_printFormat.getItem(col); return item.isPrinted(); } @Override - protected boolean isPageBreak(int row, int col) { + public boolean isPageBreak(int row, int col) { PrintDataElement pde = getPDE(row, col); return pde != null ? pde.isPageBreak() : false; } @@ -134,7 +134,7 @@ extends AbstractExcelExporter } @Override - protected boolean isFunctionRow() { + public boolean isFunctionRow() { return m_printData.isFunctionRow(); } diff --git a/base/src/org/compiere/report/core/RModelExcelExporter.java b/base/src/org/compiere/report/core/RModelExcelExporter.java index 6bc997f99e..02b3dcfc20 100644 --- a/base/src/org/compiere/report/core/RModelExcelExporter.java +++ b/base/src/org/compiere/report/core/RModelExcelExporter.java @@ -31,42 +31,42 @@ extends AbstractExcelExporter } @Override - protected int getColumnCount() { + public int getColumnCount() { return m_model.getColumnCount(); } @Override - protected int getDisplayType(int row, int col) { + public int getDisplayType(int row, int col) { return m_model.getRColumn(col).getDisplayType(); } @Override - protected String getHeaderName(int col) { + public String getHeaderName(int col) { return m_model.getRColumn(col).getColHeader(); } @Override - protected int getRowCount() { + public int getRowCount() { return m_model.getRowCount(); } @Override - protected Object getValueAt(int row, int col) { + public Object getValueAt(int row, int col) { return m_model.getValueAt(row, col); } @Override - protected boolean isColumnPrinted(int col) { + public boolean isColumnPrinted(int col) { return true; } @Override - protected boolean isFunctionRow() { + public boolean isFunctionRow() { return m_model.isGroupRow(m_currentRow); } @Override - protected boolean isPageBreak(int row, int col) { + public boolean isPageBreak(int row, int col) { return false; }