From 15290c84aa4607377fb8b7cb72615f3b72bf1682 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Sun, 6 Mar 2016 15:16:24 +0300 Subject: [PATCH] [vcs-log] cache Selection in table to only calculate it when its changed --- .../intellij/vcs/log/ui/frame/VcsLogGraphTable.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 d996469a8557..9a3bad3bc68a 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 @@ -93,6 +93,7 @@ public class VcsLogGraphTable extends JBTable implements DataProvider, CopyProvi @NotNull private final TableCellRenderer myDummyRenderer = new DefaultTableCellRenderer(); @NotNull private final GraphCommitCellRender myGraphCommitCellRenderer; private boolean myColumnsSizeInitialized = false; + @Nullable private Selection mySelection = null; @NotNull private final Collection myHighlighters = ContainerUtil.newArrayList(); @@ -121,6 +122,8 @@ public class VcsLogGraphTable extends JBTable implements DataProvider, CopyProvi addMouseMotionListener(mouseAdapter); addMouseListener(mouseAdapter); + getSelectionModel().addListSelectionListener(new MyListSelectionListener()); + PopupHandler.installPopupHandler(this, VcsLogActionPlaces.POPUP_ACTION_GROUP, VcsLogActionPlaces.VCS_LOG_TABLE_PLACE); ScrollingUtil.installActions(this, false); @@ -463,7 +466,8 @@ public class VcsLogGraphTable extends JBTable implements DataProvider, CopyProvi @NotNull public Selection getSelection() { - return new Selection(this); + if (mySelection == null) mySelection = new Selection(this); + return mySelection; } private static class Selection { @@ -917,4 +921,11 @@ public class VcsLogGraphTable extends JBTable implements DataProvider, CopyProvi mouseInputListener.mouseMoved(convertMouseEvent(e)); } } + + private class MyListSelectionListener implements ListSelectionListener { + @Override + public void valueChanged(ListSelectionEvent e) { + mySelection = null; + } + } }