summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorIan Bull2011-06-27 18:27:37 (EDT)
committer Ian Bull2011-06-27 18:27:37 (EDT)
commitaabcc06f12972f5c10857f4e3677393c155fec28 (patch)
tree0de1f61934f90b5f2cf2772d178dd331adf2faeb
parent5e1ed79533d1d6b809946cecb9a7b69e491f58a3 (diff)
downloadegit-aabcc06f12972f5c10857f4e3677393c155fec28.zip
egit-aabcc06f12972f5c10857f4e3677393c155fec28.tar.gz
egit-aabcc06f12972f5c10857f4e3677393c155fec28.tar.bz2
Refresh whenever the refs change.refs/changes/92/3792/3
This refreshes the reflog view whenever the refs fire a change notification. For example, when you commit, the view is now updated automatically. Change-Id: If0a9ffdf94d878d0c10823cf5409d5c92b2e4f2f
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
index aae9f26..9a12ac4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/reflog/ReflogView.java
@@ -39,6 +39,9 @@ import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jgit.events.ListenerHandle;
+import org.eclipse.jgit.events.RefsChangedEvent;
+import org.eclipse.jgit.events.RefsChangedListener;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryState;
@@ -50,6 +53,7 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -67,7 +71,7 @@ import org.eclipse.ui.part.ViewPart;
* A view that shows reflog entries. The View includes a quick filter that searches
* on both the commit hashes and commit messages.
*/
-public class ReflogView extends ViewPart {
+public class ReflogView extends ViewPart implements RefsChangedListener {
/**
* View id
@@ -80,6 +84,8 @@ public class ReflogView extends ViewPart {
private ISelectionListener selectionChangedListener;
+ private ListenerHandle addRefsChangedListener;
+
@Override
public void createPartControl(Composite parent) {
GridLayoutFactory.fillDefaults().applyTo(parent);
@@ -249,6 +255,7 @@ public class ReflogView extends ViewPart {
service.addPostSelectionListener(selectionChangedListener);
getSite().setSelectionProvider(refLogTableTreeViewer);
+ addRefsChangedListener = Repository.getGlobalListenerList().addRefsChangedListener(this);
}
@Override
@@ -262,6 +269,8 @@ public class ReflogView extends ViewPart {
ISelectionService service = (ISelectionService) getSite().getService(
ISelectionService.class);
service.removePostSelectionListener(selectionChangedListener);
+ if ( addRefsChangedListener != null)
+ addRefsChangedListener.remove();
}
private void reactOnSelection(ISelection selection) {
@@ -274,7 +283,8 @@ public class ReflogView extends ViewPart {
IResource resource = (IResource) ssel.getFirstElement();
RepositoryMapping mapping = RepositoryMapping
.getMapping(resource.getProject());
- repository = mapping.getRepository();
+ if ( mapping != null )
+ repository = mapping.getRepository();
}
if (ssel.getFirstElement() instanceof IAdaptable) {
IResource adapted = (IResource) ((IAdaptable) ssel
@@ -282,9 +292,8 @@ public class ReflogView extends ViewPart {
if (adapted != null) {
RepositoryMapping mapping = RepositoryMapping
.getMapping(adapted);
- if (mapping != null) {
+ if (mapping != null)
repository = mapping.getRepository();
- }
}
} else if (ssel.getFirstElement() instanceof RepositoryTreeNode) {
RepositoryTreeNode repoNode = (RepositoryTreeNode) ssel
@@ -320,4 +329,12 @@ public class ReflogView extends ViewPart {
return repoName;
}
+ public void onRefsChanged(RefsChangedEvent event) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ ReflogView.this.refLogTableTreeViewer.refresh();
+ }
+ });
+ }
+
}