diff options
author | Tobias Baumann | 2015-09-18 21:12:41 +0000 |
---|---|---|
committer | Andrey Loskutov | 2015-09-20 21:47:14 +0000 |
commit | 122267c0af9a61d9ecd9d498133debd7c26d0da5 (patch) | |
tree | 04c73e7a574d2d0554433919ae49792979fc5e89 | |
parent | ca7f7e01b19d4b2ef0120d524ecdeea5a8b48264 (diff) | |
download | egit-122267c0af9a61d9ecd9d498133debd7c26d0da5.tar.gz egit-122267c0af9a61d9ecd9d498133debd7c26d0da5.tar.xz egit-122267c0af9a61d9ecd9d498133debd7c26d0da5.zip |
Consider initial selection in Reflog view.
SWTCommit is adaptable to an instance of type Repository so that
ReflogView can show the repository after opening.
Bug: 475836
Change-Id: I7ca51f2935ab082e9a3fab04a9b4c3bae093d224
Signed-off-by: Tobias Baumann <tobbaumann@gmail.com>
3 files changed, 37 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java index 1ec39840ce..e785441fde 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTCommit.java @@ -1,25 +1,30 @@ /******************************************************************************* - * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> + * Copyright (C) 2008, 2015 Shawn O. Pearce <spearce@spearce.org> * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tobias Baumann <tobbaumann@gmail.com> - Bug 475836 *******************************************************************************/ package org.eclipse.egit.ui.internal.history; import java.io.IOException; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jgit.lib.AnyObjectId; +import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revplot.PlotCommit; -import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.swt.widgets.Widget; -class SWTCommit extends PlotCommit<SWTCommitList.SWTLane> { +class SWTCommit extends PlotCommit<SWTCommitList.SWTLane> implements IAdaptable { Widget widget; - private RevWalk walk; - SWTCommit(final AnyObjectId id, RevWalk walk) { + private SWTWalk walk; + + SWTCommit(final AnyObjectId id, SWTWalk walk) { super(id); this.walk = walk; } @@ -35,4 +40,12 @@ class SWTCommit extends PlotCommit<SWTCommitList.SWTLane> { if (getRawBuffer() == null) walk.parseBody(this); } + + @Override + public <T> T getAdapter(Class<T> adapter) { + if (adapter != Repository.class) { + return null; + } + return adapter.cast(walk.getRepository()); + } } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTWalk.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTWalk.java index a0b35a9a5e..096b406825 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTWalk.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/SWTWalk.java @@ -1,10 +1,13 @@ /******************************************************************************* - * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> + * Copyright (C) 2008, 2015 Shawn O. Pearce <spearce@spearce.org> * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tobias Baumann <tobbaumann@gmail.com> - Bug 475836 *******************************************************************************/ package org.eclipse.egit.ui.internal.history; @@ -14,8 +17,16 @@ import org.eclipse.jgit.revplot.PlotWalk; import org.eclipse.jgit.revwalk.RevCommit; class SWTWalk extends PlotWalk { + + private final Repository repo; + SWTWalk(final Repository repo) { super(repo); + this.repo = repo; + } + + Repository getRepository() { + return repo; } @Override 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 f05bb3b1cc..28ead8601d 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 @@ -9,6 +9,7 @@ * Chris Aniszczyk <caniszczyk@gmail.com> - initial implementation * EclipseSource - Filtered Viewer * Robin Stocker <robin@nibor.org> - Show In support + * Tobias Baumann <tobbaumann@gmail.com> - Bug 475836 *******************************************************************************/ package org.eclipse.egit.ui.internal.reflog; @@ -401,7 +402,13 @@ public class ReflogView extends ViewPart implements RefsChangedListener, IShowIn if (mapping != null) selectedRepo = mapping.getRepository(); } + if (selectedRepo == null) { + selectedRepo = CommonUtils.getAdapter( + ((IAdaptable) ssel.getFirstElement()), + Repository.class); + } } + if (selectedRepo == null && first instanceof RepositoryTreeNode) { RepositoryTreeNode repoNode = (RepositoryTreeNode) ssel .getFirstElement(); |