| 1 |  |  package br.mia.test.view.tabelas; | 
  | 2 |  |   | 
  | 3 |  |  import javax.swing.JTable; | 
  | 4 |  |  import javax.swing.table.AbstractTableModel; | 
  | 5 |  |   | 
  | 6 |  |  import br.mia.test.controler.ControladorErro; | 
  | 7 |  |  import br.mia.test.model.TestDataValor; | 
  | 8 |  |  import br.mia.test.testcase.DadosTeste; | 
  | 9 |  |   | 
  | 10 |  |  public class TabelaModeloValoresDados extends AbstractTableModel { | 
  | 11 |  |   | 
  | 12 |  |          TabelaModeloDados modeloDados; | 
  | 13 |  |   | 
  | 14 |  |          public TabelaModeloDados getModeloDados() { | 
  | 15 | 0 |                  return modeloDados; | 
  | 16 |  |          } | 
  | 17 |  |   | 
  | 18 |  |          public void setModeloDados(TabelaModeloDados modeloDados) { | 
  | 19 | 0 |                  this.modeloDados = modeloDados; | 
  | 20 | 0 |          } | 
  | 21 |  |   | 
  | 22 | 0 |          public TabelaModeloValoresDados() { | 
  | 23 | 0 |          } | 
  | 24 |  |   | 
  | 25 |  |          private JTable datas; | 
  | 26 |  |   | 
  | 27 |  |          private static final long serialVersionUID = -4369190215976405393L; | 
  | 28 |  |   | 
  | 29 |  |          public String getColumnName(int arg0) { | 
  | 30 |  |   | 
  | 31 | 0 |                  String[] nomes = { "Valor", "V�lido", "Resultado", "Classe" }; | 
  | 32 |  |   | 
  | 33 | 0 |                  return nomes[arg0]; | 
  | 34 |  |          } | 
  | 35 |  |   | 
  | 36 |  |          public int getColumnCount() { | 
  | 37 | 0 |                  return 4; | 
  | 38 |  |          } | 
  | 39 |  |   | 
  | 40 |  |          public int getRowCount() { | 
  | 41 |  |   | 
  | 42 |  |                  try { | 
  | 43 | 0 |                          int selected = datas.getSelectedRow(); | 
  | 44 | 0 |                          if (selected == -1) { | 
  | 45 | 0 |                                  return 0; | 
  | 46 |  |                          } else { | 
  | 47 | 0 |                                  DadosTeste testData = (DadosTeste) this.modeloDados.getDados() | 
  | 48 | 0 |                                                  .get(selected); | 
  | 49 | 0 |                                  if (testData.getValues().size() > 0) { | 
  | 50 | 0 |                                          return testData.getValues().size(); | 
  | 51 |  |                                  } else { | 
  | 52 | 0 |                                          return 0; | 
  | 53 |  |                                  } | 
  | 54 |  |                          } | 
  | 55 | 0 |                  } catch (Exception e) { | 
  | 56 | 0 |                          return 1; | 
  | 57 |  |                  } | 
  | 58 |  |          } | 
  | 59 |  |   | 
  | 60 |  |          public Object getValueAt(int arg0, int arg1) { | 
  | 61 |  |                  try { | 
  | 62 | 0 |                          int selected = datas.getSelectedRow(); | 
  | 63 | 0 |                          if (selected >= 0) { | 
  | 64 | 0 |                                  DadosTeste testData = (DadosTeste) this.modeloDados.getDados() | 
  | 65 | 0 |                                                  .get(selected); | 
  | 66 | 0 |                                  TestDataValor dataValor = testData.getValues().get(arg0); | 
  | 67 | 0 |                                  if (arg1 == 0) { | 
  | 68 |  |   | 
  | 69 | 0 |                                          return dataValor.getValor(); | 
  | 70 |  |                                  } | 
  | 71 | 0 |                                  if (arg1 == 1) { | 
  | 72 |  |   | 
  | 73 | 0 |                                          return dataValor.isValid(); | 
  | 74 |  |                                  } | 
  | 75 |  |   | 
  | 76 | 0 |                                  if (arg1 == 2) { | 
  | 77 |  |   | 
  | 78 | 0 |                                          if (dataValor.getResultadoEsperado() != null) { | 
  | 79 | 0 |                                                  return dataValor.getResultadoEsperado().toString(); | 
  | 80 |  |                                          } else { | 
  | 81 | 0 |                                                  return "Nenhum"; | 
  | 82 |  |                                          } | 
  | 83 |  |                                  } | 
  | 84 | 0 |                                  if (arg1 == 3) { | 
  | 85 |  |   | 
  | 86 | 0 |                                          return dataValor.getClasse(); | 
  | 87 |  |                                  } | 
  | 88 |  |                          } else { | 
  | 89 | 0 |                                  return "Nenhum"; | 
  | 90 |  |                          } | 
  | 91 | 0 |                  } catch (Exception e) { | 
  | 92 | 0 |                          ControladorErro.trata(e, this); | 
  | 93 |  |                  } | 
  | 94 |  |   | 
  | 95 | 0 |                  return null; | 
  | 96 |  |          } | 
  | 97 |  |   | 
  | 98 |  |          @SuppressWarnings("unchecked") | 
  | 99 |  |          public Class getColumnClass(int c) { | 
  | 100 |  |                  try { | 
  | 101 | 0 |                          return getValueAt(0, c).getClass(); | 
  | 102 | 0 |                  } catch (Exception e) { | 
  | 103 | 0 |                          return "Deletado".getClass(); | 
  | 104 |  |                  } | 
  | 105 |  |          } | 
  | 106 |  |   | 
  | 107 |  |          public boolean isCellEditable(int arg0, int arg1) { | 
  | 108 |  |   | 
  | 109 | 0 |                  return true; | 
  | 110 |  |          } | 
  | 111 |  |   | 
  | 112 |  |          public static long getSerialVersionUID() { | 
  | 113 | 0 |                  return serialVersionUID; | 
  | 114 |  |          } | 
  | 115 |  |   | 
  | 116 |  |          public JTable getDatas() { | 
  | 117 | 0 |                  return datas; | 
  | 118 |  |          } | 
  | 119 |  |   | 
  | 120 |  |          public void setDatas(JTable datas) { | 
  | 121 | 0 |                  this.datas = datas; | 
  | 122 | 0 |          } | 
  | 123 |  |   | 
  | 124 |  |  } |