mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-09-13 21:56:19 +00:00
GP-4520 fixing accessibility for SaveDataDialog and DomainFilePanel
This commit is contained in:
parent
6c60bd0313
commit
e1352bf7cc
|
@ -87,6 +87,7 @@ public class ByteViewerOptionsDialog extends DialogComponentProvider
|
||||||
addressInputField.setAddress(getAlignmentAddress());
|
addressInputField.setAddress(getAlignmentAddress());
|
||||||
panel.add(addressInputField);
|
panel.add(addressInputField);
|
||||||
addressInputField.addChangeListener(this);
|
addressInputField.addChangeListener(this);
|
||||||
|
addressInputField.setAccessibleName("Alignment Address");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ public class ByteViewerOptionsDialog extends DialogComponentProvider
|
||||||
bytesPerLineField.setValue(BigInteger.valueOf(provider.getBytesPerLine()));
|
bytesPerLineField.setValue(BigInteger.valueOf(provider.getBytesPerLine()));
|
||||||
panel.add(bytesPerLineField);
|
panel.add(bytesPerLineField);
|
||||||
bytesPerLineField.addChangeListener(this);
|
bytesPerLineField.addChangeListener(this);
|
||||||
|
bytesPerLineField.getAccessibleContext().setAccessibleName("Bytes Per Line");
|
||||||
|
|
||||||
panel.add(new GLabel("Group size (Hex View Only):"));
|
panel.add(new GLabel("Group size (Hex View Only):"));
|
||||||
groupSizeField = new FixedBitSizeValueField(8, false, true);
|
groupSizeField = new FixedBitSizeValueField(8, false, true);
|
||||||
|
@ -105,6 +107,7 @@ public class ByteViewerOptionsDialog extends DialogComponentProvider
|
||||||
groupSizeField.setValue(BigInteger.valueOf(provider.getGroupSize()));
|
groupSizeField.setValue(BigInteger.valueOf(provider.getGroupSize()));
|
||||||
panel.add(groupSizeField);
|
panel.add(groupSizeField);
|
||||||
groupSizeField.addChangeListener(this);
|
groupSizeField.addChangeListener(this);
|
||||||
|
groupSizeField.getAccessibleContext().setAccessibleName("Group Size");
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class ListPanel<T> extends JPanel {
|
||||||
private ListSelectionListener listSelectionListener;
|
private ListSelectionListener listSelectionListener;
|
||||||
private ActionListener doubleClickActionListener;
|
private ActionListener doubleClickActionListener;
|
||||||
private MouseListener mouseListener;
|
private MouseListener mouseListener;
|
||||||
|
private KeyListener keyListener;
|
||||||
private JScrollPane scrollpane;
|
private JScrollPane scrollpane;
|
||||||
private JList<T> list;
|
private JList<T> list;
|
||||||
|
|
||||||
|
@ -258,6 +259,14 @@ public class ListPanel<T> extends JPanel {
|
||||||
mouseListener = l;
|
mouseListener = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setKeyListener(KeyListener l) {
|
||||||
|
if (keyListener != null) {
|
||||||
|
list.removeKeyListener(keyListener);
|
||||||
|
}
|
||||||
|
list.addKeyListener(l);
|
||||||
|
keyListener = l;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a standard warning message about no selected objects
|
* Displays a standard warning message about no selected objects
|
||||||
* in the list.
|
* in the list.
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
package ghidra.framework.main;
|
package ghidra.framework.main;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.*;
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -159,6 +158,7 @@ public class SaveDataDialog extends DialogComponentProvider {
|
||||||
listPanel = new ListPanel<>();
|
listPanel = new ListPanel<>();
|
||||||
listPanel.setCellRenderer(new DataCellRenderer());
|
listPanel.setCellRenderer(new DataCellRenderer());
|
||||||
listPanel.setMouseListener(new ListMouseListener());
|
listPanel.setMouseListener(new ListMouseListener());
|
||||||
|
listPanel.setKeyListener(new ListKeyListener());
|
||||||
|
|
||||||
parentPanel.add(myButtonPanel, BorderLayout.EAST);
|
parentPanel.add(myButtonPanel, BorderLayout.EAST);
|
||||||
parentPanel.add(listPanel, BorderLayout.CENTER);
|
parentPanel.add(listPanel, BorderLayout.CENTER);
|
||||||
|
@ -255,11 +255,15 @@ public class SaveDataDialog extends DialogComponentProvider {
|
||||||
boldFont = font.deriveFont(font.getStyle() | Font.BOLD);
|
boldFont = font.deriveFont(font.getStyle() | Font.BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color fg = isSelected ? list.getSelectionForeground() : list.getForeground();
|
||||||
|
Color bg = isSelected ? list.getSelectionBackground() : list.getBackground();
|
||||||
// set color to red if file cannot be saved 'as is'
|
// set color to red if file cannot be saved 'as is'
|
||||||
if (!saveable[index]) {
|
if (!saveable[index]) {
|
||||||
checkboxes[index].setForeground(Colors.ERROR);
|
fg = Colors.ERROR;
|
||||||
checkboxes[index].setFont(boldFont);
|
checkboxes[index].setFont(boldFont);
|
||||||
}
|
}
|
||||||
|
checkboxes[index].setForeground(fg);
|
||||||
|
checkboxes[index].setBackground(bg);
|
||||||
return checkboxes[index];
|
return checkboxes[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,6 +294,23 @@ public class SaveDataDialog extends DialogComponentProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ListKeyListener extends KeyAdapter {
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||||
|
e.consume();
|
||||||
|
JList<?> list = (JList<?>) e.getSource();
|
||||||
|
int index = list.getSelectedIndex();
|
||||||
|
if (index < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean selected = checkboxes[index].isSelected();
|
||||||
|
checkboxes[index].setSelected(!selected);
|
||||||
|
listPanel.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SaveTask extends Task {
|
private class SaveTask extends Task {
|
||||||
private DomainFile[] domainFiles;
|
private DomainFile[] domainFiles;
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
package ghidra.framework.main.datatree;
|
package ghidra.framework.main.datatree;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.*;
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -63,6 +62,7 @@ class DomainFilesPanel extends JPanel {
|
||||||
listPanel = new ListPanel<>();
|
listPanel = new ListPanel<>();
|
||||||
listPanel.setCellRenderer(new DataCellRenderer());
|
listPanel.setCellRenderer(new DataCellRenderer());
|
||||||
listPanel.setMouseListener(new ListMouseListener());
|
listPanel.setMouseListener(new ListMouseListener());
|
||||||
|
listPanel.setKeyListener(new ListKeyListener());
|
||||||
if (listTitle != null) {
|
if (listTitle != null) {
|
||||||
listPanel.setListTitle(listTitle);
|
listPanel.setListTitle(listTitle);
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,10 @@ class DomainFilesPanel extends JPanel {
|
||||||
}
|
}
|
||||||
index = selected;
|
index = selected;
|
||||||
}
|
}
|
||||||
|
Color fg = isSelected ? list.getSelectionForeground() : list.getForeground();
|
||||||
|
Color bg = isSelected ? list.getSelectionBackground() : list.getBackground();
|
||||||
|
checkboxes[index].setForeground(fg);
|
||||||
|
checkboxes[index].setBackground(bg);
|
||||||
return checkboxes[index];
|
return checkboxes[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,4 +141,20 @@ class DomainFilesPanel extends JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ListKeyListener extends KeyAdapter {
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||||
|
e.consume();
|
||||||
|
JList<?> list = (JList<?>) e.getSource();
|
||||||
|
int index = list.getSelectedIndex();
|
||||||
|
if (index < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean selected = checkboxes[index].isSelected();
|
||||||
|
checkboxes[index].setSelected(!selected);
|
||||||
|
listPanel.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue