Skip to content

Commit eb18adf

Browse files
committed
Fixed all the unnecessary things
1 parent dc90043 commit eb18adf

File tree

12 files changed

+2260
-137
lines changed

12 files changed

+2260
-137
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
8383
- We removed support for MySQL/MariaDB and Oracle. [#12990](https://github.com/JabRef/jabref/pull/12990)
8484
- We removed library migrations (users need to use JabRef 6.0-alpha.1 to perform migrations) [#12990](https://github.com/JabRef/jabref/pull/12990)
8585

86+
8687
## [6.0-alpha2] – 2025-04-27
8788

8889
### Added

jabgui/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
requires java.sql.rowset;
1212

1313
// region JavaFX
14-
requires javafx.swing;
1514
requires javafx.base;
1615
requires javafx.controls;
1716
requires javafx.fxml;

jabgui/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static FieldEditorFX getForField(final Field field,
9090
MonthEditorViewModel(field, suggestionProvider, databaseContext.getMode(), fieldCheckers, undoManager));
9191
} else if (fieldProperties.contains(FieldProperty.LANGUAGE)) {
9292
return new OptionEditor<>(new LanguageEditorViewModel(field, suggestionProvider, databaseContext.getMode(), fieldCheckers, undoManager));
93-
} else if (field == StandardField.ICORANKING) {
93+
} else if (field == StandardField.ICORERANKING) {
9494
return new ICoreRankingEditor(field);
9595
} else if (field == StandardField.GENDER) {
9696
return new OptionEditor<>(new GenderEditorViewModel(field, suggestionProvider, fieldCheckers, undoManager));

jabgui/src/main/java/org/jabref/gui/fieldeditors/ICoreRankingEditor.java

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import javafx.scene.control.Button;
99
import javafx.scene.control.TextField;
1010
import javafx.scene.control.TextInputControl;
11+
import javafx.scene.control.Tooltip;
1112
import javafx.scene.layout.HBox;
13+
import org.jabref.gui.icon.IconTheme;
1214
import org.jabref.gui.keyboard.KeyBindingRepository;
1315
import org.jabref.gui.undo.RedoAction;
1416
import org.jabref.gui.undo.UndoAction;
@@ -33,67 +35,24 @@ public ICoreRankingEditor(Field field) {
3335

3436
this.textField.setPromptText("Enter or lookup ICORE rank");
3537

36-
Button lookupButton = new Button("Lookup Rank");
38+
// Button lookupButton = new Button("Lookup Rank");
39+
Button lookupButton = new Button();
40+
lookupButton.getStyleClass().setAll("icon-button");
41+
lookupButton.setGraphic(IconTheme.JabRefIcons.LOOKUP_IDENTIFIER.getGraphicNode());
42+
lookupButton.setTooltip(new Tooltip("Look up Icore Rank"));
3743
lookupButton.setOnAction(event -> lookupRank());
38-
3944
this.getChildren().addAll(textField, lookupButton);
4045
this.setSpacing(10);
46+
47+
lookupButton.setOnAction(event -> lookupRank());
4148
}
4249

43-
// Deprecated method it only shows rank by puttin the acronym in the text field
44-
// private void lookupRank() {
45-
// if (currentEntry == null) {
46-
//// System.out.println("No entry is currently bound.");
47-
// return;
48-
// }
49-
//
50-
// // 1. Try icoreranking field first
51-
// Optional<String> icoreField = currentEntry.getField(StandardField.ICORANKING);
52-
// if (icoreField.isPresent()) {
53-
// String raw = icoreField.get();
54-
//// System.out.println("Using ICORE field: " + raw);
55-
//
56-
// Optional<String> acronymRank = repo.getRankingFor(raw.toLowerCase());
57-
// String result = acronymRank.orElse("Not ranked");
58-
// textField.setText(result);
59-
//// System.out.println("Lookup result from ICORE: " + result);
60-
// return;
61-
// }
62-
//
63-
// // 2. Then fallback to booktitle
64-
// Optional<String> bookTitle = currentEntry.getFieldOrAlias(StandardField.BOOKTITLE);
65-
// // 3. Then fallback to journal
66-
// if (bookTitle.isEmpty()) {
67-
// bookTitle = currentEntry.getField(StandardField.JOURNAL);
68-
// }
69-
//
70-
// if (bookTitle.isEmpty()) {
71-
//// System.out.println("No usable field found.");
72-
// textField.setText("Not ranked");
73-
// return;
74-
// }
75-
//
76-
// String rawInput = bookTitle.get();
77-
//// System.out.println("Detected Title: '" + rawInput + "'");
78-
//
79-
// Optional<String> acronym = ConferenceUtil.extractAcronym(rawInput);
80-
//// acronym.ifPresent(acr -> System.out.println("Extracted acronym: " + acr));
81-
//
82-
// Optional<String> rank = acronym.flatMap(repo::getRankingFor)
83-
// .or(() -> repo.getRankingFor(rawInput));
84-
//
85-
// String result = rank.orElse("Not ranked");
86-
// textField.setText(result);
87-
//// System.out.println("Lookup result: " + result);
88-
// }
89-
90-
// By providing the acronym fetches the data from csv
9150
private void lookupRank() {
9251
if (currentEntry == null) {
9352
return;
9453
}
9554

96-
Optional<String> icoreField = currentEntry.getField(StandardField.ICORANKING);
55+
Optional<String> icoreField = currentEntry.getField(StandardField.ICORERANKING);
9756
Optional<String> bookTitle = currentEntry.getFieldOrAlias(StandardField.BOOKTITLE);
9857
if (bookTitle.isEmpty()) {
9958
bookTitle = currentEntry.getField(StandardField.JOURNAL);
@@ -104,8 +63,7 @@ private void lookupRank() {
10463

10564
Optional<String> acronym = ConferenceUtil.extractAcronym(rawInput); // Extracting the acronym from our input field
10665
Optional<ConferenceRankingEntry> result = acronym.flatMap(repo::getFullEntry)
107-
.or(() -> repo.getFullEntry(rawInput)); // Finding if any matching entry present in csv file
108-
// If present then print the info
66+
.or(() -> repo.getFullEntry(rawInput));
10967

11068
if (result.isPresent()) {
11169
ConferenceRankingEntry entry = result.get();
@@ -119,7 +77,7 @@ private void lookupRank() {
11977
alert.getDialogPane().setPrefSize(600, 400);
12078
alert.showAndWait();
12179

122-
textField.setText(entry.rank); // still show rank in the field
80+
textField.setText(entry.rank()); // still show rank in the field
12381
} else {
12482
textField.setText("Not ranked");
12583
}
@@ -128,11 +86,6 @@ private void lookupRank() {
12886
@Override
12987
public void bindToEntry(BibEntry entry) {
13088
this.currentEntry = entry;
131-
132-
// System.out.println("ENTRY booktitle = " + entry.getField(StandardField.BOOKTITLE).orElse("none"));
133-
// System.out.println("ENTRY journal = " + entry.getField(StandardField.JOURNAL).orElse("none"));
134-
// System.out.println("ENTRY title = " + entry.getField(StandardField.TITLE).orElse("none"));
135-
13689
entry.getField(field).ifPresent(textField::setText);
13790

13891
textField.textProperty().addListener((obs, oldVal, newVal) -> {

jabgui/src/main/java/org/jabref/migrations/PreferencesMigrations.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package org.jabref.migrations;
22

3-
import java.util.ArrayList;
4-
import java.util.EnumSet;
5-
import java.util.HashMap;
6-
import java.util.List;
7-
import java.util.Map;
8-
import java.util.Optional;
3+
import java.util.*;
94
import java.util.function.UnaryOperator;
105
import java.util.prefs.BackingStoreException;
116
import java.util.prefs.Preferences;
127
import java.util.stream.Collectors;
138

9+
import com.github.javakeyring.Keyring;
1410
import javafx.scene.control.TableColumn;
15-
1611
import org.jabref.gui.entryeditor.CommentsTab;
1712
import org.jabref.gui.maintable.ColumnPreferences;
1813
import org.jabref.gui.maintable.MainTableColumnModel;
@@ -29,16 +24,16 @@
2924
import org.jabref.model.entry.field.StandardField;
3025
import org.jabref.model.entry.types.EntryTypeFactory;
3126
import org.jabref.model.strings.StringUtil;
32-
33-
import com.github.javakeyring.Keyring;
3427
import org.slf4j.Logger;
3528
import org.slf4j.LoggerFactory;
3629

3730
public class PreferencesMigrations {
3831

3932
private static final Logger LOGGER = LoggerFactory.getLogger(PreferencesMigrations.class);
33+
private JabRefGuiPreferences preferences;
4034

41-
private PreferencesMigrations() {
35+
private PreferencesMigrations(JabRefGuiPreferences preferences) {
36+
this.preferences = preferences;
4237
}
4338

4439
/**
@@ -562,7 +557,21 @@ static void moveApiKeysToKeyring(JabRefCliPreferences preferences) {
562557
* The tab "Comments" is hard coded using {@link CommentsTab} since v5.10 (and thus hard-wired in {@link org.jabref.gui.entryeditor.EntryEditor#createTabs()}.
563558
* Thus, the configuration ih the preferences is obsolete
564559
*/
560+
565561
static void removeCommentsFromCustomEditorTabs(GuiPreferences preferences) {
566562
preferences.getEntryEditorPreferences().getEntryEditorTabs().remove("Comments");
567563
}
564+
565+
public void addICORERankingFieldToGeneralTab() {
566+
String key = "entryEditorTabList";
567+
String expectedValue = "General:doi;crossref;keywords;eprint;url;file;groups;owner;timestamp;printed;priority;qualityassured;ranking;readstatus;relevance";
568+
String newValue = "General:doi;icoreranking;crossref;keywords;eprint;url;file;groups;owner;timestamp;printed;priority;qualityassured;ranking;readstatus;relevance";
569+
570+
String oldValue = preferences.get(key);
571+
572+
if (expectedValue.equals(oldValue)) {
573+
preferences.put(key, newValue);
574+
}
575+
}
576+
568577
}

jabgui/src/test/java/org/jabref/gui/fieldeditors/FieldEditorsTest.java

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
package org.jabref.logic.icore;
22

3-
public class ConferenceRankingEntry {
4-
public final String title;
5-
public final String acronym;
6-
public final String source;
7-
public final String rank;
8-
public final String note;
9-
public final String dblp;
10-
public final String primaryFor;
11-
public final String comments;
12-
public final String averageRating;
13-
14-
public ConferenceRankingEntry(String title, String acronym, String source, String rank,
15-
String note, String dblp, String primaryFor,
16-
String comments, String averageRating) {
17-
this.title = title;
18-
this.acronym = acronym;
19-
this.source = source;
20-
this.rank = rank;
21-
this.note = note;
22-
this.dblp = dblp;
23-
this.primaryFor = primaryFor;
24-
this.comments = comments;
25-
this.averageRating = averageRating;
26-
}
27-
// Printing the data of of the csv we got based on the acronym lookup in a orderky format in a new window
28-
3+
public record ConferenceRankingEntry(
4+
String title,
5+
String acronym,
6+
String source,
7+
String rank,
8+
String note,
9+
String dblp,
10+
String primaryFor,
11+
String averageRating
12+
) {
2913
@Override
3014
public String toString() {
3115
return String.format("""
@@ -36,8 +20,7 @@ public String toString() {
3620
Note: %s
3721
DBLP: %s
3822
Primary FoR: %s
39-
Comments: %s
4023
Average Rating: %s
41-
""", title, acronym, source, rank, note, dblp, primaryFor, comments, averageRating);
24+
""", title, acronym, source, rank, note, dblp, primaryFor, averageRating);
4225
}
4326
}

jablib/src/main/java/org/jabref/logic/icore/ICoreRankingRepository.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jabref.logic.icore;
22

33
import java.io.BufferedReader;
4+
import java.io.IOException;
45
import java.io.InputStream;
56
import java.io.InputStreamReader;
67
import java.nio.charset.StandardCharsets;
@@ -9,17 +10,18 @@
910
import java.util.Optional;
1011

1112
import org.jabref.logic.util.strings.StringSimilarity;
13+
1214
import org.slf4j.Logger;
1315
import org.slf4j.LoggerFactory;
1416

1517
public class ICoreRankingRepository {
1618

1719
final Map<String, String> acronymToRank = new HashMap<>();
18-
private final Map<String, String> nameToRank = new HashMap<>();
19-
private final Map<String, ConferenceRankingEntry> acronymMap = new HashMap<>();
20-
private final Map<String, ConferenceRankingEntry> nameMap = new HashMap<>();
21-
private final StringSimilarity similarity = new StringSimilarity();
22-
private static final Logger LOGGER = LoggerFactory.getLogger(ICoreRankingRepository.class);
20+
private Map<String, String> nameToRank = new HashMap<>();
21+
private Map<String, ConferenceRankingEntry> acronymMap = new HashMap<>();
22+
private Map<String, ConferenceRankingEntry> nameMap = new HashMap<>();
23+
private StringSimilarity similarity = new StringSimilarity();
24+
private Logger LOGGER = LoggerFactory.getLogger(ICoreRankingRepository.class);
2325

2426
public ICoreRankingRepository() {
2527
InputStream inputStream = getClass().getResourceAsStream("/ICORE.csv");
@@ -46,45 +48,40 @@ public ICoreRankingRepository() {
4648
parts[4].trim(), // note
4749
parts[5].trim(), // dblp
4850
parts[6].trim(), // primaryFor
49-
parts[7].trim(), // comments
5051
parts[8].trim() // averageRating
5152
);
52-
acronymMap.put(entry.acronym.toLowerCase(), entry);
53-
nameMap.put(entry.title.toLowerCase(), entry);
53+
acronymMap.put(entry.acronym().toLowerCase(), entry);
54+
nameMap.put(entry.title().toLowerCase(), entry);
5455
});
5556

5657
// System.out.println("Loaded entries:");
5758
// acronymToRank.forEach((key, val) -> System.out.println("Acronym: " + key + " -> " + val));
5859
// nameToRank.forEach((key, val) -> System.out.println("Name: " + key + " -> " + val));
59-
} catch (Exception e) {
60-
LOGGER.error("Failed to load ICORE ranking data", e);
60+
} catch (NullPointerException | IOException e) {
61+
LOGGER.debug("Failed to load ICORE ranking data {}", e.getMessage());
6162
}
6263
}
6364

6465
public Optional<String> getRankingFor(String acronymOrName) {
6566
String key = acronymOrName.trim().toLowerCase();
6667

67-
// 1. Try exact acronym match
6868
if (acronymToRank.containsKey(key)) {
6969
return Optional.of(acronymToRank.get(key));
7070
}
7171

72-
// 2. Try exact name match
7372
if (nameToRank.containsKey(key)) {
7473
return Optional.of(nameToRank.get(key));
7574
}
7675

77-
// 3. Skip fuzzy matching for short strings (e.g., "icse")
7876
if (key.length() < 6) {
79-
LOGGER.info("Skipped fuzzy fallback for short string: " + key);
77+
LOGGER.debug("Skipped fuzzy fallback for short string: {}", key);
8078
return Optional.empty();
8179
}
8280

83-
// 4. Fallback: fuzzy match with strict threshold
84-
LOGGER.info("Fuzzy match fallback triggered for: " + key);
81+
LOGGER.debug("Fuzzy match fallback triggered for: {}", key);
8582
return nameToRank.entrySet().stream()
8683
.filter(e -> similarity.editDistanceIgnoreCase(e.getKey(), key) < 0.01)
87-
.peek(e -> LOGGER.info("Fuzzy match candidate: " + e.getKey()))
84+
.peek(e -> LOGGER.debug("Fuzzy match candidate: {}", e.getKey()))
8885
.map(Map.Entry::getValue)
8986
.findFirst();
9087
}

jablib/src/main/java/org/jabref/logic/util/ConferenceUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ public static Optional<String> extractAcronym(String title) {
1111
return Optional.of(matcher.group(1));
1212
}
1313
return Optional.empty();
14-
1514
}
1615
}

jablib/src/main/java/org/jabref/model/entry/field/FieldFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private static Set<Field> getAllFields() {
231231
* separate preferences object
232232
*/
233233
public static List<Field> getDefaultGeneralFields() {
234-
List<Field> defaultGeneralFields = new ArrayList<>(Arrays.asList(StandardField.DOI, StandardField.CROSSREF, StandardField.KEYWORDS, StandardField.EPRINT, StandardField.URL, StandardField.FILE, StandardField.GROUPS, StandardField.OWNER, StandardField.TIMESTAMP));
234+
List<Field> defaultGeneralFields = new ArrayList<>(Arrays.asList(StandardField.DOI, StandardField.ICORERANKING, StandardField.CROSSREF, StandardField.KEYWORDS, StandardField.EPRINT, StandardField.URL, StandardField.FILE, StandardField.GROUPS, StandardField.OWNER, StandardField.TIMESTAMP));
235235
defaultGeneralFields.addAll(EnumSet.allOf(SpecialField.class));
236236
return defaultGeneralFields;
237237
}

0 commit comments

Comments
 (0)