Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabular UI for naming linked files #12624

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9b11edf
Add fix options for integrity issues
priyanshu16095 Feb 12, 2025
02d8e75
Fix the check
priyanshu16095 Feb 12, 2025
754b6ad
Add a missing entry for Localization.lang
priyanshu16095 Feb 12, 2025
696f904
Fix the check
priyanshu16095 Feb 12, 2025
4ab36a8
Refactor code
priyanshu16095 Feb 14, 2025
28de796
Fix the check
priyanshu16095 Feb 14, 2025
70ae8eb
Add a CHANGELOG.md entry
priyanshu16095 Feb 14, 2025
77df6ea
Refactor the code
priyanshu16095 Feb 19, 2025
30c81ce
Make use of IntegrityIssue enum
priyanshu16095 Feb 20, 2025
5b389da
Add keys in Localization.lang
priyanshu16095 Feb 20, 2025
3a0d9a1
Refactor the code
priyanshu16095 Feb 20, 2025
a04e06a
Remove use of enum
priyanshu16095 Feb 20, 2025
8e9341a
Remove use of enum from PageChecker class
priyanshu16095 Feb 20, 2025
235c74f
Add fixAll method
priyanshu16095 Feb 20, 2025
9839137
Add a check for fixAll and fixByType method
priyanshu16095 Feb 20, 2025
5754680
Fix a bug
priyanshu16095 Feb 20, 2025
8f7bdc2
Use dialogService.notify() to notify
priyanshu16095 Feb 22, 2025
f57719c
Remove unused imports
priyanshu16095 Feb 22, 2025
2105a13
Merge branch 'main' into integrityCheckActions
priyanshu16095 Feb 22, 2025
e37ba79
Merge branch 'main' into integrityCheckActions
priyanshu16095 Feb 23, 2025
139777e
Add tests for methods
priyanshu16095 Feb 25, 2025
39dbfd1
Fix the check and updates based on review
priyanshu16095 Feb 26, 2025
16e9817
Use enum for passing issue message
priyanshu16095 Feb 28, 2025
102e789
Fix the checkstyle check
priyanshu16095 Feb 28, 2025
92d91b5
Add the gui
priyanshu16095 Mar 3, 2025
b726f30
Add files in logic directory
priyanshu16095 Mar 5, 2025
86518fc
Revert changes in three files
priyanshu16095 Mar 5, 2025
6f985ec
Revert some more files
priyanshu16095 Mar 5, 2025
5ea4754
Revert some more files
priyanshu16095 Mar 5, 2025
237af3d
Revert changes
priyanshu16095 Mar 5, 2025
038f8e2
Revert changes
priyanshu16095 Mar 5, 2025
e5e4f75
Revert changes
priyanshu16095 Mar 5, 2025
7c7ddd1
Revert changes
priyanshu16095 Mar 5, 2025
3e795c7
Remove comment
priyanshu16095 Mar 5, 2025
1f84f0f
Rename variables
priyanshu16095 Mar 5, 2025
429af55
Show entry types in table
priyanshu16095 Mar 6, 2025
3c1708d
Add a CHANGELOG.md entry and Fix the check
priyanshu16095 Mar 6, 2025
995760a
Merge branch 'main' into tabularUI
priyanshu16095 Mar 6, 2025
0c44228
Add more patterns and solve dropdown UI issue
priyanshu16095 Mar 6, 2025
d0153e5
Change default pattern
priyanshu16095 Mar 6, 2025
6715540
Remove commented code
priyanshu16095 Mar 7, 2025
5036cf5
Remove commented method
priyanshu16095 Mar 7, 2025
5d5ada3
Add preference migration
priyanshu16095 Mar 11, 2025
88c9e4f
Merge branch 'main' of https://github.com/priyanshu16095/jabref into …
priyanshu16095 Mar 16, 2025
de46be4
Rename LinkedFileNamePattern and CitationKeyPattern to Pattern
priyanshu16095 Mar 21, 2025
279ce8f
Merge branch 'main' into tabularUI
priyanshu16095 Mar 21, 2025
a3383a2
Renmae LinkedFileNamePatternsPanelItemModel and CitationKeyPatternsIt…
priyanshu16095 Mar 21, 2025
967a4a5
Rename LinkedFileNamePatternsSuggestionCell and CitationKeyPatternsSu…
priyanshu16095 Mar 21, 2025
1261731
Fix the checkstyle check
priyanshu16095 Mar 21, 2025
965d4df
Remove the redundant check
priyanshu16095 Mar 21, 2025
a0a00ef
Fix the check
priyanshu16095 Mar 21, 2025
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 @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added a table for naming linked files in the Linked Files tab in Preferences. [#11368](https://github.com/JabRef/jabref/issues/11368)
- We added a new Welcome tab which shows a welcome screen if no database is open. [#12272](https://github.com/JabRef/jabref/issues/12272)
- We added <kbd>F5</kbd> as a shortcut key for fetching data and <kbd>Alt+F</kbd> as a shortcut for looking up data using DOI. [#11802](https://github.com/JabRef/jabref/issues/11802)
- We added a feature to rename the subgroup, with the keybinding (<kbd>F2</kbd>) for quick access. [#11896](https://github.com/JabRef/jabref/issues/11896)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.ValueTableCellFactory;
import org.jabref.logic.citationkeypattern.AbstractCitationKeyPatterns;
import org.jabref.logic.citationkeypattern.CitationKeyPattern;
import org.jabref.logic.citationkeypattern.Pattern;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.model.entry.BibEntryType;
Expand All @@ -24,11 +24,11 @@
import com.airhacks.afterburner.views.ViewLoader;
import jakarta.inject.Inject;

public class CitationKeyPatternsPanel extends TableView<CitationKeyPatternsPanelItemModel> {
public class CitationKeyPatternsPanel extends TableView<PatternsItemModel> {

@FXML public TableColumn<CitationKeyPatternsPanelItemModel, EntryType> entryTypeColumn;
@FXML public TableColumn<CitationKeyPatternsPanelItemModel, String> patternColumn;
@FXML public TableColumn<CitationKeyPatternsPanelItemModel, EntryType> actionsColumn;
@FXML public TableColumn<PatternsItemModel, EntryType> entryTypeColumn;
@FXML public TableColumn<PatternsItemModel, String> patternColumn;
@FXML public TableColumn<PatternsItemModel, EntryType> actionsColumn;

@Inject private CliPreferences preferences;

Expand All @@ -41,9 +41,9 @@ public class CitationKeyPatternsPanel extends TableView<CitationKeyPatternsPanel
public CitationKeyPatternsPanel() {
super();
this.patterns = FXCollections.observableArrayList(
CitationKeyPattern.getAllPatterns().stream()
.map(CitationKeyPattern::stringRepresentation)
.toList()
Pattern.getAllPatterns().stream()
.map(Pattern::stringRepresentation)
.toList()
);

ViewLoader.view(this)
Expand All @@ -60,7 +60,7 @@ private void initialize() {
entryTypeColumn.setSortable(true);
entryTypeColumn.setReorderable(false);
entryTypeColumn.setCellValueFactory(cellData -> cellData.getValue().entryType());
new ValueTableCellFactory<CitationKeyPatternsPanelItemModel, EntryType>()
new ValueTableCellFactory<PatternsItemModel, EntryType>()
.withText(EntryType::getDisplayName)
.install(entryTypeColumn);
this.setOnSort(event ->
Expand All @@ -69,16 +69,16 @@ private void initialize() {
patternColumn.setSortable(true);
patternColumn.setReorderable(false);
patternColumn.setCellValueFactory(cellData -> cellData.getValue().pattern());
patternColumn.setCellFactory(_ -> new CitationKeyPatternSuggestionCell(patterns));
patternColumn.setCellFactory(_ -> new PatternSuggestionCell(patterns));
patternColumn.setEditable(true);
patternColumn.setOnEditCommit(
(TableColumn.CellEditEvent<CitationKeyPatternsPanelItemModel, String> event) ->
(TableColumn.CellEditEvent<PatternsItemModel, String> event) ->
event.getRowValue().setPattern(event.getNewValue()));

actionsColumn.setSortable(false);
actionsColumn.setReorderable(false);
actionsColumn.setCellValueFactory(cellData -> cellData.getValue().entryType());
new ValueTableCellFactory<CitationKeyPatternsPanelItemModel, EntryType>()
new ValueTableCellFactory<PatternsItemModel, EntryType>()
.withGraphic(entryType -> IconTheme.JabRefIcons.REFRESH.getGraphicNode())
.withTooltip(entryType ->
Localization.lang("Reset %s to default value").formatted(entryType.getDisplayName()))
Expand All @@ -99,11 +99,11 @@ public void resetAll() {
viewModel.resetAll();
}

public ListProperty<CitationKeyPatternsPanelItemModel> patternListProperty() {
public ListProperty<PatternsItemModel> patternListProperty() {
return viewModel.patternListProperty();
}

public ObjectProperty<CitationKeyPatternsPanelItemModel> defaultKeyPatternProperty() {
public ObjectProperty<PatternsItemModel> defaultKeyPatternProperty() {
return viewModel.defaultKeyPatternProperty();
}

Expand All @@ -124,9 +124,9 @@ private void jumpToSearchKey(KeyEvent keypressed) {
.findFirst().ifPresent(this::scrollTo);
}

private static class HighlightTableRow extends TableRow<CitationKeyPatternsPanelItemModel> {
private static class HighlightTableRow extends TableRow<PatternsItemModel> {
@Override
public void updateItem(CitationKeyPatternsPanelItemModel item, boolean empty) {
public void updateItem(PatternsItemModel item, boolean empty) {
super.updateItem(item, empty);
if (item == null || item.getEntryType() == null) {
setStyle("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import javafx.collections.FXCollections;

import org.jabref.logic.citationkeypattern.AbstractCitationKeyPatterns;
import org.jabref.logic.citationkeypattern.CitationKeyPattern;
import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences;
import org.jabref.logic.citationkeypattern.Pattern;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.EntryType;
Expand All @@ -20,7 +20,7 @@ public class CitationKeyPatternsPanelViewModel {

public static final String ENTRY_TYPE_DEFAULT_NAME = "default";

public static Comparator<CitationKeyPatternsPanelItemModel> defaultOnTopComparator = (o1, o2) -> {
public static Comparator<PatternsItemModel> defaultOnTopComparator = (o1, o2) -> {
String itemOneName = o1.getEntryType().getName();
String itemTwoName = o2.getEntryType().getName();

Expand All @@ -35,8 +35,8 @@ public class CitationKeyPatternsPanelViewModel {
return 0;
};

private final ListProperty<CitationKeyPatternsPanelItemModel> patternListProperty = new SimpleListProperty<>();
private final ObjectProperty<CitationKeyPatternsPanelItemModel> defaultItemProperty = new SimpleObjectProperty<>();
private final ListProperty<PatternsItemModel> patternListProperty = new SimpleListProperty<>();
private final ObjectProperty<PatternsItemModel> defaultItemProperty = new SimpleObjectProperty<>();

private final CitationKeyPatternPreferences keyPatternPreferences;

Expand All @@ -46,13 +46,13 @@ public CitationKeyPatternsPanelViewModel(CitationKeyPatternPreferences keyPatter

public void setValues(Collection<BibEntryType> entryTypeList, AbstractCitationKeyPatterns initialKeyPattern) {
String defaultPattern;
if ((initialKeyPattern.getDefaultValue() == null) || initialKeyPattern.getDefaultValue().equals(CitationKeyPattern.NULL_CITATION_KEY_PATTERN)) {
if ((initialKeyPattern.getDefaultValue() == null) || initialKeyPattern.getDefaultValue().equals(Pattern.NULL_PATTERN)) {
defaultPattern = "";
} else {
defaultPattern = initialKeyPattern.getDefaultValue().stringRepresentation();
}

defaultItemProperty.setValue(new CitationKeyPatternsPanelItemModel(new DefaultEntryType(), defaultPattern));
defaultItemProperty.setValue(new PatternsItemModel(new DefaultEntryType(), defaultPattern));
patternListProperty.setValue(FXCollections.observableArrayList());
patternListProperty.add(defaultItemProperty.getValue());

Expand All @@ -65,11 +65,11 @@ public void setValues(Collection<BibEntryType> entryTypeList, AbstractCitationKe
} else {
pattern = initialKeyPattern.getPatterns().get(entryType).stringRepresentation();
}
patternListProperty.add(new CitationKeyPatternsPanelItemModel(entryType, pattern));
patternListProperty.add(new PatternsItemModel(entryType, pattern));
});
}

public void setItemToDefaultPattern(CitationKeyPatternsPanelItemModel item) {
public void setItemToDefaultPattern(PatternsItemModel item) {
item.setPattern(keyPatternPreferences.getDefaultPattern());
}

Expand All @@ -78,11 +78,11 @@ public void resetAll() {
defaultItemProperty.getValue().setPattern(keyPatternPreferences.getDefaultPattern());
}

public ListProperty<CitationKeyPatternsPanelItemModel> patternListProperty() {
public ListProperty<PatternsItemModel> patternListProperty() {
return patternListProperty;
}

public ObjectProperty<CitationKeyPatternsPanelItemModel> defaultKeyPatternProperty() {
public ObjectProperty<PatternsItemModel> defaultKeyPatternProperty() {
return defaultItemProperty;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.stage.Window;

import org.jabref.logic.citationkeypattern.CitationKeyPattern;
import org.jabref.logic.citationkeypattern.Pattern;
import org.jabref.logic.l10n.Localization;

public class CitationKeyPatternSuggestionCell extends TextFieldTableCell<CitationKeyPatternsPanelItemModel, String> {
public class PatternSuggestionCell extends TextFieldTableCell<PatternsItemModel, String> {
private final CitationKeyPatternSuggestionTextField searchField;

public CitationKeyPatternSuggestionCell(List<String> citationKeyPatterns) {
public PatternSuggestionCell(List<String> citationKeyPatterns) {
this.searchField = new CitationKeyPatternSuggestionTextField(citationKeyPatterns);
searchField.setOnAction(event -> commitEdit(searchField.getText()));
}
Expand Down Expand Up @@ -145,10 +145,6 @@ public static double getAvailableSpaceBelow(TextField textField) {
}

Window window = textField.getScene().getWindow();
if (window == null) {
return 0;
}

Bounds bounds = textField.localToScreen(textField.getBoundsInLocal());
double screenHeight = window.getHeight();
double textFieldBottom = bounds.getMinY() + textField.getHeight();
Expand All @@ -159,26 +155,26 @@ public static double getAvailableSpaceBelow(TextField textField) {
private Menu createPatternsSubMenu() {
Menu patternsSubMenu = new Menu(Localization.lang("All patterns"));

Map<CitationKeyPattern.Category, List<CitationKeyPattern>> categorizedPatterns =
CitationKeyPattern.getAllPatterns().stream()
.collect(Collectors.groupingBy(CitationKeyPattern::getCategory));
Map<Pattern.Category, List<Pattern>> categorizedPatterns =
Pattern.getAllPatterns().stream()
.collect(Collectors.groupingBy(Pattern::getCategory));

Map<CitationKeyPattern.Category, String> categoryNames = Map.of(
CitationKeyPattern.Category.AUTHOR_RELATED, Localization.lang("Author related"),
CitationKeyPattern.Category.EDITOR_RELATED, Localization.lang("Editor related"),
CitationKeyPattern.Category.TITLE_RELATED, Localization.lang("Title related"),
CitationKeyPattern.Category.OTHER_FIELDS, Localization.lang("Other fields"),
CitationKeyPattern.Category.BIBENTRY_FIELDS, Localization.lang("Entry fields")
Map<Pattern.Category, String> categoryNames = Map.of(
Pattern.Category.AUTHOR_RELATED, Localization.lang("Author related"),
Pattern.Category.EDITOR_RELATED, Localization.lang("Editor related"),
Pattern.Category.TITLE_RELATED, Localization.lang("Title related"),
Pattern.Category.OTHER_FIELDS, Localization.lang("Other fields"),
Pattern.Category.BIBENTRY_FIELDS, Localization.lang("Entry fields")
);

for (Map.Entry<CitationKeyPattern.Category, String> entry : categoryNames.entrySet()) {
CitationKeyPattern.Category category = entry.getKey();
for (Map.Entry<Pattern.Category, String> entry : categoryNames.entrySet()) {
Pattern.Category category = entry.getKey();
String categoryName = entry.getValue();

Menu categoryMenu = new Menu(categoryName);
List<CitationKeyPattern> patterns = categorizedPatterns.getOrDefault(category, List.of());
List<Pattern> patterns = categorizedPatterns.getOrDefault(category, List.of());

for (CitationKeyPattern pattern : patterns) {
for (Pattern pattern : patterns) {
MenuItem menuItem = new MenuItem(pattern.stringRepresentation());
menuItem.setOnAction(event -> {
setText(pattern.stringRepresentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

import org.jabref.model.entry.types.EntryType;

public class CitationKeyPatternsPanelItemModel {
public class PatternsItemModel {
private final ObjectProperty<EntryType> entryType = new SimpleObjectProperty<>();
private final StringProperty pattern = new SimpleStringProperty("");

public CitationKeyPatternsPanelItemModel(EntryType entryType, String pattern) {
public PatternsItemModel(EntryType entryType, String pattern) {
Objects.requireNonNull(entryType);
Objects.requireNonNull(pattern);
this.entryType.setValue(entryType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;

import org.jabref.gui.commonfxcontrols.CitationKeyPatternsPanelItemModel;
import org.jabref.gui.commonfxcontrols.CitationKeyPatternsPanelViewModel;
import org.jabref.gui.commonfxcontrols.PatternsItemModel;
import org.jabref.gui.libraryproperties.PropertiesTabViewModel;
import org.jabref.logic.citationkeypattern.DatabaseCitationKeyPatterns;
import org.jabref.logic.preferences.CliPreferences;
Expand All @@ -17,9 +17,9 @@ public class KeyPatternPropertiesViewModel implements PropertiesTabViewModel {

// The list and the default properties are being overwritten by the bound properties of the tableView, but to
// prevent an NPE on storing the preferences before lazy-loading of the setValues, they need to be initialized.
private final ListProperty<CitationKeyPatternsPanelItemModel> patternListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ObjectProperty<CitationKeyPatternsPanelItemModel> defaultKeyPatternProperty = new SimpleObjectProperty<>(
new CitationKeyPatternsPanelItemModel(new CitationKeyPatternsPanelViewModel.DefaultEntryType(), ""));
private final ListProperty<PatternsItemModel> patternListProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ObjectProperty<PatternsItemModel> defaultKeyPatternProperty = new SimpleObjectProperty<>(
new PatternsItemModel(new CitationKeyPatternsPanelViewModel.DefaultEntryType(), ""));

private final CliPreferences preferences;

Expand Down Expand Up @@ -57,11 +57,11 @@ public void storeSettings() {
databaseContext.getMetaData().setCiteKeyPattern(newKeyPattern);
}

public ListProperty<CitationKeyPatternsPanelItemModel> patternListProperty() {
public ListProperty<PatternsItemModel> patternListProperty() {
return patternListProperty;
}

public ObjectProperty<CitationKeyPatternsPanelItemModel> defaultKeyPatternProperty() {
public ObjectProperty<PatternsItemModel> defaultKeyPatternProperty() {
return defaultKeyPatternProperty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<fx:root editable="true" minWidth="280.0" type="TableView"
xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.jabref.gui.linkedfile.LinkedFileNamePatternsPanel">
<columns>
<TableColumn fx:id="entryTypeColumn" editable="false" minWidth="100.0" text="%Name"/>
<TableColumn fx:id="patternColumn" minWidth="100.0" text="%Key pattern"/>
<TableColumn fx:id="actionsColumn" editable="false" maxWidth="30.0" minWidth="30.0" prefWidth="30.0"
reorderable="false" resizable="false" sortable="false"/>
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
</columnResizePolicy>
</fx:root>
Loading
Loading