Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileLabelProvider.java

Issue 10387008: External file text search engine support. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileLabelProvider.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileLabelProvider.java (revision 7355)
+++ editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileLabelProvider.java (working copy)
@@ -20,6 +20,8 @@
import com.google.dart.tools.search.ui.text.AbstractTextSearchViewPage;
import com.google.dart.tools.search.ui.text.Match;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -30,6 +32,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.model.WorkbenchLabelProvider;
+import java.io.File;
import java.util.Arrays;
import java.util.Comparator;
@@ -82,12 +85,18 @@
@Override
public Image getImage(Object element) {
+ if (element instanceof FileResource<?>) {
+ element = ((FileResource<?>) element).getResource();
+ }
+ if (element instanceof File) {
+ //TODO(pquitslund): improve image fetching
+ IFileStore file = EFS.getLocalFileSystem().fromLocalFile((File) element);
+ return fLabelProvider.getImage(file);
+ }
+
if (element instanceof LineElement) {
return fLineMatchImage;
}
- if (!(element instanceof IResource)) {
- return null;
- }
IResource resource = (IResource) element;
Image image = fLabelProvider.getImage(resource);
@@ -98,19 +107,36 @@
return fOrder;
}
- @Override
- public StyledString getStyledText(Object element) {
- if (element instanceof LineElement) {
- return getLineElementLabel((LineElement) element);
+ public StyledString getStyledString(File resource) {
+ if (!resource.exists()) {
+ return new StyledString(SearchMessages.FileLabelProvider_removed_resource_label);
}
- if (!(element instanceof IResource)) {
- return new StyledString();
+ String name = BasicElementLabels.getResourceName(resource);
+ if (fOrder == SHOW_LABEL) {
+ return getColoredLabelWithCounts(resource, new StyledString(name));
}
- IResource resource = (IResource) element;
+ String pathString = BasicElementLabels.getParentPathLabel(resource, false);
+ if (fOrder == SHOW_LABEL_PATH) {
+ StyledString str = new StyledString(name);
+ String decorated = Messages.format(fgSeparatorFormat, new String[] {
+ str.getString(), pathString});
+
+ StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.QUALIFIER_STYLER, str);
+ return getColoredLabelWithCounts(resource, str);
+ }
+
+ StyledString str = new StyledString(Messages.format(fgSeparatorFormat, new String[] {
+ pathString, name}));
+ return getColoredLabelWithCounts(resource, str);
+
+ }
+
+ public StyledString getStyledString(IResource resource) {
+
if (!resource.exists()) {
- new StyledString(SearchMessages.FileLabelProvider_removed_resource_label);
+ return new StyledString(SearchMessages.FileLabelProvider_removed_resource_label);
}
String name = BasicElementLabels.getResourceName(resource);
@@ -131,9 +157,31 @@
StyledString str = new StyledString(Messages.format(fgSeparatorFormat, new String[] {
pathString, name}));
return getColoredLabelWithCounts(resource, str);
+
}
@Override
+ public StyledString getStyledText(Object element) {
+ if (element instanceof LineElement) {
+ return getLineElementLabel((LineElement) element);
+ }
+
+ if (element instanceof WorkspaceFile) {
+ element = ((WorkspaceFile) element).getResource();
+ }
+
+ if (element instanceof IResource) {
+ return getStyledString((IResource) element);
+ }
+
+ if (element instanceof File) {
+ return getStyledString((File) element);
+ }
+
+ return new StyledString("skipped [" + element.getClass() + "]: " + element.toString());
+ }
+
+ @Override
public String getText(Object object) {
return getStyledText(object).getString();
}

Powered by Google App Engine
This is Rietveld 408576698