Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Gen. Editor: Change Font Color
Gen. Editor: Change Font Color [message #693901] Thu, 07 July 2011 13:14 Go to next message
Soenke Brightside is currently offline Soenke BrightsideFriend
Messages: 41
Registered: January 2011
Member
Hi,

index.php/fa/3273/0/

Is it possible to change the Font Color of the Model-Element ("System Component", "Parameter", "Value")? The Name of the Element (such as "Aircraft") should stay black.

Thanks.
  • Attachment: labletext.jpg
    (Size: 22.28KB, Downloaded 660 times)
Re: Gen. Editor: Change Font Color [message #694027 is a reply to message #693901] Thu, 07 July 2011 16:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Yes, you can enable Color Providers in the GenModel and the specialize
the item providers to produce the colors you want. Read the Javadoc for
IItemColorProvider for how to control the color.


On 07/07/2011 6:14 AM, S wrote:
> Hi,
>
>
>
> Is it possible to change the Font Color of the Model-Element ("System Component", "Parameter", "Value")? The Name of the Element (such as "Aircraft") should stay black.
>
> Thanks.
Re: Gen. Editor: Change Font Color [message #694311 is a reply to message #694027] Fri, 08 July 2011 10:12 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke BrightsideFriend
Messages: 41
Registered: January 2011
Member
Thank you Ed,

I have now enabled the Color Provider and regenerated the Code. Also i have overridden the getForeground(Object object) method in my ItemProvider. Unfortunately, it is never called.

[Updated on: Fri, 08 July 2011 10:12]

Report message to a moderator

Re: Gen. Editor: Change Font Color [message #694386 is a reply to message #694311] Fri, 08 July 2011 13:16 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You have to change your plugin.xml to add the IItemColorProvider in the supported interfaces.
It is only generated once and not changed afterwards.
Re: Gen. Editor: Change Font Color [message #694459 is a reply to message #694386] Fri, 08 July 2011 16:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
The registration is important for registered lookup, but if the right
one is explicitly created (as in the generated editor) you won't notice
the registration missing. It is important to use
AdapterFactoryLabelProvider.ColorProvider for colors to be supported so
that's likely the cause of the problem.

On 08/07/2011 6:16 AM, Sylvain EVEILLARD wrote:
> You have to change your plugin.xml to add the IItemColorProvider in
> the supported interfaces.
> It is only generated once and not changed afterwards.
Re: Gen. Editor: Change Font Color [message #695196 is a reply to message #694459] Mon, 11 July 2011 08:55 Go to previous messageGo to next message
Soenke Brightside is currently offline Soenke BrightsideFriend
Messages: 41
Registered: January 2011
Member
Thank you Ed,
Thank you Sylvain,

The missing ColerProvider caused the Problem.
But for now, the hole String is colored. Is there a way to use multiple colors?
In case of "System Component Aircraft", the name of the element "System Component" should has an other color as the value "Aircraft".

Ed Merks wrote on Fri, 08 July 2011 12:23
The registration is important for registered lookup, but if the right
one is explicitly created (as in the generated editor) you won't notice
the registration missing. It is important to use
AdapterFactoryLabelProvider.ColorProvider for colors to be supported so
that's likely the cause of the problem.

On 08/07/2011 6:16 AM, Sylvain EVEILLARD wrote:
> You have to change your plugin.xml to add the IItemColorProvider in
> the supported interfaces.
> It is only generated once and not changed afterwards.

Re: Gen. Editor: Change Font Color [message #695376 is a reply to message #695196] Mon, 11 July 2011 15:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Sylvain,

No, I don't believe a tree widget supports that nor do the Eclipse APIs
provide such control.


On 11/07/2011 1:55 AM, S wrote:
> Thank you Ed,
> Thank you Sylvain,
>
> The missing ColerProvider caused the Problem.
> But for now, the hole String is colored. Is there a way to use
> multiple colors?
> In case of "System Component Aircraft", the name of the element
> "System Component" should has an other color as the value "Aircraft".
>
> Ed Merks wrote on Fri, 08 July 2011 12:23
>> The registration is important for registered lookup, but if the right
>> one is explicitly created (as in the generated editor) you won't
>> notice the registration missing. It is important to use
>> AdapterFactoryLabelProvider.ColorProvider for colors to be supported
>> so that's likely the cause of the problem.
>>
>> On 08/07/2011 6:16 AM, Sylvain EVEILLARD wrote:
>> > You have to change your plugin.xml to add the IItemColorProvider in
>> > the supported interfaces.
>> > It is only generated once and not changed afterwards.
>
>
Re: Gen. Editor: Change Font Color [message #893042 is a reply to message #694459] Mon, 02 July 2012 12:17 Go to previous messageGo to next message
Markus G is currently offline Markus GFriend
Messages: 23
Registered: June 2012
Junior Member
Hi,

sorry I am reopening this thread, but I wanted to do the same thing and I'm having some trouble doing so, so I will just write in here.

I also want to use different fonts and followed the steps in here. The colors appear fine in the outline view, but not in my editors. I don't exactly understand what you, Ed, meant by "using AdapterFactoryLabelProvider.ColorProvider for colors".

That means I need a ColorProvider in my editor class, correct?

What I tried is creating a ColorProvider in the editor class and calling setForeground on it in the getContentOutlinePage() of my editor on the current viewer. That is also being called fine, but the colors again only appear in the outline.

I think that my problem is only that I don't understand how I am supposed to use the ColorProvider correctly. Maybe you could just quickly tell me how that works?

Thanks a lot!


Markus

[Updated on: Mon, 02 July 2012 12:18]

Report message to a moderator

Re: Gen. Editor: Change Font Color [message #893061 is a reply to message #893042] Mon, 02 July 2012 12:54 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Use an instance of AdapterFactoryLabelProvider.FontAndColorProvider as the label provider for you editor.
Re: Gen. Editor: Change Font Color [message #893067 is a reply to message #893061] Mon, 02 July 2012 13:07 Go to previous messageGo to next message
Markus G is currently offline Markus GFriend
Messages: 23
Registered: June 2012
Junior Member
Thanks!


Sylvain EVEILLARD wrote on Mon, 02 July 2012 08:54
Use an instance of AdapterFactoryLabelProvider.FontAndColorProvider as the label provider for you editor.

Re: Gen. Editor: Change Font Color [message #893518 is a reply to message #893067] Wed, 04 July 2012 12:32 Go to previous messageGo to next message
Markus G is currently offline Markus GFriend
Messages: 23
Registered: June 2012
Junior Member
One more thing: is that not possible for a ListViewer for some reason? It works fine in the tree and the table viewer for me, but the ListViewer does not show the same behaviour...
Re: Gen. Editor: Change Font Color [message #893529 is a reply to message #893518] Wed, 04 July 2012 13:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Markus,<br>
<br>
I see this in the Javadoc for AbstractListViewer so I'd say no, it
doesn't support that.<br>
<br>
<style type="text/css" charset="ISO-8859-1">/* Font definitions */
html { font-family: 'Segoe UI',sans-serif; font-size: 9pt; font-style: normal; font-weight: normal; }
body, h4, h5, h6, p, table, td, caption, th, ul, ol, dl, li, dd, dt { font-size: 1em; }
pre { font-family: monospace; }
h1 { font-size: 1.8em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.1em; }

/* Margins */
body { overflow: auto; margin-top: 5px; margin-bottom: 4px; margin-left: 8px; margin-right: 4px; }
h1 { margin-top: 0.3em; margin-bottom: 0.04em; }
h2 { margin-top: 2em; margin-bottom: 0.25em; }
h3 { margin-top: 1.7em; margin-bottom: 0.25em; }
h4 { margin-top: 2em; margin-bottom: 0.3em; }
h5 { margin-top: 0px; margin-bottom: 0px; }
p { margin-top: 1em; margin-bottom: 1em; }
pre { margin-left: 0.6em; }
ul { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }
li { margin-top: 0px; margin-bottom: 0px; }
li p { margin-top: 0px; margin-bottom: 0px; }
ol { margin-top: 0px; margin-bottom: 1em; margin-left: 1em; padding-left: 1em; }
dl { margin-top: 0px; margin-bottom: 1em; }
dt { margin-top: 0px; margin-bottom: 0px; font-weight: bold; }
dd { margin-top: 0px; margin-bottom: 0px; }

/* Styles and colors */
a:link { color: #0000FF; }
a:hover { color: #000080; }
a:visited { text-decoration: underline; }
a.header:link { text-decoration: none; color: #000000 }
a.header:visited { text-decoration: none; color: #000000 }
a.header:hover { text-decoration: underline; color: #000080; }
h4 { font-style: italic; }
strong { font-weight: bold; }
em { font-style: italic; }
var { font-style: italic; }
th { font-weight: bold; }
</style><br>
<p>The list viewer implementation of this <code>Viewer</code>
framework method ensures that the given label provider is an
instance of <code>ILabelProvider</code>. <b>The optional
interfaces <code><a
href="eclipse-javadoc:%E2%98%82=org.eclipse.emf.cheatsheets/D:%5C/sandbox%5C/4.2RC1%5C/eclipse%5C/plugins%5C/org.eclipse.jface_3.8.0.v20120429-1603.jar%3Corg.eclipse.jface.viewers%28AbstractListViewer.class%E2%98%83AbstractListViewer%7EsetLabelProvider%7ELorg.eclipse.jface.viewers.IBaseLabelProvider;%E2%98%82IColorProvider">IColorProvider</a></code>
and <code><a
href="eclipse-javadoc:%E2%98%82=org.eclipse.emf.cheatsheets/D:%5C/sandbox%5C/4.2RC1%5C/eclipse%5C/plugins%5C/org.eclipse.jface_3.8.0.v20120429-1603.jar%3Corg.eclipse.jface.viewers%28AbstractListViewer.class%E2%98%83AbstractListViewer%7EsetLabelProvider%7ELorg.eclipse.jface.viewers.IBaseLabelProvider;%E2%98%82IFontProvider">IFontProvider</a></code>
have no effect for this type of viewer</b>
</p>
<div><b>Overrides:</b> <a
href="eclipse-javadoc:%E2%98%82=org.eclipse.emf.cheatsheets/D:%5C/sandbox%5C/4.2RC1%5C/eclipse%5C/plugins%5C/org.eclipse.jface_3.8.0.v20120429-1603.jar%3Corg.eclipse.jface.viewers%28StructuredViewer.class%E2%98%83StructuredViewer%7EsetLabelProvider%7ELorg.eclipse.jface.viewers.IBaseLabelProvider;">setLabelProvider(...)</a>
in <a
href="eclipse-javadoc:%E2%98%82=org.eclipse.emf.cheatsheets/D:%5C/sandbox%5C/4.2RC1%5C/eclipse%5C/plugins%5C/org.eclipse.jface_3.8.0.v20120429-1603.jar%3Corg.eclipse.jface.viewers%28StructuredViewer.class%E2%98%83StructuredViewer">StructuredViewer</a></div>
<dl>
<dt>Parameters:
</dt>
<dd><b>labelProvider</b> the label provider, or <code>null</code>
if none</dd>
<dt><br>
</dt>
</dl>
<base
href="http://127.0.0.1:57694/help/nftopic/jar:file:/D:/sandbox/4.2RC1/eclipse/plugins/org.eclipse.platform.doc.isv_4.2.0.v20120518-2015.jar%21/reference/api/org/eclipse/jface/viewers/AbstractListViewer.html">You
could try a table with a single column and to table header.<br>
<br>
<br>
<div class="moz-cite-prefix">On 04/07/2012 2:32 PM, Markus G wrote:<br>
</div>
<blockquote cite="mid:jt1d40$h2r$1@xxxxxxxxe.org" type="cite">One
more thing: is that not possible for a ListViewer for some reason?
It works fine in the tree and the table viewer for me, but the
ListViewer does not show the same behaviour...
<br>
</blockquote>
<br>
<br>
</body>
</html>
Previous Topic:Genmodel Label Feature
Next Topic:Xcore how to define the value of an EnumLiterals
Goto Forum:
  


Current Time: Sat Dec 14 10:47:42 GMT 2019

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

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

Back to the top