📄 listrow.java
字号:
int iIndex = getIndex();
bDisposed = true;
Iterator iter = mapTableCells.values().iterator();
while (iter.hasNext()) {
TableCellCore item = (TableCellCore) iter.next();
try {
item.dispose();
} catch (Exception e) {
Debug.out("Disposing ListRow Column", e);
}
}
if (rowComposite != null && !rowComposite.isDisposed()) {
// Link next row to what is above this row
ListRow rowNext = view.getRow(iIndex + 1);
if (rowNext != null) {
rowNext.fixupPosition();
Composite nextComposite = rowNext.getComposite();
if (nextComposite != null && !nextComposite.isDisposed()) {
FormData fdNext = (FormData) nextComposite.getLayoutData();
if (fdNext != null) {
ListRow rowPrevious = view.getRow(iIndex - 1);
Composite previousComposite = rowPrevious == null ? null
: rowPrevious.getComposite();
if (previousComposite != null && !previousComposite.isDisposed()) {
fdNext.top = new FormAttachment(previousComposite, 0);
} else {
fdNext.top = new FormAttachment(0, 0);
}
nextComposite.setLayoutData(fdNext);
}
}
}
rowComposite.dispose();
}
}
public void doPaint(GC gc, boolean bVisible) {
// XXX Copied from TableRowImpl
if (bDisposed || !bVisible) {
return;
}
Rectangle oldClipping = gc.getClipping();
try {
gc.setForeground(getForeground());
gc.setBackground(getBackground());
Iterator iter = mapTableCells.values().iterator();
while (iter.hasNext()) {
TableCellCore cell = (TableCellCore) iter.next();
try {
if (cell.needsPainting()) {
Rectangle bounds = cell.getBounds();
if (bounds != null) {
Rectangle clipping = bounds.intersection(oldClipping);
gc.setClipping(clipping);
cell.doPaint(gc);
}
}
} catch (Exception e) {
Debug.out(e);
}
}
} finally {
gc.setClipping(oldClipping);
}
}
// XXX Copied from TableRowImpl!!
public Object getDataSource(boolean bCoreObject) {
checkCellForSetting();
if (bCoreObject) {
return coreDataSource;
}
if (pluginDataSource != null) {
return pluginDataSource;
}
if (coreDataSource instanceof DownloadManager) {
DownloadManager dm = (DownloadManager) coreDataSource;
if (dm != null) {
try {
pluginDataSource = DownloadManagerImpl.getDownloadStatic(dm);
} catch (DownloadException e) { /* Ignore */
}
}
}
if (coreDataSource instanceof PEPeer) {
PEPeer peer = (PEPeer) coreDataSource;
if (peer != null) {
pluginDataSource = PeerManagerImpl.getPeerForPEPeer(peer);
}
}
if (coreDataSource instanceof PEPiece) {
// XXX There is no Piece object for plugins yet
PEPiece piece = (PEPiece) coreDataSource;
if (piece != null) {
pluginDataSource = null;
}
}
if (coreDataSource instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) coreDataSource;
if (fileInfo != null) {
try {
pluginDataSource = new DiskManagerFileInfoImpl(
DownloadManagerImpl.getDownloadStatic(fileInfo.getDownloadManager()),
fileInfo);
} catch (DownloadException e) { /* Ignore */
}
}
}
if (coreDataSource instanceof TRHostTorrent) {
TRHostTorrent item = (TRHostTorrent) coreDataSource;
if (item != null) {
pluginDataSource = new TrackerTorrentImpl(item);
}
}
return pluginDataSource;
}
public Color getForeground() {
return rowComposite.getForeground();
}
public int getIndex() {
return view.indexOf(this);
}
public TableCellCore getTableCellCore(String field) {
if (bDisposed) {
return null;
}
return (TableCellCore) mapTableCells.get(field);
}
public void invalidate() {
// TODO Auto-generated method stub
}
public boolean isRowDisposed() {
// TODO Auto-generated method stub
return false;
}
public boolean isSelected() {
return bSelected;
}
public boolean isVisible() {
// if (position == 50) {
// System.out.println(view.getBounds());
// System.out.println(rowComposite.getBounds());
// }
return rowComposite.isVisible()
&& view.getBounds().intersects(rowComposite.getBounds());
}
public void locationChanged(int iStartColumn) {
// TODO Auto-generated method stub
}
// XXX Copied from TableRowImp!
public void refresh(boolean bDoGraphics) {
checkCellForSetting();
// If this were called from a plugin, we'd have to refresh the sorted column
// even if we weren't visible
boolean bVisible = isVisible();
if (!bVisible) {
setUpToDate(false);
return;
}
Iterator iter = mapTableCells.values().iterator();
while (iter.hasNext()) {
TableCellCore item = (TableCellCore) iter.next();
item.refresh(bDoGraphics, bVisible);
}
}
// @see org.gudy.azureus2.ui.swt.views.table.TableRowCore#refresh(boolean, boolean)
public void refresh(boolean bDoGraphics, boolean bVisible) {
refresh(bDoGraphics);
}
public void setForeground(Color c) {
Iterator iter = mapTableCells.values().iterator();
while (iter.hasNext()) {
TableCellCore item = (TableCellCore) iter.next();
item.setForeground(c);
}
}
public boolean setHeight(int iHeight) {
// TODO Auto-generated method stub
return false;
}
public boolean setIconSize(Point pt) {
// TODO Auto-generated method stub
return false;
}
public void setSelected(boolean bSelected) {
if (this.bSelected == bSelected) {
return;
}
this.bSelected = bSelected;
setBackgroundColor(getIndex());
view.rowSetSelected(this, bSelected);
}
/**
* @param b
*/
public void setFocused(boolean b) {
ListRow rowFocused = view.getRowFocused();
if (rowFocused != null && !rowFocused.equals(this)) {
rowFocused.setFocused(false);
}
if (b) {
view.rowSetFocused(this);
} else {
view.rowSetFocused(null);
}
repaint();
}
public boolean isFocused() {
return this.equals(view.getRowFocused());
}
/**
* Fixes up layout, and if something changed, it makes sure items near it
* are fixed up
*/
public boolean setTableItem(int iRowPos) {
if (!fixupPosition()) {
return false;
}
ListRow row = view.getRow(iRowPos + 1);
if (row != null) {
row.fixupPosition();
}
return true;
}
/**
* Fixes up row's layout. Does not check if rows next to it are correct,
* even if some layout information changed
*
* @return
*/
public boolean fixupPosition() {
int iRowPos = getIndex();
setBackgroundColor(iRowPos);
ListRow rowPrevious = view.getRow(iRowPos - 1);
Composite previousComposite = rowPrevious == null ? null
: rowPrevious.getComposite();
FormData fd = (FormData) rowComposite.getLayoutData();
if (previousComposite != null && !previousComposite.isDisposed()) {
if (fd.top != null && fd.top.control == previousComposite) {
return false;
}
fd.top = new FormAttachment(previousComposite, 0);
} else {
if (fd.top != null && fd.top.control == null) {
return false;
}
fd.top = new FormAttachment(0, 0);
}
rowComposite.setLayoutData(fd);
return true;
}
public void setUpToDate(boolean upToDate) {
if (bDisposed)
return;
Iterator iter = mapTableCells.values().iterator();
while (iter.hasNext()) {
TableCellCore cell = (TableCellCore)iter.next();
if (cell != null) {
boolean bOldUpToDate = cell.isUpToDate();
if (bOldUpToDate != upToDate) {
cell.setUpToDate(upToDate);
// hack.. a call to ListCell.isShown will trigger Visibility Listener
ListCell listcell = (ListCell)cell.getBufferedTableItem();
listcell.isShown();
}
}
}
}
public Object getDataSource() {
return getDataSource(false);
}
public TableCell getTableCell(String sColumnName) {
// TODO Auto-generated method stub
return null;
}
public String getTableID() {
// TODO Auto-generated method stub
return null;
}
public boolean isValid() {
// TODO Auto-generated method stub
return false;
}
public Color getBackground() {
return rowComposite.getBackground();
}
/**
* @param x
* @param y
* @return
*/
public TableCellCore getTableCellCore(int x, int y) {
Iterator iter = mapTableCells.values().iterator();
while (iter.hasNext()) {
TableCellCore cell = (TableCellCore) iter.next();
if (cell.isShown()) {
Rectangle bounds = cell.getBounds();
if (bounds != null && bounds.contains(x, y)) {
return cell;
}
}
}
return null;
}
public ListView getView() {
return view;
}
// @see org.gudy.azureus2.ui.swt.views.table.TableRowCore#repaint()
public void repaint() {
if (rowComposite != null && !rowComposite.isDisposed()) {
rowComposite.redraw();
} else {
Debug.out("ListRow repaint called after rowComposite is disposed. "
+ Debug.getCompressedStackTrace());
}
}
// @see org.gudy.azureus2.ui.swt.views.table.TableRowCore#setAlternatingBGColor(boolean)
public void setAlternatingBGColor(boolean bEvenIfNotVisible) {
setBackgroundColor(getIndex());
}
public void doPaint(GC gc) {
doPaint(gc, isVisible());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -