1 /*******************************************************************************
2 * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
3 * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * See LICENSE for the full license text, also available.
8 *******************************************************************************/
9 package org
.spearce
.egit
.ui
.internal
.decorators
;
11 import java
.io
.IOException
;
13 import org
.eclipse
.core
.resources
.IResource
;
14 import org
.eclipse
.core
.runtime
.CoreException
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.jface
.text
.IDocument
;
17 import org
.eclipse
.team
.core
.RepositoryProvider
;
18 import org
.eclipse
.ui
.IEditorInput
;
19 import org
.eclipse
.ui
.ide
.ResourceUtil
;
20 import org
.eclipse
.ui
.texteditor
.ITextEditor
;
21 import org
.eclipse
.ui
.texteditor
.quickdiff
.IQuickDiffReferenceProvider
;
22 import org
.spearce
.egit
.ui
.Activator
;
23 import org
.spearce
.egit
.ui
.UIText
;
26 * This class provides input for the Eclipse Quick Diff feature.
28 public class GitQuickDiffProvider
implements IQuickDiffReferenceProvider
{
32 private GitDocument document
;
34 private IResource resource
;
36 public void dispose() {
37 Activator
.trace("(GitQuickDiffProvider) dispose");
42 public String
getId() {
46 public IDocument
getReference(IProgressMonitor monitor
)
47 throws CoreException
{
48 Activator
.trace("(GitQuickDiffProvider) file: " + resource
);
49 RepositoryProvider provider
= RepositoryProvider
.getProvider(resource
51 if (provider
!= null) {
53 document
= GitDocument
.create(resource
);
54 } catch (CoreException e
) {
55 Activator
.error(UIText
.QuickDiff_failedLoading
, e
);
56 } catch (IOException e
) {
57 Activator
.error(UIText
.QuickDiff_failedLoading
, e
);
65 public boolean isEnabled() {
69 public void setActiveEditor(ITextEditor editor
) {
70 IEditorInput editorInput
= editor
.getEditorInput();
71 resource
= ResourceUtil
.getResource(editorInput
);
74 public void setId(String id
) {