1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.ui.texteditor.quickdiff;
15 
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 
19 import org.eclipse.jface.text.IDocument;
20 
21 import org.eclipse.ui.texteditor.ITextEditor;
22 
23 
24 /**
25  * The protocol a reference provider for Quick Diff has to implement. Quick Diff references provide
26  * a reference document (an <code>IDocument</code>) that is used as the original against which
27  * diff information is generated.
28  * <p>Extensions to the extension point <code>quickdiff.referenceprovider</code> have to implement
29  * this interface (plus another interface for plug-in and UI management.</p>
30  *
31  * @since 3.0
32  */
33 public interface IQuickDiffReferenceProvider {
34 	/**
35 	 * Returns the reference document for the quick diff display.
36 	 *
37 	 * @param monitor a preference monitor to monitor / cancel the process, or <code>null</code>
38 	 * @return the reference document for the quick diff display or <code>null</code> if getting the
39 	 * document was canceled or there is no reference available.
40 	 * @throws CoreException if getting the document fails.
41 	 */
getReference(IProgressMonitor monitor)42 	IDocument getReference(IProgressMonitor monitor) throws CoreException;
43 
44 	/**
45 	 * Called when the reference is no longer used and the provider can free resources.
46 	 */
dispose()47 	void dispose();
48 
49 	/**
50 	 * Returns the id of this reference provider.
51 	 *
52 	 * @return the id of this provider as stated in the extending plugin's manifest.
53 	 */
getId()54 	String getId();
55 
56 	/**
57 	 * Sets the active editor for the provider implementation. Will usually just be called right after
58 	 * creation of the implementation.
59 	 *
60 	 * @param editor the active editor.
61 	 */
setActiveEditor(ITextEditor editor)62 	void setActiveEditor(ITextEditor editor);
63 
64 	/**
65 	 * Gives the implementation a hook to publish its enablement. The action corresponding to this
66 	 * implementation might be grayed out or not shown at all based on the value presented here.
67 	 *
68 	 * @return <code>false</code> if the implementation cannot be executed, <code>true</code> if it can,
69 	 * or if it cannot be decided yet.
70 	 */
isEnabled()71 	boolean isEnabled();
72 
73 	/**
74 	 * Sets the id of this implementation. This method will be called right after creation, and
75 	 * <code>id</code> will be set to the <code>Id</code> attribute specified in the extension's
76 	 * declaration.
77 	 *
78 	 * @param id the provider's new id.
79 	 */
setId(String id)80 	void setId(String id);
81 }
82