r3161 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: . vatreports
Author: vsalaun Date: 2011-06-07 18:31:55 +0200 (Tue, 07 Jun 2011) New Revision: 3161 Url: http://chorem.org/repositories/revision/lima/3161 Log: #347 adding table, tableModeln, view Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTable.java 2011-06-07 16:31:55 UTC (rev 3161) @@ -0,0 +1,54 @@ +package org.chorem.lima.ui.vatreports; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.math.BigDecimal; +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; +import org.chorem.lima.ui.celleditor.DateTableCellEditor; +import org.chorem.lima.ui.celleditor.EmptyCellRenderer; +import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; +import org.jdesktop.swingx.JXTable; + +public class VatTable extends JXTable { + + /** serialVersionUID. */ + private static final long serialVersionUID = 4042515416850867834L; + + /** log. */ + private static final Log log = LogFactory.getLog(VatTable.class); + + protected VatViewHandler handler; + + public VatTable(VatViewHandler handler) { + + this.handler = handler; + + //Get new date editor + setDefaultEditor(Date.class, new DateTableCellEditor()); + //Get new entry book editor + setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor()); + //Get new account editor + setDefaultEditor(Account.class, new AccountTableCellEditor()); + //Get new amount editor + setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); + //Get new BigDecimal renderer + setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); + //get new String renderer for empty cells + setDefaultRenderer(String.class, new EmptyCellRenderer()); + //get new Account renderer for empty cells + setDefaultRenderer(Account.class, new EmptyCellRenderer()); + //get new EntryBook renderer for empty cells + setDefaultRenderer(EntryBook.class, new EmptyCellRenderer()); + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatTableModel.java 2011-06-07 16:31:55 UTC (rev 3161) @@ -0,0 +1,135 @@ +package org.chorem.lima.ui.vatreports; + +import static org.nuiton.i18n.I18n._; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Letter; + +public class VatTableModel extends AbstractTableModel implements ServiceListener { + + /** serialVersionUID. */ + private static final long serialVersionUID = -6301817853711018389L; + + /** log. */ + private static final Log log = LogFactory + .getLog(VatTableModel.class); + + /** selected financial period */ + protected FiscalPeriod selectedFiscalPeriod; + + /** data cache */ + protected List<Object> cacheDataList; + + + public VatTableModel() { + // + } + + protected List<Object> getDataList() { + List<Object> results = new ArrayList<Object>(); + return results; + } + + public void refresh(){ + cacheDataList = getDataList(); + fireTableDataChanged(); + } + + @Override + public Class<?> getColumnClass(int column) { + + Class<?> result = null; + + switch (column) { + case 0: + result = Date.class; + break; + default: + result = BigDecimal.class; + break; + } + + return result; + } + + @Override + public String getColumnName(int column) { + String result = "n/a"; + + switch (column) { + case 0: + result = _("lima.table.date"); //date + break; + case 1: + result = _("lima.table.collectedvat"); //tva collectee + break; + case 2: + result = _("lima.table.deductiblevat"); //tva deductible + break; + case 3: + result = _("lima.table.vatdue"); //tva due + break; + case 4: + result = _("lima.table.vatcredit"); //credit de tva + break; + case 5: + result = _("lima.table.repayments"); //remboursemments + break; + case 6: + result = _("lima.table.remainingcredit"); //credit restant + break; + case 7: + result = _("lima.table.vatpayable"); //tva a payer + break; + } + + return result; + } + + @Override + public int getRowCount() { + int result = 0; + + if (cacheDataList != null) { + result = cacheDataList.size(); + } + + return result; + } + + @Override + public int getColumnCount() { + return 8; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + // TODO Auto-generated method stub + return null; + } + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ + selectedFiscalPeriod = fiscalPeriod; + refresh(); + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + // TODO Auto-generated method stub + + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatView.jaxx 2011-06-07 16:31:55 UTC (rev 3161) @@ -0,0 +1,50 @@ +<Table> + <VatViewHandler id="handler" javaBean="new VatViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + + <script> + <![CDATA[ + import org.chorem.lima.entity.FiscalPeriod; + import org.chorem.lima.entity.FinancialPeriod; + import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; + import org.chorem.lima.ui.financialtransaction.FinancialPeriodComboBox; + import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; + import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; + import org.chorem.lima.ui.vatreports.VatTableModel; + import org.chorem.lima.ui.vatreports.VatTable; + + void $afterCompleteSetup() { + getHandler().refresh(); + } + + ]]> + </script> + + <row weightx="1" weighty="0" anchor="center"> + <cell anchor="east"> + <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> + </cell> + <cell anchor="west"> + <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> + <JComboBox id="fiscalPeriodComboBox" + model="{getModelFiscalPeriod()}" + renderer="{new FiscalPeriodComboBoxRenderer()}" + onActionPerformed="getVatTableModel().setFiscalPeriod((FiscalPeriod)fiscalPeriodComboBox.getSelectedItem())" + editable="false"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" rows="3" columns="11"> + <JScrollPane> + <org.chorem.lima.ui.vatreports.VatTableModel + id="vatTableModel"/> + <org.chorem.lima.ui.vatreports.VatTable + id="vatTable" sortable="false" rowHeight="22" + constructorParams="getHandler()" model="{getVatTableModel()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> + <javax.swing.ListSelectionModel javaBean="getVatTable().getSelectionModel()" + onValueChanged="setSelectedRow(vatTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> +</Table> \ No newline at end of file Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatViewHandler.java 2011-06-07 16:31:55 UTC (rev 3161) @@ -0,0 +1,29 @@ +package org.chorem.lima.ui.vatreports; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.vatreports.VatTable; +import org.chorem.lima.ui.vatreports.VatTableModel; +import org.chorem.lima.ui.vatreports.VatView; + +public class VatViewHandler { + /** log. */ + private static final Log log = + LogFactory.getLog(VatViewHandler.class); + + protected VatView view; + + protected VatTable table; + + protected VatTableModel tableModel; + + protected VatViewHandler(VatView view) { + this.view = view; + } + + public void refresh(){ + tableModel = view.getVatTableModel(); + tableModel.refresh(); + } + +}
participants (1)
-
vsalaun@users.chorem.org