Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Grid and StyledCellLabelProvider
Grid and StyledCellLabelProvider [message #62677] Tue, 17 February 2009 08:10 Go to next message
Christian Hauser is currently offline Christian HauserFriend
Messages: 189
Registered: July 2009
Senior Member
Hi all,

I've been using a normal JFace TableViewer for an editable table.
However, I had to switch to GridTableViewer, because the customer needs
wrapping of the text within cells.

The problem I'm facing now is that my StyledCellLabelProvider that
highlights text is not working with Grid. Am I missing something or is
this rather new feature (Eclipse 3.4) not yet supported on Grid?

Thanks in advance for any help,
Christian
Re: Grid and StyledCellLabelProvider [message #62704 is a reply to message #62677] Tue, 17 February 2009 09:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010204030502090506010102
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi,

No. We don't support this but it should quite easy for you to implement
a CellRenderer which uses a StyledString and renderer it.

Attached to this mail you'll find a completely untested (I only wrote
the code renderer) class but you should get the idea. Always remember
when using the Grid you are in the position of drawing everything
yourself and you are not restricted to the bounds of the native widget.

Tom

Christian Hauser schrieb:
> Hi all,
>
> I've been using a normal JFace TableViewer for an editable table.
> However, I had to switch to GridTableViewer, because the customer needs
> wrapping of the text within cells.
>
> The problem I'm facing now is that my StyledCellLabelProvider that
> highlights text is not working with Grid. Am I missing something or is
> this rather new feature (Eclipse 3.4) not yet supported on Grid?
>
> Thanks in advance for any help,
> Christian


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------

--------------010204030502090506010102
Content-Type: text/plain;
name="StyledTextCellRenderer.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="StyledTextCellRenderer.java"

LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioq
KioqKioqKioqKioqKio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hbiBp c0NlbnRlcmVk
Q2hlY2tCb3hPbmx5KEdyaWRJdGVtIGl0ZW0pIHsKCQlyZXR1cm4gIWlzVHJl ZSgpICYmIGl0
ZW0uZ2V0SW1hZ2UoZ2V0Q29sdW1uKCkpID09IG51bGwKCQkJCSYmIGl0ZW0u Z2V0VGV4dChn
ZXRDb2x1bW4oKSkuZXF1YWxzKCIiKQoJCQkJJiYgZ2V0QWxpZ25tZW50KCkg PT0gU1dULkNF
TlRFUjsKCX0KfQ==
--------------010204030502090506010102--
Re: Grid and StyledCellLabelProvider [message #62752 is a reply to message #62704] Tue, 17 February 2009 13:31 Go to previous messageGo to next message
Christian Hauser is currently offline Christian HauserFriend
Messages: 189
Registered: July 2009
Senior Member
Hi Tom

I'm using a StyledCellLabelProvider, which is not a
IStyledLabelProvider, but thank you anyway. I think I can handle it now,
well, I'll have a look at it and try to adapt it somehow.

Thank you for your help and time!

Christian


Tom Schindl wrote:
> Hi,
>
> No. We don't support this but it should quite easy for you to implement
> a CellRenderer which uses a StyledString and renderer it.
>
> Attached to this mail you'll find a completely untested (I only wrote
> the code renderer) class but you should get the idea. Always remember
> when using the Grid you are in the position of drawing everything
> yourself and you are not restricted to the bounds of the native widget.
>
> Tom
>
> Christian Hauser schrieb:
>
>> Hi all,
>>
>> I've been using a normal JFace TableViewer for an editable table.
>> However, I had to switch to GridTableViewer, because the customer needs
>> wrapping of the text within cells.
>>
>> The problem I'm facing now is that my StyledCellLabelProvider that
>> highlights text is not working with Grid. Am I missing something or is
>> this rather new feature (Eclipse 3.4) not yet supported on Grid?
>>
>> Thanks in advance for any help,
>> Christian
>>
>
>
>
Re: Grid and StyledCellLabelProvider [message #593625 is a reply to message #62677] Tue, 17 February 2009 09:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010204030502090506010102
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi,

No. We don't support this but it should quite easy for you to implement
a CellRenderer which uses a StyledString and renderer it.

Attached to this mail you'll find a completely untested (I only wrote
the code renderer) class but you should get the idea. Always remember
when using the Grid you are in the position of drawing everything
yourself and you are not restricted to the bounds of the native widget.

Tom

Christian Hauser schrieb:
> Hi all,
>
> I've been using a normal JFace TableViewer for an editable table.
> However, I had to switch to GridTableViewer, because the customer needs
> wrapping of the text within cells.
>
> The problem I'm facing now is that my StyledCellLabelProvider that
> highlights text is not working with Grid. Am I missing something or is
> this rather new feature (Eclipse 3.4) not yet supported on Grid?
>
> Thanks in advance for any help,
> Christian


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------

--------------010204030502090506010102
Content-Type: text/plain;
name="StyledTextCellRenderer.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="StyledTextCellRenderer.java"

LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioKICogQ29weXJpZ2h0IChjKSAy MDA2IElCTSBD
b3Jwb3JhdGlvbiBhbmQgb3RoZXJzLgogKiBBbGwgcmlnaHRzIHJlc2VydmVk LiBUaGlzIHBy
b2dyYW0gYW5kIHRoZSBhY2NvbXBhbnlpbmcgbWF0ZXJpYWxzCiAqIGFyZSBt YWRlIGF2YWls
YWJsZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExp Y2Vuc2UgdjEu
MAogKiB3aGljaCBhY2NvbXBhbmllcyB0aGlzIGRpc3RyaWJ1dGlvbiwgYW5k IGlzIGF2YWls
YWJsZSBhdAogKiBodHRwOi8vd3d3LmVjbGlwc2Uub3JnL2xlZ2FsL2VwbC12 MTAuaHRtbAog
KgogKiBDb250cmlidXRvcnM6CiAqICAgIGNocmlzLmdyb3NzQHVzLmlibS5j b20gLSBpbml0
aWFsIEFQSSBhbmQgaW1wbGVtZW50YXRp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dGFuZ2xlIGJvdW5kcyA9IG5ldyBSZWN0YW5nbGUo eCwgdG9wTWFy
Z2luICsgdGV4dFRvcE1hcmdpbiwgMCwgMCk7CgoJCUdDIGdjID0gbmV3IEdD KGl0ZW0uZ2V0
UGFyZW50KCkpOwoJCWdjLnNldEZvbnQoaXRlbS5nZXRGb250KGdldENvbHVt bigpKSk7CgkJ
UG9pbnQgc2l6ZSA9IGdjLnN0cmluZ0V4dGVudChpdGVtLmdldFRleHQoZ2V0 Q29sdW1uKCkp
KTsKCgkJYm91bmRzLmhlaWdodCA9IHNpemUueTsKCgkJaWYgKHByZWZlcnJl ZCkgewoJCQli
b3VuZHMud2lkdGggPSBzaXplLnggLSAxOwoJCX0gZWxzZSB7CgkJCWJvdW5k cy53aWR0aCA9
IGdldEJvdW5kcygpLndpZHRoIC0geCAtIHJpZ2h0TWFyZ2luOwoJCX0KCgkJ Z2MuZGlzcG9z
ZSgpOwoKCQlyZXR1cm4gYm91bmRzOwoJfQoKCXByaXZhdGUgYm9vbGVhbiBp c0NlbnRlcmVk
Q2hlY2tCb3hPbmx5KEdyaWRJdGVtIGl0ZW0pIHsKCQlyZXR1cm4gIWlzVHJl ZSgpICYmIGl0
ZW0uZ2V0SW1hZ2UoZ2V0Q29sdW1uKCkpID09IG51bGwKCQkJCSYmIGl0ZW0u Z2V0VGV4dChn
ZXRDb2x1bW4oKSkuZXF1YWxzKCIiKQoJCQkJJiYgZ2V0QWxpZ25tZW50KCkg PT0gU1dULkNF
TlRFUjsKCX0KfQ==
--------------010204030502090506010102--
Re: Grid and StyledCellLabelProvider [message #593652 is a reply to message #62704] Tue, 17 February 2009 13:31 Go to previous messageGo to next message
Christian Hauser is currently offline Christian HauserFriend
Messages: 189
Registered: July 2009
Senior Member
Hi Tom

I'm using a StyledCellLabelProvider, which is not a
IStyledLabelProvider, but thank you anyway. I think I can handle it now,
well, I'll have a look at it and try to adapt it somehow.

Thank you for your help and time!

Christian


Tom Schindl wrote:
> Hi,
>
> No. We don't support this but it should quite easy for you to implement
> a CellRenderer which uses a StyledString and renderer it.
>
> Attached to this mail you'll find a completely untested (I only wrote
> the code renderer) class but you should get the idea. Always remember
> when using the Grid you are in the position of drawing everything
> yourself and you are not restricted to the bounds of the native widget.
>
> Tom
>
> Christian Hauser schrieb:
>
>> Hi all,
>>
>> I've been using a normal JFace TableViewer for an editable table.
>> However, I had to switch to GridTableViewer, because the customer needs
>> wrapping of the text within cells.
>>
>> The problem I'm facing now is that my StyledCellLabelProvider that
>> highlights text is not working with Grid. Am I missing something or is
>> this rather new feature (Eclipse 3.4) not yet supported on Grid?
>>
>> Thanks in advance for any help,
>> Christian
>>
>
>
>
Re: Grid and StyledCellLabelProvider [message #1706005 is a reply to message #593625] Fri, 21 August 2015 01:51 Go to previous messageGo to next message
Immanuel Stephen is currently offline Immanuel StephenFriend
Messages: 2
Registered: August 2015
Junior Member
Tom,
The snippet you gave is showing up as junk chars.could you pls post it again

Thanks
Immanuel
Re: Grid and StyledCellLabelProvider [message #1737980 is a reply to message #1706005] Thu, 14 July 2016 15:51 Go to previous message
Casi Colada is currently offline Casi ColadaFriend
Messages: 1
Registered: July 2016
Junior Member
@Immanuel: Copy the junk chars and send them through a Base64 decoder (also available online).
Previous Topic:[CDateTime] Setting a date with days before month
Next Topic:draw graph with bars
Goto Forum:
  


Current Time: Thu Dec 26 16:51:11 GMT 2024

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

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

Back to the top