forked from abhishekbh/egit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround to enable linking multiple resources to HistoryView
When given a selection the GenericHistoryView only considers the first element and adapts it to an IResource before passing it on as input. To work around this behavior the GitHistoryPage now looks at the current selection itself and uses it as input if preferable. Bug: 392948 Signed-off-by: Stefan Dirix <[email protected]> Signed-off-by: Axel Richard <[email protected]> Change-Id: Idd3f2434881085d90a547f825fb20ba8895b7e79
- Loading branch information
Showing
2 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
* Copyright (C) 2012, François Rey <eclipse.org_@_francois_._rey_._name> | ||
* Copyright (C) 2015, IBM Corporation (Dani Megert <[email protected]>) | ||
* Copyright (C) 2015, Thomas Wolf <[email protected]> | ||
* Copyright (C) 2015, Stefan Dirix (Stefan Dirix <[email protected]>) | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
|
@@ -55,6 +56,7 @@ | |
import org.eclipse.egit.ui.internal.repository.tree.RefNode; | ||
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode; | ||
import org.eclipse.egit.ui.internal.repository.tree.TagNode; | ||
import org.eclipse.egit.ui.internal.selection.SelectionUtils; | ||
import org.eclipse.egit.ui.internal.trace.GitTraceLocation; | ||
import org.eclipse.jgit.annotations.NonNull; | ||
import org.eclipse.jface.action.Action; | ||
|
@@ -1341,17 +1343,32 @@ public void run() { | |
@Override | ||
public boolean setInput(Object object) { | ||
try { | ||
Object useAsInput = object; | ||
|
||
// Workaround for the limitation of GenericHistoryView to only | ||
// forward the first part of a selection and adapting it | ||
// immediately to IResource. | ||
ISelection selection = getSite().getPage().getSelection(); | ||
if (selection instanceof IStructuredSelection) { | ||
IStructuredSelection structuredSelection = (IStructuredSelection) selection; | ||
HistoryPageInput mostFittingInput = SelectionUtils | ||
.getMostFittingInput(structuredSelection, object); | ||
if (mostFittingInput != null) { | ||
useAsInput = mostFittingInput; | ||
} | ||
} | ||
|
||
// hide the warning text initially | ||
setWarningText(null); | ||
trace = GitTraceLocation.HISTORYVIEW.isActive(); | ||
if (trace) | ||
GitTraceLocation.getTrace().traceEntry( | ||
GitTraceLocation.HISTORYVIEW.getLocation(), object); | ||
GitTraceLocation.HISTORYVIEW.getLocation(), useAsInput); | ||
|
||
if (object == getInput()) | ||
if (useAsInput == getInput()) | ||
return true; | ||
this.input = null; | ||
return super.setInput(object); | ||
return super.setInput(useAsInput); | ||
} finally { | ||
if (trace) | ||
GitTraceLocation.getTrace().traceExit( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters