From 47484c79b8263b03620f5a0f1bc07fda84732b01 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Wed, 28 Dec 2016 19:00:17 +0300 Subject: [PATCH] [vcs-log] speedsearch uses index and does not initiate loading details by trying to get them --- .../vcs/log/data/index/IndexedDetails.java | 11 +++- .../vcs/log/ui/frame/IndexSpeedSearch.java | 59 +++++++++++++++++++ .../vcs/log/ui/frame/VcsLogGraphTable.java | 13 +--- 3 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/IndexSpeedSearch.java diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java index 9218a04cbe58..fbd4ae80794a 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/IndexedDetails.java @@ -45,10 +45,15 @@ public class IndexedDetails extends LoadingDetails { public String getSubject() { String message = myIndex.getFullMessage(myCommitIndex); if (message != null) { - int subjectEnd = message.indexOf("\n\n"); - if (subjectEnd > 0) return message.substring(0, subjectEnd).replace("\n", " "); - return message.replace("\n", " "); + return getSubject(message); } return super.getSubject(); } + + @NotNull + public static String getSubject(@NotNull String fullMessage) { + int subjectEnd = fullMessage.indexOf("\n\n"); + if (subjectEnd > 0) return fullMessage.substring(0, subjectEnd).replace("\n", " "); + return fullMessage.replace("\n", " "); + } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/IndexSpeedSearch.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/IndexSpeedSearch.java new file mode 100644 index 000000000000..5d7fefe81be6 --- /dev/null +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/IndexSpeedSearch.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.vcs.log.ui.frame; + +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.vcs.log.data.VisiblePack; +import com.intellij.vcs.log.data.index.IndexedDetails; +import com.intellij.vcs.log.data.index.VcsLogIndex; +import com.intellij.vcs.log.impl.VcsLogUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Set; + +public class IndexSpeedSearch extends VcsLogSpeedSearch { + @NotNull private final VcsLogIndex myIndex; + + public IndexSpeedSearch(@NotNull VcsLogIndex index, @NotNull VcsLogGraphTable component) { + super(component); + myIndex = index; + } + + @Override + protected boolean isSpeedSearchEnabled() { + if (super.isSpeedSearchEnabled()) { + VisiblePack visiblePack = myComponent.getModel().getVisiblePack(); + Set roots = visiblePack.getLogProviders().keySet(); + Set visibleRoots = VcsLogUtil.getAllVisibleRoots(roots, visiblePack.getFilters().getRootFilter(), + visiblePack.getFilters().getStructureFilter()); + for (VirtualFile root : visibleRoots) { + if (!myIndex.isIndexed(root)) return false; + } + return true; + } + return false; + } + + @Nullable + @Override + protected String getElementText(@NotNull Object row) { + Integer id = myComponent.getModel().getIdAtRow((Integer)row); + String message = myIndex.getFullMessage(id); + if (message == null) return super.getElementText(row); + return IndexedDetails.getSubject(message); + } +} diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java index 6d8331acf5cf..88af0dcf8b6f 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/VcsLogGraphTable.java @@ -131,18 +131,7 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider, PopupHandler.installPopupHandler(this, VcsLogActionPlaces.POPUP_ACTION_GROUP, VcsLogActionPlaces.VCS_LOG_TABLE_PLACE); ScrollingUtil.installActions(this, false); - new VcsLogSpeedSearch(this) { - @Override - protected boolean isSpeedSearchEnabled() { - if (super.isSpeedSearchEnabled()) { - for (VirtualFile root : getModel().getVisiblePack().getLogProviders().keySet()) { - if (!myLogData.getIndex().isIndexed(root)) return false; - } - return true; - } - return false; - } - }; + new IndexSpeedSearch(myLogData.getIndex(), this); initColumnSize(); addComponentListener(new ComponentAdapter() {