// uniCenta oPOS - Touch Friendly Point Of Sale // Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works // http://www.unicenta.net/unicentaopos // // This file is part of uniCenta oPOS // // uniCenta oPOS is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // uniCenta oPOS is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130 package com.openbravo.pos.inventory; import com.openbravo.basic.BasicException; import com.openbravo.data.user.BrowsableData; import com.openbravo.format.Formats; import javax.swing.table.AbstractTableModel; /** * * @author adrianromero */ public class StockModel extends AbstractTableModel { private BrowsableData m_bd; private Formats[] m_formats; private boolean[] m_bedit; /** Creates a new instance of StockModel */ public StockModel(BrowsableData bd, Formats[] f, boolean[] bedit) { m_bd = bd; m_formats = f; m_bedit = bedit; } @Override public int getRowCount() { return m_bd.getSize(); } @Override public int getColumnCount() { return m_formats.length; } @Override public Object getValueAt(int row, int column) { return m_formats[column].formatValue( ((Object[]) m_bd.getElementAt(row))[column]); } @Override public boolean isCellEditable(int row, int column) { return m_bedit[column]; } @Override public void setValueAt(Object aValue, int row, int column) { Object[] record = (Object[]) m_bd.getElementAt(row); try { record[column] = m_formats[column].parseValue((String) aValue); m_bd.updateRecord(row, record); } catch (BasicException e) { } } }