mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
ShowUsagesAction: instantiate table renderer once since its fields doesn't change
Also less parameters to pass into ShowUsagesAction#rebuildTable. GitOrigin-RevId: 686ecfc380219c535ed97458a60e3a51d0a53e48
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8bf3398e57
commit
d55b5b5e56
@@ -310,7 +310,8 @@ public class ShowUsagesAction extends AnAction implements PopupAction, HintManag
|
||||
});
|
||||
|
||||
final SearchScope searchScope = actionHandler.getSelectedScope();
|
||||
ShowUsagesTable table = new ShowUsagesTable();
|
||||
final AtomicInteger outOfScopeUsages = new AtomicInteger();
|
||||
ShowUsagesTable table = new ShowUsagesTable(new ShowUsagesTableCellRenderer(usageView, outOfScopeUsages, searchScope));
|
||||
AsyncProcessIcon processIcon = new AsyncProcessIcon("xxx");
|
||||
|
||||
addUsageNodes(usageView.getRoot(), usageView, new ArrayList<>());
|
||||
@@ -318,8 +319,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction, HintManag
|
||||
List<Usage> usages = new ArrayList<>();
|
||||
Set<UsageNode> visibleNodes = new LinkedHashSet<>();
|
||||
List<UsageNode> data = collectData(usages, visibleNodes, usageView, presentation);
|
||||
AtomicInteger outOfScopeUsages = new AtomicInteger();
|
||||
table.setTableModel(usageView, data, outOfScopeUsages, searchScope);
|
||||
table.setTableModel(data);
|
||||
|
||||
boolean isPreviewMode =
|
||||
Boolean.TRUE == PreviewManager.SERVICE.preview(project, UsagesPreviewPanelProvider.ID, Pair.create(usageView, table), false);
|
||||
@@ -366,8 +366,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction, HintManag
|
||||
}
|
||||
|
||||
rebuildTable(
|
||||
usageView, copy, nodes, table, popup, presentation, popupPosition, minWidth, !processIcon.isDisposed(),
|
||||
outOfScopeUsages, searchScope
|
||||
usageView, copy, nodes, table, popup, presentation, popupPosition, minWidth, !processIcon.isDisposed()
|
||||
);
|
||||
});
|
||||
|
||||
@@ -780,9 +779,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction, HintManag
|
||||
@NotNull UsageViewPresentation presentation,
|
||||
@NotNull RelativePoint popupPosition,
|
||||
@NotNull IntRef minWidth,
|
||||
boolean findUsagesInProgress,
|
||||
@NotNull AtomicInteger outOfScopeUsages,
|
||||
@NotNull SearchScope searchScope) {
|
||||
boolean findUsagesInProgress) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
boolean shouldShowMoreSeparator = usages.contains(ShowUsagesTable.MORE_USAGES_SEPARATOR);
|
||||
@@ -805,7 +802,7 @@ public class ShowUsagesAction extends AnAction implements PopupAction, HintManag
|
||||
}
|
||||
|
||||
List<UsageNode> data = collectData(usages, nodes, usageView, presentation);
|
||||
ShowUsagesTable.MyModel tableModel = table.setTableModel(usageView, data, outOfScopeUsages, searchScope);
|
||||
ShowUsagesTable.MyModel tableModel = table.setTableModel(data);
|
||||
List<UsageNode> existingData = tableModel.getItems();
|
||||
|
||||
int row = table.getSelectedRow();
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SpeedSearchBase;
|
||||
import com.intellij.ui.SpeedSearchComparator;
|
||||
@@ -43,7 +42,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
class ShowUsagesTable extends JBTable implements DataProvider {
|
||||
@@ -51,7 +49,10 @@ class ShowUsagesTable extends JBTable implements DataProvider {
|
||||
static final Usage USAGES_OUTSIDE_SCOPE_SEPARATOR = new UsageAdapter();
|
||||
private static final int MARGIN = 2;
|
||||
|
||||
ShowUsagesTable() {
|
||||
private final ShowUsagesTableCellRenderer myRenderer;
|
||||
|
||||
ShowUsagesTable(@NotNull ShowUsagesTableCellRenderer renderer) {
|
||||
myRenderer = renderer;
|
||||
ScrollingUtil.installActions(this);
|
||||
HintUpdateSupply.installDataContextHintUpdateSupply(this);
|
||||
}
|
||||
@@ -202,10 +203,7 @@ class ShowUsagesTable extends JBTable implements DataProvider {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
MyModel setTableModel(@NotNull UsageViewImpl usageView,
|
||||
@NotNull final List<UsageNode> data,
|
||||
@NotNull AtomicInteger outOfScopeUsages,
|
||||
@NotNull SearchScope searchScope) {
|
||||
MyModel setTableModel(@NotNull final List<UsageNode> data) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
final int columnCount = calcColumnCount(data);
|
||||
MyModel model = getModel() instanceof MyModel ? (MyModel)getModel() : null;
|
||||
@@ -213,11 +211,10 @@ class ShowUsagesTable extends JBTable implements DataProvider {
|
||||
model = new MyModel(data, columnCount);
|
||||
setModel(model);
|
||||
|
||||
ShowUsagesTableCellRenderer renderer = new ShowUsagesTableCellRenderer(usageView, outOfScopeUsages, searchScope);
|
||||
for (int i = 0; i < getColumnModel().getColumnCount(); i++) {
|
||||
TableColumn column = getColumnModel().getColumn(i);
|
||||
column.setPreferredWidth(0);
|
||||
column.setCellRenderer(renderer);
|
||||
column.setCellRenderer(myRenderer);
|
||||
}
|
||||
}
|
||||
return model;
|
||||
|
||||
Reference in New Issue
Block a user