| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
package tempcontroller.gui; |
| 11 |
|
|
| 12 |
|
import java.text.Format; |
| 13 |
|
import java.text.SimpleDateFormat; |
| 14 |
|
import java.util.Date; |
| 15 |
|
import javax.swing.table.AbstractTableModel; |
| 16 |
|
import tempcontroller.base.IAmostragem; |
| 17 |
|
import tempcontroller.base.IProgramacaoAmostragem; |
| 18 |
|
import tempcontroller.base.ProgramacaoAmostragemSimples; |
| 19 |
|
import tempcontroller.base.Utilities; |
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
public class ProgramacaoTableModel extends AbstractTableModel { |
| 26 |
|
private IProgramacaoAmostragem programacaoAmostragem; |
| 27 |
|
|
| 28 |
0 |
public ProgramacaoTableModel() { |
| 29 |
0 |
programacaoAmostragem = null; |
| 30 |
0 |
} |
| 31 |
|
|
| 32 |
|
|
| 33 |
0 |
public ProgramacaoTableModel(IProgramacaoAmostragem programacao) { |
| 34 |
0 |
setProgramacaoAmostragem(programacao); |
| 35 |
0 |
} |
| 36 |
|
|
| 37 |
|
public int getRowCount() { |
| 38 |
0 |
if(programacaoAmostragem == null) { |
| 39 |
0 |
return 0; |
| 40 |
|
} |
| 41 |
0 |
return programacaoAmostragem.getAmostragens().size(); |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
public int getColumnCount() { |
| 45 |
0 |
return 3; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public Object getValueAt(int rowIndex, int columnIndex) { |
| 49 |
0 |
Object toReturn = ""; |
| 50 |
0 |
if(programacaoAmostragem != null) { |
| 51 |
0 |
IAmostragem amostragem = |
| 52 |
|
programacaoAmostragem.getAmostragens().get(rowIndex); |
| 53 |
0 |
if(columnIndex == 0) { |
| 54 |
0 |
toReturn = amostragem.getNome(); |
| 55 |
0 |
} else if(columnIndex == 1) { |
| 56 |
0 |
Utilities utilities = Utilities.getUtilities(); |
| 57 |
0 |
toReturn = utilities.formatTempo(amostragem.getDuracao()); |
| 58 |
0 |
} else if(columnIndex == 2) { |
| 59 |
0 |
Utilities utilities = Utilities.getUtilities(); |
| 60 |
0 |
toReturn = utilities.formatTemperatura( |
| 61 |
|
amostragem.getTemperatura()); |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
|
|
| 65 |
0 |
return toReturn; |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
public boolean isCellEditable(int rowIndex, int columnIndex) { |
| 69 |
0 |
return false; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
public void setProgramacaoAmostragem(IProgramacaoAmostragem programacaoAmostragem) { |
| 73 |
0 |
this.programacaoAmostragem = programacaoAmostragem; |
| 74 |
0 |
} |
| 75 |
|
|
| 76 |
|
public String getColumnName(int column) { |
| 77 |
0 |
if(column == 0) { |
| 78 |
0 |
return "Nome"; |
| 79 |
0 |
} else if(column == 1) { |
| 80 |
0 |
return "Duração"; |
| 81 |
|
} else { |
| 82 |
0 |
return "Temperatura"; |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
|
} |