Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into controlsfx-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
calixtus committed Aug 1, 2022
2 parents bcc9098 + 0d82506 commit c40d5f9
Show file tree
Hide file tree
Showing 92 changed files with 4,653 additions and 3,425 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- JabRef now writes log files. Linux: `$home/.cache/jabref/logs/version`, Windows: `%APPDATA%\..\Local\harawata\jabref\version\logs`, Mac: `Users/.../Library/Logs/jabref/version`
- We added an importer for Citavi backup files, support ".ctv5bak" and ".ctv6bak" file formats. [#8322](https://github.com/JabRef/jabref/issues/8322)
- We added a feature to drag selected entries and drop them to other opened inactive library tabs [koppor521](https://github.com/koppor/jabref/issues/521).
- We added support for the [biblatex-apa](https://github.com/plk/biblatex-apa) legal entry types `Legislation`, `Legadminmaterial`, `Jurisdiction`, `Constitution` and `Legal` [#8931](https://github.com/JabRef/jabref/issues/8931)

### Changed

Expand Down
18 changes: 7 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ repositories {
}

configurations {
antlr3
antlr4
// TODO: Remove the following workaround for split error messages such as
// error: module java.xml.bind reads package javax.annotation from both jsr305 and java.annotation
Expand Down Expand Up @@ -139,9 +138,6 @@ dependencies {
implementation 'io.github.java-diff-utils:java-diff-utils:4.12'
implementation 'info.debatty:java-string-similarity:2.0.0'

antlr3 'org.antlr:antlr:3.5.3'
implementation 'org.antlr:antlr-runtime:3.5.3'

antlr4 'org.antlr:antlr4:4.9.3'
implementation 'org.antlr:antlr4-runtime:4.9.3'

Expand Down Expand Up @@ -212,8 +208,8 @@ dependencies {
implementation group: 'net.harawata', name: 'appdirs', version: '1.2.1'

testImplementation 'io.github.classgraph:classgraph:4.8.149'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.9.0'

testImplementation 'org.mockito:mockito-core:4.6.1'
testImplementation 'org.xmlunit:xmlunit-core:2.9.0'
Expand Down Expand Up @@ -277,14 +273,14 @@ task generateSource(dependsOn: ["generateBstGrammarSource",
}

tasks.register("generateBstGrammarSource", JavaExec) {
main = "org.antlr.Tool"
classpath = configurations.antlr3
main = "org.antlr.v4.Tool"
classpath = configurations.antlr4
group = "JabRef"
description = 'Generates BstLexer.java and BstParser.java from the Bst.g grammar file using antlr3.'
description = 'Generates BstLexer.java and BstParser.java from the Bst.g grammar file using antlr4.'

inputs.dir('src/main/antlr3/org/jabref/bst/')
inputs.dir('src/main/antlr4/org/jabref/bst/')
outputs.dir("src-gen/main/java/org/jabref/logic/bst/")
args = ["-o", "src-gen/main/java/org/jabref/logic/bst/" , "$projectDir/src/main/antlr3/org/jabref/bst/Bst.g" ]
args = ["-o", "src-gen/main/java/org/jabref/logic/bst/", "-visitor", "-no-listener", "-package", "org.jabref.logic.bst", "$projectDir/src/main/antlr4/org/jabref/bst/Bst.g4"]
}

tasks.register("generateSearchGrammarSource", JavaExec) {
Expand Down
96 changes: 0 additions & 96 deletions src/main/antlr3/org/jabref/bst/Bst.g

This file was deleted.

85 changes: 85 additions & 0 deletions src/main/antlr4/org/jabref/bst/Bst.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
grammar Bst;

// Lexer

STRINGS : 'STRINGS';
INTEGERS : 'INTEGERS';
FUNCTION : 'FUNCTION';
EXECUTE : 'EXECUTE';
SORT : 'SORT';
ITERATE : 'ITERATE';
REVERSE : 'REVERSE';
ENTRY : 'ENTRY';
READ : 'READ';
MACRO : 'MACRO';

GT : '>';
LT : '<';
EQUAL : '=';
ASSIGN : ':=';
ADD : '+';
SUB : '-';
CONCAT : '*';
LBRACE : '{';
RBRACE : '}';

fragment LETTER : ('a'..'z'|'A'..'Z'|'.'|'$');
fragment NUMERAL : ('0'..'9');

IDENTIFIER : LETTER (LETTER|NUMERAL|'_')*;
INTEGER : '#' ('+'|'-')? NUMERAL+;
QUOTED : '\'' IDENTIFIER;
STRING : '"' (~('"'))* '"';

WS: [ \r\n\t]+ -> skip;
LINE_COMMENT : '%' ~('\n'|'\r')* '\r'? '\n' -> skip;

// Parser

bstFile
: commands+ EOF
;

commands
: STRINGS ids=idListObl #stringsCommand
| INTEGERS ids=idListObl #integersCommand
| FUNCTION LBRACE id=identifier RBRACE function=stack #functionCommand
| MACRO LBRACE id=identifier RBRACE LBRACE repl=STRING RBRACE #macroCommand
| READ #readCommand
| EXECUTE LBRACE bstFunction RBRACE #executeCommand
| ITERATE LBRACE bstFunction RBRACE #iterateCommand
| REVERSE LBRACE bstFunction RBRACE #reverseCommand
| ENTRY idListOpt idListOpt idListOpt #entryCommand
| SORT #sortCommand
;

identifier
: IDENTIFIER
;

// Obligatory identifier list
idListObl
: LBRACE identifier+ RBRACE
;

// Optional identifier list
idListOpt
: LBRACE identifier* RBRACE
;

bstFunction
: LT | GT | EQUAL | ADD | SUB | ASSIGN | CONCAT
| identifier
;

stack
: LBRACE stackitem+ RBRACE
;

stackitem
: bstFunction
| STRING
| INTEGER
| QUOTED
| stack
;
1 change: 0 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
requires org.mariadb.jdbc;
uses org.mariadb.jdbc.credential.CredentialPlugin;
requires org.apache.commons.lang3;
requires antlr.runtime;
requires org.antlr.antlr4.runtime;
requires org.fxmisc.flowless;
requires org.apache.tika.core;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.types.BiblatexAPAEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexEntryTypeDefinitions;
import org.jabref.model.entry.types.BiblatexSoftwareEntryTypeDefinitions;
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions;
Expand Down Expand Up @@ -157,6 +158,7 @@ public void initialize() {
.filter(e -> !recommendedEntries.contains(e))
.collect(Collectors.toList());
otherEntries.addAll(BiblatexSoftwareEntryTypeDefinitions.ALL);
otherEntries.addAll(BiblatexAPAEntryTypeDefinitions.ALL);
} else {
recommendedEntries = BibtexEntryTypeDefinitions.RECOMMENDED;
otherEntries = BibtexEntryTypeDefinitions.ALL
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/jabref/gui/StateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyListProperty;
import javafx.beans.property.ReadOnlyListWrapper;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
import javafx.concurrent.Task;
import javafx.scene.Node;
import javafx.util.Pair;

import org.jabref.gui.edit.automaticfiededitor.LastAutomaticFieldEditorEdit;
import org.jabref.gui.sidepane.SidePaneType;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.CustomLocalDragboard;
Expand Down Expand Up @@ -62,6 +65,8 @@ public class StateManager {
private final ObservableMap<String, DialogWindowState> dialogWindowStates = FXCollections.observableHashMap();
private final ObservableList<SidePaneType> visibleSidePanes = FXCollections.observableArrayList();

private final ObjectProperty<LastAutomaticFieldEditorEdit> lastAutomaticFieldEditorEdit = new SimpleObjectProperty<>();

public StateManager() {
activeGroups.bind(Bindings.valueAt(selectedGroups, activeDatabase.orElse(null)));
}
Expand Down Expand Up @@ -172,4 +177,16 @@ public DialogWindowState getDialogWindowState(String className) {
public void setDialogWindowState(String className, DialogWindowState state) {
dialogWindowStates.put(className, state);
}

public ObjectProperty<LastAutomaticFieldEditorEdit> lastAutomaticFieldEditorEditProperty() {
return lastAutomaticFieldEditorEdit;
}

public LastAutomaticFieldEditorEdit getLastAutomaticFieldEditorEdit() {
return lastAutomaticFieldEditorEditProperty().get();
}

public void setLastAutomaticFieldEditorEdit(LastAutomaticFieldEditorEdit automaticFieldEditorEdit) {
lastAutomaticFieldEditorEditProperty().set(automaticFieldEditorEdit);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.jabref.gui.edit.automaticfiededitor;

import java.util.Collection;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.StateManager;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class AbstractAutomaticFieldEditorTabViewModel extends AbstractViewModel {
public static final Logger LOGGER = LoggerFactory.getLogger(AbstractAutomaticFieldEditorTabViewModel.class);

protected final StateManager stateManager;

private final ObservableList<Field> allFields = FXCollections.observableArrayList();

public AbstractAutomaticFieldEditorTabViewModel(BibDatabase bibDatabase, StateManager stateManager) {
Objects.requireNonNull(bibDatabase);
Objects.requireNonNull(stateManager);
this.stateManager = stateManager;

addFields(EnumSet.allOf(StandardField.class));
addFields(bibDatabase.getAllVisibleFields());
allFields.sort(Comparator.comparing(Field::getName));
}

public ObservableList<Field> getAllFields() {
return allFields;
}

private void addFields(Collection<? extends Field> fields) {
Set<Field> fieldsSet = new HashSet<>(allFields);
fieldsSet.addAll(fields);
allFields.setAll(fieldsSet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public AutomaticFieldEditorAction(StateManager stateManager, DialogService dialo

@Override
public void execute() {
dialogService.showCustomDialogAndWait(new AutomaticFieldEditorDialog(stateManager.getSelectedEntries(),
stateManager.getActiveDatabase().orElseThrow()));
dialogService.showCustomDialogAndWait(new AutomaticFieldEditorDialog(stateManager));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE"/>
</content>
<ButtonType fx:id="saveButton" text="Keep Modifications" buttonData="OK_DONE"/>
<ButtonType fx:id="cancelButton"
text="Revert" buttonData="CANCEL_CLOSE"/>
<ButtonType fx:constant="CANCEL"/>
</DialogPane>
Loading

0 comments on commit c40d5f9

Please sign in to comment.