📄 cachetablemodelex.java
字号:
return vector.elementAt(j);
} else
{
Trace.print("CacheTableModelEx", "getValueAt", "Out the data area-----rowIndex = " + i);
Trace.print("CacheTableModelEx", "getValueAt", "Out the data area-----low = " + low);
Trace.print("CacheTableModelEx", "getValueAt", "Out the data area-----columnIndex = " + j);
Trace.print("CacheTableModelEx", "getValueAt", "Out the data area-----colCount = " + colCount);
Trace.print("CacheTableModelEx", "getValueAt", "Out the data area-----cachedataSize = " + cachedData.size());
return null;
}
}
public Object getValueAtEx(int i, int j)
{
Vector vector = new Vector();
if(i >= low && i - low <= getDataCount() - 1 && j < colCount && j >= 0)
{
vector = (Vector)cachedData.elementAt(i - low);
return vector.elementAt(j);
}
Trace.print("CacheTableModelEx", "getValueAtEx", "Out the data area2-----");
if(i < endLow || i > endUp)
{
endData = new Vector();
endLow = i;
endUp = i + 300 <= getRowCount() - 1 ? i + 300 : getRowCount() - 1;
IDList idlist = constructIds(endLow, endUp);
if(idlist == null || idlist.size() == 0)
{
Trace.print("CacheTableModelEx", "getValueAtEx", "Error");
return null;
}
IDList idlist1 = null;
IDList idlist2 = null;
idlist1 = (IDList)idlist.clone();
idlist2 = _listener.requestData(idlist, endData);
if(idlist2 != null && idlist2.size() > 0)
{
int k = idlist2.size();
for(int l = 0; l < k; l++)
{
int i1 = idlist1.indexOf(idlist2.elementAt(l));
if(i1 != -1)
endData.insertElementAt(new Vector(1), i1);
}
}
}
vector = (Vector)endData.elementAt(i - endLow);
if(vector != null && vector.size() != 0)
return vector.elementAt(j);
else
return null;
}
public int getColumnCount()
{
if(tableHead != null)
{
Trace.print("", "", "Head Size is " + tableHead.size());
return tableHead.size();
} else
{
Trace.print("", "", "Head Size is 0");
return 0;
}
}
public int getRowCount()
{
if(idList != null)
return idList.size();
else
return 0;
}
public Class getColumnClass(int i)
{
return java.lang.String.class;
}
public String getColumnName(int i)
{
if(tableHead != null && i < tableHead.size())
{
Trace.print("", (String)tableHead.elementAt(i), "get name OK");
return (String)tableHead.elementAt(i);
} else
{
Trace.print("", "", "get name ERROR");
return null;
}
}
public void removeRows(int ai[])
{
if(ai == null || ai.length == 0)
return;
Arrays.sort(ai);
int i = low;
int j = up;
for(int k = ai.length - 1; k >= 0; k--)
{
Object obj = idList.elementAt(ai[k]);
idList.removeElementAt(ai[k]);
if(ai[k] < i)
{
low--;
up--;
} else
if(ai[k] >= i && ai[k] <= j)
{
cachedData.removeElementAt(ai[k] - i);
up--;
}
}
rowCount = idList.size();
fireTableChanged();
}
public void insertRow(int i, IDType idtype, Vector vector)
{
if(idtype == null)
return;
if(i < 0)
return;
idList.insertElementAt(idtype, i);
if(i >= low && i <= up)
{
cachedData.insertElementAt(vector, i - low);
up++;
}
rowCount = idList.size();
fireTableChanged();
}
public void addRows(IDList idlist)
{
Object obj = null;
int i = 0;
if(idlist == null || idlist.size() == 0)
return;
i = idlist.size();
for(int j = 0; j < i; j++)
{
IDType idtype = (IDType)idlist.elementAt(j);
if(idtype != null)
idList.addElement(idtype);
}
rowCount = idList.size();
fireTableChanged();
}
public void addRow(IDType idtype, Vector vector)
{
if(idtype == null)
return;
if(vector == null || vector.size() < 0)
return;
if(getRowCount() - super.lowestLine < 100)
{
cachedData.addElement(vector);
up++;
}
idList.addElement(idtype);
fireTableChanged();
}
private int getDataCount()
{
if(cachedData == null)
return 0;
else
return cachedData.size();
}
public IDList getSelectedId(int ai[])
{
IDList idlist = new IDList();
if(ai == null || ai.length < 0)
return idlist;
for(int i = 0; i < ai.length; i++)
if(ai[i] >= 0)
idlist.addElement(idList.elementAt(ai[i]));
return idlist;
}
public void setIDList(IDList idlist)
{
try
{
idList = (IDList)idlist.clone();
}
catch(NullPointerException nullpointerexception)
{
idList = null;
}
low = up = -1;
fireTableChanged();
Trace.print("CacheTableModelEx", "setIDList", "setIDList-----Ok");
}
public void setInitIDList(IDList idlist)
{
try
{
idList = (IDList)idlist.clone();
}
catch(NullPointerException nullpointerexception)
{
idList = null;
}
up = -1;
Trace.print("CacheTableModelEx", "setInitIDList", "setInitIDList-----Ok");
}
public IDList getAllId()
{
try
{
return (IDList)idList.clone();
}
catch(NullPointerException nullpointerexception)
{
return null;
}
}
public void destroy()
{
idList = null;
cachedData = null;
_listener = null;
tableHead = null;
endData = null;
}
public Vector getCachedData()
{
if(cachedData != null)
return (Vector)cachedData.clone();
else
return null;
}
private int getItemIndexById(IDType idtype)
{
if(idList == null)
return -1;
boolean flag = false;
int i = 0;
IDType idtype1;
for(int j = idList.size(); !flag && i < j; flag = idtype.value.intValue() == idtype1.value.intValue())
idtype1 = (IDType)idList.elementAt(i++);
if(flag)
return i - 1;
else
return -1;
}
public int isItemInCurrentShownTable(IDType idtype)
{
int i = getItemIndexById(idtype);
if(i != -1 && i >= low && i - low <= cachedData.size() - 1)
return i;
else
return -1;
}
int rowCount;
int colCount;
IDList idList;
Vector cachedData;
int low;
int up;
int pageSize;
int currentIndex;
private RequestDataListener _listener;
private boolean error;
private int errorCount;
Vector tableHead;
int endLow;
int endUp;
Vector endData;
private boolean bInit;
public CacheTableScrollPane js;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -