View Javadoc

1   /*
2    * ProgramacaoTableModel.java
3    *
4    * Created on June 13, 2007, 11:26 AM
5    *
6    * To change this template, choose Tools | Template Manager
7    * and open the template in the editor.
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   * @author ipen
24   */
25  public class ProgramacaoTableModel extends AbstractTableModel {
26      private IProgramacaoAmostragem programacaoAmostragem;
27      
28      public ProgramacaoTableModel() {
29          programacaoAmostragem = null;
30      }
31      
32      /** Creates a new instance of ProgramacaoTableModel */
33      public ProgramacaoTableModel(IProgramacaoAmostragem programacao) {
34          setProgramacaoAmostragem(programacao);
35      }
36      
37      public int getRowCount() {
38          if(programacaoAmostragem == null) {
39              return 0;
40          }
41          return programacaoAmostragem.getAmostragens().size();
42      }
43      
44      public int getColumnCount() {
45          return 3;
46      }
47      
48      public Object getValueAt(int rowIndex, int columnIndex) {
49          Object toReturn = "";
50          if(programacaoAmostragem != null) {
51              IAmostragem amostragem =
52                      programacaoAmostragem.getAmostragens().get(rowIndex);
53              if(columnIndex == 0) {
54                  toReturn = amostragem.getNome();
55              } else if(columnIndex == 1) {
56                  Utilities utilities = Utilities.getUtilities();
57                  toReturn = utilities.formatTempo(amostragem.getDuracao());
58              } else if(columnIndex == 2) {
59                  Utilities utilities = Utilities.getUtilities();
60                  toReturn = utilities.formatTemperatura(
61                          amostragem.getTemperatura());
62              }
63          }
64          
65          return toReturn;
66      }
67      
68      public boolean isCellEditable(int rowIndex, int columnIndex) {
69          return false;
70      }
71      
72      public void setProgramacaoAmostragem(IProgramacaoAmostragem programacaoAmostragem) {
73          this.programacaoAmostragem = programacaoAmostragem;
74      }
75  
76      public String getColumnName(int column) {
77          if(column == 0) {
78              return "Nome";
79          } else if(column == 1) {
80              return "Duração";
81          } else {
82              return "Temperatura";
83          }
84      }
85  }