Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » EMF Compare: Start over!?(Getting started with the newest versions of EMF Compare)
EMF Compare: Start over!? [message #1747279] Fri, 11 November 2016 15:07 Go to next message
Anthony Okala is currently offline Anthony OkalaFriend
Messages: 6
Registered: November 2016
Junior Member
Hi everyone,
first thing first: please forgive my poor english. i usually speak french and German Razz
i'm new in this forum and a also a noob programmer.

i got a project and have to build an Editor on an ecore model (i think you all know about the model driven software dev, don't you?).
now i want to integrate a Graphical model comparison for the models created in the driven Editor.

i started by writing a class to programmaticaly compare two ecore model with respect to the given example in the developer documentation https://www.eclipse.org/emf/compare/documentation/latest/developer/developer-guide.html:
@SuppressWarnings("restriction")
	public void compareOE(String model1, String model2) {
		URI uri1 = URI.createFileURI("C:/Users/AnthonySO/Documents/Bachelorarbeit/Vorbereitung/Workspace/MARS4/emab.project.test1/model/emab.ecore");
		URI uri2 = URI.createFileURI("C:/Users/AnthonySO/Documents/Bachelorarbeit/Vorbereitung/Workspace/MARS4/emab.project.test2/model/emab.ecore");

		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());

		ResourceSet resourceSet1 = new ResourceSetImpl();
		ResourceSet resourceSet2 = new ResourceSetImpl();

		resourceSet1.getResource(uri1, true);
		resourceSet2.getResource(uri2, true);
	    EMFCompare.Builder builder = EMFCompare.builder();
	    EMFCompare comparator = builder.build();
	    IComparisonScope scope = new DefaultComparisonScope(resourceSet1, resourceSet2, null);

	    ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(resourceSet1, resourceSet2, null);
	    AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
	    EMFCompareConfiguration compareConfig = new EMFCompareConfiguration(new CompareConfiguration());
	    CompareEditorInput input = new ComparisonScopeEditorInput(compareConfig, 
	        editingDomain, adapterFactory, comparator, scope);

	    CompareUI.openCompareDialog(input); // or CompareUI.openCompareEditor(input);
	}

1. i got a restriction warning and i want to solve it, but i don't know how. i thing it is not so that important, is it?
2. then i got the following error code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
	at org.eclipse.emf.compare.EMFCompare.<clinit>(EMFCompare.java:73)
	at emab.diagram.compare.cutom.CustomCompare.compareOE(CustomCompare.java:79)
	at emab.diagram.compare.cutom.CustomCompare.main(CustomCompare.java:94)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger

is there any way out of this error?

Re: EMF Compare: Start over!? [message #1747600 is a reply to message #1747279] Wed, 16 November 2016 12:13 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 83
Registered: March 2015
Location: Vienna, Austria
Member

Hi Anthony,

the code looks good on a first quick look.

Quote:
1. i got a restriction warning and i want to solve it, but i don't know how. i thing it is not so that important, is it?


This warning means that you are probably using internal classes. Thus, you are not only using public API and take the risk that the classes you are using may change also in upcoming minor version updates (e.g. from 3.3 to 3.4). By using public API only, you can be sure that the API would break only if it is a major version update (e.g. from 3.3 to 4.0).

Quote:
2. then i got the following error code:
<snip>
is there any way out of this error?


You have to make sure that a plug-in exists in your Run Config or product, which exports the class org.apache.log4j.Logger. Are you using target platforms or do you use your running IDE as target? If the former is true, I'd recommend to add the feature "org.apache.log4j" from the update site http://download.eclipse.org/tools/orbit/downloads/drops/R20150519210750/repository/ in your target.

Hope that helps,

Philip

--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: EMF Compare: Start over!? [message #1748083 is a reply to message #1747600] Fri, 18 November 2016 11:30 Go to previous messageGo to next message
Anthony Okala is currently offline Anthony OkalaFriend
Messages: 6
Registered: November 2016
Junior Member
Hi Philip,
thank you for the reply.

for the 1. problem i'll just use CompareConfiguration instead of EMFCompareConfiguration.

for the second Problem i decided to choose another approach for my project.
i would like to graphically compare Models (comming from my Ecore Metamodel). but i'm struggling to reload the resources is this way correct for that?
r_left = resourceSet.getResource(((IResource) left).getLocationURI(), true);
		r_right = resourceSet.getResource(((IResource) right).getLocationURI(), true);


or this way maybe?
r_left = ResourceUtil.loadResource((IStorage) ((ResourceNode) left).getResource().getFullPath(), resourceSet, Collections.EMPTY_MAP);
		r_right= ResourceUtil.loadResource((IStorage) ((ResourceNode) right).getResource().getFullPath(), resourceSet, Collections.EMPTY_MAP);

or do you know how i can do it?

Best regards
Anthony
Re: EMF Compare: Start over!? [message #1748214 is a reply to message #1748083] Mon, 21 November 2016 09:19 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1855
Registered: July 2009
Senior Member
Hi Anthony,

First things first, you should try and use distinct resource sets for your left and right models to avoid any unwanted interactions.

Then, to load a file as an EMF model you have to provide an URI EMF understands.
ResourceSet leftRS = new ResourceSetImpl();
URI leftResourceURI = URI.createPlatformResourceURI(((IResource)left).getFullPath().toString(), true);
Resource left = leftRS.getResource(leftResourceURI, true);


Do note that if you are running this code in standalone you will have to register all resource factories and do the necessary setup on your resource set to load the resource. Since your talking about a graphical comparison, I suspect you're trying to compare ecoretools files?

Laurent Goubet
Obeo
Re: EMF Compare: Start over!? [message #1748429 is a reply to message #1748214] Wed, 23 November 2016 06:57 Go to previous messageGo to next message
Anthony Okala is currently offline Anthony OkalaFriend
Messages: 6
Registered: November 2016
Junior Member
Hi Laurent,
thank you for the advice. (you can speak french right?

You are right! actually i want to graphically compare my diagrams.
i created a GMF-Based Editor and the i can create some Diagrams, so i want to compare them.
i looked for EMF compare plug-ins, which supports the model driven development, so that i just have to set the content type. But didn't found.

i followed the tutorial
GMF_Notation_model_Comparison but seems not working for me.

what i did understand to graphically compare my models. I must start with


    content Type: in order to register my Diagram file extension and so


    custom ContentMergeViewerCreator Class where i have to call my ContentMergeViewer Class. so in the last one i have to create the control, (re)load the resources and create a View model in order to create and show my GMF Diagram


    custom the StructureMergeViewer. Where i have to implement the inputChanged method


    custom the diffprocessor. to compute the diff, merge and get the merged notation diagram model.


    custom the decoratorProvider. But i think it is optional, isn't it?

please tell me if i am right.
it all is some kind of blurred for me. As you can see i'm really noob with EMF Compare.(i've to say too, i started with JAVA 2 years ago)

After this 4 Step i don't know anymore how to continue

please can you tell me how to proceed? Because i really want to program it and get that work

Re: EMF Compare: Start over!? [message #1749290 is a reply to message #1748429] Mon, 05 December 2016 08:58 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1855
Registered: July 2009
Senior Member
Hi Anthony,

Before you try and get your use case working in stand alone, have you tried comparing these files through the regular eclipse UI with EMF Compare's GMF Diagram support installed? Use the latest release's (3.3.0) update site to install the "GMF Support" feature, then try to compare your files through the normal action (select your two files -> compare with -> each other). If that doesn't work and you use a custom file extension, try and add that extension to our known content-types (Window > Preferences > General > Content Types > EMF Compare) and try again.

This will at least tell you if EMF Compare can support your files out of the box. If not, then you will have to see how to implement your own comparison algorithms and integrate them with EMF Compare. You can take a look at the supports we have for Papyrus (most advanced, probably most complicated as well) and Sirius to see how we integrate with graphical tools for the comparison. You can retrieve their source code by cloning our repository, they're located in the plugins folder and are prefixed by "org.eclipse.emf.compare.diagram".

Basically, you shouldn't need steps as high level as you outlined above (for example, the structure merge view is already provided by emf compare so you can just let us to the heavy lifting).

Laurent Goubet
Obeo
Previous Topic:Hiding nodes in Content Merge Viewer
Next Topic:EMF Compare tries to match an added/new element with existing one
Goto Forum:
  


Current Time: Tue Apr 24 16:52:56 GMT 2018

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

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