mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Add on-hover selection on Board/Library manager
User testing on skilled devs showed that "buttons appear on click" behaviour is far from being understood. Accessibility features (like moving with Arrow keys) should be untouched.
This commit is contained in:
parent
a47e62627c
commit
60f267745b
@ -76,9 +76,12 @@ public class ContributedLibraryTableCellEditor extends InstallerTableCell {
|
|||||||
ContributedLibrary lib = (ContributedLibrary) chooser.getSelectedItem();
|
ContributedLibrary lib = (ContributedLibrary) chooser.getSelectedItem();
|
||||||
onInstall(lib, editorValue.getInstalled());
|
onInstall(lib, editorValue.getInstalled());
|
||||||
});
|
});
|
||||||
editorCell.versionToInstallChooser.addItemListener(e -> editorValue
|
editorCell.versionToInstallChooser.addActionListener(e -> {
|
||||||
.select((ContributedLibrary) editorCell.versionToInstallChooser
|
editorValue.select((ContributedLibrary) editorCell.versionToInstallChooser.getSelectedItem());
|
||||||
.getSelectedItem()));
|
if (editorCell.versionToInstallChooser.getSelectedIndex() != 0) {
|
||||||
|
InstallerTableCell.dropdownSelected(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
|
|
||||||
|
@ -54,10 +54,13 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
downgradeChooser.addItem("-");
|
downgradeChooser.addItem("-");
|
||||||
downgradeChooser.setMaximumSize(new Dimension((int)downgradeChooser.getPreferredSize().getWidth() + 50, (int)downgradeChooser.getPreferredSize().getHeight()));
|
downgradeChooser.setMaximumSize(new Dimension((int)downgradeChooser.getPreferredSize().getWidth() + 50, (int)downgradeChooser.getPreferredSize().getHeight()));
|
||||||
downgradeChooser.setMinimumSize(new Dimension((int)downgradeChooser.getPreferredSize().getWidth() + 50, (int)downgradeChooser.getPreferredSize().getHeight()));
|
downgradeChooser.setMinimumSize(new Dimension((int)downgradeChooser.getPreferredSize().getWidth() + 50, (int)downgradeChooser.getPreferredSize().getHeight()));
|
||||||
downgradeChooser.addItemListener(e -> {
|
downgradeChooser.addActionListener(e -> {
|
||||||
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
||||||
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
boolean disableDowngrade = (downgradeChooser.getSelectedItem() == selectVersionItem);
|
||||||
downgradeButton.setEnabled(!disableDowngrade);
|
downgradeButton.setEnabled(!disableDowngrade);
|
||||||
|
if (!disableDowngrade) {
|
||||||
|
InstallerTableCell.dropdownSelected(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
versionToInstallChooser = new JComboBox();
|
versionToInstallChooser = new JComboBox();
|
||||||
|
@ -117,6 +117,7 @@ public class LibraryManagerUI extends InstallerJDialog<ContributedLibrary> {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
DropdownItem<ContributedLibrary> selected = (DropdownItem<ContributedLibrary>) typeChooser.getSelectedItem();
|
DropdownItem<ContributedLibrary> selected = (DropdownItem<ContributedLibrary>) typeChooser.getSelectedItem();
|
||||||
|
previousRowAtPoint = -1;
|
||||||
if (typeFilter == null || !typeFilter.equals(selected)) {
|
if (typeFilter == null || !typeFilter.equals(selected)) {
|
||||||
typeFilter = selected.getFilterPredicate();
|
typeFilter = selected.getFilterPredicate();
|
||||||
if (contribTable.getCellEditor() != null) {
|
if (contribTable.getCellEditor() != null) {
|
||||||
|
@ -74,9 +74,12 @@ public class ContributedPlatformTableCellEditor extends InstallerTableCell {
|
|||||||
.getSelectedItem();
|
.getSelectedItem();
|
||||||
onInstall(selected, value.getInstalled());
|
onInstall(selected, value.getInstalled());
|
||||||
});
|
});
|
||||||
cell.versionToInstallChooser.addItemListener(e -> value
|
cell.versionToInstallChooser.addActionListener(e -> {
|
||||||
.select((ContributedPlatform) cell.versionToInstallChooser
|
value.select((ContributedPlatform) cell.versionToInstallChooser.getSelectedItem());
|
||||||
.getSelectedItem()));
|
if (cell.versionToInstallChooser.getSelectedIndex() != 0) {
|
||||||
|
InstallerTableCell.dropdownSelected(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
|
|
||||||
|
@ -98,6 +98,9 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
Object selectVersionItem = downgradeChooser.getItemAt(0);
|
||||||
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
boolean disableDowngrade = (e.getItem() == selectVersionItem);
|
||||||
downgradeButton.setEnabled(!disableDowngrade);
|
downgradeButton.setEnabled(!disableDowngrade);
|
||||||
|
if (!disableDowngrade) {
|
||||||
|
InstallerTableCell.dropdownSelected(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
versionToInstallChooser = new JComboBox();
|
versionToInstallChooser = new JComboBox();
|
||||||
|
@ -43,6 +43,8 @@ import java.awt.event.FocusEvent;
|
|||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -88,6 +90,8 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
|||||||
private final JButton closeButton;
|
private final JButton closeButton;
|
||||||
private final JButton dismissErrorMessageButton;
|
private final JButton dismissErrorMessageButton;
|
||||||
|
|
||||||
|
protected int previousRowAtPoint = -1;
|
||||||
|
|
||||||
abstract protected FilteredAbstractTableModel<T> createContribModel();
|
abstract protected FilteredAbstractTableModel<T> createContribModel();
|
||||||
|
|
||||||
abstract protected TableCellRenderer createCellRenderer();
|
abstract protected TableCellRenderer createCellRenderer();
|
||||||
@ -118,6 +122,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
|||||||
filterField = new FilterJTextField(tr("Filter your search...")) {
|
filterField = new FilterJTextField(tr("Filter your search...")) {
|
||||||
@Override
|
@Override
|
||||||
protected void onFilter(String[] _filters) {
|
protected void onFilter(String[] _filters) {
|
||||||
|
previousRowAtPoint = -1;
|
||||||
filters = _filters;
|
filters = _filters;
|
||||||
if (contribTable.getCellEditor() != null) {
|
if (contribTable.getCellEditor() != null) {
|
||||||
contribTable.getCellEditor().stopCellEditing();
|
contribTable.getCellEditor().stopCellEditing();
|
||||||
@ -167,6 +172,25 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
contribTable.addMouseMotionListener(new MouseMotionListener() {
|
||||||
|
|
||||||
|
public void mouseDragged(MouseEvent e) {}
|
||||||
|
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
// avoid firing edits events until the mouse changes cell or the user is back on the cell after selecting a dropdown
|
||||||
|
int rowAtPoint = contribTable.rowAtPoint(e.getPoint());
|
||||||
|
if (!InstallerTableCell.isDropdownSelected() && rowAtPoint != previousRowAtPoint) {
|
||||||
|
contribTable.editCellAt(rowAtPoint, 0);
|
||||||
|
previousRowAtPoint = rowAtPoint;
|
||||||
|
InstallerTableCell.dropdownSelected(false);
|
||||||
|
}
|
||||||
|
if (InstallerTableCell.isDropdownSelected() && rowAtPoint == previousRowAtPoint) {
|
||||||
|
// back to the original cell, can drop dropdown selector lock
|
||||||
|
InstallerTableCell.dropdownSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
TableColumnModel tcm = contribTable.getColumnModel();
|
TableColumnModel tcm = contribTable.getColumnModel();
|
||||||
TableColumn col = tcm.getColumn(0);
|
TableColumn col = tcm.getColumn(0);
|
||||||
@ -286,6 +310,7 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
DropdownItem<T> selected = (DropdownItem<T>) categoryChooser.getSelectedItem();
|
DropdownItem<T> selected = (DropdownItem<T>) categoryChooser.getSelectedItem();
|
||||||
|
previousRowAtPoint = -1;
|
||||||
if (categoryFilter == null || !categoryFilter.equals(selected)) {
|
if (categoryFilter == null || !categoryFilter.equals(selected)) {
|
||||||
categoryFilter = selected.getFilterPredicate();
|
categoryFilter = selected.getFilterPredicate();
|
||||||
if (contribTable.getCellEditor() != null) {
|
if (contribTable.getCellEditor() != null) {
|
||||||
|
@ -41,6 +41,16 @@ public abstract class InstallerTableCell extends AbstractCellEditor implements T
|
|||||||
|
|
||||||
abstract public void setEnabled(boolean b);
|
abstract public void setEnabled(boolean b);
|
||||||
|
|
||||||
|
private static boolean dropdownSelected = false;
|
||||||
|
|
||||||
|
public static boolean isDropdownSelected( ) {
|
||||||
|
return dropdownSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dropdownSelected(boolean b) {
|
||||||
|
dropdownSelected = b;
|
||||||
|
}
|
||||||
|
|
||||||
abstract public void setStatus(String s);
|
abstract public void setStatus(String s);
|
||||||
|
|
||||||
public static void setJTextPaneDimensionToFitContainedText(JTextPane jTextPane, int width) {
|
public static void setJTextPaneDimensionToFitContainedText(JTextPane jTextPane, int width) {
|
||||||
|
Loading…
Reference in New Issue
Block a user