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 |
Anthony Okala Messages: 6 Registered: November 2016 |
Junior Member |
|
|
Hi everyone,
first thing first: please forgive my poor english. i usually speak french and German
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 |
|
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 #1748214 is a reply to message #1748083] |
Mon, 21 November 2016 09:19 |
|
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 #1749290 is a reply to message #1748429] |
Mon, 05 December 2016 08:58 |
|
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
|
|
|
Goto Forum:
Current Time: Tue Nov 05 16:26:46 GMT 2024
Powered by FUDForum. Page generated in 0.03552 seconds
|