Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We improved the event viewer for debugging [#13783](https://github.com/JabRef/jabref/pull/13783).
- We improved "REDACTED" replacement of API key value in web fetcher search URL [#13796](https://github.com/JabRef/jabref/issues/13796)
- When the pin "Keep dialog always on top" in the global search dialog is selected, the search window stays open when double-clicking on an entry. [#13840](https://github.com/JabRef/jabref/issues/13840)
- We improved the UI of regex replacement in the citation key generator tab.

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public enum StandardActions implements Action {

HELP(Localization.lang("Online help"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
HELP_GROUPS(Localization.lang("Open Help page"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
HELP_KEY_PATTERNS(Localization.lang("Help on key patterns"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
HELP_REGEX_SEARCH(Localization.lang("Help on regular expression search"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
HELP_NAME_FORMATTER(Localization.lang("Help on Name Formatting"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
HELP_SPECIAL_FIELDS(Localization.lang("Help on special fields"), IconTheme.JabRefIcons.HELP, KeyBinding.HELP),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package org.jabref.gui.libraryproperties.keypattern;

import javafx.fxml.FXML;
import javafx.scene.control.Button;

import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.commonfxcontrols.CitationKeyPatternsPanel;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.libraryproperties.AbstractPropertiesTabView;
import org.jabref.gui.libraryproperties.PropertiesTab;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -20,7 +15,6 @@

public class KeyPatternPropertiesView extends AbstractPropertiesTabView<KeyPatternPropertiesViewModel> implements PropertiesTab {

@FXML private Button keyPatternHelp;
@FXML private CitationKeyPatternsPanel bibtexKeyPatternTable;

@Inject private GuiPreferences preferences;
Expand All @@ -44,9 +38,6 @@ public void initialize() {

bibtexKeyPatternTable.patternListProperty().bindBidirectional(viewModel.patternListProperty());
bibtexKeyPatternTable.defaultKeyPatternProperty().bindBidirectional(viewModel.defaultKeyPatternProperty());

ActionFactory actionFactory = new ActionFactory();
actionFactory.configureIconButton(StandardActions.HELP_KEY_PATTERNS, new HelpAction(HelpFile.CITATION_KEY_PATTERN, dialogService, preferences.getExternalApplicationsPreferences()), keyPatternHelp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package org.jabref.gui.preferences.citationkeypattern;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;

import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
import org.jabref.gui.commonfxcontrols.CitationKeyPatternsPanel;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.preferences.AbstractPreferenceTabView;
import org.jabref.gui.preferences.PreferencesTab;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntryTypesManager;

Expand All @@ -31,7 +26,6 @@ public class CitationKeyPatternTab extends AbstractPreferenceTabView<CitationKey
@FXML private TextField keyPatternRegex;
@FXML private TextField keyPatternReplacement;
@FXML private TextField unwantedCharacters;
@FXML private Button keyPatternHelp;
@FXML private CitationKeyPatternsPanel bibtexKeyPatternTable;

public CitationKeyPatternTab() {
Expand Down Expand Up @@ -61,9 +55,6 @@ public void initialize() {

bibtexKeyPatternTable.patternListProperty().bindBidirectional(viewModel.patternListProperty());
bibtexKeyPatternTable.defaultKeyPatternProperty().bindBidirectional(viewModel.defaultKeyPatternProperty());

ActionFactory actionFactory = new ActionFactory();
actionFactory.configureIconButton(StandardActions.HELP_KEY_PATTERNS, new HelpAction(HelpFile.CITATION_KEY_PATTERN, dialogService, preferences.getExternalApplicationsPreferences()), keyPatternHelp);
}

@Override
Expand Down
24 changes: 24 additions & 0 deletions jabgui/src/main/java/org/jabref/gui/util/component/HelpButton.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.util.component;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.control.Button;

import org.jabref.gui.DialogService;
Expand All @@ -14,6 +16,8 @@
import org.jspecify.annotations.NonNull;

public class HelpButton extends Button {
private StringProperty helpUrl;

public HelpButton() {
setGraphic(IconTheme.JabRefIcons.HELP.getGraphicNode());
getStyleClass().add("icon-button");
Expand All @@ -38,4 +42,24 @@ public void setHelpPage(@NonNull String helpDocumentationUrl) {
public void setHelpFile(@NonNull HelpFile helpFile, @NonNull DialogService dialogService, @NonNull ExternalApplicationsPreferences externalApplicationsPreferences) {
setOnAction(_ -> new HelpAction(helpFile, dialogService, externalApplicationsPreferences).execute());
}

public final StringProperty helpUrlProperty() {
Copy link
Member

@Siedlerchr Siedlerchr Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the idea behind this? updating the help url dynamically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that we can set this in the FXML :)

if (helpUrl == null) {
helpUrl = new SimpleStringProperty(this, "helpUrl");
helpUrl.addListener((observable, oldValue, newValue) -> {
if (newValue != null && !newValue.isEmpty()) {
setHelpPage(newValue);
}
});
}
return helpUrl;
}

public final String getHelpUrl() {
return helpUrlProperty().get();
}

public final void setHelpUrl(String url) {
helpUrlProperty().set(url);
}
}
9 changes: 9 additions & 0 deletions jabgui/src/main/resources/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,15 @@ We want to have a look that matches our icons in the tool-bar */
-fx-background-color: -fx-control-inner-background;
}

.innerGridPane {
-fx-hgap: 1em;
-fx-vgap: 1em;
}

.prefIndent {
-fx-padding: 0 0 0 1.667em;
}

.code-area .text {
-fx-fill: -fx-text-background-color;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.commonfxcontrols.CitationKeyPatternsPanel?>
<?import org.jabref.gui.util.component.HelpButton?>
<fx:root spacing="10.0" type="VBox"
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="org.jabref.gui.libraryproperties.keypattern.KeyPatternPropertiesView">
<HBox alignment="BOTTOM_LEFT" spacing="8.0">
<Label styleClass="sectionHeader" text="%Key patterns"/>
<Button fx:id="keyPatternHelp" styleClass="icon-button,narrow" />
<HelpButton helpUrl="https://docs.jabref.org/setup/citationkeypatterns"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the improvement. Reads nice!

</HBox>
<Label text="%( Note: Press return to commit changes in the table! )"/>
<AnchorPane VBox.vgrow="ALWAYS">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,67 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.commonfxcontrols.CitationKeyPatternsPanel?>
<fx:root spacing="10.0" type="VBox"
xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml"
fx:controller="org.jabref.gui.preferences.citationkeypattern.CitationKeyPatternTab">
<?import org.jabref.gui.util.component.HelpButton?>
<fx:root
spacing="10.0"
type="VBox"
xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.jabref.gui.preferences.citationkeypattern.CitationKeyPatternTab">
<fx:define>
<ToggleGroup fx:id="uniqueKeyLetters"/>
<ToggleGroup
fx:id="uniqueKeyLetters"/>
</fx:define>
<Label styleClass="titleHeader" text="%Citation key patterns"/>
<Label styleClass="titleHeader"
text="%Citation key patterns"/>

<Label styleClass="sectionHeader" text="%General"/>
<CheckBox fx:id="overwriteAllow" text="%Overwrite existing keys"/>
<CheckBox fx:id="overwriteWarning" text="%Warn before overwriting existing keys" disable="${!overwriteAllow.selected}">
<padding>
<Insets left="20.0"/>
</padding>
</CheckBox>
<CheckBox fx:id="generateOnSave" text="%Generate keys before saving (for entries without a key)"/>
<CheckBox fx:id="generateNewKeyOnImport" text="%Generate a new key for imported entries (overwriting their default)"/>
<GridPane
styleClass="innerGridPane">
<columnConstraints>
<ColumnConstraints
hgrow="SOMETIMES"
percentWidth="30.0"/>
<ColumnConstraints
hgrow="SOMETIMES"/>
<ColumnConstraints
hgrow="NEVER"/>
</columnConstraints>

<Label text="%Letters after duplicate generated keys"/>
<VBox spacing="10.0">
<RadioButton fx:id="letterStartA" text="%Start on second duplicate key with letter A (a, b, ...)" toggleGroup="$uniqueKeyLetters"/>
<RadioButton fx:id="letterStartB" text="%Start on second duplicate key with letter B (b, c, ...)" toggleGroup="$uniqueKeyLetters"/>
<RadioButton fx:id="letterAlwaysAdd" text="%Always add letter (a, b, ...) to generated keys" toggleGroup="$uniqueKeyLetters"/>
<padding>
<Insets left="20.0"/>
</padding>
</VBox>
<Label styleClass="sectionHeader"
text="%General"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="0"/>

<Label text="%Replace (regular expression)"/>
<HBox spacing="4.0" alignment="CENTER">
<TextField fx:id="keyPatternRegex" HBox.hgrow="ALWAYS"/>
<Label text="%by"/>
<TextField fx:id="keyPatternReplacement" HBox.hgrow="ALWAYS"/>
<padding>
<Insets left="20.0"/>
</padding>
</HBox>
<CheckBox
fx:id="overwriteAllow"
text="%Overwrite existing keys"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="1"/>
<HBox styleClass="prefIndent"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="2">
<CheckBox
fx:id="overwriteWarning"
text="%Warn before overwriting existing keys"
disable="${!overwriteAllow.selected}"/>
</HBox>
<CheckBox
fx:id="generateOnSave"
text="%Generate keys before saving (for entries without a key)"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="3"/>
<CheckBox
fx:id="generateNewKeyOnImport"
text="%Generate a new key for imported entries (overwriting their default)"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="4"/>

<HBox alignment="CENTER_LEFT" spacing="10.0">
<Label text="%Remove the following characters:"/>
<TextField fx:id="unwantedCharacters" HBox.hgrow="ALWAYS"/>
</HBox>
<Label text="%Letters after duplicate generated keys"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="5"/>
<VBox spacing="10.0"
styleClass="prefIndent"
GridPane.columnIndex="0"
GridPane.columnSpan="3"
GridPane.rowIndex="6">
<RadioButton
fx:id="letterStartA"
text="%Start on second duplicate key with letter A (a, b, ...)"
toggleGroup="$uniqueKeyLetters"/>
<RadioButton
fx:id="letterStartB"
text="%Start on second duplicate key with letter B (b, c, ...)"
toggleGroup="$uniqueKeyLetters"/>
<RadioButton
fx:id="letterAlwaysAdd"
text="%Always add letter (a, b, ...) to generated keys"
toggleGroup="$uniqueKeyLetters"/>
</VBox>

<Label text="%Replace (regular expression)"
GridPane.columnIndex="0"
GridPane.rowIndex="7"/>
<HBox spacing="4.0"
alignment="CENTER_LEFT"
GridPane.columnIndex="1"
GridPane.rowIndex="7">
<TextField
fx:id="keyPatternRegex"
HBox.hgrow="ALWAYS"/>
<Label text="%by"/>
<TextField
fx:id="keyPatternReplacement"
HBox.hgrow="ALWAYS"/>
</HBox>
<HelpButton
helpUrl="https://docs.jabref.org/setup/citationkeypatterns#replace-via-regular-expression"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this as a constant to URL class to have it in a single place

GridPane.columnIndex="2"
GridPane.rowIndex="7"/>

<HBox>
<Label styleClass="sectionHeader" text="%Key patterns"/>
<HBox HBox.hgrow="ALWAYS"/>
<Button fx:id="keyPatternHelp" prefWidth="20.0"/>
<Label text="%Remove the following characters:"
GridPane.columnIndex="0"
GridPane.rowIndex="8"/>
<TextField
fx:id="unwantedCharacters"
GridPane.columnIndex="1"
GridPane.rowIndex="8"/>
</GridPane>


<HBox spacing="8.0">
<Label styleClass="sectionHeader"
text="%Key patterns"/>
<VBox alignment="BOTTOM_CENTER" >
<HelpButton
helpUrl="https://docs.jabref.org/setup/citationkeypatterns"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, move it to Urls class so that there is a single class with all urls, easier for changing

styleClass="headerHelpButton"
/>
</VBox>
</HBox>

<Label text="%( Note: Press return to commit changes in the table! )"/>
<AnchorPane>
<CitationKeyPatternsPanel fx:id="bibtexKeyPatternTable" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" prefHeight="180.0"/>
<Button text="%Reset All" onAction="#resetAllKeyPatterns" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
<CitationKeyPatternsPanel
fx:id="bibtexKeyPatternTable"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
prefHeight="180.0"/>
<Button text="%Reset All"
onAction="#resetAllKeyPatterns"
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0"/>
</AnchorPane>
</fx:root>
Loading