Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Some questions about TableTree
Some questions about TableTree [message #444704] Thu, 21 October 2004 03:32 Go to next message
Nicole is currently offline NicoleFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

Been trying to use a TableTree in my plugin. During which, I have some
doubts about how to do some stuff. Hopefully someone can help me with
these... Thanks.

1) How do I set the background colour of the header row?

2) I am using a CheckBoxCellEditor for my cells. So according to an
example I have seen, I used the LabelProvider to put a different image
(Checked or Unchecked) according to my object's state. But because my cell
width is much bigger than my image width, my image always appears left
justified. How do I make the image appear in the center?

3) I use the TableColumn.setText() to define the string to be displayed in
the header. Is it possible to make this multi-line? If not, maybe I need
to draw on the Control itself. How do I do this?

4) I need to paint the background of individual items in my TableTree. I
currently am trying to do this with the help of TableTreeEditor with a
Canvas as its control. My question is if I do it this way, will my Canvas
control hide my Check / Uncheck images?

This is all so far. Appreciate any help. Thank you all again.

Regards,
Nicole
Re: Some questions about TableTree [message #444856 is a reply to message #444704] Thu, 21 October 2004 13:32 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
1) It is not possible to change the background of a table header. Not that
on many platforms the header is not a solid colour but a gradient or some
rounded effect.

2) Using the ILabelProvider to change the image from checked to unchecked is
a bad idea because it does not support accessibility (screen readers can not
report the state based on the image because the image has no title and also
it does not have any built in keyboard support for changing the state).
Ideally you should use TableTreeItem.setChecked(boolean). This will give
you a fully supported check box in the first column.

3) Multi-line text in a Table/Tree/TableTree is not supported.

4) You can set a solid colour in the background of any row using
TableTreeItem.setBackground(Color). I will add support for setting the
background of any cell using TableTreeItem.setBackground(int, Color) in 3.1.
In response to your question, the image is not covered by the editor.

"Nicole" <nicole_kidding@yahoo.com> wrote in message
news:cl7akf$k0r$1@eclipse.org...
> Hi,
>
> Been trying to use a TableTree in my plugin. During which, I have some
> doubts about how to do some stuff. Hopefully someone can help me with
> these... Thanks.
>
> 1) How do I set the background colour of the header row?
>
> 2) I am using a CheckBoxCellEditor for my cells. So according to an
> example I have seen, I used the LabelProvider to put a different image
> (Checked or Unchecked) according to my object's state. But because my cell
> width is much bigger than my image width, my image always appears left
> justified. How do I make the image appear in the center?
>
> 3) I use the TableColumn.setText() to define the string to be displayed in
> the header. Is it possible to make this multi-line? If not, maybe I need
> to draw on the Control itself. How do I do this?
>
> 4) I need to paint the background of individual items in my TableTree. I
> currently am trying to do this with the help of TableTreeEditor with a
> Canvas as its control. My question is if I do it this way, will my Canvas
> control hide my Check / Uncheck images?
>
> This is all so far. Appreciate any help. Thank you all again.
>
> Regards,
> Nicole
>
>
Re: Some questions about TableTree [message #444864 is a reply to message #444856] Thu, 21 October 2004 18:00 Go to previous messageGo to next message
Nicole is currently offline NicoleFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

Thanks for replying. :)

However for (2), I need to have a checkbox behaviour for every cell in the
row, except for the first column. That's why I had to use the
CheckBoxCellEditor. And then because this class does not actually return a
Checkbox control in the cell, I had to use the LabelProvider to display
the checkbox image. Do you mean I can use the TableTreeItem.setChecked()
to create a checkbox effect on every other cell in the row?

Thanks.

Regards,
Nicole


Veronika Irvine wrote:

> 1) It is not possible to change the background of a table header. Not that
> on many platforms the header is not a solid colour but a gradient or some
> rounded effect.

> 2) Using the ILabelProvider to change the image from checked to unchecked is
> a bad idea because it does not support accessibility (screen readers can not
> report the state based on the image because the image has no title and also
> it does not have any built in keyboard support for changing the state).
> Ideally you should use TableTreeItem.setChecked(boolean). This will give
> you a fully supported check box in the first column.

> 3) Multi-line text in a Table/Tree/TableTree is not supported.

> 4) You can set a solid colour in the background of any row using
> TableTreeItem.setBackground(Color). I will add support for setting the
> background of any cell using TableTreeItem.setBackground(int, Color) in 3.1.
> In response to your question, the image is not covered by the editor.

> "Nicole" <nicole_kidding@yahoo.com> wrote in message
> news:cl7akf$k0r$1@eclipse.org...
> > Hi,
> >
> > Been trying to use a TableTree in my plugin. During which, I have some
> > doubts about how to do some stuff. Hopefully someone can help me with
> > these... Thanks.
> >
> > 1) How do I set the background colour of the header row?
> >
> > 2) I am using a CheckBoxCellEditor for my cells. So according to an
> > example I have seen, I used the LabelProvider to put a different image
> > (Checked or Unchecked) according to my object's state. But because my cell
> > width is much bigger than my image width, my image always appears left
> > justified. How do I make the image appear in the center?
> >
> > 3) I use the TableColumn.setText() to define the string to be displayed in
> > the header. Is it possible to make this multi-line? If not, maybe I need
> > to draw on the Control itself. How do I do this?
> >
> > 4) I need to paint the background of individual items in my TableTree. I
> > currently am trying to do this with the help of TableTreeEditor with a
> > Canvas as its control. My question is if I do it this way, will my Canvas
> > control hide my Check / Uncheck images?
> >
> > This is all so far. Appreciate any help. Thank you all again.
> >
> > Regards,
> > Nicole
> >
> >
Re: Some questions about TableTree [message #444968 is a reply to message #444864] Fri, 22 October 2004 16:01 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Unfortunately SWT Table only supports a checkbox in the first column.

You should implement an IAccessibleControlListener if you are going to
include state information in the image:

final static String STATE = "CheckedIndices";

public static void main (String [] args) {
final Display display = new Display ();
Image checkedImage = getCheckedImage (display);
Image uncheckedImage = getUncheckedImage (display);
Shell shell = new Shell (display);
shell.setLayout (new FillLayout ());
final Table table = new Table (shell, SWT.BORDER);
TableColumn column1 = new TableColumn (table, SWT.NONE);
TableColumn column2 = new TableColumn (table, SWT.NONE);
TableColumn column3 = new TableColumn (table, SWT.NONE);
TableItem item1 = new TableItem (table, SWT.NONE);
item1.setText (new String [] {"first item", "a", "b"});
item1.setImage (1, uncheckedImage);
item1.setImage (2, uncheckedImage);
item1.setData (STATE, null);
TableItem item2 = new TableItem (table, SWT.NONE);
item2.setText (new String [] {"second item", "c", "d"});
item2.setImage (1, uncheckedImage);
item2.setImage (2, checkedImage);
item2.setData (STATE, new int [] {2});
TableItem item3 = new TableItem (table, SWT.NONE);
item3.setText (new String [] {"third", "e", "f"});
item3.setImage (1, checkedImage);
item3.setImage (2, checkedImage);
item3.setData (STATE, new int [] {1, 2});
column1.pack ();
column2.pack ();
column3.pack ();
Accessible accessible = table.getAccessible ();
accessible.addAccessibleControlListener (new
AccessibleControlAdapter () {
public void getState (AccessibleControlEvent e) {
super.getState (e);
if (e.childID >= 0 && e.childID < table.getItemCount
()) {
TableItem item = table.getItem (e.childID);
int [] data = (int []) item.getData (STATE);
if (data != null) {
Point pt = display.getCursorLocation
();
pt = display.map (null, table, pt);
for (int i = 0; i < data.length;
i++) {
if (item.getBounds (data
[i]).contains (pt)) {
e.detail |=
ACC.STATE_CHECKED;
break;
}
}
}
}
}
});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

static Image getCheckedImage (Display display) {
Image image = new Image (display, 16, 16);
GC gc = new GC (image);
gc.setBackground (display.getSystemColor (SWT.COLOR_YELLOW));
gc.fillOval (0, 0, 16, 16);
gc.setForeground (display.getSystemColor (SWT.COLOR_DARK_GREEN));
gc.drawLine (0, 0, 16, 16);
gc.drawLine (16, 0, 0, 16);
gc.dispose ();
return image;
}

static Image getUncheckedImage (Display display) {
Image image = new Image (display, 16, 16);
GC gc = new GC (image);
gc.setBackground (display.getSystemColor (SWT.COLOR_YELLOW));
gc.fillOval (0, 0, 16, 16);
gc.dispose ();
return image;
}
}


"Nicole" <nicole_kidding@yahoo.com> wrote in message
news:cl8tfm$tvs$1@eclipse.org...
> Hi,
>
> Thanks for replying. :)
>
> However for (2), I need to have a checkbox behaviour for every cell in the
> row, except for the first column. That's why I had to use the
> CheckBoxCellEditor. And then because this class does not actually return a
> Checkbox control in the cell, I had to use the LabelProvider to display
> the checkbox image. Do you mean I can use the TableTreeItem.setChecked()
> to create a checkbox effect on every other cell in the row?
>
> Thanks.
>
> Regards,
> Nicole
>
>
> Veronika Irvine wrote:
>
>> 1) It is not possible to change the background of a table header. Not
>> that
>> on many platforms the header is not a solid colour but a gradient or some
>> rounded effect.
>
>> 2) Using the ILabelProvider to change the image from checked to unchecked
>> is
>> a bad idea because it does not support accessibility (screen readers can
>> not
>> report the state based on the image because the image has no title and
>> also
>> it does not have any built in keyboard support for changing the state).
>> Ideally you should use TableTreeItem.setChecked(boolean). This will give
>> you a fully supported check box in the first column.
>
>> 3) Multi-line text in a Table/Tree/TableTree is not supported.
>
>> 4) You can set a solid colour in the background of any row using
>> TableTreeItem.setBackground(Color). I will add support for setting the
>> background of any cell using TableTreeItem.setBackground(int, Color) in
>> 3.1.
>> In response to your question, the image is not covered by the editor.
>
>> "Nicole" <nicole_kidding@yahoo.com> wrote in message
>> news:cl7akf$k0r$1@eclipse.org...
>> > Hi,
>> >
>> > Been trying to use a TableTree in my plugin. During which, I have some
>> > doubts about how to do some stuff. Hopefully someone can help me with
>> > these... Thanks.
>> >
>> > 1) How do I set the background colour of the header row?
>> >
>> > 2) I am using a CheckBoxCellEditor for my cells. So according to an
>> > example I have seen, I used the LabelProvider to put a different image
>> > (Checked or Unchecked) according to my object's state. But because my
>> > cell
>> > width is much bigger than my image width, my image always appears left
>> > justified. How do I make the image appear in the center?
>> >
>> > 3) I use the TableColumn.setText() to define the string to be displayed
>> > in
>> > the header. Is it possible to make this multi-line? If not, maybe I
>> > need
>> > to draw on the Control itself. How do I do this?
>> >
>> > 4) I need to paint the background of individual items in my TableTree.
>> > I
>> > currently am trying to do this with the help of TableTreeEditor with a
>> > Canvas as its control. My question is if I do it this way, will my
>> > Canvas
>> > control hide my Check / Uncheck images?
>> >
>> > This is all so far. Appreciate any help. Thank you all again.
>> >
>> > Regards,
>> > Nicole
>> >
>> >
>
>
Previous Topic:Wheel Mouse
Next Topic:how to fix the size of Excel OLE object
Goto Forum:
  


Current Time: Fri Apr 19 02:44:17 GMT 2024

Powered by FUDForum. Page generated in 0.02247 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top