|
|
|
|
|
Re: CompareUI with Syntax Colouring [message #312900 is a reply to message #312898] |
Fri, 23 February 2007 14:39 |
Michael Valenta 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 |
Glenn Dollard 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!
>>
|
|
|
|
Powered by
FUDForum. Page generated in 0.08041 seconds