diff options
| author | Kevin Sawicki | 2011-04-23 21:22:03 +0000 |
|---|---|---|
| committer | Chris Aniszczyk | 2011-04-28 17:11:55 +0000 |
| commit | efb1c35a24a3cb16feae6231d1a98aaf1a91c073 (patch) | |
| tree | bd29b718be5e9c53379c92861334aa6ebe5e82e4 | |
| parent | dd1e200ef74854a1d5b8286cdfd639b53874a834 (diff) | |
| download | egit-efb1c35a24a3cb16feae6231d1a98aaf1a91c073.tar.gz egit-efb1c35a24a3cb16feae6231d1a98aaf1a91c073.tar.xz egit-efb1c35a24a3cb16feae6231d1a98aaf1a91c073.zip | |
Add class to capture commit search results
Bug: 341652
Change-Id: I6ea7f2eed9ad81a65ca94eb4cbba36b95889217e
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
4 files changed, 138 insertions, 1 deletions
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF index 70555bf0f3..eb3d5b197e 100644 --- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF @@ -26,7 +26,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", org.eclipse.equinox.security;bundle-version="[1.0.0,2.0.0)", - org.eclipse.help;bundle-version="[3.4.0,4.0.0)" + org.eclipse.help;bundle-version="[3.4.0,4.0.0)", + org.eclipse.search;bundle-version="[3.4.0,4.0.0)";resolution:=optional Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Import-Package: org.eclipse.egit.core;version="[0.12.0,0.13.0)", diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java index 4a20dc5a25..211afe4a91 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java @@ -3437,6 +3437,12 @@ public class UIText extends NLS { public static String CommitFileDiffViewer_OpenWorkingTreeVersionInEditorMenuLabel; /** */ + public static String CommitSearchResult_LabelPlural; + + /** */ + public static String CommitSearchResult_LabelSingle; + + /** */ public static String CommitSelectionDialog_BuildingCommitListMessage; /** */ diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchResult.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchResult.java new file mode 100644 index 0000000000..42d821dbc4 --- /dev/null +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchResult.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2011 GitHub Inc. + * 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: + * Kevin Sawicki (GitHub Inc.) - initial API and implementation + *******************************************************************************/ +package org.eclipse.egit.ui.internal.search; + +import java.text.MessageFormat; + +import org.eclipse.egit.ui.UIText; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.search.ui.ISearchQuery; +import org.eclipse.search.ui.text.AbstractTextSearchResult; +import org.eclipse.search.ui.text.IEditorMatchAdapter; +import org.eclipse.search.ui.text.IFileMatchAdapter; +import org.eclipse.search.ui.text.Match; +import org.eclipse.ui.model.IWorkbenchAdapter; + +/** + * Commit search result class. + */ +public class CommitSearchResult extends AbstractTextSearchResult implements + IWorkbenchAdapter { + + private ISearchQuery query; + + /** + * Create commit search result + * + * @param query + */ + public CommitSearchResult(ISearchQuery query) { + this.query = query; + } + + /** + * Add result + * + * @param object + * @return this result + */ + public CommitSearchResult addResult(Object object) { + if (object != null) + addMatch(new Match(object, 0, 0)); + return this; + } + + /** + * @see org.eclipse.search.ui.ISearchResult#getLabel() + */ + public String getLabel() { + int matches = getMatchCount(); + if (matches != 1) + return UIText.CommitSearchResult_LabelSingle; + else + return MessageFormat.format(UIText.CommitSearchResult_LabelPlural, + Integer.valueOf(matches)); + } + + /** + * @see org.eclipse.search.ui.ISearchResult#getTooltip() + */ + public String getTooltip() { + return getLabel(); + } + + /** + * @see org.eclipse.search.ui.ISearchResult#getImageDescriptor() + */ + public ImageDescriptor getImageDescriptor() { + return null; + } + + /** + * @see org.eclipse.search.ui.ISearchResult#getQuery() + */ + public ISearchQuery getQuery() { + return this.query; + } + + /** + * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getEditorMatchAdapter() + */ + public IEditorMatchAdapter getEditorMatchAdapter() { + return null; + } + + /** + * @see org.eclipse.search.ui.text.AbstractTextSearchResult#getFileMatchAdapter() + */ + public IFileMatchAdapter getFileMatchAdapter() { + return null; + } + + /** + * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) + */ + public Object[] getChildren(Object o) { + return getElements(); + } + + /** + * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) + */ + public ImageDescriptor getImageDescriptor(Object object) { + return null; + } + + /** + * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) + */ + public String getLabel(Object o) { + return getLabel(); + } + + /** + * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) + */ + public Object getParent(Object o) { + return null; + } + +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties index 8b6ef61d88..e1e1c9ba6a 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties @@ -1024,6 +1024,8 @@ CommitFileDiffViewer_SelectOneCommitMessage=Please select exactly one commit CommitGraphTable_CommitId=Id CommitGraphTable_Committer=Committer CommitGraphTable_CompareWithEachOtherInTreeMenuLabel=Compare with each other in &Tree +CommitSearchResult_LabelPlural=Git Commit Search - {0} matches +CommitSearchResult_LabelSingle=Git Commit Search - 1 match CommitSelectionDialog_BuildingCommitListMessage=Building commit list CommitSelectionDialog_DialogMessage=Please select a commit from the list CommitSelectionDialog_DialogTitle={0} commits in Repository {1} |
