1 /**
2 * Copyright 2008 WebPhotos
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 /*
17 * FTPTabelModel.java
18 *
19 * Created on 31 de Maio de 2006, 11:57
20 *
21 * To change this template, choose Tools | Template Manager
22 * and open the template in the editor.
23 */
24
25 package net.sf.webphotos.gui.util;
26
27 import java.util.ArrayList;
28 import java.util.Iterator;
29 import javax.swing.table.DefaultTableModel;
30 import net.sf.webphotos.util.legacy.Arquivo;
31
32 /**
33 * Modelo da tabela de dados do frame FtpClient.
34 * TODO: Modelo Antigo (Eliminar).
35 * @author guilherme
36 */
37 public class FTPTabelModel extends DefaultTableModel {
38
39 private static final long serialVersionUID = -4674468107065732418L;
40
41 final String[] nomesColuna={"Status","Ação","Álbum","Foto","Arquivo","Bytes"};
42 private Object[][] modelo;
43
44 /**
45 * Cria uma instancia do Modelo usando um array de dados.
46 * @param listaArquivos Dados a serem preenchidos
47 */
48 public FTPTabelModel(ArrayList<Arquivo> listaArquivos) {
49 super();
50 // transforma a colecao em um modelo para a tabela
51 refresh(listaArquivos);
52 }
53
54 /**
55 * Realiza a atualização dos dados da tabela.
56 * @param listaArquivos Dados usados para atualizar a tabela
57 */
58 public void refresh(ArrayList<Arquivo> listaArquivos) {
59 modelo=null;
60 modelo=new Object[listaArquivos.size()][6];
61 Iterator<Arquivo> iter = listaArquivos.iterator();
62 Arquivo a; int ct=0;
63 while(iter.hasNext()) {
64 a=(Arquivo) iter.next();
65 modelo[ct][0]=a.getStatus();
66 modelo[ct][1]=a.getNomeAcao();
67 modelo[ct][2]=Integer.toString(a.getAlbumID());
68 modelo[ct][3]=Integer.toString(a.getFotoID());
69 modelo[ct][4]=a.getNomeArquivo();
70 modelo[ct][5]=(Object) Long.toString(a.getTamanho());
71 ct++;
72 }
73 setDataVector(modelo, nomesColuna);
74 }
75
76 }