GP-2464 fixing key navigation for filter options dialog

This commit is contained in:
ghidragon 2024-04-04 11:37:52 -04:00
parent 42c17a20f8
commit 24a661cb49

View File

@ -53,7 +53,7 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
private InvertPanel invertPanel;
private PathPanel pathPanel;
private MultiTermPanel multiTermPanel;
private JLayer<?> multiTermDisabledPanel;
private JLayer<?> multiTermDisabledLayer;
public FilterOptionsEditorDialog(FilterOptions filterOptions) {
super("Text Filter Options");
@ -65,7 +65,7 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
multiTermPanel.setEvalMode(filterOptions.getMultitermEvaluationMode());
multiTermPanel.setDelimiter(filterOptions.getDelimitingCharacter());
updatedEnablementForNonRegularExpressionOptions(
enableStandardOptions(
filterStrategyPanel.getFilterStrategy() != TextFilterStrategy.REGULAR_EXPRESSION);
multiTermPanel.setMultitermEnabled(filterOptions.isMultiterm());
@ -110,17 +110,18 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
multiTermPanel = new MultiTermPanel();
panel.add(multiTermPanel);
multiTermDisabledPanel = DisabledComponentLayerFactory.getDisabledLayer(multiTermPanel);
panel.add(multiTermDisabledPanel);
multiTermDisabledLayer = DisabledComponentLayerFactory.getDisabledLayer(multiTermPanel);
panel.add(multiTermDisabledLayer);
return panel;
}
protected void updatedEnablementForNonRegularExpressionOptions(boolean b) {
booleanPanel.setCaseSensitiveCBEnabled(b);
booleanPanel.setGlobbingCBEnabled(b);
multiTermDisabledPanel.setEnabled(b);
// standard options are those that don't apply to regexes
private void enableStandardOptions(boolean enable) {
booleanPanel.setCaseSensitiveCBEnabled(enable);
booleanPanel.setGlobbingCBEnabled(enable);
multiTermPanel.setEnabled(enable);
multiTermDisabledLayer.setEnabled(enable);
}
/**
@ -151,8 +152,8 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
setLayout(new PairLayout(2, 2));
setBorder(BorderFactory.createTitledBorder("Text Filter Strategy"));
ButtonGroup buttonGroup = new ButtonGroup();
GRadioButton startsWithButton = new GRadioButton("Starts With");
GRadioButton containsButton = new GRadioButton("Contains");
GRadioButton startsWithButton = new GRadioButton("Starts With");
GRadioButton matchesExactlyButton = new GRadioButton("Matches Exactly");
GRadioButton regularExpressionButton = new GRadioButton("Regular Expression");
@ -165,27 +166,27 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
regularExpressionButton.setToolTipText(
"The filter will match all entries that match a regular expression generated from the filter text.");
buttonGroup.add(startsWithButton);
buttonGroup.add(containsButton);
buttonGroup.add(startsWithButton);
buttonGroup.add(matchesExactlyButton);
buttonGroup.add(regularExpressionButton);
startsWithButton.addActionListener(ev -> {
filterStrategy = TextFilterStrategy.STARTS_WITH;
updatedEnablementForNonRegularExpressionOptions(true);
enableStandardOptions(true);
});
containsButton.addActionListener(ev -> {
filterStrategy = TextFilterStrategy.CONTAINS;
updatedEnablementForNonRegularExpressionOptions(true);
enableStandardOptions(true);
});
matchesExactlyButton.addActionListener(ev -> {
filterStrategy = TextFilterStrategy.MATCHES_EXACTLY;
updatedEnablementForNonRegularExpressionOptions(true);
enableStandardOptions(true);
});
regularExpressionButton.addActionListener(ev -> {
filterStrategy = TextFilterStrategy.REGULAR_EXPRESSION;
updatedEnablementForNonRegularExpressionOptions(false);
enableStandardOptions(false);
});
switch (initialFilterOptions.getTextFilterStrategy()) {
@ -372,6 +373,20 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
return evalMode;
}
@Override
public void setEnabled(boolean enable) {
super.setEnabled(enable);
enableCheckbox.setEnabled(enable);
// When we disable this options panel, uncheck the panel so that its internal options
// are disabled as well. When we become enabled, the user is required to recheck the
// box.
if (!enable) {
enableCheckbox.setSelected(false);
setOptionsEnabled(false);
}
}
/**
* Sets the evaluation mode to what is given. This is done by activating the
* appropriate radio button associated with that mode.
@ -397,6 +412,10 @@ public class FilterOptionsEditorDialog extends DialogComponentProvider {
public void setOptionsEnabled(boolean enabled) {
optionsPaneDisableLayer.setEnabled(enabled);
delimiterCharacterCB.setEnabled(enabled);
for (JRadioButton button : modeButtons) {
button.setEnabled(enabled);
}
}
public boolean isMultitermEnabled() {