Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CompareUI with Syntax Colouring
CompareUI with Syntax Colouring [message #312863] Thu, 22 February 2007 11:26 Go to next message
Glenn Dollard is currently offline Glenn DollardFriend
Messages: 61
Registered: July 2009
Member
Hi All,
I have been reading lots on the CompareUI and have used it successfully
to implement a basic compare editor. However now I need to add code/syntax
colouring to my editor! The files I am comparing already have syntax
colouring in their editors but when viewed in the Compare Editor they look
like just plain text with not syntax colouring. Do I need to provide my own
editor instead of using CompareUI.openCompareEditor(..) in order to achieve
syntax colouring or can I somehow plug my own editor into the CompareUI
etc?? (I'm new to this!)

I have also looked at ResourceCompareInput but cannot see how it handles the
syntax colouring.

Can anyone provide me with some info on this and what I may need to do?
Thanks!
Re: CompareUI with Syntax Colouring [message #312880 is a reply to message #312863] Thu, 22 February 2007 18:02 Go to previous messageGo to next message
Michael Valenta is currently offline Michael ValentaFriend
Messages: 560
Registered: July 2009
Senior Member
You'll need to create your own contentMergeViewer. Here are the set of
steps to create your own content merge viewer:

1) Add extension for org.eclipse.compare.contentMergeViewer. This allows
you to register a view factory (IViewerCreator) for creating a subclass
of TextMergeViewer. The association is by content type or file extension.
2) In your subclass of TextMergeViewer you'll need to override
getDocumentPartitioner/getDocumentPartitioning. You should use the same
partitioner you use for your editor. You will also need to override
configureTextViewer to provide a source viewer configuration (again, the
same one you use for your editor should work).
3) You may want to provide token comparator for breaking a line into
tokens (override createTokenComparator).

Hope this helps,
Michael

gdollard wrote:
> Hi All,
> I have been reading lots on the CompareUI and have used it successfully
> to implement a basic compare editor. However now I need to add code/syntax
> colouring to my editor! The files I am comparing already have syntax
> colouring in their editors but when viewed in the Compare Editor they look
> like just plain text with not syntax colouring. Do I need to provide my own
> editor instead of using CompareUI.openCompareEditor(..) in order to achieve
> syntax colouring or can I somehow plug my own editor into the CompareUI
> etc?? (I'm new to this!)
>
> I have also looked at ResourceCompareInput but cannot see how it handles the
> syntax colouring.
>
> Can anyone provide me with some info on this and what I may need to do?
> Thanks!
>
>
Re: CompareUI with Syntax Colouring [message #312888 is a reply to message #312880] Fri, 23 February 2007 08:21 Go to previous messageGo to next message
Glenn Dollard is currently offline Glenn DollardFriend
Messages: 61
Registered: July 2009
Member
Thank you for that. It is nice to read a set of steps because after reading
the API stuff I was still none the wiser on the actual flow of things and
which components to use! Learning about all these plugins is not easy due to
lack of concrete examples etc. I'll give it a go.

"Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
news:erklpj$8s2$1@utils.eclipse.org...
> You'll need to create your own contentMergeViewer. Here are the set of
> steps to create your own content merge viewer:
>
> 1) Add extension for org.eclipse.compare.contentMergeViewer. This allows
> you to register a view factory (IViewerCreator) for creating a subclass of
> TextMergeViewer. The association is by content type or file extension.
> 2) In your subclass of TextMergeViewer you'll need to override
> getDocumentPartitioner/getDocumentPartitioning. You should use the same
> partitioner you use for your editor. You will also need to override
> configureTextViewer to provide a source viewer configuration (again, the
> same one you use for your editor should work).
> 3) You may want to provide token comparator for breaking a line into
> tokens (override createTokenComparator).
>
> Hope this helps,
> Michael
>
> gdollard wrote:
>> Hi All,
>> I have been reading lots on the CompareUI and have used it
>> successfully to implement a basic compare editor. However now I need to
>> add code/syntax colouring to my editor! The files I am comparing already
>> have syntax colouring in their editors but when viewed in the Compare
>> Editor they look like just plain text with not syntax colouring. Do I
>> need to provide my own editor instead of using
>> CompareUI.openCompareEditor(..) in order to achieve syntax colouring or
>> can I somehow plug my own editor into the CompareUI etc?? (I'm new to
>> this!)
>>
>> I have also looked at ResourceCompareInput but cannot see how it handles
>> the syntax colouring.
>>
>> Can anyone provide me with some info on this and what I may need to do?
>> Thanks!
Re: CompareUI with Syntax Colouring [message #312891 is a reply to message #312880] Fri, 23 February 2007 10:16 Go to previous messageGo to next message
Glenn Dollard is currently offline Glenn DollardFriend
Messages: 61
Registered: July 2009
Member
Just one question from what you mention below:
"The association is by content type or file extension" => The stuff I am
comparing is not file based so extension is not possible. How do I specify
contentType? I am concerned (after reading up on contentType) that I may not
be able to use the contentMergeViewer plugin because I am not comparing
'files'!

Can anyone verify this please?


"Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
news:erklpj$8s2$1@utils.eclipse.org...
> You'll need to create your own contentMergeViewer. Here are the set of
> steps to create your own content merge viewer:
>
> 1) Add extension for org.eclipse.compare.contentMergeViewer. This allows
> you to register a view factory (IViewerCreator) for creating a subclass of
> TextMergeViewer. The association is by content type or file extension.
> 2) In your subclass of TextMergeViewer you'll need to override
> getDocumentPartitioner/getDocumentPartitioning. You should use the same
> partitioner you use for your editor. You will also need to override
> configureTextViewer to provide a source viewer configuration (again, the
> same one you use for your editor should work).
> 3) You may want to provide token comparator for breaking a line into
> tokens (override createTokenComparator).
>
> Hope this helps,
> Michael
>
> gdollard wrote:
>> Hi All,
>> I have been reading lots on the CompareUI and have used it
>> successfully to implement a basic compare editor. However now I need to
>> add code/syntax colouring to my editor! The files I am comparing already
>> have syntax colouring in their editors but when viewed in the Compare
>> Editor they look like just plain text with not syntax colouring. Do I
>> need to provide my own editor instead of using
>> CompareUI.openCompareEditor(..) in order to achieve syntax colouring or
>> can I somehow plug my own editor into the CompareUI etc?? (I'm new to
>> this!)
>>
>> I have also looked at ResourceCompareInput but cannot see how it handles
>> the syntax colouring.
>>
>> Can anyone provide me with some info on this and what I may need to do?
>> Thanks!
Re: CompareUI with Syntax Colouring [message #312898 is a reply to message #312880] Fri, 23 February 2007 14:10 Go to previous messageGo to next message
Glenn Dollard is currently offline Glenn DollardFriend
Messages: 61
Registered: July 2009
Member
I am trying to display a basic TextMergeViewer but am having problems doing
so! Maybe I am not getting the big picture here but can someone please fill
me in on how to get the basics up and running!

I have a CompareItem which implements IStreamContentAccessor, ITypedElement

Then my ActionDelegate class has the following:

CompareItem left =
new CompareItem("Left", pou1);

CompareItem right =

new CompareItem("Right", pou2);


IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

TextMergeViewer tmv = new TextMergeViewer(page, new CompareConfiguration());

tmv.setInput(new DiffNode(left, right));

The TextMergeViewer is not being displayed! Any help would be appreciated!




"Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
news:erklpj$8s2$1@utils.eclipse.org...
> You'll need to create your own contentMergeViewer. Here are the set of
> steps to create your own content merge viewer:
>
> 1) Add extension for org.eclipse.compare.contentMergeViewer. This allows
> you to register a view factory (IViewerCreator) for creating a subclass of
> TextMergeViewer. The association is by content type or file extension.
> 2) In your subclass of TextMergeViewer you'll need to override
> getDocumentPartitioner/getDocumentPartitioning. You should use the same
> partitioner you use for your editor. You will also need to override
> configureTextViewer to provide a source viewer configuration (again, the
> same one you use for your editor should work).
> 3) You may want to provide token comparator for breaking a line into
> tokens (override createTokenComparator).
>
> Hope this helps,
> Michael
>
> gdollard wrote:
>> Hi All,
>> I have been reading lots on the CompareUI and have used it
>> successfully to implement a basic compare editor. However now I need to
>> add code/syntax colouring to my editor! The files I am comparing already
>> have syntax colouring in their editors but when viewed in the Compare
>> Editor they look like just plain text with not syntax colouring. Do I
>> need to provide my own editor instead of using
>> CompareUI.openCompareEditor(..) in order to achieve syntax colouring or
>> can I somehow plug my own editor into the CompareUI etc?? (I'm new to
>> this!)
>>
>> I have also looked at ResourceCompareInput but cannot see how it handles
>> the syntax colouring.
>>
>> Can anyone provide me with some info on this and what I may need to do?
>> Thanks!
Re: CompareUI with Syntax Colouring [message #312900 is a reply to message #312898] Fri, 23 February 2007 14:39 Go to previous messageGo to next message
Michael Valenta is currently offline Michael ValentaFriend
Messages: 560
Registered: July 2009
Senior Member
You can associate a type with an element using the
ITypedElement.getType() method. So, for example, you can decide for type
is "BLAH". Then getType should return blah and you shoudl associate your
merge viewer with BLAH as well (i.e. the type is usually a file
extension but doesn;t need to be).

To actually get the merge viewer to appear, you would want to make use
of a CompareEditorInput. In the prepareInput, you should prepare and
return your ICompareInput. The CompareEditorInput then takes care of
finding an appropriate viewer. You can host the editor input in an
editor by calling CompareUI#openInEditor.

Michael

gdollard wrote:
> I am trying to display a basic TextMergeViewer but am having problems doing
> so! Maybe I am not getting the big picture here but can someone please fill
> me in on how to get the basics up and running!
>
> I have a CompareItem which implements IStreamContentAccessor, ITypedElement
>
> Then my ActionDelegate class has the following:
>
> CompareItem left =
> new CompareItem("Left", pou1);
>
> CompareItem right =
>
> new CompareItem("Right", pou2);
>
>
> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>
> TextMergeViewer tmv = new TextMergeViewer(page, new CompareConfiguration());
>
> tmv.setInput(new DiffNode(left, right));
>
> The TextMergeViewer is not being displayed! Any help would be appreciated!
>
>
>
>
> "Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
> news:erklpj$8s2$1@utils.eclipse.org...
>> You'll need to create your own contentMergeViewer. Here are the set of
>> steps to create your own content merge viewer:
>>
>> 1) Add extension for org.eclipse.compare.contentMergeViewer. This allows
>> you to register a view factory (IViewerCreator) for creating a subclass of
>> TextMergeViewer. The association is by content type or file extension.
>> 2) In your subclass of TextMergeViewer you'll need to override
>> getDocumentPartitioner/getDocumentPartitioning. You should use the same
>> partitioner you use for your editor. You will also need to override
>> configureTextViewer to provide a source viewer configuration (again, the
>> same one you use for your editor should work).
>> 3) You may want to provide token comparator for breaking a line into
>> tokens (override createTokenComparator).
>>
>> Hope this helps,
>> Michael
>>
>> gdollard wrote:
>>> Hi All,
>>> I have been reading lots on the CompareUI and have used it
>>> successfully to implement a basic compare editor. However now I need to
>>> add code/syntax colouring to my editor! The files I am comparing already
>>> have syntax colouring in their editors but when viewed in the Compare
>>> Editor they look like just plain text with not syntax colouring. Do I
>>> need to provide my own editor instead of using
>>> CompareUI.openCompareEditor(..) in order to achieve syntax colouring or
>>> can I somehow plug my own editor into the CompareUI etc?? (I'm new to
>>> this!)
>>>
>>> I have also looked at ResourceCompareInput but cannot see how it handles
>>> the syntax colouring.
>>>
>>> Can anyone provide me with some info on this and what I may need to do?
>>> Thanks!
>
>
Re: CompareUI with Syntax Colouring [message #312943 is a reply to message #312900] Mon, 26 February 2007 15:00 Go to previous messageGo to next message
Glenn Dollard is currently offline Glenn DollardFriend
Messages: 61
Registered: July 2009
Member
After some thinking and stepping back from the problem to try and see the
big picture I got it working!

I was having problems trying to understand the actual link between providing
my functionality and where it hooks into the functionality provided by the
contentMergeViewers plugin!

But now I understand (for now anyway!)

Thanks for your great feedback.
Glenn.


"Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
news:ermu9v$1qp$1@utils.eclipse.org...
> You can associate a type with an element using the ITypedElement.getType()
> method. So, for example, you can decide for type is "BLAH". Then getType
> should return blah and you shoudl associate your merge viewer with BLAH as
> well (i.e. the type is usually a file extension but doesn;t need to be).
>
> To actually get the merge viewer to appear, you would want to make use of
> a CompareEditorInput. In the prepareInput, you should prepare and return
> your ICompareInput. The CompareEditorInput then takes care of finding an
> appropriate viewer. You can host the editor input in an editor by calling
> CompareUI#openInEditor.
>
> Michael
>
> gdollard wrote:
>> I am trying to display a basic TextMergeViewer but am having problems
>> doing so! Maybe I am not getting the big picture here but can someone
>> please fill me in on how to get the basics up and running!
>>
>> I have a CompareItem which implements IStreamContentAccessor,
>> ITypedElement
>>
>> Then my ActionDelegate class has the following:
>>
>> CompareItem left =
>> new CompareItem("Left", pou1);
>>
>> CompareItem right =
>>
>> new CompareItem("Right", pou2);
>>
>>
>> IWorkbenchPage page =
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>>
>> TextMergeViewer tmv = new TextMergeViewer(page, new
>> CompareConfiguration());
>>
>> tmv.setInput(new DiffNode(left, right));
>>
>> The TextMergeViewer is not being displayed! Any help would be
>> appreciated!
>>
>>
>>
>>
>> "Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
>> news:erklpj$8s2$1@utils.eclipse.org...
>>> You'll need to create your own contentMergeViewer. Here are the set of
>>> steps to create your own content merge viewer:
>>>
>>> 1) Add extension for org.eclipse.compare.contentMergeViewer. This allows
>>> you to register a view factory (IViewerCreator) for creating a subclass
>>> of TextMergeViewer. The association is by content type or file
>>> extension.
>>> 2) In your subclass of TextMergeViewer you'll need to override
>>> getDocumentPartitioner/getDocumentPartitioning. You should use the same
>>> partitioner you use for your editor. You will also need to override
>>> configureTextViewer to provide a source viewer configuration (again, the
>>> same one you use for your editor should work).
>>> 3) You may want to provide token comparator for breaking a line into
>>> tokens (override createTokenComparator).
>>>
>>> Hope this helps,
>>> Michael
>>>
>>> gdollard wrote:
>>>> Hi All,
>>>> I have been reading lots on the CompareUI and have used it
>>>> successfully to implement a basic compare editor. However now I need to
>>>> add code/syntax colouring to my editor! The files I am comparing
>>>> already have syntax colouring in their editors but when viewed in the
>>>> Compare Editor they look like just plain text with not syntax
>>>> colouring. Do I need to provide my own editor instead of using
>>>> CompareUI.openCompareEditor(..) in order to achieve syntax colouring or
>>>> can I somehow plug my own editor into the CompareUI etc?? (I'm new to
>>>> this!)
>>>>
>>>> I have also looked at ResourceCompareInput but cannot see how it
>>>> handles the syntax colouring.
>>>>
>>>> Can anyone provide me with some info on this and what I may need to do?
>>>> Thanks!
>>
Re: CompareUI with Syntax Colouring [message #982578 is a reply to message #312863] Tue, 13 November 2012 08:43 Go to previous message
Karen Avdiev is currently offline Karen AvdievFriend
Messages: 1
Registered: November 2012
Junior Member
hello,

do you have some simple code for UI implementation,

just little tutorial to launch editor,

do i need to imlement plugin? or add somr extention point in my current plugin,

or i can use, as it, in my program.

or you can redirect me to an existing tutorial,

thanks.

have a nice day Smile

Previous Topic:Incorrect Intro/Welcome behavior after move to 4.2
Next Topic:"Toggle Source/Header" interferes with "Next Editor" in Juno
Goto Forum:
  


Current Time: Sat Apr 20 03:38:35 GMT 2024

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

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

Back to the top