Added Accessibility to FieldPanel

This commit is contained in:
ghidragon 2023-05-30 16:24:59 -04:00
parent 7dfaa2ccc3
commit 89e46f2ad9
18 changed files with 2163 additions and 34 deletions

View file

@ -79,7 +79,8 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
*/
protected ByteViewerComponent(ByteViewerPanel vpanel, ByteViewerLayoutModel layoutModel,
DataFormatModel model, int bytesPerLine, FontMetrics fm) {
super(layoutModel);
super(layoutModel, "Byte Viewer");
setFieldDescriptionProvider((l, f) -> getFieldDescription(l, f));
this.panel = vpanel;
this.model = model;
@ -94,6 +95,17 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
setBackgroundColorModel(new ByteViewerBackgroundColorModel());
}
private String getFieldDescription(FieldLocation fieldLoc, Field field) {
ByteBlockInfo info = indexMap.getBlockInfo(fieldLoc.getIndex(), fieldLoc.getFieldNum());
if (info != null) {
String modelName = model.getName();
return modelName + " format at " +
info.getBlock().getLocationRepresentation(info.getOffset()) + ", value = " +
field.getText();
}
return null;
}
@Override
public void buttonPressed(FieldLocation fieldLocation, Field field, MouseEvent mouseEvent) {
if (fieldLocation == null || field == null) {
@ -468,8 +480,7 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
else {
++endFieldOffset;
}
fsel.addRange(
new FieldLocation(startLoc.getIndex(), startLoc.getFieldNum(), 0, 0),
fsel.addRange(new FieldLocation(startLoc.getIndex(), startLoc.getFieldNum(), 0, 0),
new FieldLocation(endIndex, endFieldOffset, 0, 0));
}
return fsel;

View file

@ -752,7 +752,7 @@ public class ByteViewerPanel extends JPanel
// for the index/address column
indexFactory = new IndexFieldFactory(fm);
indexPanel = new FieldPanel(this);
indexPanel = new FieldPanel(this, "Byte Viewer");
indexPanel.enableSelection(false);
indexPanel.setCursorOn(false);