Search in sources :

Example 11 with CompareEditorInput

use of org.eclipse.compare.CompareEditorInput in project egit by eclipse.

the class CompareUtils method openInCompare.

/**
 * Compares two files between the given commits, taking possible renames
 * into account.
 *
 * @param commit1
 *            the "left" commit for the comparison editor
 * @param commit2
 *            the "right" commit for the comparison editor
 * @param commit1Path
 *            path to the file within commit1's tree
 * @param commit2Path
 *            path to the file within commit2's tree
 * @param repository
 *            the repository this commit was loaded out of
 * @param workBenchPage
 *            the page to open the compare editor in
 */
public static void openInCompare(RevCommit commit1, RevCommit commit2, String commit1Path, String commit2Path, Repository repository, IWorkbenchPage workBenchPage) {
    final ITypedElement base = CompareUtils.getFileRevisionTypedElement(commit1Path, commit1, repository);
    final ITypedElement next = CompareUtils.getFileRevisionTypedElement(commit2Path, commit2, repository);
    CompareEditorInput in = new GitCompareFileRevisionEditorInput(base, next, null);
    CompareUtils.openInCompare(workBenchPage, in);
}
Also used : CompareEditorInput(org.eclipse.compare.CompareEditorInput) GitCompareEditorInput(org.eclipse.egit.ui.internal.merge.GitCompareEditorInput) SaveableCompareEditorInput(org.eclipse.team.ui.synchronize.SaveableCompareEditorInput) GitCompareFileRevisionEditorInput(org.eclipse.egit.ui.internal.revision.GitCompareFileRevisionEditorInput) ITypedElement(org.eclipse.compare.ITypedElement)

Example 12 with CompareEditorInput

use of org.eclipse.compare.CompareEditorInput in project egit by eclipse.

the class MergeToolActionHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    int mergeMode = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.MERGE_MODE);
    IPath[] locations = getSelectedLocations(event);
    CompareEditorInput input;
    if (mergeMode == 0) {
        MergeModeDialog dlg = new MergeModeDialog(getShell(event));
        if (dlg.open() != Window.OK)
            return null;
        input = new GitMergeEditorInput(dlg.useWorkspace(), locations);
    } else {
        boolean useWorkspace = mergeMode == 1;
        input = new GitMergeEditorInput(useWorkspace, locations);
    }
    CompareUI.openCompareEditor(input);
    return null;
}
Also used : CompareEditorInput(org.eclipse.compare.CompareEditorInput) GitMergeEditorInput(org.eclipse.egit.ui.internal.merge.GitMergeEditorInput) IPath(org.eclipse.core.runtime.IPath) MergeModeDialog(org.eclipse.egit.ui.internal.merge.MergeModeDialog)

Aggregations

CompareEditorInput (org.eclipse.compare.CompareEditorInput)12 CompareConfiguration (org.eclipse.compare.CompareConfiguration)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ITypedElement (org.eclipse.compare.ITypedElement)5 DiffNode (org.eclipse.compare.structuremergeviewer.DiffNode)4 IPath (org.eclipse.core.runtime.IPath)3 GitCompareEditorInput (org.eclipse.egit.ui.internal.merge.GitCompareEditorInput)3 SaveableCompareEditorInput (org.eclipse.team.ui.synchronize.SaveableCompareEditorInput)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 Job (org.eclipse.core.runtime.jobs.Job)2 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)2 GitMergeEditorInput (org.eclipse.egit.ui.internal.merge.GitMergeEditorInput)2 MergeModeDialog (org.eclipse.egit.ui.internal.merge.MergeModeDialog)2 LocalNonWorkspaceTypedElement (org.eclipse.egit.ui.internal.synchronize.compare.LocalNonWorkspaceTypedElement)2 ArrayList (java.util.ArrayList)1 IResourceProvider (org.eclipse.compare.IResourceProvider)1 ICompareInput (org.eclipse.compare.structuremergeviewer.ICompareInput)1