📄 cachetablepanel.java
字号:
for(int i3 = 0; i3 < selectedRows.size(); i3++)
{
int j4 = ((Integer)selectedRows.elementAt(i3)).intValue();
if(j4 >= upEdge + cachedIDList.size())
{
j4 -= k - upEdge - cachedIDList.size();
if(!selectedRows.contains(new Integer(j4)))
selectedRows.setElementAt(new Integer(j4), i3);
else
vector.add(new Integer(i3));
}
}
for(int k4 = vector.size(); k4 > 0; k4--)
{
int i6 = ((Integer)vector.elementAt(k4 - 1)).intValue();
selectedRows.removeElementAt(i6);
}
}
} else
{
replaceCachedSegmentIDList(idList, cachedIDList, l, lowEdge);
if(!isSelectAll)
{
Vector vector1 = new Vector();
for(int j3 = 0; j3 < selectedRows.size(); j3++)
{
int l4 = ((Integer)selectedRows.elementAt(j3)).intValue();
if(l4 >= l + cachedIDList.size())
{
l4 -= lowEdge - l - cachedIDList.size();
if(!selectedRows.contains(new Integer(l4)))
selectedRows.setElementAt(new Integer(l4), j3);
else
vector1.add(new Integer(j3));
}
}
for(int i5 = vector1.size(); i5 > 0; i5--)
{
int j6 = ((Integer)vector1.elementAt(i5 - 1)).intValue();
selectedRows.removeElementAt(j6);
}
}
}
max = idList.size() * rowHeight;
isProgramSetValue = true;
cacheScrlBar.setMaximum(max);
cacheScrlBar.setValue(current);
isProgramSetValue = false;
model = (DefaultTableModel)cacheTable.getModel();
int j2 = cacheTable.getRowCount();
if(requestDataEvent == 1)
{
for(int k3 = 0; k3 < j2 - i - j; k3++)
model.removeRow(i + j);
} else
if(requestDataEvent == 2)
{
for(int l3 = 0; l3 < j2 - i - j; l3++)
model.removeRow(0);
}
int i4 = cachedIDList.size();
if(requestDataEvent == 1)
{
for(int j5 = 0; j5 < i4 - i - j; j5++)
cachedIDList.removeElementAt(i + j);
} else
if(requestDataEvent == 2)
{
for(int k5 = 0; k5 < i4 - i - j; k5++)
cachedIDList.removeElementAt(0);
}
if(requestDataEvent == 1)
{
lowEdge = Math.min(lowEdge, max / rowHeight);
upEdge = Math.max(upEdge, min / rowHeight);
} else
if(requestDataEvent == 2)
{
lowEdge = Math.min(l + j2, max / rowHeight);
upEdge = Math.max(lowEdge - cacheTable.getRowCount(), min / rowHeight);
}
oldLow = lowEdge;
oldUp = upEdge;
cacheScrlPane.getViewport().add(cacheTable);
iSetSelection = true;
for(int l5 = 0; l5 < selectedRows.size(); l5++)
{
int k6 = ((Integer)selectedRows.elementAt(l5)).intValue();
if(k6 >= upEdge && k6 < lowEdge)
cacheTable.getSelectionModel().addSelectionInterval(k6 - upEdge, k6 - upEdge);
}
iSetSelection = false;
} else
{
IDList idlist1 = _listener.requestAllItemIDList();
cacheTable.currentItemIndex = 0;
cleanCacheTable();
setIDListAwaredContent(idlist1);
if(idList != null && idList.size() > 0)
{
isInit = true;
startWork();
isInit = false;
}
}
revalidate();
repaint();
}
}
catch(Exception exception)
{
System.out.println(exception.toString());
}
}
private void replaceCachedSegmentIDList(IDList idlist, IDList idlist1, int i, int j)
{
for(int k = 0; k < idlist1.size(); k++)
idlist.setElementAt(idlist1.elementAt(k), i + k);
for(int l = 0; l < j - i - idlist1.size(); l++)
idlist.removeElementAt(i + idlist1.size());
}
private IDList getRequestDataIDList()
{
IDList idlist;
if(isInit)
{
idlist = new IDList();
caculateEdgeValue();
cachedIDList = new IDList();
for(int i = upEdge; i < lowEdge; i++)
cachedIDList.add(idList.elementAt(i));
idlist = cachedIDList;
requestDataEvent = 1;
needToReadData = true;
} else
{
if(current / rowHeight >= upEdge && (current + visibleAmount) / rowHeight <= lowEdge)
{
needToReadData = false;
return null;
}
caculateEdgeValue();
idlist = new IDList();
if(upEdge == oldUp && lowEdge == oldLow)
{
needToReadData = false;
return null;
}
if(upEdge == oldUp && lowEdge > oldLow)
{
for(int j = oldLow; j < lowEdge; j++)
{
cachedIDList.add(idList.elementAt(j));
idlist.add(idList.elementAt(j));
}
requestDataEvent = 1;
needToReadData = true;
} else
{
if(upEdge == oldUp && lowEdge < oldLow)
{
cachedIDList.subList(lowEdge - upEdge, oldLow - upEdge).clear();
for(int k = lowEdge; k < oldLow; k++)
model.removeRow(cacheSize);
needToReadData = false;
return null;
}
if(upEdge > oldUp && lowEdge == oldLow)
{
cachedIDList.subList(0, upEdge - oldUp).clear();
for(int l = oldUp; l < upEdge; l++)
model.removeRow(0);
needToReadData = false;
return null;
}
if(upEdge < oldUp && lowEdge == oldLow)
{
for(int i1 = upEdge; i1 < oldUp; i1++)
{
cachedIDList.insertElementAt(idList.elementAt(i1), i1 - upEdge);
idlist.add(idList.elementAt(i1));
}
requestDataEvent = 2;
needToReadData = true;
} else
{
int l1 = cacheTable.getRowCount();
for(int j1 = 0; j1 < l1; j1++)
model.removeRow(0);
cachedIDList = new IDList();
for(int k1 = upEdge; k1 < lowEdge; k1++)
cachedIDList.add(idList.elementAt(k1));
idlist = cachedIDList;
requestDataEvent = 1;
needToReadData = true;
}
}
}
oldUp = upEdge;
oldLow = lowEdge;
return idlist;
}
private void setViewportPoint()
{
int i = cacheScrlPane.getViewport().getViewSize().height;
if(compPos + visibleAmount <= i)
cacheScrlPane.getViewport().setViewPosition(new Point(hValue, compPos));
else
if(i <= visibleAmount)
cacheScrlPane.getViewport().setViewPosition(new Point(hValue, 0));
else
cacheScrlPane.getViewport().setViewPosition(new Point(hValue, i - visibleAmount));
revalidate();
repaint();
}
private void caculateEdgeValue()
{
upEdge = Math.max((current - compPos) / rowHeight, 0);
if(compPos < visibleAmount && max < upEdge * rowHeight + visibleAmount && upEdge != 0)
upEdge -= cacheSize;
if(visibleAmount > cacheSize * rowHeight - compPos)
lowEdge = Math.min((current - compPos) + 2 * cacheSize * rowHeight, max) / rowHeight;
else
lowEdge = Math.min((current - compPos) + cacheSize * rowHeight, max) / rowHeight;
if(lowEdge - upEdge > cacheSize)
lowEdge = upEdge + cacheSize;
}
private int getCompPos(int i)
{
int j;
for(j = i; j >= 0; j -= cacheSize * rowHeight);
j += cacheSize * rowHeight;
return j;
}
private void cacheScrlBar_adjusted(AdjustmentEvent adjustmentevent)
{
if(!isProgramSetValue && !cacheScrlBar.getValueIsAdjusting())
{
hValue = cacheScrlPane.getHorizontalScrollBar().getValue();
current = cacheScrlBar.getValue();
compPos = getCompPos(current);
setData(getRequestDataIDList());
setViewportPoint();
}
}
public void setIDListTable(IDListTable idlisttable)
{
if(_listener != null)
initAllData(idlisttable);
}
void setIDListTableFromIDListTable(IDListTable idlisttable)
{
for(; idlisttable.getRowCount() > 0; ((DefaultTableModel)idlisttable.getModel()).removeRow(0));
setIDListTable(idlisttable);
}
void setIDList(IDList idlist)
{
cleanCacheTable();
setIDListAwaredContent(idlist);
if(idList != null && idList.size() > 0 && _listener != null)
{
isInit = true;
startWork();
isInit = false;
}
}
public void setListener(RequestDataListener requestdatalistener)
{
_listener = requestdatalistener;
}
private int searchIDFromIDList(IDType idtype, IDList idlist)
{
if(idlist == null)
return -1;
boolean flag = false;
int i;
IDType idtype1;
for(i = 0; !flag && i < idlist.size(); flag = idtype.value.intValue() == idtype1.value.intValue())
idtype1 = (IDType)idlist.elementAt(i++);
if(flag)
return i - 1;
else
return -1;
}
public void setTableDataByHand(CacheTablePanel cachetablepanel)
{
}
public int getSelectRow()
{
if(APressed)
{
APressed = false;
return cacheTable.idList.size();
} else
{
return cacheTable.getSelectedRowCount();
}
}
public int getRowCount()
{
return cacheTable.idList.size();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -