📄 listtablemodel.java
字号:
package com.esri.solutions.jitk.web.data.results;
import java.util.List;
/**
* @author Carsten Piepel
*
*/
public class ListTableModel extends AbstractTableModel {
/**
* The current row index (0-based).
*/
private int rowIndex = -1;
/**
* The list we are wrapping.
*/
@SuppressWarnings("unchecked")
private List data;
private EntityInfo entityInfo;
/**
* <p>
* Construct a new {@link ListTableModel} with no specified bound data.
* </p>
*/
public ListTableModel() {
this(null);
}
/**
* <p>
* Construct a new {@link ListTableModel} binding the specified list.
* </p>
*
* @param data
* List to be wrapped (if any)
*/
@SuppressWarnings("unchecked")
public ListTableModel(List data) {
super();
setData(data);
}
public boolean isRowAvailable() {
if (data == null) {
return (false);
} else if ((rowIndex >= 0) && (rowIndex < data.size())) {
return (true);
} else {
return (false);
}
}
public int getRowCount() {
if (data == null) {
return (-1);
}
return (data.size());
}
public Object getRowData() throws DataBindingException {
if (data == null) {
return (null);
} else if (!isRowAvailable()) {
throw new IllegalArgumentException("no row available");
} else {
return (data.get(rowIndex));
}
}
public Object getRowData(int rowIndex) throws DataBindingException {
if (data == null) {
return (null);
} else if (rowIndex < 0) {
throw new IllegalArgumentException("rowIndex < 0");
} else if (rowIndex >= data.size()) {
throw new IllegalArgumentException("rowIndex >= getRowCount()");
} else {
return (data.get(rowIndex));
}
}
public int getRowIndex() {
return rowIndex;
}
public void setRowIndex(int rowIndex) {
if (rowIndex < -1) {
throw new IllegalArgumentException();
}
int oldIndex = this.rowIndex;
this.rowIndex = rowIndex;
if (data == null) {
return;
}
if (oldIndex != rowIndex) {
Object rowData = null;
if (isRowAvailable()) {
rowData = getRowData();
}
RowSelectionEvent event =
new RowSelectionEvent(this, rowIndex, rowData);
fireRowSelectedEvent(event);
}
}
public Object getData() {
return getListData();
}
@SuppressWarnings("unchecked")
public void setData(Object data) {
setListData((List) data);
}
@SuppressWarnings("unchecked")
public List getListData() {
return data;
}
@SuppressWarnings("unchecked")
public void setListData(List data) {
this.data = data;
if (getRowIndex() > -1) {
rowIndex = -1;
}
if (getPageIndex() > -1) {
pageIndex = -1;
}
DataBindingEvent event = new DataBindingEvent(this, this.data);
fireDataBoundEvent(event);
}
public EntityInfo getEntityInfo() {
return entityInfo;
}
public void setEntityInfo(EntityInfo entityInfo) {
this.entityInfo = entityInfo;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -