Skip to content

Commit 41ebd96

Browse files
committed
Merge remote-tracking branch 'upstream/master'
* upstream/master: Ignore generated .mv file Fix checkstyle, moved some comments for better understanding Sorting custom entry fields that contain numerical values (#6426) UI consistency - BibTexStringEditorDialog rework (#6287) Squashed 'src/main/resources/csl-styles/' changes from 270cd32..c35d219
2 parents de13952 + b44d0e4 commit 41ebd96

15 files changed

+618
-134
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
src/main/gen/
33
src/main/generated/
44

5+
# the journal list cache
6+
*.mv
7+
58
# private data
69
/buildres/jabref-cert-2016.p12
710

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
5555
- We fixed an issue where JabRef switched to discrete graphics under macOS [#5935](https://github.com/JabRef/jabref/issues/5935)
5656
- We fixed an issue where the Preferences entry preview will be unexpected modified leads to Value too long exception [#6198](https://github.com/JabRef/jabref/issues/6198)
5757
- We fixed an issue where custom jstyles for Open/LibreOffice would only be valid if a layout line for the entry type `default` was at the end of the layout section [#6303](https://github.com/JabRef/jabref/issues/6303)
58+
- We fixed an issue where sort on numeric cases was broken. [#6349](https://github.com/JabRef/jabref/issues/6349)
5859

5960

6061
### Removed

src/main/java/org/jabref/gui/Base.css

+5
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@
613613
-fx-text-fill: -jr-black;
614614
}
615615

616+
.table-cell:invalid,
617+
.list-cell:invalid {
618+
-fx-background-color: -jr-warn;
619+
}
620+
616621
.combo-box-base {
617622
-fx-background-color: -fx-outer-border, -fx-control-inner-background;
618623
-fx-background-insets: 0, 1;

src/main/java/org/jabref/gui/entryeditor/EntryEditor.css

-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@
8686
-fx-background-color: -jr-error;
8787
}
8888

89-
.list-cell:invalid {
90-
-fx-background-color: -jr-warn;
91-
}
92-
9389
.code-area .context-menu {
9490
-fx-font-family: sans-serif;
9591
}

src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.jabref.gui.specialfields.SpecialFieldsPreferences;
3939
import org.jabref.gui.util.OptionalValueTableCellFactory;
4040
import org.jabref.gui.util.ValueTableCellFactory;
41+
import org.jabref.gui.util.comparator.NumericFieldComparator;
4142
import org.jabref.gui.util.comparator.PriorityFieldComparator;
4243
import org.jabref.gui.util.comparator.RankingFieldComparator;
4344
import org.jabref.gui.util.comparator.ReadStatusFieldComparator;
@@ -212,6 +213,7 @@ private Node createGroupColorRegion(BibEntryTableViewModel entry, List<AbstractG
212213
new ValueTableCellFactory<BibEntryTableViewModel, String>()
213214
.withText(text -> text)
214215
.install(column);
216+
column.setComparator(new NumericFieldComparator());
215217
column.setSortable(true);
216218
return column;
217219
}

src/main/java/org/jabref/gui/metadata/BibtexStringEditorDialog.fxml

+45-27
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,49 @@
77
<?import javafx.scene.control.TableView?>
88
<?import javafx.scene.layout.HBox?>
99
<?import javafx.scene.layout.VBox?>
10-
<DialogPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="340.0" prefWidth="427.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.metadata.BibtexStringEditorDialogView">
11-
<content>
12-
<VBox>
13-
<children>
14-
<TableView fx:id="tblStrings" prefHeight="250.0">
15-
<columns>
16-
<TableColumn fx:id="colLabel" prefWidth="75.0" text="%Label" />
17-
<TableColumn fx:id="colContent" prefWidth="75.0" text="%Content" />
18-
</columns>
19-
<columnResizePolicy>
20-
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
21-
</columnResizePolicy>
22-
</TableView>
23-
<HBox minWidth="-Infinity" prefHeight="100.0" prefWidth="300.0">
24-
<children>
25-
<Button fx:id="btnNewString" minWidth="-Infinity" mnemonicParsing="false" onAction="#addString" text="%Add new String" HBox.hgrow="ALWAYS" />
26-
<Button fx:id="btnRemove" mnemonicParsing="false" onAction="#removeString" text="%Remove selected Strings" HBox.hgrow="ALWAYS" />
27-
<Button fx:id="btnHelp" mnemonicParsing="false" onAction="#openHelp" HBox.hgrow="ALWAYS" />
28-
</children>
29-
</HBox>
30-
</children>
31-
</VBox>
32-
</content>
33-
<buttonTypes>
34-
<ButtonType fx:constant="CANCEL" />
35-
<ButtonType fx:id="saveButton" buttonData="OK_DONE" text="%Save" />
36-
</buttonTypes>
10+
<?import javafx.scene.control.Tooltip?>
11+
<?import org.jabref.gui.icon.JabRefIconView?>
12+
13+
<DialogPane minHeight="-Infinity" minWidth="-Infinity" prefHeight="350.0" prefWidth="450.0"
14+
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
15+
fx:controller="org.jabref.gui.metadata.BibtexStringEditorDialogView">
16+
<content>
17+
<HBox spacing="4.0">
18+
<VBox spacing="4.0" HBox.hgrow="ALWAYS">
19+
<TableView fx:id="stringsList">
20+
<columns>
21+
<TableColumn fx:id="labelColumn" minWidth="75.0" text="%Label"/>
22+
<TableColumn fx:id="contentColumn" minWidth="75.0" text="%Content"/>
23+
<TableColumn fx:id="actionsColumn" maxWidth="30.0" minWidth="30.0" prefWidth="30.0"
24+
editable="false" resizable="false" reorderable="false"/>
25+
</columns>
26+
<columnResizePolicy>
27+
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
28+
</columnResizePolicy>
29+
</TableView>
30+
</VBox>
31+
<VBox>
32+
<Button styleClass="icon-button,narrow" onAction="#openHelp">
33+
<graphic>
34+
<JabRefIconView glyph="HELP"/>
35+
</graphic>
36+
<tooltip>
37+
<Tooltip text="%Open Help page"/>
38+
</tooltip>
39+
</Button>
40+
<VBox VBox.vgrow="ALWAYS"/>
41+
<Button styleClass="icon-button,narrow" fx:id="addStringButton" minWidth="-Infinity"
42+
onAction="#addString">
43+
<graphic>
44+
<JabRefIconView glyph="ADD_NOBOX"/>
45+
</graphic>
46+
<tooltip>
47+
<Tooltip text="%Add new String"/>
48+
</tooltip>
49+
</Button>
50+
</VBox>
51+
</HBox>
52+
</content>
53+
<ButtonType fx:constant="CANCEL"/>
54+
<ButtonType fx:id="saveButton" buttonData="OK_DONE" text="%Save"/>
3755
</DialogPane>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.jabref.gui.metadata;
22

3+
import java.util.Optional;
4+
35
import javax.inject.Inject;
46

5-
import javafx.event.ActionEvent;
67
import javafx.fxml.FXML;
78
import javafx.scene.control.Button;
89
import javafx.scene.control.ButtonType;
@@ -13,34 +14,30 @@
1314
import javafx.util.converter.DefaultStringConverter;
1415

1516
import org.jabref.gui.DialogService;
16-
import org.jabref.gui.icon.IconTheme.JabRefIcons;
17+
import org.jabref.gui.icon.IconTheme;
1718
import org.jabref.gui.util.BaseDialog;
18-
import org.jabref.gui.util.IconValidationDecorator;
19+
import org.jabref.gui.util.ValueTableCellFactory;
1920
import org.jabref.gui.util.ViewModelTextFieldTableCellVisualizationFactory;
2021
import org.jabref.logic.l10n.Localization;
2122
import org.jabref.model.database.BibDatabase;
2223

2324
import com.airhacks.afterburner.views.ViewLoader;
24-
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
2525

2626
public class BibtexStringEditorDialogView extends BaseDialog<Void> {
2727

28-
@FXML private Button btnNewString;
29-
@FXML private Button btnRemove;
30-
@FXML private Button btnHelp;
28+
@FXML private TableView<BibtexStringEditorItemModel> stringsList;
29+
@FXML private TableColumn<BibtexStringEditorItemModel, String> labelColumn;
30+
@FXML private TableColumn<BibtexStringEditorItemModel, String> contentColumn;
31+
@FXML private TableColumn<BibtexStringEditorItemModel, String> actionsColumn;
32+
@FXML private Button addStringButton;
3133
@FXML private ButtonType saveButton;
3234

33-
@FXML private TableView<BibtexStringViewModel> tblStrings;
34-
@FXML private TableColumn<BibtexStringViewModel, String> colLabel;
35-
@FXML private TableColumn<BibtexStringViewModel, String> colContent;
36-
37-
private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer();
3835
private final BibtexStringEditorDialogViewModel viewModel;
3936

4037
@Inject private DialogService dialogService;
4138

4239
public BibtexStringEditorDialogView(BibDatabase database) {
43-
viewModel = new BibtexStringEditorDialogViewModel(database);
40+
this.viewModel = new BibtexStringEditorDialogViewModel(database);
4441

4542
ViewLoader.view(this)
4643
.load()
@@ -62,53 +59,67 @@ public BibtexStringEditorDialogView(BibDatabase database) {
6259

6360
@FXML
6461
private void initialize() {
65-
visualizer.setDecoration(new IconValidationDecorator());
66-
67-
btnHelp.setGraphic(JabRefIcons.HELP.getGraphicNode());
68-
btnHelp.setTooltip(new Tooltip(Localization.lang("Open Help page")));
62+
addStringButton.setTooltip(new Tooltip(Localization.lang("New string")));
6963

70-
btnNewString.setTooltip(new Tooltip(Localization.lang("New string")));
71-
btnRemove.setTooltip(new Tooltip(Localization.lang("Remove selected strings")));
64+
labelColumn.setSortable(true);
65+
labelColumn.setReorderable(false);
7266

73-
colLabel.setCellValueFactory(cellData -> cellData.getValue().labelProperty());
74-
new ViewModelTextFieldTableCellVisualizationFactory<BibtexStringViewModel, String>().withValidation(BibtexStringViewModel::labelValidation, visualizer).install(colLabel, new DefaultStringConverter());
67+
labelColumn.setCellValueFactory(cellData -> cellData.getValue().labelProperty());
68+
new ViewModelTextFieldTableCellVisualizationFactory<BibtexStringEditorItemModel, String>()
69+
.withValidation(BibtexStringEditorItemModel::labelValidation)
70+
.install(labelColumn, new DefaultStringConverter());
71+
labelColumn.setOnEditCommit((CellEditEvent<BibtexStringEditorItemModel, String> cellEvent) -> {
7572

76-
colContent.setCellValueFactory(cellData -> cellData.getValue().contentProperty());
77-
new ViewModelTextFieldTableCellVisualizationFactory<BibtexStringViewModel, String>().withValidation(BibtexStringViewModel::contentValidation, visualizer).install(colContent, new DefaultStringConverter());
73+
BibtexStringEditorItemModel cellItem = cellEvent.getTableView()
74+
.getItems()
75+
.get(cellEvent.getTablePosition().getRow());
7876

79-
colLabel.setOnEditCommit((CellEditEvent<BibtexStringViewModel, String> cell) -> {
77+
Optional<BibtexStringEditorItemModel> existingItem = viewModel.labelAlreadyExists(cellEvent.getNewValue());
8078

81-
String newLabelValue = cell.getNewValue();
82-
if (cell.getTableView().getItems().stream().anyMatch(strs -> strs.labelProperty().get().equals(newLabelValue))) {
79+
if (existingItem.isPresent() && !existingItem.get().equals(cellItem)) {
80+
dialogService.showErrorDialogAndWait(Localization.lang(
81+
"A string with the label '%0' already exists.",
82+
cellEvent.getNewValue()));
8383

84-
dialogService.showErrorDialogAndWait(Localization.lang("A string with the label '%0' already exists.", newLabelValue));
85-
cell.getRowValue().setLabel("");
84+
cellItem.setLabel(cellEvent.getOldValue());
8685
} else {
87-
cell.getRowValue().setLabel(cell.getNewValue());
86+
cellItem.setLabel(cellEvent.getNewValue());
8887
}
89-
});
90-
colContent.setOnEditCommit((CellEditEvent<BibtexStringViewModel, String> cell) -> {
91-
cell.getRowValue().setContent(cell.getNewValue());
92-
});
9388

94-
tblStrings.itemsProperty().bindBidirectional(viewModel.allStringsProperty());
95-
tblStrings.setEditable(true);
89+
cellEvent.getTableView().refresh();
90+
});
9691

97-
viewModel.seletedItemProperty().bind(tblStrings.getSelectionModel().selectedItemProperty());
92+
contentColumn.setSortable(true);
93+
contentColumn.setReorderable(false);
94+
contentColumn.setCellValueFactory(cellData -> cellData.getValue().contentProperty());
95+
new ViewModelTextFieldTableCellVisualizationFactory<BibtexStringEditorItemModel, String>()
96+
.withValidation(BibtexStringEditorItemModel::contentValidation)
97+
.install(contentColumn, new DefaultStringConverter());
98+
contentColumn.setOnEditCommit((CellEditEvent<BibtexStringEditorItemModel, String> cell) ->
99+
cell.getRowValue().setContent(cell.getNewValue()));
100+
101+
actionsColumn.setSortable(false);
102+
actionsColumn.setReorderable(false);
103+
actionsColumn.setCellValueFactory(cellData -> cellData.getValue().labelProperty());
104+
new ValueTableCellFactory<BibtexStringEditorItemModel, String>()
105+
.withGraphic(label -> IconTheme.JabRefIcons.DELETE_ENTRY.getGraphicNode())
106+
.withTooltip(label -> Localization.lang("Remove string %0", label))
107+
.withOnMouseClickedEvent(item -> evt ->
108+
viewModel.removeString(stringsList.getFocusModel().getFocusedItem()))
109+
.install(actionsColumn);
110+
111+
stringsList.itemsProperty().bindBidirectional(viewModel.stringsListProperty());
112+
stringsList.setEditable(true);
98113
}
99114

100115
@FXML
101-
private void addString(ActionEvent event) {
116+
private void addString() {
102117
viewModel.addNewString();
118+
stringsList.edit(stringsList.getItems().size() - 1, labelColumn);
103119
}
104120

105121
@FXML
106-
private void openHelp(ActionEvent event) {
122+
private void openHelp() {
107123
viewModel.openHelpPage();
108124
}
109-
110-
@FXML
111-
private void removeString(ActionEvent event) {
112-
viewModel.removeString();
113-
}
114125
}

0 commit comments

Comments
 (0)