📄 searchresultlist.java
字号:
package de.uni_bremen.informatik.p2p.plugins.filesharing.data;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import de.uni_bremen.informatik.p2p.plugins.filesharing.control.FormatUtilities;
/**
* The SearchResultList class represents a datastructur of all searchresults.
* The class extends the functions of a AbstractTableModel to be the data
* class behind a JTable.
*
* @author Philipp Hoheisel, Cecile Prigge, Lars Kordes
*/
public class SearchResultList
extends AbstractTableModel {
/** List of all requested searchresults. */
private ArrayList list;
/**
* Classconstructor.
*
* @param list ArrayList with all searchresults of the filesharing plugin.
*/
public SearchResultList(ArrayList list) {
if (list == null) {
list = new ArrayList();
}
this.list = list;
}
//----------------- ABSTRACT TABLE MODEL CLASSES -------------------//
/**
* Method returns the number of columns in the table. There are 3 columns.
*
* @see javax.swing.table.TableModel#getColumnCount()
*/
public int getColumnCount() {
return 3;
}
/**
* Method return the number of rows in the table. The number equals the
* length of the searchresultlist.
*
* @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;
}
SearchResult sr = (SearchResult) list.get(arg0);
if (sr == null) {
return null;
}
switch (arg1) {
case 0 :
return sr.filename;
case 1 :
return FormatUtilities.giveCorrectSizeString(sr.size);
case 2 :
//return sr.username;
return new Integer(sr.sources.size());
}
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 "Filename";
case 1 :
return "Size";
case 2 :
//return "User";
return "Source(s)";
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -