VCS: quick search for shelf
authorirengrig <Irina.Chernushina@jetbrains.com>
Wed, 3 Feb 2010 17:23:04 +0000 (20:23 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Wed, 3 Feb 2010 17:23:04 +0000 (20:23 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChange.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/ShelvedChangesViewManager.java

index eabdd4733b46e06868f9b78ae7c710664a3fa6cd..62210f3339a3d057db567f359177d402a414fe8e 100644 (file)
@@ -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);
index 1b6336c366618938f22f311c08103cdcf5d62891..d76b9e8aff674deafa4304067b0648aff11c6e49 100644 (file)
@@ -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<TreePath, String>() {
+      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() {