/*
* Copyright (C) 2008 Universidade Federal de Campina Grande
*
* This file is part of OurGrid.
*
* OurGrid is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.ourgrid.peer.ui.async.gui;
import javax.swing.table.AbstractTableModel;
import org.ourgrid.common.interfaces.status.CommunityInfo;
public class CommunityTableModel extends AbstractTableModel {
private CommunityInfo info;
public CommunityTableModel() {
this.info = new CommunityInfo();
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getColumnCount()
*/
public int getColumnCount() {
return 1;
}
@Override
public String getColumnName(int column) {
switch (column) {
case 0:
return "Peer address";
default:
return "";
}
}
@Override
public Class<?> getColumnClass(int columnIndex) {
switch (columnIndex) {
case 0:
return String.class;
default:
return Object.class;
}
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getRowCount()
*/
public int getRowCount() {
return info.getConnectedPeers().size();
}
/* (non-Javadoc)
* @see javax.swing.table.TableModel#getValueAt(int, int)
*/
public Object getValueAt(int rowIndex, int columnIndex) {
return info.getConnectedPeers().get(rowIndex);
}
public void setData(CommunityInfo info) {
this.info = info;
}
}