ColumnDateAdded2Linerpublic class ColumnDateAdded2Liner extends org.gudy.azureus2.ui.swt.views.table.utils.CoreTableColumn implements org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener
Fields Summary |
---|
public static String | COLUMN_ID | static final String[] | FORMATS | static int | globalFormat | int | curFormat |
Constructors Summary |
---|
public ColumnDateAdded2Liner(String sTableID, boolean bVisible)
super(COLUMN_ID, ALIGN_TRAIL,
bVisible ? POSITION_LAST : POSITION_INVISIBLE, 70, sTableID);
setMaxWidthAuto(true);
|
Methods Summary |
---|
public void | refresh(org.gudy.azureus2.plugins.ui.tables.TableCell cell)
DownloadManager dm = (DownloadManager) cell.getDataSource();
long value = (dm == null) ? 0 : dm.getDownloadState().getLongParameter(
DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME);
if (!cell.setSortValue(value) && cell.isValid()
&& curFormat == globalFormat) {
return;
}
if (!cell.isShown()) {
return;
}
int cellWidth = cell.getWidth();
Date date = new Date(value);
GC gc = new GC(Display.getDefault());
Point minSize = new Point(99999, 0);
int idxFormat = -1;
for (int i = globalFormat; i < FORMATS.length; i++) {
SimpleDateFormat temp = new SimpleDateFormat(FORMATS[i]);
Point newSize = gc.stringExtent(temp.format(date));
if (newSize.x < cellWidth) {
idxFormat = i;
break;
}
if (newSize.x < minSize.x) {
minSize = newSize;
idxFormat = i;
}
}
gc.dispose();
if (idxFormat >= 0) {
if (idxFormat > globalFormat) {
globalFormat = idxFormat;
cell.getTableColumn().invalidateCells();
} else if (idxFormat < globalFormat) {
idxFormat = globalFormat;
}
curFormat = idxFormat;
SimpleDateFormat temp = new SimpleDateFormat(FORMATS[idxFormat]
+ "\nh:mm a");
cell.setText(temp.format(date));
}
|
|