1 | |
package br.mia.test.view.tabelas; |
2 | |
|
3 | |
import java.io.IOException; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import javax.swing.table.AbstractTableModel; |
7 | |
|
8 | |
import br.mia.test.pessoas.Funcionario; |
9 | |
import br.mia.test.testcase.CasosTeste; |
10 | |
import br.mia.test.util.Util; |
11 | |
|
12 | 0 | public class TabelaModeloCasoTeste extends AbstractTableModel |
13 | 0 | { |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
private static final long serialVersionUID = 1L; |
19 | |
|
20 | |
private List<CasosTeste> testCases; |
21 | 0 | |
22 | |
public List<CasosTeste> getTestCases() { |
23 | 0 | return testCases; |
24 | 0 | } |
25 | 0 | |
26 | 0 | public void setTestCases(List<CasosTeste> testCases2) { |
27 | 0 | this.testCases = testCases2; |
28 | 0 | } |
29 | 0 | |
30 | 0 | public void setValueAt(Object value, int rowIndex, int columnIndex) { |
31 | 0 | |
32 | 0 | if (columnIndex == 2) { |
33 | 0 | CasosTeste testCase = (CasosTeste) this.testCases.get(rowIndex); |
34 | 0 | Funcionario funcionario = (Funcionario) value; |
35 | 0 | testCase.setTestador(funcionario); |
36 | 0 | |
37 | 0 | } |
38 | |
|
39 | 0 | } |
40 | 0 | |
41 | 0 | public String getColumnName(int arg0) { |
42 | |
|
43 | 0 | String[] nomes = { "Nome", "Data", "N�mero de Execu��es no TestLink" }; |
44 | 0 | |
45 | 0 | return nomes[arg0]; |
46 | 0 | } |
47 | |
|
48 | |
public int getColumnCount() { |
49 | |
|
50 | 0 | String testlink; |
51 | 0 | try { |
52 | 0 | testlink = Util.getPropriedade("testlink"); |
53 | 0 | } catch (IOException e) { |
54 | 0 | testlink = "false"; |
55 | 0 | } |
56 | 0 | |
57 | 0 | if ((testlink != null) && (testlink.equals("true"))) { |
58 | 0 | return 3; |
59 | 0 | |
60 | 0 | } |
61 | |
|
62 | 0 | return 2; |
63 | 0 | } |
64 | |
|
65 | 0 | public int getRowCount() { |
66 | |
|
67 | 0 | return this.testCases.size(); |
68 | 0 | } |
69 | |
|
70 | 0 | public Object getValueAt(int arg0, int arg1) { |
71 | 0 | |
72 | 0 | CasosTeste testCase = (CasosTeste) this.testCases.get(arg0); |
73 | 0 | if (arg1 == 0) { |
74 | 0 | |
75 | 0 | return testCase.getNome(); |
76 | 0 | } |
77 | 0 | if (arg1 == 1) { |
78 | 0 | |
79 | 0 | return testCase.getData(); |
80 | 0 | } |
81 | |
|
82 | 0 | if (arg1 == 2) { |
83 | 0 | |
84 | 0 | return testCase.getNumeroExecucoesTestLink(); |
85 | 0 | |
86 | |
} |
87 | 0 | if (arg1 == 4) { |
88 | 0 | |
89 | 0 | if (testCase.getTestador() != null) { |
90 | 0 | return testCase.getTestador(); |
91 | 0 | } else { |
92 | 0 | return "Nenhum"; |
93 | 0 | } |
94 | |
} |
95 | 0 | |
96 | |
else { |
97 | 0 | return "Nenhum"; |
98 | 0 | } |
99 | |
|
100 | |
} |
101 | |
|
102 | 0 | @SuppressWarnings("unchecked") |
103 | |
public Class getColumnClass(int c) { |
104 | |
try { |
105 | 0 | return getValueAt(0, c).getClass(); |
106 | 0 | } catch (Exception e) { |
107 | 0 | return CasosTeste.class; |
108 | 0 | } |
109 | |
} |
110 | |
|
111 | |
public boolean isCellEditable(int arg0, int arg1) { |
112 | |
|
113 | 0 | return true; |
114 | 0 | } |
115 | |
|
116 | |
} |