File: ResultsTableModel.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (61 lines) | stat: -rw-r--r-- 1,282 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package tim.prune.function.filesleuth.gui;

import java.io.File;
import java.util.List;

import javax.swing.table.DefaultTableModel;

import tim.prune.I18nManager;
import tim.prune.function.filesleuth.SearchResult;


/** Table model to hold the results of the search */
public class ResultsTableModel extends DefaultTableModel
{
	private List<SearchResult> _results = null;


	public void setResults(List<SearchResult> inResults)
	{
		_results = inResults;
		fireTableStructureChanged();
	}

	@Override
	public int getColumnCount() {
		return 2;
	}

	@Override
	public String getColumnName(int inColNum) {
		return I18nManager.getText("dialog.findfile.resultscolumn."
			+ (inColNum == 0 ? "file" : "contents"));
	}

	@Override
	public int getRowCount() {
		return _results == null ? 0 : _results.size();
	}

	@Override
	public Object getValueAt(int inRowNum, int inColNum)
	{
		if (inRowNum >= getRowCount()) {
			return "";
		}
		if (inColNum == 0) {
			return _results.get(inRowNum).getFilename();
		}
		return _results.get(inRowNum).getContents();
	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		return false;
	}

	/** @return the file at the given index */
	public File getFile(int inIndex) {
		return _results.get(inIndex).getTrackFile().getFile();
	}
}