mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-171869 Win10 LAF checkboxes in tables and trees
This commit is contained in:
+23
-46
@@ -29,7 +29,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.profile.codeInspection.ui.InspectionsAggregationUtil;
|
||||
import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
|
||||
@@ -114,55 +113,33 @@ public class InspectionsConfigTreeTable extends TreeTable {
|
||||
addMouseMotionListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent e) {
|
||||
Point point = e.getPoint();
|
||||
int column = columnAtPoint(point);
|
||||
int row = rowAtPoint(point);
|
||||
Point point = e.getPoint();
|
||||
int column = columnAtPoint(point);
|
||||
int row = rowAtPoint(point);
|
||||
|
||||
if (row < 0 || row >= getModel().getRowCount()) return;
|
||||
|
||||
UIUtil.resetEnabledRollOver(InspectionsConfigTreeTable.this, IS_ENABLED_COLUMN);
|
||||
|
||||
switch (column) {
|
||||
case SEVERITIES_COLUMN:
|
||||
Object maybeIcon = getModel().getValueAt(row, column);
|
||||
if (maybeIcon instanceof MultiScopeSeverityIcon) {
|
||||
MultiScopeSeverityIcon icon = (MultiScopeSeverityIcon)maybeIcon;
|
||||
LinkedHashMap<String, HighlightDisplayLevel> scopeToAverageSeverityMap =
|
||||
icon.getScopeToAverageSeverityMap();
|
||||
JComponent component = null;
|
||||
if (scopeToAverageSeverityMap.size() == 1 &&
|
||||
icon.getDefaultScopeName().equals(ContainerUtil.getFirstItem(scopeToAverageSeverityMap.keySet()))) {
|
||||
HighlightDisplayLevel level = ContainerUtil.getFirstItem(scopeToAverageSeverityMap.values());
|
||||
if (level != null) {
|
||||
JLabel label = new JLabel();
|
||||
label.setIcon(level.getIcon());
|
||||
label.setText(SingleInspectionProfilePanel.renderSeverity(level.getSeverity()));
|
||||
component = label;
|
||||
}
|
||||
} else {
|
||||
component = new ScopesAndSeveritiesHintTable(scopeToAverageSeverityMap, icon.getDefaultScopeName());
|
||||
}
|
||||
IdeTooltipManager.getInstance().show(
|
||||
new IdeTooltip(InspectionsConfigTreeTable.this, point, component), false);
|
||||
if (column == SEVERITIES_COLUMN && row >= 0 && row < getRowCount()) {
|
||||
Object maybeIcon = getModel().getValueAt(row, column);
|
||||
if (maybeIcon instanceof MultiScopeSeverityIcon) {
|
||||
MultiScopeSeverityIcon icon = (MultiScopeSeverityIcon)maybeIcon;
|
||||
LinkedHashMap<String, HighlightDisplayLevel> scopeToAverageSeverityMap =
|
||||
icon.getScopeToAverageSeverityMap();
|
||||
JComponent component = null;
|
||||
if (scopeToAverageSeverityMap.size() == 1 &&
|
||||
icon.getDefaultScopeName().equals(ContainerUtil.getFirstItem(scopeToAverageSeverityMap.keySet()))) {
|
||||
HighlightDisplayLevel level = ContainerUtil.getFirstItem(scopeToAverageSeverityMap.values());
|
||||
if (level != null) {
|
||||
JLabel label = new JLabel();
|
||||
label.setIcon(level.getIcon());
|
||||
label.setText(SingleInspectionProfilePanel.renderSeverity(level.getSeverity()));
|
||||
component = label;
|
||||
}
|
||||
break;
|
||||
|
||||
case IS_ENABLED_COLUMN:
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
JComponent rc = (JComponent)getColumnModel().getColumn(column).getCellRenderer();
|
||||
rc.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, row);
|
||||
((AbstractTableModel)getModel()).fireTableCellUpdated(row, column);
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
} else {
|
||||
component = new ScopesAndSeveritiesHintTable(scopeToAverageSeverityMap, icon.getDefaultScopeName());
|
||||
}
|
||||
IdeTooltipManager.getInstance().show(
|
||||
new IdeTooltip(InspectionsConfigTreeTable.this, point, component), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override public void mouseExited(MouseEvent e) {
|
||||
UIUtil.resetEnabledRollOver(InspectionsConfigTreeTable.this, IS_ENABLED_COLUMN);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
-2
@@ -19,7 +19,6 @@ import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigT
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.ui.ThreeStateCheckBox;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -81,7 +80,6 @@ public class ThreeStateCheckBoxRenderer extends ThreeStateCheckBox implements Ta
|
||||
setSelected((Boolean) value);
|
||||
}
|
||||
|
||||
UIUtil.setCellRolloverState(this, row);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ public class BooleanTableCellRenderer extends JCheckBox implements TableCellRend
|
||||
setSelected(((Boolean)value).booleanValue());
|
||||
}
|
||||
setEnabled(table.isCellEditable(row, column));
|
||||
UIUtil.setCellRolloverState(this, row);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchSupply;
|
||||
import com.intellij.util.Function;
|
||||
@@ -31,9 +32,7 @@ import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -41,9 +40,12 @@ import java.util.Map;
|
||||
* @author oleg
|
||||
*/
|
||||
public class CheckBoxList<T> extends JBList<JCheckBox> {
|
||||
private final static int RESET_ROLLOVER = -1;
|
||||
|
||||
private final CellRenderer myCellRenderer;
|
||||
private CheckBoxListListener checkBoxListListener;
|
||||
private final BidirectionalMap<T, JCheckBox> myItemMap = new BidirectionalMap<>();
|
||||
private int rollOverIndex = RESET_ROLLOVER;
|
||||
|
||||
public CheckBoxList(final CheckBoxListListener checkBoxListListener) {
|
||||
this(new DefaultListModel<>(), checkBoxListListener);
|
||||
@@ -108,6 +110,57 @@ public class CheckBoxList<T> extends JBList<JCheckBox> {
|
||||
return false;
|
||||
}
|
||||
}.installOn(this);
|
||||
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override public void mouseMoved(MouseEvent e) {
|
||||
Point point = e.getPoint();
|
||||
int index = locationToIndex(point);
|
||||
fireRollOverUpdated(index);
|
||||
}
|
||||
});
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override public void mouseExited(MouseEvent e) {
|
||||
fireRollOverUpdated(RESET_ROLLOVER);
|
||||
}
|
||||
|
||||
@Override public void mousePressed(MouseEvent e) {
|
||||
setPressed(e, true);
|
||||
}
|
||||
|
||||
@Override public void mouseReleased(MouseEvent e) {
|
||||
setPressed(e, false);
|
||||
}
|
||||
|
||||
private void setPressed(MouseEvent e, boolean pressed) {
|
||||
Point point = e.getPoint();
|
||||
int index = locationToIndex(point);
|
||||
JCheckBox cb = getModel().getElementAt(index);
|
||||
cb.getModel().setPressed(pressed);
|
||||
UIUtil.repaintViewport(CheckBoxList.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset old rollover row and set new rollover row.
|
||||
* @param newIndex new rollover row. If newIndex is -1 then reset old rollover row only.
|
||||
*/
|
||||
private void fireRollOverUpdated(int newIndex) {
|
||||
if (rollOverIndex >= 0) {
|
||||
JCheckBox oldRollover = getModel().getElementAt(rollOverIndex);
|
||||
oldRollover.getModel().setRollover(false);
|
||||
}
|
||||
|
||||
rollOverIndex = newIndex;
|
||||
|
||||
if (rollOverIndex >= 0) {
|
||||
JCheckBox newRollover = getModel().getElementAt(rollOverIndex);
|
||||
newRollover.getModel().setRollover(true);
|
||||
}
|
||||
UIUtil.repaintViewport(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -339,7 +392,9 @@ public class CheckBoxList<T> extends JBList<JCheckBox> {
|
||||
|
||||
rootComponent.setBorder(isSelected ? mySelectedBorder : myBorder);
|
||||
|
||||
boolean isRollOver = checkbox.getModel().isRollover();
|
||||
rootComponent = adjustRendering(rootComponent, checkbox, index, isSelected, cellHasFocus);
|
||||
checkbox.getModel().setRollover(isRollOver);
|
||||
|
||||
return rootComponent;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.ui.ThreeStateCheckBox;
|
||||
@@ -145,7 +146,7 @@ public class CheckboxTreeBase extends Tree {
|
||||
myCheckbox.setSelected(false);
|
||||
myCheckbox.setThirdStateEnabled(false);
|
||||
myTextRenderer = new ColoredTreeCellRenderer() {
|
||||
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { }
|
||||
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { }
|
||||
};
|
||||
myTextRenderer.setOpaque(opaque);
|
||||
add(myCheckbox, BorderLayout.WEST);
|
||||
@@ -168,6 +169,14 @@ public class CheckboxTreeBase extends Tree {
|
||||
myCheckbox.setOpaque(false);
|
||||
myCheckbox.setBackground(null);
|
||||
setBackground(null);
|
||||
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
Object hoverValue = getClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY);
|
||||
myCheckbox.getModel().setRollover(hoverValue == value);
|
||||
|
||||
Object pressedValue = getClientProperty(UIUtil.CHECKBOX_PRESSED_PROPERTY);
|
||||
myCheckbox.getModel().setPressed(pressedValue == value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myCheckbox.setVisible(false);
|
||||
@@ -229,7 +238,7 @@ public class CheckboxTreeBase extends Tree {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CheckboxTreeCellRendererBase#customizeRenderer(javax.swing.JTree, Object, boolean, boolean, boolean, int, boolean)
|
||||
* @see CheckboxTreeCellRendererBase#customizeRenderer(JTree, Object, boolean, boolean, boolean, int, boolean)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class TableCell {
|
||||
column = columnIndex;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
@Override public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TableCell)) return false;
|
||||
|
||||
@@ -36,7 +36,11 @@ public final class TableCell {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
public boolean at(int row, int column) {
|
||||
return row == this.row && column == this.column;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
int result;
|
||||
result = row;
|
||||
result = 29 * result + column;
|
||||
|
||||
@@ -19,9 +19,9 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.ExpirableRunnable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBViewport;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchSupply;
|
||||
import com.intellij.util.ui.*;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
@@ -38,6 +38,7 @@ import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.Arrays;
|
||||
@@ -68,6 +69,8 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
|
||||
private int myMaxItemsForSizeCalculation = Integer.MAX_VALUE;
|
||||
|
||||
private TableCell rollOverCell;
|
||||
|
||||
public JBTable() {
|
||||
this(new DefaultTableModel());
|
||||
}
|
||||
@@ -94,6 +97,38 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
|
||||
addMouseListener(new MyMouseListener());
|
||||
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override public void mouseMoved(MouseEvent e) {
|
||||
Point point = e.getPoint();
|
||||
int column = columnAtPoint(point);
|
||||
int row = rowAtPoint(point);
|
||||
|
||||
resetRollOverCell();
|
||||
|
||||
if (row >= 0 && row < getRowCount() && column >= 0 && column < getColumnCount()) {
|
||||
TableCellRenderer cellRenderer = getCellRenderer(row, column);
|
||||
if (cellRenderer != null) {
|
||||
Component rc = cellRenderer.getTableCellRendererComponent(JBTable.this,
|
||||
getValueAt(row, column),
|
||||
isCellSelected(row, column),
|
||||
hasFocus(),
|
||||
row, column);
|
||||
if (rc instanceof JCheckBox && (rollOverCell == null || !rollOverCell.at(row, column))) {
|
||||
Rectangle cellRect = getCellRect(row, column, false);
|
||||
rollOverCell = new TableCell(row, column);
|
||||
((JCheckBox)rc).putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, cellRect);
|
||||
|
||||
if (getModel() instanceof AbstractTableModel) {
|
||||
((AbstractTableModel)getModel()).fireTableCellUpdated(row, column);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final TableModelListener modelListener = new TableModelListener() {
|
||||
@Override
|
||||
public void tableChanged(@NotNull final TableModelEvent e) {
|
||||
@@ -105,7 +140,7 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
addPropertyChangeListener("model", new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(@NotNull PropertyChangeEvent evt) {
|
||||
repaintViewport();
|
||||
UIUtil.repaintViewport(JBTable.this);
|
||||
|
||||
if (evt.getOldValue() instanceof TableModel) {
|
||||
((TableModel)evt.getOldValue()).removeTableModelListener(modelListener);
|
||||
@@ -125,8 +160,10 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
if (!myRowHeightIsExplicitlySet) {
|
||||
myRowHeight = -1;
|
||||
}
|
||||
if (e.getType() == TableModelEvent.DELETE && isEmpty() || e.getType() == TableModelEvent.INSERT && !isEmpty()) {
|
||||
repaintViewport();
|
||||
if (e.getType() == TableModelEvent.DELETE && isEmpty() ||
|
||||
e.getType() == TableModelEvent.INSERT && !isEmpty() ||
|
||||
e.getType() == TableModelEvent.UPDATE) {
|
||||
UIUtil.repaintViewport(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,15 +238,6 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
}
|
||||
}
|
||||
|
||||
private void repaintViewport() {
|
||||
if (!isDisplayable() || !isVisible()) return;
|
||||
|
||||
Container p = getParent();
|
||||
if (p instanceof JBViewport) {
|
||||
p.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected JTableHeader createDefaultTableHeader() {
|
||||
@@ -523,6 +551,10 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
if (myExpandableItemsHandler.getExpandedItems().contains(new TableCell(row, column))) {
|
||||
result = ExpandedItemRendererComponentWrapper.wrap(result);
|
||||
}
|
||||
|
||||
if(renderer instanceof JCheckBox) {
|
||||
((JCheckBox)renderer).getModel().setRollover(rollOverCell != null && rollOverCell.at(row, column));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -635,6 +667,10 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void mouseExited(MouseEvent e) {
|
||||
resetRollOverCell();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"MethodMayBeStatic", "unchecked"})
|
||||
@@ -967,4 +1003,24 @@ public class JBTable extends JTable implements ComponentWithEmptyText, Component
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetRollOverCell() {
|
||||
if (Registry.is("ide.intellij.laf.win10.ui") && getModel() instanceof AbstractTableModel && rollOverCell != null) {
|
||||
TableCellRenderer cellRenderer = getCellRenderer(rollOverCell.row, rollOverCell.column);
|
||||
if (cellRenderer != null) {
|
||||
Object value = getValueAt(rollOverCell.row, rollOverCell.column);
|
||||
boolean selected = isCellSelected(rollOverCell.row, rollOverCell.column);
|
||||
|
||||
Component rc = cellRenderer.getTableCellRendererComponent(this, value, selected, hasFocus(), rollOverCell.row, rollOverCell.column);
|
||||
if (rc instanceof JCheckBox) {
|
||||
((JCheckBox)rc).putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (getModel() instanceof AbstractTableModel) {
|
||||
((AbstractTableModel)getModel()).fireTableCellUpdated(rollOverCell.row, rollOverCell.column);
|
||||
}
|
||||
rollOverCell = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
@@ -57,6 +58,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
private final MySelectionModel mySelectionModel = new MySelectionModel();
|
||||
private boolean myHorizontalAutoScrolling = true;
|
||||
|
||||
private TreePath rollOverPath;
|
||||
|
||||
public Tree() {
|
||||
this(getDefaultTreeModel());
|
||||
}
|
||||
@@ -76,6 +79,29 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
|
||||
myExpandableItemsHandler = ExpandableItemsHandlerFactory.install(this);
|
||||
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Point p = e.getPoint();
|
||||
TreePath newPath = getPathForLocation(p.x, p.y);
|
||||
if (newPath != null && !newPath.equals(rollOverPath)) {
|
||||
TreeCellRenderer renderer = getCellRenderer();
|
||||
TreeNode node = (TreeNode)newPath.getLastPathComponent();
|
||||
JComponent c = (JComponent)renderer.getTreeCellRendererComponent(Tree.this, node,
|
||||
isPathSelected(newPath),
|
||||
isExpanded(newPath),
|
||||
getModel().isLeaf(node),
|
||||
getRowForPath(newPath), hasFocus());
|
||||
|
||||
c.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, c instanceof JCheckBox ? getPathBounds(newPath) : node);
|
||||
rollOverPath = newPath;
|
||||
UIUtil.repaintViewport(Tree.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addMouseListener(new MyMouseListener());
|
||||
addFocusListener(new MyFocusListener());
|
||||
|
||||
@@ -672,6 +698,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
private class MyMouseListener extends MouseAdapter {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent event) {
|
||||
setPressed(event, true);
|
||||
|
||||
if (!JBSwingUtilities.isLeftMouseButton(event) &&
|
||||
(JBSwingUtilities.isRightMouseButton(event) || JBSwingUtilities.isMiddleMouseButton(event))) {
|
||||
TreePath path = getClosestPathForLocation(event.getX(), event.getY());
|
||||
@@ -693,9 +721,48 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && isLocationInExpandControl(getClosestPathForLocation(e.getX(), e.getY()), e.getX())) {
|
||||
e.consume();
|
||||
public void mouseReleased(MouseEvent event) {
|
||||
setPressed(event, false);
|
||||
if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2 && isLocationInExpandControl(getClosestPathForLocation(event.getX(), event.getY()), event.getX())) {
|
||||
event.consume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void mouseExited(MouseEvent e) {
|
||||
if (Registry.is("ide.intellij.laf.win10.ui") && rollOverPath != null) {
|
||||
TreeCellRenderer renderer = getCellRenderer();
|
||||
TreeNode node = (TreeNode)rollOverPath.getLastPathComponent();
|
||||
JComponent c = (JComponent)renderer.getTreeCellRendererComponent(Tree.this, node,
|
||||
isPathSelected(rollOverPath),
|
||||
isExpanded(rollOverPath),
|
||||
getModel().isLeaf(node),
|
||||
getRowForPath(rollOverPath), hasFocus());
|
||||
|
||||
c.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, null);
|
||||
rollOverPath = null;
|
||||
UIUtil.repaintViewport(Tree.this);
|
||||
}
|
||||
}
|
||||
|
||||
private void setPressed(MouseEvent e, boolean pressed) {
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
Point p = e.getPoint();
|
||||
TreePath path = getPathForLocation(p.x, p.y);
|
||||
if (path != null) {
|
||||
TreeCellRenderer renderer = getCellRenderer();
|
||||
TreeNode node = (TreeNode)path.getLastPathComponent();
|
||||
JComponent c = (JComponent)renderer.getTreeCellRendererComponent(Tree.this, node,
|
||||
isPathSelected(path), isExpanded(path),
|
||||
getModel().isLeaf(node),
|
||||
getRowForPath(path), hasFocus());
|
||||
if (pressed) {
|
||||
c.putClientProperty(UIUtil.CHECKBOX_PRESSED_PROPERTY, c instanceof JCheckBox ? getPathBounds(path) : node);
|
||||
} else {
|
||||
c.putClientProperty(UIUtil.CHECKBOX_PRESSED_PROPERTY, null);
|
||||
}
|
||||
|
||||
UIUtil.repaintViewport(Tree.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-2
@@ -38,10 +38,11 @@ public class WinIntelliJCheckBoxUI extends IntelliJCheckBoxUI {
|
||||
@Override
|
||||
protected void drawCheckIcon(JComponent c, Graphics2D g, JCheckBox b, Rectangle iconRect, boolean selected, boolean enabled) {
|
||||
ButtonModel bm = b.getModel();
|
||||
boolean focused = c.hasFocus() || bm.isRollover();
|
||||
boolean focused = c.hasFocus() || bm.isRollover() || isCellRollover(b);
|
||||
boolean pressed = bm.isPressed() || isCellPressed(b);
|
||||
|
||||
String iconName = isIndeterminate(b) ? "checkBoxIndeterminate" : "checkBox";
|
||||
Icon icon = MacIntelliJIconCache.getIcon(iconName, false, selected || isIndeterminate(b), focused, enabled, bm.isPressed());
|
||||
Icon icon = MacIntelliJIconCache.getIcon(iconName, false, selected || isIndeterminate(b), focused, enabled, pressed);
|
||||
|
||||
Rectangle viewRect = new Rectangle(c.getSize());
|
||||
int x = (iconRect.width - icon.getIconWidth()) / 2;
|
||||
@@ -49,6 +50,16 @@ public class WinIntelliJCheckBoxUI extends IntelliJCheckBoxUI {
|
||||
icon.paintIcon(c, g, x, y);
|
||||
}
|
||||
|
||||
private static boolean isCellRollover(JCheckBox checkBox) {
|
||||
Rectangle cellPosition = (Rectangle)checkBox.getClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY);
|
||||
return cellPosition != null && cellPosition.getBounds().equals(checkBox.getBounds());
|
||||
}
|
||||
|
||||
private static boolean isCellPressed(JCheckBox checkBox) {
|
||||
Rectangle cellPosition = (Rectangle)checkBox.getClientProperty(UIUtil.CHECKBOX_PRESSED_PROPERTY);
|
||||
return cellPosition != null && cellPosition.getBounds().equals(checkBox.getBounds());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawText(JComponent c, Graphics2D g, JCheckBox b, FontMetrics fm, Rectangle textRect, String text) {
|
||||
super.drawText(c, g, b, fm, textRect, text);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class WinOnOffButtonUI extends BasicToggleButtonUI {
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension size = new JBDimension(BUTTON_SIZE.width, BUTTON_SIZE.height);
|
||||
Dimension size = new Dimension(BUTTON_SIZE); // Don't scale it twice.
|
||||
JBInsets.addTo(size, BUTTON_BORDER.getBorderInsets(c));
|
||||
return size;
|
||||
}
|
||||
|
||||
+4
-31
@@ -25,7 +25,6 @@ import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||
import com.intellij.openapi.ui.StripeTable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.BooleanTableCellRenderer;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
@@ -41,14 +40,16 @@ import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeCellRenderer;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@@ -264,34 +265,6 @@ public class NotificationsConfigurablePanel extends JPanel implements Disposable
|
||||
readAloudColumn.setCellRenderer(new BooleanTableCellRenderer());
|
||||
}
|
||||
|
||||
if (Registry.is("ide.intellij.laf.win10.ui")) {
|
||||
addMouseMotionListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent e) {
|
||||
Point point = e.getPoint();
|
||||
int column = columnAtPoint(point);
|
||||
int row = rowAtPoint(point);
|
||||
|
||||
if (row < 0 || row >= getModel().getRowCount()) return;
|
||||
|
||||
UIUtil.resetEnabledRollOver(NotificationsTreeTable.this, LOG_COLUMN);
|
||||
|
||||
if (column == LOG_COLUMN) {
|
||||
JComponent rc = (JComponent)getColumnModel().getColumn(column).getCellRenderer();
|
||||
rc.putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, row);
|
||||
((AbstractTableModel)getModel()).fireTableCellUpdated(row, column);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override public void mouseExited(MouseEvent e) {
|
||||
UIUtil.resetEnabledRollOver(NotificationsTreeTable.this, LOG_COLUMN);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
new TableSpeedSearch(this);
|
||||
getEmptyText().setText("No notifications configured");
|
||||
TreeUtil.expandAll(getTree());
|
||||
|
||||
@@ -54,7 +54,6 @@ import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
import javax.swing.plaf.basic.ComboPopup;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
@@ -4012,36 +4011,15 @@ public class UIUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public static final String CHECKBOX_ROLLOVER_PROPERTY = "CheckBoxRenderer.rolloverRow";
|
||||
public static final String CHECKBOX_ROLLOVER_PROPERTY = "JCheckBox.rollOver.rectangle";
|
||||
public static final String CHECKBOX_PRESSED_PROPERTY = "JCheckBox.pressed.rectangle";
|
||||
|
||||
public static void resetEnabledRollOver(JTable table, int column) {
|
||||
if (!Registry.is("ide.intellij.laf.win10.ui")) return;
|
||||
public static void repaintViewport(@NotNull JComponent c) {
|
||||
if (!c.isDisplayable() || !c.isVisible()) return;
|
||||
|
||||
JComponent rc = (JComponent)table.getColumnModel().getColumn(column).getCellRenderer();
|
||||
AbstractTableModel tm = (AbstractTableModel)table.getModel();
|
||||
int lastRow = -1;
|
||||
|
||||
//noinspection EmptyCatchBlock
|
||||
try {
|
||||
lastRow = Integer.valueOf(String.valueOf(rc.getClientProperty(CHECKBOX_ROLLOVER_PROPERTY)));
|
||||
} catch (NumberFormatException nfe) {}
|
||||
|
||||
rc.putClientProperty(CHECKBOX_ROLLOVER_PROPERTY, null);
|
||||
|
||||
if (lastRow >= 0) {
|
||||
tm.fireTableCellUpdated(lastRow, column);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCellRolloverState(AbstractButton cellRenderer, int row) {
|
||||
if (!Registry.is("ide.intellij.laf.win10.ui")) return;
|
||||
|
||||
try {
|
||||
Object cv = cellRenderer.getClientProperty(CHECKBOX_ROLLOVER_PROPERTY);
|
||||
Integer rr = Integer.valueOf(String.valueOf(cv));
|
||||
cellRenderer.getModel().setRollover(rr == row);
|
||||
} catch (NumberFormatException ex) {
|
||||
cellRenderer.getModel().setRollover(false);
|
||||
Container p = c.getParent();
|
||||
if (p instanceof JViewport) {
|
||||
p.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user