| <?xml version='1.0' encoding='utf-8' ?> | 
 | <html xmlns="http://www.w3.org/1999/xhtml"> | 
 | 	<head> | 
 | 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | 
 | 		<title>How to open compare dialog</title> | 
 | 		<style type="text/css"> | 
 | 			.info {border: 1px solid #3c78b5;background-color: #D8E4F1;margin: 20px;padding: 0px 6px 0px 6px;} | 
 | 			.note {border: 1px solid #F0C000;background-color: #FFFFCE;margin: 20px;padding: 0px 6px 0px 6px;} | 
 | 			.panel {border: 1px solid #ccc;background-color: #FFFFCE;margin: 10px;padding: 0px 6px 0px 6px;} | 
 | 			.tip {border: 1px solid #090;background-color: #dfd;margin: 20px;padding: 0px 6px 0px 6px;} | 
 | 			.warning {border: 1px solid #c00;background-color: #fcc;margin: 20px;padding: 0px 6px 0px 6px;} | 
 | </style> | 
 | 		<link type="text/css" rel="stylesheet" href="/help/topic/org.eclipse.emf.compare.doc/help/resources/bootstrap.css"/> | 
 | 		<link type="text/css" rel="stylesheet" href="/help/topic/org.eclipse.emf.compare.doc/help/resources/custom.css"/> | 
 | 	</head> | 
 | 	<body> | 
 | 		<h1 id="How_To_Open_Compare_Dialog">How To Open Compare Dialog</h1> | 
 | 		<p>This is only valid since release 2.1M4. </p> | 
 | 		<p>In this page you will learn how to open a dialog displaying the result of a comparison. </p> | 
 | 		<h2 id="Preparing_the_input">Preparing the input</h2> | 
 | 		<p>The first thing to do is to choose an EMF Compare sub-implementation of the class of  | 
 | 			<a href="http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcompare%2FCompareEditorInput.html">CompareEditorInput</a>.  | 
 | 		</p> | 
 | 		<p>Two implementations are provided: </p> | 
 | 		<ul> | 
 | 			<li> | 
 | 				<i>ComparisonEditorInput</i>, that should be use when you want to display a pre-computed Comparison (the results of EMFCompare). | 
 | 			</li> | 
 | 			<li> | 
 | 				<i>ComparisonScopeEditorInput</i>, that should be use when you want to open the compare editor or dialog and to let it perform the comparison. | 
 | 			</li> | 
 | 		</ul> | 
 | 		<p>Both are available from the  | 
 | 			<b>org.eclipse.emf.compare.ide.ui</b> plug-in, in the package  | 
 | 			<b>org.eclipse.emf.compare.ide.ui.internal.editor</b>. This is still provisional API so we may break it any time. | 
 | 		</p> | 
 | 		<h2 id="Preparing_the_configuration">Preparing the configuration</h2> | 
 | 		<p>When instantiating an EMF Compare specific implementation of CompareEditorInput, you have to give it at least three parameters:</p> | 
 | 		<ul> | 
 | 			<li>An  | 
 | 				<a href="http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.emf.compare.doc%2Fhelp%2Fdeveloper%2Fjavadoc%2Forg%2Feclipse%2Femf%2Fcompare%2Fide%2Fui%2Finternal%2Fconfiguration%2FEMFCompareConfiguration.html">EMFCompareConfiguration</a>. This is a refined configuration of the standard CompareConfiguration so you just instantiate it like this: | 
 | 			</li> | 
 | 		</ul> | 
 | 		<pre class="source-java">EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration()); | 
 |  | 
 | </pre> | 
 | 		<ul> | 
 | 			<li>An EMFCompareEditingDomain. It is not an implementation of  | 
 | 				<a href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.5.0/org/eclipse/emf/edit/domain/EditingDomain.html">EditingDomain</a> from EMF. It shares similar concepts (it has a command stack, it can create some commands) but is much simpler. You can create it through the factory method: | 
 | 			</li> | 
 | 		</ul> | 
 | 		<pre class="source-java">// ancestor may be null | 
 | ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(left, right, ancestor);  | 
 |  | 
 | </pre> | 
 | 		<p>You can even give your own command(s) stack(s) if you need to know about executed merge commands. </p> | 
 | 		<ul> | 
 | 			<li>An  | 
 | 				<a href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.5.0/org/eclipse/emf/common/notify/AdapterFactory.html">AdapterFactory</a> used by the framework to adapt EObjects to be nicely displayed. Most of the time, a  | 
 | 				<a href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.5.0/org/eclipse/emf/edit/provider/ComposedAdapterFactory.html">ComposedAdapterFactory</a> with the global registry is sufficient as created in the example below: | 
 | 			</li> | 
 | 		</ul> | 
 | 		<pre class="source-java">AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); | 
 |  | 
 | </pre> | 
 | 		<p>Depending on the choosen sub-implementation of CompareEditorInput, you may need to provide additional parameters.</p> | 
 | 		<h3 id="ComparisonEditorInput">ComparisonEditorInput</h3> | 
 | 		<p>You must provide a Comparison object, the result of the comparison computation of EMFCompare.</p> | 
 | 		<pre class="source-java">EMFCompare comparator = EMFCompare.builder().build(); | 
 | Comparison comparison = comparator.compare(EMFCompare.createDefaultScope(left, right, ancestor)); | 
 |  | 
 | </pre> | 
 | 		<h3 id="ComparisonScopeEditorInput">ComparisonScopeEditorInput</h3> | 
 | 		<p>You must provide the comparator (instance of EMFCompare) and the scope of the comparison.</p> | 
 | 		<pre class="source-java">EMFCompare comparator = EMFCompare.builder().build(); | 
 | IComparisonScope scope = EMFCompare.createDefaultScope(left, right, ancestor); | 
 |  | 
 | </pre> | 
 | 		<h2 id="Opening_the_compare_UI">Opening the compare UI</h2> | 
 | 		<p>Then, you can call the black magic method from Eclipse Compare framework. You have two choices. You may either open the compare UI wihtin a modal dialog or within an editor. Just call one of the two following methods: </p> | 
 | 		<ul> | 
 | 			<li> | 
 | 				<a href="http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fcompare%2FCompareUI.html&anchor=openCompareEditorOnPage(org.eclipse.compare.CompareEditorInput,%20org.eclipse.ui.IWorkbenchPage)">CompareUI.openCompareEditorOnPage(CompareEditorInput, IWorkbenchPage)</a>, to open an editor.  | 
 | 			</li> | 
 | 			<li> | 
 | 				<a href="http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/compare/CompareUI.html#openCompareDialog(org.eclipse.compare.CompareEditorInput)">CompareUI.openCompareDialog(CompareEditorInput)</a>, to open a modal dialog. | 
 | 			</li> | 
 | 		</ul> | 
 | 		<h2 id="End-to-end_examples">End-to-end examples</h2> | 
 | 		<h3 id="With_pre-computed_comparison">With pre-computed comparison</h3> | 
 | 		<pre class="source-java">public void compare(Notifier left, Notifier right, Notifier ancestor) { | 
 |     EMFCompare comparator = EMFCompare.builder().build(); | 
 |     Comparison comparison = comparator.compare(EMFCompare.createDefaultScope(left, right, ancestor)); | 
 |  | 
 |     EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration()); | 
 |     ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(left, right, ancestor); | 
 |     AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); | 
 |     CompareEditorInput input = new ComparisonEditorInput(configuration, comparison, editingDomain, adapterFactory); | 
 |  | 
 |     CompareUI.openCompareDialog(input); // or CompareUI.openCompareEditor(input); | 
 | } | 
 |  | 
 | </pre> | 
 | 		<h3 id="With_a_comparison_scope">With a comparison scope</h3> | 
 | 		<pre class="source-java">public void compare(Notifier left, Notifier right, Notifier ancestor) { | 
 |     EMFCompare comparator = EMFCompare.builder().build(); | 
 |     IComparisonScope scope = EMFCompare.createDefaultScope(left, right, ancestor)); | 
 |  | 
 |     EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration()); | 
 |     ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(left, right, ancestor); | 
 |     AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); | 
 |     CompareEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain, adapterFactory, comparator, scope); | 
 |  | 
 |     CompareUI.openCompareDialog(input); // or CompareUI.openCompareEditor(input); | 
 | } | 
 |  | 
 | </pre> | 
 | 	</body> | 
 | </html> |