[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Problem with setting the foreground of a selected TableItem
|
- From: saintveni@xxxxxx (Nevena)
- Date: Tue, 1 Apr 2008 11:23:16 +0000 (UTC)
- Newsgroups: eclipse.platform.swt
- Organization: Eclipse
- User-agent: NewsPortal/0.36 (http://florian-amrhein.de/newsportal)
Hi, all
I am a three weeks' newbee in SWT, and I have a problem to which I found
no answer.
In my application I display a Table (certificateTable), populated with the
properties of some objects (Certificates). I want to color those items of
the table, that display certificates out of date, in red.
All works well, as long as the out-of-date-certificate is not the selected
item. If the out-of-date-certificate is selected, then the setting of the
foreground color is overridden by the default foreground color(white). Or
am I missing something...? Does anyone have a solution to the problem? Any
help would be appreciated!
I post a code snippet:
public void fillCertificateTable() {
certificateTable.removeAll();
WelderProcessor wp = ui.getWelderProcessor();
CertificateProcessor cp = wp.getCertificateProcessor();
int maxWC = cp.getNumEntities();
// populate the data
for (int j = 0; j < maxWC; j++) {
Certificate certificate = cp.getEntityByIndex(j);
Welder welder = wp.getEntityByNum(certificate.getWelder()
.getNumber());
TableItem itemCert = new TableItem(certificateTable, SWT.NONE);
String date = "";
Date valiDt = certificate.getValidDt();
if (valiDt != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
date = sdf.format(valiDt);
}
itemCert
.setText(new String[] { welder.getNumber(),
welder.getLastName() + " " + welder.getFirstName(),
certificate.getNorm(), certificate.getNumber(),
certificate.getRemarks(),
"" + certificate.getDiameter(),
"" + certificate.getThickness(),
certificate.getDiameterDimensions(),
certificate.getThicknessDimensions(),
certificate.getPosition(),
certificate.getProcess(), date });
// check the date of the certificate,
// and if it is before the current date,
// color the table item in red
if (valiDt != null && valiDt.before(new Date())) {
Color red = display.getSystemColor(SWT.COLOR_RED);
itemCert.setForeground(red);
}
}
// get the table item to be selected
int selIndex = cp.getEntityIdByNum(c.getNumber());
// set the selection
certificateTable.setSelection(selIndex);
Thanks for your help in advance!