From 33a1d079066cea2d8371a9fbdf7a609f660db058 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 24 Mar 2008 22:31:08 -0400 Subject: [PATCH] Override getInput in the history page to conform to Eclipse contract We replace the real IResource given to us with our own ResourceList, allowing the history page to show multiple resources at once within the same graph. This works great until some part of Eclipse calls our view and tries to get the current IResource input, to see if it needs to create a new view or can reuse the existing one. We now unpack our ResourceList and return the single IResource within it if there is only one IResource in the list. This should make us better conform to the IHistoryPage API. Signed-off-by: Shawn O. Pearce --- .../spearce/egit/ui/internal/history/GitHistoryPage.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java index 18f3dc8b..159f2d7b 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/history/GitHistoryPage.java @@ -214,6 +214,18 @@ public class GitHistoryPage extends HistoryPage { return ourControl; } + public Object getInput() { + final ResourceList r = (ResourceList) super.getInput(); + if (r == null) + return null; + final IResource[] in = r.getItems(); + if (in == null || in.length == 0) + return null; + if (in.length == 1) + return in[0]; + return r; + } + public boolean setInput(final Object o) { final Object in; if (o instanceof IResource) @@ -232,7 +244,7 @@ public class GitHistoryPage extends HistoryPage { if (graph == null) return false; - final IResource[] in = ((ResourceList) getInput()).getItems(); + final IResource[] in = ((ResourceList) super.getInput()).getItems(); if (in == null || in.length == 0) return false; @@ -381,7 +393,7 @@ public class GitHistoryPage extends HistoryPage { } public String getName() { - final ResourceList in = (ResourceList) getInput(); + final ResourceList in = (ResourceList) super.getInput(); if (currentWalk == null || in == null) return ""; final IResource[] items = in.getItems(); -- 2.11.4.GIT