Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to change the font in my custom CVS merge viewer?
How to change the font in my custom CVS merge viewer? [message #251118] Wed, 09 June 2004 18:20 Go to next message
Eclipse UserFriend
Originally posted by: mark.melvin.dspfactory.com

Hi Everyone,

I have created my own 'MergeViewer' (extending TextMergeViewer), so that
my source code is highlighted when I view it in the Team Synchronize
view. I did this by extending the extension point
"org.eclipse.compare.contentMergeViewers" for my particular file types.
Right now, my source viewer is dead simple with only partitioning and
syntax highlighting going on. All of the colors and stuff are
hard-coded as I have not implemented Preference Pages yet. This all
works great - I get colored source code in the CVS compare viewer - and
it really didn't take much effort (nice!).

The problem is - it is presented in a variable width font, and doesn't
seem to be affected by any of the preference settings in the Workbench >
Colors and Fonts preference settings. Not even the Text Compare
settings. My code to set up my viewer is simple and is as follows:


protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
if (fSourceViewerConfiguration == null) {
fSourceViewerConfiguration = new MySourceViewerConfiguration(new
ColorManager());
}
((SourceViewer) textViewer).configure(getSourceViewerConfiguration());
}
}

I've tried setting the Font directly in the textViewer with something like:

textViewer.getTextWidget().setFont(new
Font(textViewer.getControl().getDisplay(), new FontData("Courier", 14,
SWT.NORMAL)));

But it seems to do nothing. Can anyone point me in the right direction
to set the font in my MergeViewer?

Thanks,
Mark.
Re: How to change the font in my custom CVS merge viewer? [message #251167 is a reply to message #251118] Wed, 09 June 2004 19:34 Go to previous message
Eclipse UserFriend
Originally posted by: mark.melvin.dspfactory.com

Well - after digging around a bit I found that TextMergeViewer tries to
pull a font out of the font registry who key is my classname (weird?).
Anyway - I managed to get my own Font to work by inserting the following
at the end of configureTextViewer():

JFaceResources.getFontRegistry().put(getClass().getName(),
new FontData[] {new FontData("Courier New", 10, SWT.NORMAL)});


This strikes me as a bit of a *hack*. I assume this will all work once
I start implementing preference pages for my source viewer (which is
coming later in my schedule) - but if someone knows the right way to do
this or would like to comment on the magnitude on the "hack-o-meter" of
the above line of code, please feel free. ;o)

Thanks,
Mark.


Mark Melvin wrote:
> Hi Everyone,
>
> I have created my own 'MergeViewer' (extending TextMergeViewer), so that
> my source code is highlighted when I view it in the Team Synchronize
> view. I did this by extending the extension point
> "org.eclipse.compare.contentMergeViewers" for my particular file types.
> Right now, my source viewer is dead simple with only partitioning and
> syntax highlighting going on. All of the colors and stuff are
> hard-coded as I have not implemented Preference Pages yet. This all
> works great - I get colored source code in the CVS compare viewer - and
> it really didn't take much effort (nice!).
>
> The problem is - it is presented in a variable width font, and doesn't
> seem to be affected by any of the preference settings in the Workbench >
> Colors and Fonts preference settings. Not even the Text Compare
> settings. My code to set up my viewer is simple and is as follows:
>
>
> protected void configureTextViewer(TextViewer textViewer) {
> if (textViewer instanceof SourceViewer) {
> if (fSourceViewerConfiguration == null) {
> fSourceViewerConfiguration = new
> MySourceViewerConfiguration(new ColorManager());
> }
> ((SourceViewer)
> textViewer).configure(getSourceViewerConfiguration());
> }
> }
>
> I've tried setting the Font directly in the textViewer with something like:
>
> textViewer.getTextWidget().setFont(new
> Font(textViewer.getControl().getDisplay(), new FontData("Courier", 14,
> SWT.NORMAL)));
>
> But it seems to do nothing. Can anyone point me in the right direction
> to set the font in my MergeViewer?
>
> Thanks,
> Mark.
Previous Topic:RC1 runtime workbench problems test case
Next Topic:Very Slow UI in editor list (Ctrl-E)
Goto Forum:
  


Current Time: Fri Aug 16 20:45:57 GMT 2024

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

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

Back to the top