Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Hiding nodes in the model tree(I need to hide some intermediate nodes, while keeping the rest of the tree.)
Hiding nodes in the model tree [message #1385965] Thu, 12 June 2014 13:47 Go to next message
Mattias Backman is currently offline Mattias BackmanFriend
Messages: 4
Registered: June 2014
Location: Sweden
Junior Member
Hi,

I'm new to coding with EMF Compare, so I might have overlooked something well-known, please let me know if that's the case. Smile

I would like to hide some tree nodes in the match results, since they are just containers with no meaning to our users.

This is an actual example, where the two instances of "RT Variable Setup List" should be hidden:
> settings
    > RT Variable Setup List
        > v2
            > RT Variable Setup List
                > field4
                [details of diff]
                > field6
                [details of diff]


So, I would want this instead:
> settings
    > v2
        > field4
        [details of diff]
        > field6
        [details of diff]

since that matches the actual model, known by our users.

I have tried tweaking the scope by removing the class that represents those nodes. That ruins the tree structure, so I only get the separate diffs in the top "Model differences" view. I would like to get a trimmed tree structure.

I attach the saved comparisons, in case that helps.

What I have done:
...
		DefaultComparisonScope scope = new DefaultComparisonScope(changedModel, referenceModel, null);
		scope.setEObjectContentFilter(and(not(IS_RT_VARIABLE_SETUP_LIST), not(IS_EGENERIC_TYPE_WITHOUT_PARAMETERS)));
		scope.setResourceContentFilter(and(not(IS_RT_VARIABLE_SETUP_LIST), not(IS_EGENERIC_TYPE_WITHOUT_PARAMETERS)));
		result = comparator.compare(scope);
...

with this new Predicate, which is combined with the default scope Predicate.
	/**
	 * Predicate used to know if the given object is an Domain object that should not be included in matching. 
	 * 
	 * @return true, if the given EObject is an DomainRTVariableSetupList, false otherwise.
	 */
	public static final Predicate<? super EObject> IS_RT_VARIABLE_SETUP_LIST = new Predicate<EObject>() {
		public boolean apply(EObject input) {
			return input instanceof DomainRTVariableSetupList;
		}
	};


I'd really appreciate some pointers as to how to move forward with this.

Thanks,

Mattias
Re: Hiding nodes in the model tree [message #1386946 is a reply to message #1385965] Mon, 23 June 2014 08:42 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Mattias,

Hiding a "mid-level" container from the "top" tree view (structural differences) of the comparison isn't easily possible without also hiding its children : filters or other easily implementable solutions are out. There are still two ways you could achieve such a result.

A first possibility is to write your own group (look it up in the documentation for technical details) in order to rewrite the tree itself, which will allow you to "skip" a level entirely by subclassing the "getChildren()" implementation of all levels.

Another option would be to implement a post-processor that will remove the Match elements corresponding to those you wish to hide away in its "postMatch()" method, making sure that you move the children Match of the removed one up to their new container. This might cause issues with the differencing though, so you might want to try and do this in the "postComparison()" instead : EMF Compare will have finished its work, both matching and differencing will be done... so modifications you do then will have no impact if you make sure to move all "Match" where they really belong when you remove one of their parents. Please also note that the differences are attached to the Match elements : if one of your "containers" is removed while it had a difference (for example, if said container has been added or removed in one of the compared versions), your merge operations might corrupt the model (since we'll be missing that particular diff, along with its Match).

Laurent Goubet
Obeo
Re: Hiding nodes in the model tree [message #1387115 is a reply to message #1386946] Tue, 24 June 2014 09:07 Go to previous message
Mattias Backman is currently offline Mattias BackmanFriend
Messages: 4
Registered: June 2014
Location: Sweden
Junior Member
Hi Laurent,

Thanks for your reply!

Regards,

Mattias
Previous Topic:What is the data structure used in the Model Compare pane?
Next Topic:Need to extend EMF Compare mechanism as well as EMF Compare Editor
Goto Forum:
  


Current Time: Tue Mar 19 07:14:39 GMT 2024

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

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

Back to the top