Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Checkbox rendered in Table Cells
Checkbox rendered in Table Cells [message #451322] Fri, 25 February 2005 16:13 Go to next message
J. Shanonn is currently offline J. ShanonnFriend
Messages: 12
Registered: July 2009
Junior Member
Hello,
Can anyone tell me if it is possible using SWT/JFace to display a checkbox
in a table cell in a TableViewer? So far I have managed to display a
single checkbox at the beginning of each table row, but have not been able
to put checkboxes within multiple table cells in the row. I'm wanting my
table to have several columns with boolean data types that each display as
checkboxes. Any help would be greatly appreciated.

JS
Re: Checkbox rendered in Table Cells [message #451367 is a reply to message #451322] Mon, 28 February 2005 06:13 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Jason Shannon:


> Hello,
> Can anyone tell me if it is possible using SWT/JFace to display a
> checkbox in a table cell in a TableViewer? So far I have managed to
> display a single checkbox at the beginning of each table row, but have
> not been able to put checkboxes within multiple table cells in the row.
> I'm wanting my table to have several columns with boolean data types
> that each display as checkboxes. Any help would be greatly appreciated.
You could use image and change it on click.

--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)


Konstantin Scheglov,
Google, Inc.
Re: Checkbox rendered in Table Cells [message #451384 is a reply to message #451367] Mon, 28 February 2005 19:56 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
If you just change the image 1) you will not have the platform image, 2) you
will not be accessible by screen readers or keyboard access 3) you will have
to write code to detect the mouse down (up?) in the image.

You could create a Button with style SWT.CHECK make it an editor in the
TableEditor:

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
Table table = new Table(shell, SWT.BORDER);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn column0 = new TableColumn(table, SWT.NONE);
TableColumn column1 = new TableColumn(table, SWT.NONE);
TableColumn column2 = new TableColumn(table, SWT.NONE);
int minWidth = 0;
for (int i = 0; i < 100; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] {"item "+i, "asdadasd", "sada d
asd asd a dasd"});
if (i %3 == 0 || i % 5 == 0) {
Button b = new Button(table, SWT.CHECK);
b.pack();
TableEditor editor = new TableEditor(table);
Point size = b.computeSize(SWT.DEFAULT,
SWT.DEFAULT);
editor.minimumWidth = size.x;
minWidth = Math.max(size.x, minWidth);
editor.minimumHeight = size.y;
editor.horizontalAlignment = SWT.RIGHT;
editor.verticalAlignment = SWT.CENTER;
if (i % 3 == 0) {
editor.setEditor(b, item , 1);
} else {
editor.setEditor(b, item , 2);
}
}
}
column0.pack();
column1.pack();
column1.setWidth(column1.getWidth() + minWidth);
column2.pack();
column2.setWidth(column2.getWidth() + minWidth);
shell.setSize(300, 300);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

"Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
news:BrUWoyVHFHA.704@fairy.ao.nlmk...
> Jason Shannon:
>
>
>> Hello,
>> Can anyone tell me if it is possible using SWT/JFace to display a
>> checkbox in a table cell in a TableViewer? So far I have managed to
>> display a single checkbox at the beginning of each table row, but have
>> not been able to put checkboxes within multiple table cells in the row.
>> I'm wanting my table to have several columns with boolean data types that
>> each display as checkboxes. Any help would be greatly appreciated.
> You could use image and change it on click.
>
> --
> SY, Konstantin.
> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
Re: Checkbox rendered in Table Cells [message #451385 is a reply to message #451384] Mon, 28 February 2005 19:58 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
If you are using a JFace TableViewer, you could use a CheckboxCellEditor.

"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:cvvt34$p85$1@www.eclipse.org...
> If you just change the image 1) you will not have the platform image, 2)
> you will not be accessible by screen readers or keyboard access 3) you
> will have to write code to detect the mouse down (up?) in the image.
>
> You could create a Button with style SWT.CHECK make it an editor in the
> TableEditor:
>
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
> Table table = new Table(shell, SWT.BORDER);
> table.setHeaderVisible(true);
> table.setLinesVisible(true);
> TableColumn column0 = new TableColumn(table, SWT.NONE);
> TableColumn column1 = new TableColumn(table, SWT.NONE);
> TableColumn column2 = new TableColumn(table, SWT.NONE);
> int minWidth = 0;
> for (int i = 0; i < 100; i++) {
> TableItem item = new TableItem(table, SWT.NONE);
> item.setText(new String[] {"item "+i, "asdadasd", "sada d
> asd asd a dasd"});
> if (i %3 == 0 || i % 5 == 0) {
> Button b = new Button(table, SWT.CHECK);
> b.pack();
> TableEditor editor = new TableEditor(table);
> Point size = b.computeSize(SWT.DEFAULT,
> SWT.DEFAULT);
> editor.minimumWidth = size.x;
> minWidth = Math.max(size.x, minWidth);
> editor.minimumHeight = size.y;
> editor.horizontalAlignment = SWT.RIGHT;
> editor.verticalAlignment = SWT.CENTER;
> if (i % 3 == 0) {
> editor.setEditor(b, item , 1);
> } else {
> editor.setEditor(b, item , 2);
> }
> }
> }
> column0.pack();
> column1.pack();
> column1.setWidth(column1.getWidth() + minWidth);
> column2.pack();
> column2.setWidth(column2.getWidth() + minWidth);
> shell.setSize(300, 300);
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> "Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
> news:BrUWoyVHFHA.704@fairy.ao.nlmk...
>> Jason Shannon:
>>
>>
>>> Hello,
>>> Can anyone tell me if it is possible using SWT/JFace to display a
>>> checkbox in a table cell in a TableViewer? So far I have managed to
>>> display a single checkbox at the beginning of each table row, but have
>>> not been able to put checkboxes within multiple table cells in the row.
>>> I'm wanting my table to have several columns with boolean data types
>>> that each display as checkboxes. Any help would be greatly appreciated.
>> You could use image and change it on click.
>>
>> --
>> SY, Konstantin.
>> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
>
>
Re: Checkbox rendered in Table Cells [message #451396 is a reply to message #451384] Tue, 01 March 2005 05:52 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Veronika Irvine:

BTW, when I try in this example scroll table using keyboard
checkboxes don't move and become out of synch with their items. If I use
scrollbar I don't have such problem.
I use 3.1 M5 (M4 has same problem).

> If you just change the image 1) you will not have the platform image, 2) you
> will not be accessible by screen readers or keyboard access 3) you will have
> to write code to detect the mouse down (up?) in the image.
>
> You could create a Button with style SWT.CHECK make it an editor in the
> TableEditor:
>
> public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
> Table table = new Table(shell, SWT.BORDER);
> table.setHeaderVisible(true);
> table.setLinesVisible(true);
> TableColumn column0 = new TableColumn(table, SWT.NONE);
> TableColumn column1 = new TableColumn(table, SWT.NONE);
> TableColumn column2 = new TableColumn(table, SWT.NONE);
> int minWidth = 0;
> for (int i = 0; i < 100; i++) {
> TableItem item = new TableItem(table, SWT.NONE);
> item.setText(new String[] {"item "+i, "asdadasd", "sada d
> asd asd a dasd"});
> if (i %3 == 0 || i % 5 == 0) {
> Button b = new Button(table, SWT.CHECK);
> b.pack();
> TableEditor editor = new TableEditor(table);
> Point size = b.computeSize(SWT.DEFAULT,
> SWT.DEFAULT);
> editor.minimumWidth = size.x;
> minWidth = Math.max(size.x, minWidth);
> editor.minimumHeight = size.y;
> editor.horizontalAlignment = SWT.RIGHT;
> editor.verticalAlignment = SWT.CENTER;
> if (i % 3 == 0) {
> editor.setEditor(b, item , 1);
> } else {
> editor.setEditor(b, item , 2);
> }
> }
> }
> column0.pack();
> column1.pack();
> column1.setWidth(column1.getWidth() + minWidth);
> column2.pack();
> column2.setWidth(column2.getWidth() + minWidth);
> shell.setSize(300, 300);
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
> "Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
> news:BrUWoyVHFHA.704@fairy.ao.nlmk...
>
>>Jason Shannon:
>>
>>
>>
>>>Hello,
>>>Can anyone tell me if it is possible using SWT/JFace to display a
>>>checkbox in a table cell in a TableViewer? So far I have managed to
>>>display a single checkbox at the beginning of each table row, but have
>>>not been able to put checkboxes within multiple table cells in the row.
>>>I'm wanting my table to have several columns with boolean data types that
>>>each display as checkboxes. Any help would be greatly appreciated.
>>
>> You could use image and change it on click.
>>
>>--
>>SY, Konstantin.
>>Advanced Eclipse SWT Designer (http://www.swt-designer.com)
>
>
>


--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)


Konstantin Scheglov,
Google, Inc.
Re: Checkbox rendered in Table Cells [message #451666 is a reply to message #451385] Fri, 04 March 2005 17:35 Go to previous messageGo to next message
J. Shanonn is currently offline J. ShanonnFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Veronika,
Thanks for the advice. I like your suggestion and have implemented it
successfully. I'm now looking into using a checkBoxCellEditor, but cannot
find any good examples. Do you have any?

Thanks
Jason

Veronika Irvine wrote:

> If you are using a JFace TableViewer, you could use a CheckboxCellEditor.

> "Veronika Irvine" <veronika_irvine@oti.com> wrote in message
> news:cvvt34$p85$1@www.eclipse.org...
>> If you just change the image 1) you will not have the platform image, 2)
>> you will not be accessible by screen readers or keyboard access 3) you
>> will have to write code to detect the mouse down (up?) in the image.
>>
>> You could create a Button with style SWT.CHECK make it an editor in the
>> TableEditor:
>>
>> public static void main (String [] args) {
>> Display display = new Display ();
>> Shell shell = new Shell (display);
>> shell.setLayout(new FillLayout());
>> Table table = new Table(shell, SWT.BORDER);
>> table.setHeaderVisible(true);
>> table.setLinesVisible(true);
>> TableColumn column0 = new TableColumn(table, SWT.NONE);
>> TableColumn column1 = new TableColumn(table, SWT.NONE);
>> TableColumn column2 = new TableColumn(table, SWT.NONE);
>> int minWidth = 0;
>> for (int i = 0; i < 100; i++) {
>> TableItem item = new TableItem(table, SWT.NONE);
>> item.setText(new String[] {"item "+i, "asdadasd", "sada d
>> asd asd a dasd"});
>> if (i %3 == 0 || i % 5 == 0) {
>> Button b = new Button(table, SWT.CHECK);
>> b.pack();
>> TableEditor editor = new TableEditor(table);
>> Point size = b.computeSize(SWT.DEFAULT,
>> SWT.DEFAULT);
>> editor.minimumWidth = size.x;
>> minWidth = Math.max(size.x, minWidth);
>> editor.minimumHeight = size.y;
>> editor.horizontalAlignment = SWT.RIGHT;
>> editor.verticalAlignment = SWT.CENTER;
>> if (i % 3 == 0) {
>> editor.setEditor(b, item , 1);
>> } else {
>> editor.setEditor(b, item , 2);
>> }
>> }
>> }
>> column0.pack();
>> column1.pack();
>> column1.setWidth(column1.getWidth() + minWidth);
>> column2.pack();
>> column2.setWidth(column2.getWidth() + minWidth);
>> shell.setSize(300, 300);
>> shell.open ();
>> while (!shell.isDisposed ()) {
>> if (!display.readAndDispatch ()) display.sleep ();
>> }
>> display.dispose ();
>> }
>>
>> "Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
>> news:BrUWoyVHFHA.704@fairy.ao.nlmk...
>>> Jason Shannon:
>>>
>>>
>>>> Hello,
>>>> Can anyone tell me if it is possible using SWT/JFace to display a
>>>> checkbox in a table cell in a TableViewer? So far I have managed to
>>>> display a single checkbox at the beginning of each table row, but have
>>>> not been able to put checkboxes within multiple table cells in the row.
>>>> I'm wanting my table to have several columns with boolean data types
>>>> that each display as checkboxes. Any help would be greatly appreciated.
>>> You could use image and change it on click.
>>>
>>> --
>>> SY, Konstantin.
>>> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
>>
>>
Re: Checkbox rendered in Table Cells [message #451667 is a reply to message #451666] Fri, 04 March 2005 19:48 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
See:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.test s/Eclipse%20JFace%20Tests/org/eclipse/jface/tests/viewers/Ch eckboxTableViewerTest.java?rev=HEAD&content-type=text/vn d.viewcvs-markup

Also, ask about the CheckboxCellEditor on the eclipse.platform newsgroup.
It is a part of JFace and the owners of JFace primarily read that news
group:

news://news.eclipse.org/eclipse.platform


"Jason Shannon" <jshannon@securac.net> wrote in message
news:d0a68u$pfo$1@www.eclipse.org...
> Hi Veronika,
> Thanks for the advice. I like your suggestion and have implemented it
> successfully. I'm now looking into using a checkBoxCellEditor, but cannot
> find any good examples. Do you have any?
>
> Thanks
> Jason
>
> Veronika Irvine wrote:
>
>> If you are using a JFace TableViewer, you could use a CheckboxCellEditor.
>
>> "Veronika Irvine" <veronika_irvine@oti.com> wrote in message
>> news:cvvt34$p85$1@www.eclipse.org...
>>> If you just change the image 1) you will not have the platform image, 2)
>>> you will not be accessible by screen readers or keyboard access 3) you
>>> will have to write code to detect the mouse down (up?) in the image.
>>>
>>> You could create a Button with style SWT.CHECK make it an editor in the
>>> TableEditor:
>>>
>>> public static void main (String [] args) {
>>> Display display = new Display ();
>>> Shell shell = new Shell (display);
>>> shell.setLayout(new FillLayout());
>>> Table table = new Table(shell, SWT.BORDER);
>>> table.setHeaderVisible(true);
>>> table.setLinesVisible(true);
>>> TableColumn column0 = new TableColumn(table, SWT.NONE);
>>> TableColumn column1 = new TableColumn(table, SWT.NONE);
>>> TableColumn column2 = new TableColumn(table, SWT.NONE);
>>> int minWidth = 0;
>>> for (int i = 0; i < 100; i++) {
>>> TableItem item = new TableItem(table, SWT.NONE);
>>> item.setText(new String[] {"item "+i, "asdadasd", "sada d
>>> asd asd a dasd"});
>>> if (i %3 == 0 || i % 5 == 0) {
>>> Button b = new Button(table, SWT.CHECK);
>>> b.pack();
>>> TableEditor editor = new TableEditor(table);
>>> Point size = b.computeSize(SWT.DEFAULT,
>>> SWT.DEFAULT);
>>> editor.minimumWidth = size.x;
>>> minWidth = Math.max(size.x, minWidth);
>>> editor.minimumHeight = size.y;
>>> editor.horizontalAlignment = SWT.RIGHT;
>>> editor.verticalAlignment = SWT.CENTER;
>>> if (i % 3 == 0) {
>>> editor.setEditor(b, item , 1);
>>> } else {
>>> editor.setEditor(b, item , 2);
>>> }
>>> }
>>> }
>>> column0.pack();
>>> column1.pack();
>>> column1.setWidth(column1.getWidth() + minWidth);
>>> column2.pack();
>>> column2.setWidth(column2.getWidth() + minWidth);
>>> shell.setSize(300, 300);
>>> shell.open ();
>>> while (!shell.isDisposed ()) {
>>> if (!display.readAndDispatch ()) display.sleep ();
>>> }
>>> display.dispose ();
>>> }
>>>
>>> "Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
>>> news:BrUWoyVHFHA.704@fairy.ao.nlmk...
>>>> Jason Shannon:
>>>>
>>>>
>>>>> Hello,
>>>>> Can anyone tell me if it is possible using SWT/JFace to display a
>>>>> checkbox in a table cell in a TableViewer? So far I have managed to
>>>>> display a single checkbox at the beginning of each table row, but have
>>>>> not been able to put checkboxes within multiple table cells in the
>>>>> row. I'm wanting my table to have several columns with boolean data
>>>>> types that each display as checkboxes. Any help would be greatly
>>>>> appreciated.
>>>> You could use image and change it on click.
>>>>
>>>> --
>>>> SY, Konstantin.
>>>> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
>>>
>>>
>
>
Previous Topic:Composite-wide, deep focus?
Next Topic:Scrollbar direction
Goto Forum:
  


Current Time: Fri Apr 19 15:49:17 GMT 2024

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

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

Back to the top