| 1 | |
package br.mia.test.view.tabelas; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
import javax.swing.JTable; |
| 7 | |
import javax.swing.table.AbstractTableModel; |
| 8 | |
|
| 9 | |
import br.mia.test.model.Atividade; |
| 10 | 0 | |
| 11 | 0 | public class TabelaModeloCronogramaTotal extends AbstractTableModel { |
| 12 | 0 | private List<Atividade> atividades=new ArrayList<Atividade>(); |
| 13 | |
private JTable tabela; |
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
private static final long serialVersionUID = 1L; |
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | 0 | public List<Atividade> getAtividades() { |
| 24 | 0 | return atividades; |
| 25 | |
} |
| 26 | |
|
| 27 | 0 | public void setAtividades(List<Atividade> atividades1) { |
| 28 | 0 | this.atividades = atividades1; |
| 29 | 0 | } |
| 30 | |
|
| 31 | |
public String getColumnName(int arg0) { |
| 32 | 0 | |
| 33 | 0 | String[] nomes = { "Nome","Dura��o", "Respons�vel", "Estado","Data Inicio" ,"Data Fim"}; |
| 34 | 0 | |
| 35 | 0 | return nomes[arg0]; |
| 36 | |
} |
| 37 | |
|
| 38 | 0 | public int getColumnCount() { |
| 39 | 0 | return 1; |
| 40 | |
} |
| 41 | |
|
| 42 | |
public int getRowCount() { |
| 43 | 0 | |
| 44 | 0 | return 3; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public Object getValueAt(int arg0, int arg1) { |
| 48 | 0 | |
| 49 | 0 | double total=0; |
| 50 | 0 | double completo=0; |
| 51 | 0 | double emAndamento=0; |
| 52 | 0 | |
| 53 | 0 | for (Object objeto : this.getAtividades()) { |
| 54 | 0 | Atividade atividade=(Atividade) objeto; |
| 55 | 0 | total+=atividade.getDuracao(); |
| 56 | 0 | if (atividade.getStatus().equals("Completa")){ |
| 57 | 0 | completo+=atividade.getDuracao(); |
| 58 | 0 | } |
| 59 | 0 | if (atividade.getStatus().equals("Em Andamento")){ |
| 60 | 0 | emAndamento+=atividade.getDuracao(); |
| 61 | |
} |
| 62 | |
} |
| 63 | |
|
| 64 | 0 | |
| 65 | 0 | if (arg0==0){ |
| 66 | 0 | return "Total de horas :"+total; |
| 67 | |
} |
| 68 | 0 | |
| 69 | 0 | if (arg0==1){ |
| 70 | 0 | return "Total de horas completas:"+completo; |
| 71 | 0 | } |
| 72 | 0 | if (arg0==2){ |
| 73 | 0 | return "Total de horas em andamento:"+emAndamento; |
| 74 | 0 | } |
| 75 | 0 | return "Nenhum"; |
| 76 | |
} |
| 77 | |
|
| 78 | |
@SuppressWarnings("unchecked") |
| 79 | |
public Class getColumnClass(int c) { |
| 80 | 0 | try{ |
| 81 | 0 | return getValueAt(0, c).getClass(); |
| 82 | 0 | } |
| 83 | 0 | catch (Exception e) { |
| 84 | 0 | return "Nenhum".getClass(); |
| 85 | |
} |
| 86 | |
} |
| 87 | |
|
| 88 | |
public boolean isCellEditable(int arg0, int arg1) { |
| 89 | 0 | |
| 90 | 0 | return true; |
| 91 | |
} |
| 92 | |
|
| 93 | 0 | public JTable getTabela() { |
| 94 | 0 | return tabela; |
| 95 | |
} |
| 96 | |
|
| 97 | 0 | public void setTabela(JTable tabela) { |
| 98 | 0 | this.tabela = tabela; |
| 99 | 0 | } |
| 100 | |
|
| 101 | |
} |