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

Fix moving of file into library #12001

Merged
merged 35 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bdd871d
Fix comments
koppor Oct 16, 2024
2f14437
Improve comment
koppor Oct 16, 2024
c43604c
Fix variable name
koppor Oct 16, 2024
fd617a0
Add list of entries to ImportFilesResultItemViewModel
koppor Oct 16, 2024
395543b
Fix support to move files into library
koppor Oct 16, 2024
65c1eb7
Handle existing files in the case of "Copy"
koppor Oct 16, 2024
b36b7d8
Add link to PR
koppor Oct 16, 2024
a8fd477
Merge remote-tracking branch 'origin/main' into fix-melting-630
koppor Oct 17, 2024
df626a4
Fix mocking for CitationsRelationTabViewModelTest
koppor Oct 17, 2024
af40b8d
Merge remote-tracking branch 'origin/main' into fix-melting-630
koppor Oct 17, 2024
3523d1c
Merge remote-tracking branch 'origin/main' into fix-melting-630
koppor Oct 17, 2024
0d61ce7
Merge remote-tracking branch 'origin/main' into fix-melting-630
koppor Oct 17, 2024
59f38fb
Use Files.isSameFile
koppor Oct 20, 2024
69f142d
Merge branch 'main' into fix-melting-630
koppor Oct 21, 2024
bf3c303
Clean filenames at "getValidFileName"
koppor Oct 21, 2024
af78347
Add JavaDoc comment
koppor Oct 21, 2024
f0ba422
Rewrite LinkedFileHandler to do the renaming, too
koppor Oct 21, 2024
0b2d27a
Remove unused method
koppor Oct 21, 2024
cf59fc1
Introduce DragDrop.handleDropOfFiles (to avoid code duplication)
koppor Oct 21, 2024
0d200eb
Group file related methods together (in BibEntry)
koppor Oct 21, 2024
c343a9b
Remove unused methods
koppor Oct 21, 2024
ccfb397
Refine CHANGELOG.md
koppor Oct 21, 2024
b1b06d1
Avoid double-addition when linking files
koppor Oct 21, 2024
2f552b3
Fix condition
koppor Oct 21, 2024
a884568
Fix flag
koppor Oct 21, 2024
84c2f52
Add notification also on move/copy if file exists
koppor Oct 21, 2024
5fa7653
Merge branch 'fix-melting-630' of github.com:JabRef/jabref into fix-m…
koppor Oct 21, 2024
a206fcd
Fix checkstyle error
koppor Oct 21, 2024
8cf71ca
Merge branch 'main' into fix-melting-630
koppor Oct 23, 2024
5856894
Streamline code
koppor Oct 23, 2024
8a086ff
Fix target directory creation
koppor Oct 23, 2024
a64c4d8
Merge remote-tracking branch 'origin/main' into fix-melting-630
koppor Oct 23, 2024
6533615
Fix compilation, and remove Index Manager from ImportHandler
LoayGhreeb Oct 23, 2024
65d2f75
Remove IndexManager from EntryEditor
LoayGhreeb Oct 23, 2024
5c329fe
Update CommentsTabTest.java
LoayGhreeb Oct 23, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658)
- We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732)
- We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825)
- We added support for modifier keys when dropping a file on an entry in the main table. [#12001](https://github.com/JabRef/jabref/pull/12001)
- We added an importer for SSRN URLs. [#12021](https://github.com/JabRef/jabref/pull/12021)
- We added a compare button to the duplicates in the citation relations tab to open the "Possible duplicate entries" window. [#11192](https://github.com/JabRef/jabref/issues/11192)
- We added automatic browser extension install on Windows for Chrome and Edge. [#6076](https://github.com/JabRef/jabref/issues/6076)
Expand All @@ -48,6 +49,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- JabRef respects the [configuration for storing files relative to the .bib file](https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files) in more cases. [#11492](https://github.com/JabRef/jabref/pull/11492)
- JabRef does not show finished background tasks in the status bar popup. [#11821](https://github.com/JabRef/jabref/pull/11821)
- We enhanced the indexing speed. [#11502](https://github.com/JabRef/jabref/pull/11502)
- When dropping a file into the main table, after copy or move, the file is now put in the [configured directory and renamed according to the configured patterns](https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#filename-format-and-file-directory-pattern). [#12001](https://github.com/JabRef/jabref/pull/12001)
- ⚠️ Renamed command line parameters `embeddBibfileInPdf` to `embedBibFileInPdf`, `writeMetadatatoPdf` to `writeMetadataToPdf`, and `writeXMPtoPdf` to `writeXmpToPdf`. [#11575](https://github.com/JabRef/jabref/pull/11575)
- The browse button for a Custom theme now opens in the directory of the current used CSS file. [#11597](https://github.com/JabRef/jabref/pull/11597)
- The browse button for a Custom exporter now opens in the directory of the current used exporter file. [#11717](https://github.com/JabRef/jabref/pull/11717)
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/jabref/gui/entryeditor/CommentsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
Expand All @@ -56,7 +55,6 @@ public CommentsTab(GuiPreferences preferences,
ThemeManager themeManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
super(
false,
Expand All @@ -70,7 +68,6 @@ public CommentsTab(GuiPreferences preferences,
themeManager,
taskExecutor,
journalAbbreviationRepository,
indexManager,
searchQueryProperty
);
this.defaultOwner = preferences.getOwnerPreferences().getDefaultOwner().toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9]", "-");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
Expand Down Expand Up @@ -47,9 +46,8 @@ public DeprecatedFieldsTab(BibDatabaseContext databaseContext,
BibEntryTypesManager entryTypesManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
super(false, databaseContext, suggestionProviders, undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, indexManager, searchQueryProperty);
super(false, databaseContext, suggestionProviders, undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, searchQueryProperty);
this.entryTypesManager = entryTypesManager;

setText(Localization.lang("Deprecated fields"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -32,7 +31,6 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext,
BibEntryTypesManager entryTypesManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
super(
Localization.lang("Optional fields 2"),
Expand All @@ -48,7 +46,6 @@ public DetailOptionalFieldsTab(BibDatabaseContext databaseContext,
entryTypesManager,
taskExecutor,
journalAbbreviationRepository,
indexManager,
searchQueryProperty
);
}
Expand Down
37 changes: 14 additions & 23 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.undo.RedoAction;
import org.jabref.gui.undo.UndoAction;
import org.jabref.gui.util.DragDrop;
import org.jabref.gui.util.UiTaskExecutor;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.bibtex.TypedBibEntry;
Expand Down Expand Up @@ -171,21 +172,11 @@ private void setupDragAndDrop(LibraryTab libraryTab) {
boolean success = false;

if (event.getDragboard().hasContent(DataFormat.FILES)) {
List<Path> draggedFiles = event.getDragboard().getFiles().stream().map(File::toPath).collect(Collectors.toList());
switch (event.getTransferMode()) {
case COPY -> {
LOGGER.debug("Mode COPY");
fileLinker.copyFilesToFileDirAndAddToEntry(entry, draggedFiles, libraryTab.getIndexManager());
}
case MOVE -> {
LOGGER.debug("Mode MOVE");
fileLinker.moveFilesToFileDirRenameAndAddToEntry(entry, draggedFiles, libraryTab.getIndexManager());
}
case LINK -> {
LOGGER.debug("Mode LINK");
fileLinker.addFilesToEntry(entry, draggedFiles);
}
}
TransferMode transferMode = event.getTransferMode();
List<Path> files = event.getDragboard().getFiles().stream().map(File::toPath).collect(Collectors.toList());
// Modifiers do not work on macOS: https://bugs.openjdk.org/browse/JDK-8264172
// Similar code as org.jabref.gui.externalfiles.ImportHandler.importFilesInBackground
DragDrop.handleDropOfFiles(files, transferMode, fileLinker, entry);
success = true;
}

Expand Down Expand Up @@ -276,21 +267,21 @@ private void navigateToNextEntry() {
private List<EntryEditorTab> createTabs() {
List<EntryEditorTab> tabs = new LinkedList<>();

tabs.add(new PreviewTab(databaseContext, dialogService, preferences, themeManager, taskExecutor, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new PreviewTab(databaseContext, dialogService, preferences, themeManager, taskExecutor, libraryTab.searchQueryProperty()));

// Required, optional (important+detail), deprecated, and "other" fields
tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));
tabs.add(new ImportantOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));
tabs.add(new DetailOptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));
tabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));
tabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, bibEntryTypesManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));

// Comment Tab: Tab for general and user-specific comments
tabs.add(new CommentsTab(preferences, databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, themeManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new CommentsTab(preferences, databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, themeManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));

Map<String, Set<Field>> entryEditorTabList = getAdditionalUserConfiguredTabs();
for (Map.Entry<String, Set<Field>> tab : entryEditorTabList.entrySet()) {
tabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, libraryTab.getIndexManager(), libraryTab.searchQueryProperty()));
tabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, undoAction, redoAction, dialogService, preferences, themeManager, taskExecutor, journalAbbreviationRepository, libraryTab.searchQueryProperty()));
}

tabs.add(new MathSciNetTab());
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.jabref.gui.undo.UndoAction;
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -64,7 +63,6 @@ abstract class FieldsEditorTab extends EntryEditorTab implements OffersPreview {
private final JournalAbbreviationRepository journalAbbreviationRepository;
private PreviewPanel previewPanel;
private final UndoManager undoManager;
private final IndexManager indexManager;
private final OptionalObjectProperty<SearchQuery> searchQueryProperty;
private Collection<Field> fields = new ArrayList<>();
@SuppressWarnings("FieldCanBeLocal")
Expand All @@ -81,7 +79,6 @@ public FieldsEditorTab(boolean compressed,
ThemeManager themeManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
this.isCompressed = compressed;
this.databaseContext = Objects.requireNonNull(databaseContext);
Expand All @@ -94,7 +91,6 @@ public FieldsEditorTab(boolean compressed,
this.themeManager = themeManager;
this.taskExecutor = Objects.requireNonNull(taskExecutor);
this.journalAbbreviationRepository = Objects.requireNonNull(journalAbbreviationRepository);
this.indexManager = indexManager;
this.searchQueryProperty = searchQueryProperty;
}

Expand Down Expand Up @@ -265,7 +261,6 @@ private void initPanel() {
preferences,
themeManager,
taskExecutor,
indexManager,
searchQueryProperty);
EasyBind.subscribe(preferences.getPreviewPreferences().showPreviewAsExtraTabProperty(), show -> {
if (show) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -32,7 +31,6 @@ public ImportantOptionalFieldsTab(BibDatabaseContext databaseContext,
BibEntryTypesManager entryTypesManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
super(
Localization.lang("Optional fields"),
Expand All @@ -48,7 +46,6 @@ public ImportantOptionalFieldsTab(BibDatabaseContext databaseContext,
entryTypesManager,
taskExecutor,
journalAbbreviationRepository,
indexManager,
searchQueryProperty
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
Expand All @@ -45,7 +44,6 @@ public OptionalFieldsTabBase(String title,
BibEntryTypesManager entryTypesManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
super(true,
databaseContext,
Expand All @@ -58,7 +56,6 @@ public OptionalFieldsTabBase(String title,
themeManager,
taskExecutor,
journalAbbreviationRepository,
indexManager,
searchQueryProperty);
this.entryTypesManager = entryTypesManager;
this.isImportantOptionalFields = isImportantOptionalFields;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.search.IndexManager;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
Expand Down Expand Up @@ -52,7 +51,6 @@ public OtherFieldsTab(BibDatabaseContext databaseContext,
BibEntryTypesManager entryTypesManager,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository,
IndexManager indexManager,
OptionalObjectProperty<SearchQuery> searchQueryProperty) {
super(false,
databaseContext,
Expand All @@ -65,7 +63,6 @@ public OtherFieldsTab(BibDatabaseContext databaseContext,
themeManager,
taskExecutor,
journalAbbreviationRepository,
indexManager,
searchQueryProperty);

this.entryTypesManager = entryTypesManager;
Expand Down
Loading