Unable to set left/right/ancestor viewer labels [message #1746586] |
Tue, 01 November 2016 08:40  |
Eclipse User |
|
|
|
Hi,
I am trying to display custom labels for the left, right, and ancestor compare/merge viewers. To do this, I have implemented a class like the following (I am only showing the relevant code here):
public class MyEditorInput extends CompareEditorInput {
protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
CompareConfiguration compConfig = getCompareConfiguration();
compConfig.setAncestorLabel("My Ancestor Label");
compConfig.setLeftLabel("My Left Label");
compConfig.setRightLabel("My Right Label");
}
}
However, the viewers are still displayed with different titles.
I know that the labels I set myself are only used "if the element for which a label is requested does not have a left/right/ancestor contributor or the element does not have a registered label provider or the label provider returns null as the label". To check that this is not the case, I set a breakpoint in the getLeftLabel(Object input) method of the CompareConfiguration$DefaultLabelProvider inner class. I can see that this method always returns the values I have set, so I don't know why the displayed labels are still different.
Cheers,
Vlad
|
|
|
|
|
Re: Unable to set left/right/ancestor viewer labels [message #1746702 is a reply to message #1746586] |
Thu, 03 November 2016 09:11  |
Eclipse User |
|
|
|
Hi Philip and Laurent,
Thank you both for the helpful answers. I eventually followed Laurent's advice of setting a breakpoint in EMFCompareConfiguration.getLeftLabel, and I could see that there were several calls to this method. The last call was not returning the label I had set myself.
This was due to a label provider already being registered for instances of TreeNodeCompareInput.
My solution was to extend the TreeNodeCompareInputLabelProvider class, and include my new label provider in the EMFCompareConfiguration provided to the EMFCompareTextMergeViewer as an argument to its constructor.
Cheers,
Vlad
|
|
|
Powered by
FUDForum. Page generated in 0.04846 seconds