[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-swt-dev] RE: Row headers
|
> Bianca Xue Jiang Mon, 29 Nov 2004 15:43:09 -0500
> > When using SWT Table, we need row Headers as well as column
> headers.
> > This is not currently available in 3.0. I'm wondering if there is a
> > request for it
>
> I don't know that there is: consider looking @
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=37998
Essential Data's MROTable is designed to do this.
Here's the MROTable example from the Essential Data's doc rewritten to have
headers on each row:
// Replace the appropriate parts of View.java with this:
private int[] getColumnWeights() {
return new int[] {25, 25, 10, 20, 20};
}
private class ContactsRowFactory implements IPartControlFactory {
public Composite createPartControl(Composite parent) {
Color white =
Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
// The row Composite
Composite part = new Composite(parent, SWT.NULL);
part.setBackground(white);
part.setLayout(new FillLayout(SWT.VERTICAL));
// Include the header on each row
Composite rowHeader = new Composite(part, SWT.NULL);
rowHeader.setLayout(new TableLayout(getColumnWeights(),
SWT.CENTER | SWT.BORDER));
new Label(rowHeader, SWT.NULL).setText("First Name");
new Label(rowHeader, SWT.NULL).setText("Last Name");
new Label(rowHeader, SWT.NULL).setText("Age");
new Label(rowHeader, SWT.NULL).setText("Phone");
new Label(rowHeader, SWT.NULL).setText("Gender");
// The actual SWT editor objects
Composite row = new Composite(part, SWT.NULL);
row.setBackground(white);
row.setLayout(new TableLayout(getColumnWeights(), SWT.CENTER |
SWT.BORDER));
new Text(row, SWT.NULL).setData("boundTo", "FirstName");
new Text(row, SWT.NULL).setData("boundTo", "LastName");
new Text(row, SWT.NULL).setData("boundTo", "Age");
new Text(row, SWT.NULL).setData("boundTo", "PhoneNumber");
new Combo(row, SWT.READ_ONLY).setData("boundTo", "Gender");
return part;
}
}
Actually, running this code shows a few minor bugs in the keyboard handling
that I'll fix. The fix should be in CVS this afternoon.
You can find Essential Data at:
http://www.swtworkbench.com
Full Disclosure:
I'm the project lead for Essential Data.
Essential Data is dual-licensed: GPL for open-source use only and commercial
for closed-source use.
Regards,
Dave Orme
Visual Editor Project lead
Chief Architect - SWTworkbench