mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[vcs-log] Get rid of selection manipulations via MyDummyTableCellEditor
It was introduced to avoid selection updates when clicking a graph. However, similar behavior can be achieved without mimicking the cell editor. See javax.swing.plaf.basic.BasicTableUI.Handler.adjustSelection GitOrigin-RevId: 6537867cfc173da128868fb04c9dcd022dc65ff9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
181d4b7e2d
commit
07f027ba7e
@@ -1689,13 +1689,13 @@ c:com.intellij.vcs.log.ui.table.VcsLogGraphTable
|
||||
- addHighlighter(com.intellij.vcs.log.VcsLogHighlighter):V
|
||||
- p:appendActionToEmptyText(java.lang.String,java.lang.Runnable):V
|
||||
- applyHighlighters(java.awt.Component,I,I,Z,Z):com.intellij.ui.SimpleTextAttributes
|
||||
- changeSelection(I,I,Z,Z):V
|
||||
- dispose():V
|
||||
- doLayout():V
|
||||
- forceReLayout(com.intellij.vcs.log.ui.table.column.VcsLogColumn):V
|
||||
- getActionUpdateThread():com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
- getAutoCreateColumnsFromModel():Z
|
||||
- getBaseStyle(I,I,Z,Z):com.intellij.vcs.log.VcsLogHighlighter$VcsCommitStyle
|
||||
- getCellEditor():javax.swing.table.TableCellEditor
|
||||
- getColorManager():com.intellij.vcs.log.ui.VcsLogColorManager
|
||||
- f:getColumnViewIndex(com.intellij.vcs.log.ui.table.column.VcsLogColumn):I
|
||||
- getCommitColumn():javax.swing.table.TableColumn
|
||||
|
||||
@@ -54,7 +54,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.CellEditorListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.table.*;
|
||||
import java.awt.*;
|
||||
@@ -100,7 +99,6 @@ public class VcsLogGraphTable extends TableWithProgress
|
||||
private final @NotNull VcsLogUiProperties myProperties;
|
||||
private final @NotNull VcsLogColorManager myColorManager;
|
||||
|
||||
private final @NotNull MyDummyTableCellEditor myDummyEditor = new MyDummyTableCellEditor();
|
||||
private final @NotNull BaseStyleProvider myBaseStyleProvider;
|
||||
private final @NotNull GraphCommitCellRenderer myGraphCommitCellRenderer;
|
||||
private final @NotNull MyMouseAdapter myMouseAdapter;
|
||||
@@ -734,13 +732,6 @@ public class VcsLogGraphTable extends TableWithProgress
|
||||
return getModel().getVisiblePack().getVisibleGraph();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableCellEditor getCellEditor() {
|
||||
// this fixes selection problems by prohibiting selection when user clicks on graph (CellEditor does that)
|
||||
// what is fun about this code is that if you set cell editor in constructor with setCellEditor method it would not work
|
||||
return myDummyEditor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowHeight() {
|
||||
return myGraphCommitCellRenderer.getPreferredHeight();
|
||||
@@ -921,53 +912,25 @@ public class VcsLogGraphTable extends TableWithProgress
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDummyTableCellEditor implements TableCellEditor {
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
return null;
|
||||
@Override
|
||||
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
|
||||
if (shouldChangeSelect(EventQueue.getCurrentEvent(), rowIndex, columnIndex )) {
|
||||
super.changeSelection(rowIndex, columnIndex, toggle, extend);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Allows avoiding selection update when graph is clicked
|
||||
*/
|
||||
private boolean shouldChangeSelect(@Nullable AWTEvent event, int rowIndex, int columnIndex) {
|
||||
if (!(event instanceof MouseEvent)) return true;
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(EventObject anEvent) {
|
||||
return false;
|
||||
}
|
||||
VcsLogColumn<?> column = getVcsLogColumn(columnIndex);
|
||||
if (column == null) return false;
|
||||
VcsLogCellController controller = getController(column);
|
||||
if (controller == null) return true;
|
||||
|
||||
@Override
|
||||
public boolean shouldSelectCell(EventObject anEvent) {
|
||||
if (!(anEvent instanceof MouseEvent e)) return true;
|
||||
|
||||
int row = rowAtPoint(e.getPoint());
|
||||
if (row < 0 || row >= getRowCount()) return true;
|
||||
|
||||
VcsLogColumn<?> column = getVcsLogColumn(columnAtPoint(e.getPoint()));
|
||||
if (column == null) return true;
|
||||
VcsLogCellController controller = getController(column);
|
||||
if (controller == null) return true;
|
||||
|
||||
return controller.shouldSelectCell(row, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelCellEditing() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellEditorListener(CellEditorListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCellEditorListener(CellEditorListener l) {
|
||||
}
|
||||
return controller.shouldSelectCell(rowIndex, (MouseEvent)event);
|
||||
}
|
||||
|
||||
private class MyProgressListener implements VcsLogProgress.ProgressListener {
|
||||
|
||||
Reference in New Issue
Block a user