Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Non-editable Grid columns?
Non-editable Grid columns? [message #23527] Fri, 19 January 2007 07:22 Go to next message
Eclipse User
Originally posted by: johan.kannala.comsol.com

Hi!

I'm using the Grid widget to store and edit data. Now, some of my
columns may need to be non-editable, something which simply is achieved
by not providing editors for these particular columns. So far, so good.

Check columns, however, don't necessarily need to have editors since
they are intrinsically clickable/editable. The question now is how I can
make them non-clickable/editable? Maybe the best way is to create a
custom renderer using the default checkbox renderer?
There is a "grayed" property in the grid item which makes the check box
render as gray, something which I would interpret as being disabled. Is
there possibly a particular way in which this is intended to be used?

Another (related) problem is that I would like to render my non-editable
columns in, say, a slightly different color. But since the default cell
renderer belongs to the grid.internal package, it is not possible to
simply inherit and modify, nor does the renderer provide any
"foreground" or "background" properties. In general I find it a bit
strange that the default renderers are hidden away in the internal
package, since it could be quite useful to have access to them.

/Johan
Re: Non-editable Grid columns? [message #23696 is a reply to message #23527] Fri, 19 January 2007 14:36 Go to previous messageGo to next message
Chris Gross is currently offline Chris Gross
Messages: 253
Registered: July 2009
Senior Member
Hi Johan,

There's no way to make a checkbox read only. It would be a good feature
to add. Can you add a bugzilla item for this?

Re changing the background color, why not use
GridItem.setBackground(int, Color)? The default renderers are internal
because they are not designed to be supported API. Things in those
classes could change at anytime. What would you do if those classes
were public? Subclass them? If they were public I would definitely
mark them final, so that wouldn't be an option.

-Chris

Johan Kannala wrote:
> Hi!
>
> I'm using the Grid widget to store and edit data. Now, some of my
> columns may need to be non-editable, something which simply is achieved
> by not providing editors for these particular columns. So far, so good.
>
> Check columns, however, don't necessarily need to have editors since
> they are intrinsically clickable/editable. The question now is how I can
> make them non-clickable/editable? Maybe the best way is to create a
> custom renderer using the default checkbox renderer?
> There is a "grayed" property in the grid item which makes the check box
> render as gray, something which I would interpret as being disabled. Is
> there possibly a particular way in which this is intended to be used?
>
> Another (related) problem is that I would like to render my non-editable
> columns in, say, a slightly different color. But since the default cell
> renderer belongs to the grid.internal package, it is not possible to
> simply inherit and modify, nor does the renderer provide any
> "foreground" or "background" properties. In general I find it a bit
> strange that the default renderers are hidden away in the internal
> package, since it could be quite useful to have access to them.
>
> /Johan
Re: Non-editable Grid columns? [message #23867 is a reply to message #23696] Mon, 22 January 2007 09:27 Go to previous messageGo to next message
Eclipse User
Originally posted by: johan.kannala.comsol.com

> There's no way to make a checkbox read only. It would be a good feature
> to add. Can you add a bugzilla item for this?

Will do.


> Re changing the background color, why not use
> GridItem.setBackground(int, Color)?

Yes, that will work, although it is a bit inconvenient since the
editable property is set on the columns. Setting the color on the
GridItem means I have to keep changing the color on these indexes for
each new item that is added and I have to iterate through all the rows
if the editable state is toggled for a column.
Since GridColumn has a cell renderer property, I thought it'd be much
easier to set it to a "NotEditableCellRenderer" and be done with it.

I guess what I want is a flag "editable" on the column which a
custom render simply picks up and uses.


> The default renderers are internal
> because they are not designed to be supported API. Things in those
> classes could change at anytime. What would you do if those classes
> were public? Subclass them? If they were public I would definitely
> mark them final, so that wouldn't be an option.

Yes, I'd prefer to subclass them, though I would also like to use for
example the check box renderer as part of my own cell renderer
implementation.

Most things of what one wants to do in a cell renderer, such as
rendering selection, focus, text, and so on, are already implemented in
your default renderer, so for minor cosmetic changes I'd prefer to reuse
them instead writing my own from scratch. Now, I didn't mean that you
should make these very renderers public right away (nor would that be
appropriate), but I think it would be worthwhile to provide some easily
customizable default implementations of the renderers sometime in the
future.


/Johan
Re: Non-editable Grid columns? [message #24288 is a reply to message #23867] Wed, 24 January 2007 17:42 Go to previous message
Chris Gross is currently offline Chris Gross
Messages: 253
Registered: July 2009
Senior Member
Hi Johan,

Right, I think writing your own renderers sounds like a good idea in
your case. But I don't think I will ever make the default renderers
public because I won't ever make them extendable. There would just be
too much difficultly in adding new features to the Grid and at the same
time ensuring backward compatibility with the renderers and subclasses.
Its just too hard. But feel free to use the code as a guide to
implement your own renderers.

-Chris

Johan Kannala wrote:
>> There's no way to make a checkbox read only. It would be a good
>> feature to add. Can you add a bugzilla item for this?
>
> Will do.
>
>
>> Re changing the background color, why not use
>> GridItem.setBackground(int, Color)?
>
> Yes, that will work, although it is a bit inconvenient since the
> editable property is set on the columns. Setting the color on the
> GridItem means I have to keep changing the color on these indexes for
> each new item that is added and I have to iterate through all the rows
> if the editable state is toggled for a column.
> Since GridColumn has a cell renderer property, I thought it'd be much
> easier to set it to a "NotEditableCellRenderer" and be done with it.
>
> I guess what I want is a flag "editable" on the column which a
> custom render simply picks up and uses.
>
>
>> The default renderers are internal because they are not designed to be
>> supported API. Things in those classes could change at anytime. What
>> would you do if those classes were public? Subclass them? If they
>> were public I would definitely mark them final, so that wouldn't be an
>> option.
>
> Yes, I'd prefer to subclass them, though I would also like to use for
> example the check box renderer as part of my own cell renderer
> implementation.
>
> Most things of what one wants to do in a cell renderer, such as
> rendering selection, focus, text, and so on, are already implemented in
> your default renderer, so for minor cosmetic changes I'd prefer to reuse
> them instead writing my own from scratch. Now, I didn't mean that you
> should make these very renderers public right away (nor would that be
> appropriate), but I think it would be worthwhile to provide some easily
> customizable default implementations of the renderers sometime in the
> future.
>
>
> /Johan
Re: Non-editable Grid columns? [message #575178 is a reply to message #23527] Fri, 19 January 2007 14:36 Go to previous message
Chris Gross is currently offline Chris Gross
Messages: 471
Registered: July 2009
Senior Member
Hi Johan,

There's no way to make a checkbox read only. It would be a good feature
to add. Can you add a bugzilla item for this?

Re changing the background color, why not use
GridItem.setBackground(int, Color)? The default renderers are internal
because they are not designed to be supported API. Things in those
classes could change at anytime. What would you do if those classes
were public? Subclass them? If they were public I would definitely
mark them final, so that wouldn't be an option.

-Chris

Johan Kannala wrote:
> Hi!
>
> I'm using the Grid widget to store and edit data. Now, some of my
> columns may need to be non-editable, something which simply is achieved
> by not providing editors for these particular columns. So far, so good.
>
> Check columns, however, don't necessarily need to have editors since
> they are intrinsically clickable/editable. The question now is how I can
> make them non-clickable/editable? Maybe the best way is to create a
> custom renderer using the default checkbox renderer?
> There is a "grayed" property in the grid item which makes the check box
> render as gray, something which I would interpret as being disabled. Is
> there possibly a particular way in which this is intended to be used?
>
> Another (related) problem is that I would like to render my non-editable
> columns in, say, a slightly different color. But since the default cell
> renderer belongs to the grid.internal package, it is not possible to
> simply inherit and modify, nor does the renderer provide any
> "foreground" or "background" properties. In general I find it a bit
> strange that the default renderers are hidden away in the internal
> package, since it could be quite useful to have access to them.
>
> /Johan
Re: Non-editable Grid columns? [message #575313 is a reply to message #23696] Mon, 22 January 2007 09:27 Go to previous message
Johan Kannala is currently offline Johan Kannala
Messages: 3
Registered: July 2009
Junior Member
> There's no way to make a checkbox read only. It would be a good feature
> to add. Can you add a bugzilla item for this?

Will do.


> Re changing the background color, why not use
> GridItem.setBackground(int, Color)?

Yes, that will work, although it is a bit inconvenient since the
editable property is set on the columns. Setting the color on the
GridItem means I have to keep changing the color on these indexes for
each new item that is added and I have to iterate through all the rows
if the editable state is toggled for a column.
Since GridColumn has a cell renderer property, I thought it'd be much
easier to set it to a "NotEditableCellRenderer" and be done with it.

I guess what I want is a flag "editable" on the column which a
custom render simply picks up and uses.


> The default renderers are internal
> because they are not designed to be supported API. Things in those
> classes could change at anytime. What would you do if those classes
> were public? Subclass them? If they were public I would definitely
> mark them final, so that wouldn't be an option.

Yes, I'd prefer to subclass them, though I would also like to use for
example the check box renderer as part of my own cell renderer
implementation.

Most things of what one wants to do in a cell renderer, such as
rendering selection, focus, text, and so on, are already implemented in
your default renderer, so for minor cosmetic changes I'd prefer to reuse
them instead writing my own from scratch. Now, I didn't mean that you
should make these very renderers public right away (nor would that be
appropriate), but I think it would be worthwhile to provide some easily
customizable default implementations of the renderers sometime in the
future.


/Johan
Re: Non-editable Grid columns? [message #575621 is a reply to message #23867] Wed, 24 January 2007 17:42 Go to previous message
Chris Gross is currently offline Chris Gross
Messages: 471
Registered: July 2009
Senior Member
Hi Johan,

Right, I think writing your own renderers sounds like a good idea in
your case. But I don't think I will ever make the default renderers
public because I won't ever make them extendable. There would just be
too much difficultly in adding new features to the Grid and at the same
time ensuring backward compatibility with the renderers and subclasses.
Its just too hard. But feel free to use the code as a guide to
implement your own renderers.

-Chris

Johan Kannala wrote:
>> There's no way to make a checkbox read only. It would be a good
>> feature to add. Can you add a bugzilla item for this?
>
> Will do.
>
>
>> Re changing the background color, why not use
>> GridItem.setBackground(int, Color)?
>
> Yes, that will work, although it is a bit inconvenient since the
> editable property is set on the columns. Setting the color on the
> GridItem means I have to keep changing the color on these indexes for
> each new item that is added and I have to iterate through all the rows
> if the editable state is toggled for a column.
> Since GridColumn has a cell renderer property, I thought it'd be much
> easier to set it to a "NotEditableCellRenderer" and be done with it.
>
> I guess what I want is a flag "editable" on the column which a
> custom render simply picks up and uses.
>
>
>> The default renderers are internal because they are not designed to be
>> supported API. Things in those classes could change at anytime. What
>> would you do if those classes were public? Subclass them? If they
>> were public I would definitely mark them final, so that wouldn't be an
>> option.
>
> Yes, I'd prefer to subclass them, though I would also like to use for
> example the check box renderer as part of my own cell renderer
> implementation.
>
> Most things of what one wants to do in a cell renderer, such as
> rendering selection, focus, text, and so on, are already implemented in
> your default renderer, so for minor cosmetic changes I'd prefer to reuse
> them instead writing my own from scratch. Now, I didn't mean that you
> should make these very renderers public right away (nor would that be
> appropriate), but I think it would be worthwhile to provide some easily
> customizable default implementations of the renderers sometime in the
> future.
>
>
> /Johan
Previous Topic:Example of MonthCalendar
Next Topic:Grid Widget
Goto Forum:
  


Current Time: Mon Jul 28 02:24:26 EDT 2014

Powered by FUDForum. Page generated in 0.03077 seconds