From 347b9a770e4ecef542bb70a43d7601c61bef3bd8 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 3 Feb 2010 20:23:04 +0300 Subject: [PATCH] VCS: quick search for shelf --- .../vcs/changes/shelf/ShelvedChange.java | 8 +++++++ .../shelf/ShelvedChangesViewManager.java | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java index eabdd4733b46..62210f3339a3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java @@ -65,6 +65,14 @@ public class ShelvedChange { return myAfterPath; } + @Nullable + public String getAfterFileName() { + if (myAfterPath == null) return null; + int pos = myAfterPath.lastIndexOf('/'); + if (pos >= 0) return myAfterPath.substring(pos+1); + return myAfterPath; + } + public String getBeforeFileName() { int pos = myBeforePath.lastIndexOf('/'); if (pos >= 0) return myBeforePath.substring(pos+1); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java index 1b6336c36661..d76b9e8aff67 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java @@ -47,9 +47,11 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.PopupHandler; import com.intellij.ui.SimpleTextAttributes; +import com.intellij.ui.TreeSpeedSearch; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.containers.Convertor; import com.intellij.util.messages.MessageBus; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NonNls; @@ -126,6 +128,25 @@ public class ShelvedChangesViewManager implements ProjectComponent { DiffShelvedChangesAction.showShelvedChangesDiff(DataManager.getInstance().getDataContext(myTree)); } }); + new TreeSpeedSearch(myTree, new Convertor() { + public String convert(TreePath o) { + final Object lc = o.getLastPathComponent(); + final Object lastComponent = lc == null ? null : ((DefaultMutableTreeNode) lc).getUserObject(); + if (lastComponent instanceof ShelvedChangeList) { + return ((ShelvedChangeList) lastComponent).DESCRIPTION; + } else if (lastComponent instanceof ShelvedChange) { + final ShelvedChange shelvedChange = (ShelvedChange)lastComponent; + return shelvedChange.getBeforeFileName() == null ? shelvedChange.getAfterFileName() : shelvedChange.getBeforeFileName(); + } else if (lastComponent instanceof ShelvedBinaryFile) { + final ShelvedBinaryFile sbf = (ShelvedBinaryFile) lastComponent; + final String value = sbf.BEFORE_PATH == null ? sbf.AFTER_PATH : sbf.BEFORE_PATH; + int idx = value.lastIndexOf("/"); + idx = (idx == -1) ? value.lastIndexOf("\\") : idx; + return idx > 0 ? value.substring(idx + 1) : value; + } + return null; + } + }, true); } public void projectOpened() {