Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Unable to set left/right/ancestor viewer labels
Unable to set left/right/ancestor viewer labels [message #1746586] Tue, 01 November 2016 12:40 Go to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
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 #1746632 is a reply to message #1746586] Wed, 02 November 2016 09:50 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 99
Registered: March 2015
Location: Vienna, Austria
Member

Hi Vlad,

are you talking about the labels on top of the left and right tree viewer in the tree content merge viewer?

If yes, you could try to add a storage path adapter to the left/right/origin resource of the comparison scope of your comparison input. This should allow you to control the left and right titles of the tree content merge viewer:

StoragePathAdapter storagePathAdapter = new StoragePathAdapter(label, isLocal);
resource.eAdapters().add(storagePathAdapter)


Hope that helps!

Best wishes,

Philip


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Unable to set left/right/ancestor viewer labels [message #1746661 is a reply to message #1746586] Wed, 02 November 2016 15:05 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Vlad,

I'm not exactly sure how to trace that, but what happens if you put a breakpoint in EMFCompareConfiguration.getLabel and go back up in the stack? is there any place where your labels are ditched in favor of generic ones? I don't really have a setup to test this atm.

Laurent Goubet
Obeo
Re: Unable to set left/right/ancestor viewer labels [message #1746702 is a reply to message #1746586] Thu, 03 November 2016 13:11 Go to previous message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
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
Previous Topic:Undoing the merged ADD difference throwing exception.
Next Topic:Release date for EMF Compare v3.3.0?
Goto Forum:
  


Current Time: Sat May 11 11:18:18 GMT 2024

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

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

Back to the top