GP-4543 fixed some accesibility issues with bsim dialog

This commit is contained in:
ghidragon 2024-04-22 18:02:32 +00:00
parent 9abfa3da86
commit 861f7fe578
5 changed files with 47 additions and 52 deletions

View File

@ -21,6 +21,7 @@ import java.awt.event.ItemListener;
import java.util.*;
import java.util.List;
import javax.accessibility.AccessibleContext;
import javax.swing.*;
import docking.DialogComponentProvider;
@ -118,9 +119,14 @@ public abstract class AbstractBSimSearchDialog extends DialogComponentProvider {
confidenceField.setValue(0);
confidenceField.setMinValue(0.0);
panel.add(new JLabel("Similarity Threshold (0-1):"));
JLabel similarityLabel = new JLabel("Similarity Threshold (0-1):");
JLabel confidenceLabel = new JLabel("Confidence Threshold:");
similarityLabel.setLabelFor(similarityField);
confidenceLabel.setLabelFor(confidenceField);
panel.add(similarityLabel);
panel.add(similarityField);
panel.add(new JLabel("Confidence Threshold:"));
panel.add(confidenceLabel);
panel.add(confidenceField);
return panel;
}
@ -223,6 +229,10 @@ public abstract class AbstractBSimSearchDialog extends DialogComponentProvider {
comboPanel.add(serverCombo, BorderLayout.CENTER);
panel.add(comboPanel, BorderLayout.CENTER);
AccessibleContext context = serverCombo.getAccessibleContext();
context.setAccessibleName("BSim Server");
context.setAccessibleDescription("Select a predefined Bsim Server");
JButton button = new EmptyBorderButton(Icons.CONFIGURE_FILTER_ICON);
button.setToolTipText("Show Server Manager Dialog");
button.addActionListener(e -> managerServers());

View File

@ -128,8 +128,13 @@ public class BSimSearchDialog extends AbstractBSimSearchDialog {
maxResultsField.setAllowsHexPrefix(false);
maxResultsField.setShowNumberMode(false);
panel.add(new JLabel("Max Matches Per Function:"));
panel.add(maxResultsField.getComponent());
JComponent maxResultsComponent = maxResultsField.getComponent();
JLabel maxLabel = new JLabel("Max Matches Per Function:");
maxLabel.setLabelFor(maxResultsComponent);
panel.add(maxLabel);
panel.add(maxResultsComponent);
return panel;
}

View File

@ -51,8 +51,8 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
private JPanel cardPanel;
private PostgresPanel postgresPanel;
private ElasticPanel elasticPanel;
private DbPanel postgresPanel;
private DbPanel elasticPanel;
private FilePanel filePanel;
private ServerPanel activePanel;
@ -65,12 +65,13 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
addOKButton();
addCancelButton();
setOkEnabled(false);
setHelpLocation(new HelpLocation("BSimSearchPlugin","Add_Server_Definition_Dialog" ));
setHelpLocation(new HelpLocation("BSimSearchPlugin", "Add_Server_Definition_Dialog"));
}
public BSimServerInfo getBsimServerInfo() {
return result;
}
@Override
public void setHelpLocation(HelpLocation helpLocation) {
// TODO Auto-generated method stub
@ -101,7 +102,8 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
errorMessage = e.getMessage();
}
int answer = OptionDialog.showYesNoDialog(null, "Connection Test Failed!",
"Can't connect to server: " + errorMessage + "\nDo you want to proceed with creation anyway?");
"Can't connect to server: " + errorMessage +
"\nDo you want to proceed with creation anyway?");
return answer == OptionDialog.YES_OPTION;
}
@ -113,8 +115,8 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
}
private Component buildCardPanel() {
postgresPanel = new PostgresPanel();
elasticPanel = new ElasticPanel();
postgresPanel = new DbPanel(DBType.postgres);
elasticPanel = new DbPanel(DBType.elastic);
filePanel = new FilePanel();
cardPanel = new JPanel(new CardLayout());
@ -193,23 +195,33 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
setOkEnabled(serverInfo != null);
}
private class PostgresPanel extends ServerPanel {
private class DbPanel extends ServerPanel {
private JTextField nameField;
private JTextField hostField;
private JTextField portField;
private DBType type;
PostgresPanel() {
private DbPanel(DBType type) {
super(new PairLayout(10, 10));
this.type = type;
nameField = new NotifyingTextField();
hostField = new NotifyingTextField();
portField =
new NotifyingTextField(Integer.toString(BSimServerInfo.DEFAULT_POSTGRES_PORT));
add(new JLabel("DB Name:", SwingConstants.RIGHT));
JLabel nameLabel = new JLabel("DB Name:", SwingConstants.RIGHT);
JLabel hostLabel = new JLabel("Host:", SwingConstants.RIGHT);
JLabel portLabel = new JLabel("Port:", SwingConstants.RIGHT);
nameLabel.setLabelFor(nameField);
hostLabel.setLabelFor(hostField);
portLabel.setLabelFor(portField);
add(nameLabel);
add(nameField);
add(new JLabel("Host:", SwingConstants.RIGHT));
add(hostLabel);
add(hostField);
add(new JLabel("Port:", SwingConstants.RIGHT));
add(portLabel);
add(portField);
}
@ -221,43 +233,10 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
if (name.isBlank() || host.isBlank() || port < 0) {
return null;
}
return new BSimServerInfo(DBType.postgres, host, port, name);
return new BSimServerInfo(type, host, port, name);
}
}
private class ElasticPanel extends ServerPanel {
private JTextField nameField;
private JTextField hostField;
private JTextField portField;
ElasticPanel() {
super(new PairLayout(10, 10));
nameField = new NotifyingTextField();
hostField = new NotifyingTextField();
portField =
new NotifyingTextField(Integer.toString(BSimServerInfo.DEFAULT_ELASTIC_PORT));
add(new JLabel("DB Name:", SwingConstants.RIGHT));
add(nameField);
add(new JLabel("Host:", SwingConstants.RIGHT));
add(hostField);
add(new JLabel("Port:", SwingConstants.RIGHT));
add(portField);
}
@Override
BSimServerInfo getServerInfo() {
String name = nameField.getText().trim();
String host = hostField.getText().trim();
int port = getPort(portField.getText().trim());
if (name.isBlank() || host.isBlank() || port < 0) {
return null;
}
return new BSimServerInfo(DBType.elastic, host, port, name);
}
}
private class FilePanel extends ServerPanel {
private JTextField fileField;

View File

@ -155,7 +155,9 @@ public class FilterWidget extends JPanel {
editor = createEditor(filterType, null);
contentPanel = new JPanel(new BorderLayout());
contentPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
contentPanel.add(editor.getComponent());
JComponent editorComponent = editor.getComponent();
editorComponent.getAccessibleContext().setAccessibleName("Filter Value");
contentPanel.add(editorComponent);
return contentPanel;
}

View File

@ -551,7 +551,6 @@ class MemSearchDialog extends ReusableDialogComponentProvider {
setAdvancedPanelVisible(advancedButton.isSelected());
});
advancedButton.setFocusable(false);
JPanel advancedButtonPanel = new JPanel();
advancedButtonPanel.setLayout(new BoxLayout(advancedButtonPanel, BoxLayout.X_AXIS));
advancedButtonPanel.add(Box.createHorizontalGlue());