Skip to content

Commit

Permalink
Fix radiobuttons in preference menu (JabRef#4409)
Browse files Browse the repository at this point in the history
Previously multiple radiobuttons in preference menu belonging to the same group were selectable simultaneously
  • Loading branch information
paulKra committed Oct 29, 2018
1 parent 05047f3 commit 68469b2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javafx.scene.control.RadioButton;
import javafx.scene.control.Separator;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

Expand Down Expand Up @@ -102,18 +103,26 @@ public EntryEditorPrefsTab(JabRefPreferences prefs) {

Label nameFormat = new Label(Localization.lang("Name format used for autocompletion"));
nameFormat.getStyleClass().add("sectionHeader");
final ToggleGroup autocompletionToggleGroup = new ToggleGroup();
builder.add(nameFormat, 1, 14);
builder.add(autoCompFF, 1, 15);
builder.add(autoCompLF, 1, 16);
builder.add(autoCompBoth, 1, 17);
autoCompFF.setToggleGroup(autocompletionToggleGroup);
autoCompLF.setToggleGroup(autocompletionToggleGroup);
autoCompBoth.setToggleGroup(autocompletionToggleGroup);
builder.add(new Label(""), 1, 18);

Label treatment = new Label(Localization.lang("Treatment of first names"));
treatment.getStyleClass().add("sectionHeader");
final ToggleGroup treatmentOfFirstNamesToggleGroup = new ToggleGroup();
builder.add(treatment, 1, 19);
builder.add(firstNameModeAbbr, 1, 20);
builder.add(firstNameModeFull, 1, 21);
builder.add(firstNameModeBoth, 1, 22);
firstNameModeAbbr.setToggleGroup(treatmentOfFirstNamesToggleGroup);
firstNameModeFull.setToggleGroup(treatmentOfFirstNamesToggleGroup);
firstNameModeBoth.setToggleGroup(treatmentOfFirstNamesToggleGroup);
}

@Override
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/gui/preferences/ExternalTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

import org.jabref.Globals;
Expand Down Expand Up @@ -69,20 +70,26 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere
browseAdobeAcrobatReader.setOnAction(e -> showAdobeChooser());

GridPane consoleOptionPanel = new GridPane();
final ToggleGroup consoleGroup = new ToggleGroup();
defaultConsole.setToggleGroup(consoleGroup);
executeConsole.setToggleGroup(consoleGroup);
consoleOptionPanel.add(defaultConsole, 1, 1);
consoleOptionPanel.add(executeConsole, 1, 2);
consoleOptionPanel.add(consoleCommand, 2, 2);
consoleOptionPanel.add(browseButton, 3, 2);
consoleOptionPanel.add(commandDescription, 2, 3);

GridPane pdfOptionPanel = new GridPane();
final ToggleGroup pdfReaderGroup = new ToggleGroup();
pdfOptionPanel.add(adobeAcrobatReader, 1, 1);
pdfOptionPanel.add(adobeAcrobatReaderPath, 2, 1);
adobeAcrobatReader.setToggleGroup(pdfReaderGroup);
pdfOptionPanel.add(browseAdobeAcrobatReader, 3, 1);

if (OS.WINDOWS) {
browseSumatraReader.setOnAction(e -> showSumatraChooser());
pdfOptionPanel.add(sumatraReader, 1, 2);
sumatraReader.setToggleGroup(pdfReaderGroup);
pdfOptionPanel.add(sumatraReaderPath, 2, 2);
pdfOptionPanel.add(browseSumatraReader, 3, 2);
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/jabref/gui/preferences/FileTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

Expand Down Expand Up @@ -95,11 +96,13 @@ public FileTab(DialogService dialogService, JabRefPreferences prefs) {
builder.add(backup, 1, 3);
Label label = new Label(Localization.lang("Do not wrap the following fields when saving") + ":");
builder.add(label, 1, 4);
final ToggleGroup resolveGroup = new ToggleGroup();
builder.add(nonWrappableFields, 2, 4);
builder.add(resolveStringsStandard, 1, 5);
builder.add(resolveStringsAll, 1, 6);
builder.add(doNotResolveStringsFor, 2, 6);

resolveStringsStandard.setToggleGroup(resolveGroup);
resolveStringsAll.setToggleGroup(resolveGroup);
Label newlineSeparatorLabel = new Label(Localization.lang("Newline separator") + ":");
builder.add(newlineSeparatorLabel, 1, 7);
builder.add(newlineSeparator, 2, 7);
Expand All @@ -125,10 +128,14 @@ public FileTab(DialogService dialogService, JabRefPreferences prefs) {
});
builder.add(browse, 3, 12);
builder.add(bibLocAsPrimaryDir, 1, 13);
final ToggleGroup autolinkGroup = new ToggleGroup();
builder.add(matchStartsWithKey, 1, 14);
builder.add(matchExactKeyOnly, 1, 15);
builder.add(useRegExpComboBox, 1, 16);
builder.add(regExpTextField, 2, 16);
matchStartsWithKey.setToggleGroup(autolinkGroup);
matchExactKeyOnly.setToggleGroup(autolinkGroup);
useRegExpComboBox.setToggleGroup(autolinkGroup);

Button help = new Button("?");
help.setOnAction(event -> new HelpAction(Localization.lang("Help on regular expression search"),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/gui/preferences/GroupsPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

Expand Down Expand Up @@ -45,8 +46,11 @@ public void handle(ActionEvent event) {
builder.add(view, 1, 1);
builder.add(hideNonHits, 2, 2);
builder.add(grayOut, 2, 3);
final ToggleGroup selectionModeGroup = new ToggleGroup();
builder.add(multiSelectionModeIntersection, 2, 4);
builder.add(multiSelectionModeUnion, 2, 5);
multiSelectionModeIntersection.setToggleGroup(selectionModeGroup);
multiSelectionModeUnion.setToggleGroup(selectionModeGroup);
builder.add(autoAssignGroup, 2, 6);
builder.add(new Label(""), 1, 7);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javafx.scene.control.RadioButton;
import javafx.scene.control.Separator;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

Expand Down Expand Up @@ -60,11 +61,16 @@ public ImportSettingsTab(JabRefPreferences prefs) {
Label defaultImportStyle = new Label(Localization.lang("Default import style for drag and drop of PDFs"));
defaultImportStyle.getStyleClass().add("sectionHeader");
builder.add(defaultImportStyle, 1, 1);
final ToggleGroup defaultImportStyleDragDropPdfs = new ToggleGroup();
builder.add(new Separator(), 2, 1);
builder.add(radioButtonNoMeta, 2, 2);
builder.add(radioButtonXmp, 2, 3);
builder.add(radioButtonPDFcontent, 2, 4);
builder.add(radioButtononlyAttachPDF, 2, 5);
radioButtonNoMeta.setToggleGroup(defaultImportStyleDragDropPdfs);
radioButtonXmp.setToggleGroup(defaultImportStyleDragDropPdfs);
radioButtonPDFcontent.setToggleGroup(defaultImportStyleDragDropPdfs);
radioButtononlyAttachPDF.setToggleGroup(defaultImportStyleDragDropPdfs);
builder.add(useDefaultPDFImportStyle, 2, 6);
builder.add(new Label(""), 1, 7);

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/gui/preferences/TableColumnsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
Expand Down Expand Up @@ -284,14 +285,20 @@ public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
specialTableColumnsBuilder.add(priorityColumn, 1, 5);
specialTableColumnsBuilder.add(printedColumn, 1, 6);
specialTableColumnsBuilder.add(readStatusColumn, 1, 7);
final ToggleGroup syncGroup = new ToggleGroup();
specialTableColumnsBuilder.add(syncKeywords, 1, 8);
specialTableColumnsBuilder.add(writeSpecialFields, 1, 9);
syncKeywords.setToggleGroup(syncGroup);
writeSpecialFields.setToggleGroup(syncGroup);
specialTableColumnsBuilder.add(helpButton, 1, 10);

specialTableColumnsBuilder.add(fileColumn, 2, 1);
specialTableColumnsBuilder.add(urlColumn, 2, 2);
final ToggleGroup preferUrlOrDoi = new ToggleGroup();
specialTableColumnsBuilder.add(preferUrl, 2 ,3);
specialTableColumnsBuilder.add(preferDoi, 2, 4);
preferUrl.setToggleGroup(preferUrlOrDoi);
preferDoi.setToggleGroup(preferUrlOrDoi);
specialTableColumnsBuilder.add(arxivColumn, 2, 5);

specialTableColumnsBuilder.add(extraFileColumns,2, 6);
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/org/jabref/gui/preferences/TablePrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

Expand Down Expand Up @@ -54,26 +55,33 @@ public TablePrefsTab(JabRefPreferences prefs) {
Label formatOfAuthor = new Label(Localization.lang("Format of author and editor names"));
formatOfAuthor.getStyleClass().add("sectionHeader");
builder.add(formatOfAuthor, 1, 1);
final ToggleGroup formatNamesToggleGroup = new ToggleGroup();
final ToggleGroup nameAbbrevToggleGroup = new ToggleGroup();
builder.add(namesAsIs, 1, 2);
namesAsIs.setToggleGroup(formatNamesToggleGroup);
builder.add(noAbbrNames, 2, 2);
noAbbrNames.setToggleGroup(nameAbbrevToggleGroup);
builder.add(namesFf, 1, 3);
namesFf.setToggleGroup(formatNamesToggleGroup);
builder.add(abbrNames, 2, 3);
abbrNames.setToggleGroup(nameAbbrevToggleGroup);
builder.add(namesFl, 1, 4);
namesFl.setToggleGroup(formatNamesToggleGroup);
builder.add(lastNamesOnly, 2, 4);
lastNamesOnly.setToggleGroup(nameAbbrevToggleGroup);
builder.add(namesNatbib, 1, 5);

namesNatbib.setToggleGroup(formatNamesToggleGroup);
Label label1 = new Label("");
builder.add(label1, 1, 6);

Label general = new Label(Localization.lang("General"));
general.getStyleClass().add("sectionHeader");
builder.add(general, 1, 7);
builder.add(autoResizeMode, 1, 8);
namesNatbib.setOnAction(e -> {
abbrNames.setDisable(namesNatbib.isSelected());
lastNamesOnly.setDisable(namesNatbib.isSelected());
noAbbrNames.setDisable(namesNatbib.isSelected());
});

abbrNames.disableProperty().bind(namesNatbib.selectedProperty());
lastNamesOnly.disableProperty().bind(namesNatbib.selectedProperty());
noAbbrNames.disableProperty().bind(namesNatbib.selectedProperty());

}

@Override
Expand Down Expand Up @@ -102,10 +110,6 @@ public void setValues() {
noAbbrNames.setSelected(true);
}

abbrNames.setDisable(namesNatbib.isSelected());
lastNamesOnly.setDisable(namesNatbib.isSelected());
noAbbrNames.setDisable(namesNatbib.isSelected());

}

/**
Expand Down

0 comments on commit 68469b2

Please sign in to comment.