📄 sharelist.java
字号:
package de.uni_bremen.informatik.p2p.plugins.filesharing.data;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
* The ShareList class represents a datastructur of all shares of the
* filesharing plugin. The class extends the functions of a
* AbstractTableModel to be the data class behind a JTable.
*
* @author Lars Kordes, Philipp Hoheisel
*/
public class ShareList
extends AbstractTableModel {
/** List of all shares. */
private ArrayList list;
/**
* Classconstructor.
*
* @param list ArrayList with all shares of the filesharing plugin.
*/
public ShareList(ArrayList list) {
if (list == null) {
list = new ArrayList();
}
this.list = list;
}
//----------------- ABSTRACT TABLE MODEL CLASS -------------------//
/**
* Method returns the number of columns in the table. There are 3 columns.
*
* @see javax.swing.table.TableModel#getColumnCount()
*/
public int getColumnCount() {
return 3;
//return 2;
}
/**
* Method return the number of rows in the table. The number equals the
* length of the sharelist.
*
* @see javax.swing.table.TableModel#getRowCount()
*/
public int getRowCount() {
return list.size();
}
/**
* Returns the value at a specific tablecell.
*
* @see javax.swing.table.TableModel#getValueAt(int, int)
*/
public Object getValueAt(int arg0,
int arg1) {
if (list == null) {
return null;
}
Share sf = (Share) list.get(arg0);
if (sf == null) {
return null;
}
switch (arg1) {
case 0 :
return sf.file.getParent();
case 1 :
if (sf.file.getName().equals("")) {
return "";
} else {
return sf.file.getName();
}
case 2 :
return sf.hash;
}
return null;
}
/**
* Method returns the names of the specific columns.
*
* @param arg0 Index of the column.
*
* @return Name of the specific column.
*/
public String getColumnName(int arg0) {
switch (arg0) {
case 0 :
return "Path";
case 1 :
return "Filename";
case 2 :
return "Hash value";
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -