mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] speedsearch uses index and does not initiate loading details by trying to get them
This commit is contained in:
@@ -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", " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<VirtualFile> roots = visiblePack.getLogProviders().keySet();
|
||||
Set<VirtualFile> 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);
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user