Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Creating dynamic tableviewer with enable/disable cells
Creating dynamic tableviewer with enable/disable cells [message #1232666] Fri, 17 January 2014 13:05 Go to next message
Melwyn Jensen is currently offline Melwyn JensenFriend
Messages: 15
Registered: January 2014
Junior Member
We are trying to create tableviewer wherein it should be dynamic i.e first column will have a dropdown and based on the selection of the dropdown the consecutive columns will be enabled or disabled.

For eg. First column dropdown will have 1,2 as values and when 1 is selected column 2 (row 1 column 2 cell) will be disabled and column 3 (row 1 column 3 cell) will be enabled and when 2 is selected column 2 (row 2 column 2 cell) will be enabled and column 3 (row 2 column 3 cell) will be disabled.

Can someone point out the best way to start with this? Tried with tablelisteners but not sure how to get the hold of particular cell in tableviewer and disable them.

Reply asap is highly appreciable.

Thank you.
Re: Creating dynamic tableviewer with enable/disable cells [message #1233046 is a reply to message #1232666] Sat, 18 January 2014 12:49 Go to previous messageGo to next message
Melwyn Jensen is currently offline Melwyn JensenFriend
Messages: 15
Registered: January 2014
Junior Member
Can someone reply?
Re: Creating dynamic tableviewer with enable/disable cells [message #1233928 is a reply to message #1232666] Mon, 20 January 2014 21:22 Go to previous messageGo to next message
Andi Thomas is currently offline Andi ThomasFriend
Messages: 38
Registered: July 2009
Member
Try looking at org.eclipse.jface.viewers.EditingSupport.canEdit(Object)

Essentially, when you set up the editing support on the column viewer,
it can conditionally return true/false for the subsequent columns based
on the value selected in the first drop down cell editor.

This value should be retrieved from the model element that is passed in
as the argument to the method - which should be the element for that row.

If you haven't found them already, these snippets are extremely helpful
for figuring out all the various things you can do with tables and
jface: http://wiki.eclipse.org/index.php/JFaceSnippets

On 1/17/14, 8:05 AM, Melwyn Jensen wrote:
> We are trying to create tableviewer wherein it should be dynamic i.e
> first column will have a dropdown and based on the selection of the
> dropdown the consecutive columns will be enabled or disabled.
> For eg. First column dropdown will have 1,2 as values and when 1 is
> selected column 2 (row 1 column 2 cell) will be disabled and column 3
> (row 1 column 3 cell) will be enabled and when 2 is selected column 2
> (row 2 column 2 cell) will be enabled and column 3 (row 2 column 3 cell)
> will be disabled.
>
> Can someone point out the best way to start with this? Tried with
> tablelisteners but not sure how to get the hold of particular cell in
> tableviewer and disable them.
>
> Reply asap is highly appreciable.
>
> Thank you.
Re: Creating dynamic tableviewer with enable/disable cells [message #1234624 is a reply to message #1233928] Wed, 22 January 2014 12:01 Go to previous messageGo to next message
Melwyn Jensen is currently offline Melwyn JensenFriend
Messages: 15
Registered: January 2014
Junior Member
Hi Andi,

Thanks a lot for the reply..

Yea I have checked various snippets and also worked with org.eclipse.jface.viewers.EditingSupport.canEdit(Object) with some small snippets (not with model).

With your comment I just remembered that from model we can enable and disable at any point for sure when the cell is selected Smile but will it be possible to gray out the cells based on the drop down selection of first row? cause canEdit will be called only when we select on the particular cell but it will be good if the cells can be grayed out based on the selection itself which makes the user to know that the cells will not be accessible at all.

I searched but not able to get an hold of proper code snippet on that. It will be good if you can point to one..

Thanks.

[Updated on: Wed, 22 January 2014 12:01]

Report message to a moderator

Re: Creating dynamic tableviewer with enable/disable cells [message #1238166 is a reply to message #1234624] Fri, 31 January 2014 15:08 Go to previous message
Andi Thomas is currently offline Andi ThomasFriend
Messages: 38
Registered: July 2009
Member
If you want to gray out cells then you need to look at
ColumnLabelProvider.getBackground(Object)

Basically, your label provider for the column can return gray if the
model selection is such that it should be grayed out.

On 1/22/14, 7:01 AM, Melwyn Jensen wrote:
> Hi Andi,
>
> Thanks a lot for the reply..
>
> Yea I have checked various snippets and also worked with
> org.eclipse.jface.viewers.EditingSupport.canEdit(Object) with some small
> snippets (not with model).
>
> With your comment I just remembered that from model we can enable and
> disable at any point for sure when the cell is selected :) but will it
> be possible to gray out the cells based on the drop down selection of
> first row? cause canEdit will be called only when we select on the
> particular cell but it will be good if the cells can be grayed out based
> on the selection itself which makes the user to know that the cells will
> not be accessible at all.
>
> I searched but not able to get an hold of proper code snippet on that.
> It will be good if you can point at to one..
>
> Thanks.
Previous Topic:Is it possible to know if an event triggered other events?
Next Topic:SWT Tools Update Sites are offline - zipped p2 repo available?
Goto Forum:
  


Current Time: Wed Apr 24 22:50:15 GMT 2024

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

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

Back to the top