Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Disable editing checkboxes in a Table
Disable editing checkboxes in a Table [message #542522] Fri, 25 June 2010 07:59 Go to next message
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
I have a table with checkboxes in my application. However, they only show information from my model and letting the user check or uncheck them doesn't make sense.

Unfortunately, TableColumn doesn't have setEnabled method. I've tried to wrap the table into an extra Composite and call setEnabled(false) on it, but this prevents me from scrolling the table as well.

Is there a way to do this?
Re: Disable editing checkboxes in a Table [message #542551 is a reply to message #542522] Fri, 25 June 2010 09:55 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel Krügler
Messages: 853
Registered: July 2009
Senior Member
On 25.06.2010 09:59, Alexey Romanov wrote:
> I have a table with checkboxes in my application. However, they only
> show information from my model and letting the user check or uncheck
> them doesn't make sense.
>
> Unfortunately, TableColumn doesn't have setEnabled method. I've tried to
> wrap the table into an extra Composite and call setEnabled(false) on it,
> but this prevents me from scrolling the table as well.
>
> Is there a way to do this?

AFAIK there is no "clean" solution. You may want to try the workaround
suggested in:

http://tom-eclipse-dev.blogspot.com/2008/10/disable-parts-sw t-tabletree-with.html

(I believe it should work by restricting to the pure SWT Table API).

HTH & Greetings from Bremen,

Daniel Krügler
Re: Disable editing checkboxes in a Table [message #542562 is a reply to message #542551] Fri, 25 June 2010 10:40 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel Krügler
Messages: 853
Registered: July 2009
Senior Member
On 25.06.2010 11:55, Daniel Krügler wrote:
> On 25.06.2010 09:59, Alexey Romanov wrote:
>> I have a table with checkboxes in my application. However, they only
>> show information from my model and letting the user check or uncheck
>> them doesn't make sense.
>>
>> Unfortunately, TableColumn doesn't have setEnabled method. I've tried to
>> wrap the table into an extra Composite and call setEnabled(false) on it,
>> but this prevents me from scrolling the table as well.
>>
>> Is there a way to do this?
>
> AFAIK there is no "clean" solution. You may want to try the workaround
> suggested in:
>
> http://tom-eclipse-dev.blogspot.com/2008/10/disable-parts-sw t-tabletree-with.html

Alternatively you might want to experiment with custom drawing in
tables. This would mean that you would just use icons (e.g. via the
jface TableViewer API or by manually) instead of native check-boxes.

See e.g.

http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html

If working on the jface level, this is so-called owner drawing, as shown in

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet010OwnerDraw.java?view=markup

You could also try-out faked native checkboxes as described in

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet061FakedNativeCellEditor.java?view=markup

HTH & Greetings from Bremen,

Daniel Krügler
Re: Disable editing checkboxes in a Table [message #542590 is a reply to message #542562] Fri, 25 June 2010 11:42 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel Krügler
Messages: 853
Registered: July 2009
Senior Member
On 25.06.2010 12:40, Daniel Krügler wrote:
> On 25.06.2010 11:55, Daniel Krügler wrote:
>> On 25.06.2010 09:59, Alexey Romanov wrote:
>>> I have a table with checkboxes in my application. However, they only
>>> show information from my model and letting the user check or uncheck
>>> them doesn't make sense.
>>>
>>> Unfortunately, TableColumn doesn't have setEnabled method. I've tried to
>>> wrap the table into an extra Composite and call setEnabled(false) on it,
>>> but this prevents me from scrolling the table as well.
>>>
>>> Is there a way to do this?
>>
>> AFAIK there is no "clean" solution. You may want to try the workaround
>> suggested in:
>>
>> http://tom-eclipse-dev.blogspot.com/2008/10/disable-parts-sw t-tabletree-with.html
>>

I just recognize that on the jface-level a solution seems possible by
defining a ICheckStateProvider implementation. You could check-out what
this implementation does internally to realize the same on the pure
SWT level.

> Alternatively you might want to experiment with custom drawing in
> tables. This would mean that you would just use icons (e.g. via the
> jface TableViewer API or by manually) instead of native check-boxes.
>
> See e.g.
>
> http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html
>
>
> If working on the jface level, this is so-called owner drawing, as shown in
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet010OwnerDraw.java?view=markup
>
>
> You could also try-out faked native checkboxes as described in
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet061FakedNativeCellEditor.java?view=markup

HTH & Greetings from Bremen,

Daniel Krügler
Re: Disable editing checkboxes in a Table [message #542605 is a reply to message #542590] Fri, 25 June 2010 12:18 Go to previous message
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
> I just recognize that on the jface-level a solution seems possible by
> defining a ICheckStateProvider implementation. You could check-out what
> this implementation does internally to realize the same on the pure
> SWT level.

Actually, I am using an ICheckStateProvider on a CheckboxTableViewer, and this doesn't disable toggling checkboxes. Am I missing something?

After thinking some more, I can use ICheckStateListener...
Previous Topic:Disable hiding celleditor controls
Next Topic:Setting visible items count in Combo dynamically
Goto Forum:
  


Current Time: Sat Sep 20 12:07:58 GMT 2014

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

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