Agregada una ventana para realizar el calculo del fondo de la caja, es wip, falta la aprobacion del jefe jajaj
This commit is contained in:
102
src/danielcortes/xyz/views/components/FondoTableModel.java
Normal file
102
src/danielcortes/xyz/views/components/FondoTableModel.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2018-2019 Daniel Cortes
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package danielcortes.xyz.views.components;
|
||||
|
||||
import danielcortes.xyz.models.calculo_fondo.CalculoFondo;
|
||||
import danielcortes.xyz.models.egreso.Egreso;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FondoTableModel extends AbstractTableModel {
|
||||
|
||||
private String[] columns;
|
||||
private ArrayList<CalculoFondo> rows;
|
||||
private NumberFormat nf;
|
||||
|
||||
|
||||
public FondoTableModel(){
|
||||
super();
|
||||
this.columns = new String[]{"Valor", "Descripcion"};
|
||||
this.rows = new ArrayList<>();
|
||||
this.nf = NumberFormat.getIntegerInstance();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int col) {
|
||||
return columns[col];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columns.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return rows.size();
|
||||
}
|
||||
|
||||
public void addRow(CalculoFondo calculoFondo) {
|
||||
rows.add(calculoFondo);
|
||||
this.fireTableRowsInserted(getRowCount()-1, getRowCount()-1);
|
||||
|
||||
}
|
||||
|
||||
public void removeRow(int row){
|
||||
this.rows.remove(row);
|
||||
this.fireTableRowsDeleted(row,row);
|
||||
}
|
||||
|
||||
public void removeRows(){
|
||||
int rowCount = getRowCount();
|
||||
if(rowCount > 0){
|
||||
this.rows.clear();
|
||||
this.fireTableRowsDeleted(0, rowCount-1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCalculoFondo(int editingId, CalculoFondo calculoFondo) {
|
||||
this.rows.set(editingId, calculoFondo);
|
||||
this.fireTableRowsUpdated(0,getRowCount()-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row, int col) {
|
||||
switch (col){
|
||||
case 0:
|
||||
return rows.get(row).getValor();
|
||||
case 1:
|
||||
return rows.get(row).getDescripcion();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CalculoFondo getCalculoFondo(int row){
|
||||
return rows.get(row);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user