[vcs-log] cache Selection in table to only calculate it when its changed

This commit is contained in:
Julia Beliaeva
2016-03-06 15:16:24 +03:00
parent bfc6e667fe
commit 15290c84aa
@@ -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<VcsLogHighlighter> 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;
}
}
}