Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions jabgui/src/main/java/org/jabref/gui/actions/ActionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static BooleanExpression isAnyFieldSetForSelectedEntry(List<Field> fields
ObservableList<BibEntry> selectedEntries = stateManager.getSelectedEntries();
Binding<Boolean> fieldsAreSet = EasyBind.valueAt(selectedEntries, 0)
.mapObservable(entry -> Bindings.createBooleanBinding(
() -> entry.getFields().stream().anyMatch(fields::contains),
entry.getFieldsObservable()))
() -> entry.getFields().stream().anyMatch(fields::contains),
entry.getFieldsObservable()))
.orElseOpt(false);
return BooleanExpression.booleanExpression(fieldsAreSet);
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public static BooleanExpression isFilePresentForSelectedEntry(StateManager state
/**
* Check if at least one of the selected entries has linked files
* <br>
* Used in {@link org.jabref.gui.maintable.OpenExternalFileAction} when multiple entries selected
* Used in {@link org.jabref.gui.maintable.OpenSelectedEntriesFilesAction} when multiple entries selected
*
* @param stateManager manager for the state of the GUI
* @return a boolean binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.jabref.gui.documentviewer.DocumentViewerView;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.entryeditor.EntryEditorTab;
import org.jabref.gui.maintable.OpenExternalFileAction;
import org.jabref.gui.maintable.OpenFolderAction;
import org.jabref.gui.maintable.OpenSingleExternalFileAction;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.search.SearchType;
import org.jabref.gui.util.TooltipTextUtil;
Expand Down Expand Up @@ -181,7 +181,7 @@ private ContextMenu getFileContextMenu(LinkedFile file) {
fileContextMenu.getItems().add(actionFactory.createMenuItem(
StandardActions.OPEN_FOLDER, new OpenFolderAction(dialogService, stateManager, preferences, entry, file, taskExecutor)));
fileContextMenu.getItems().add(actionFactory.createMenuItem(
StandardActions.OPEN_EXTERNAL_FILE, new OpenExternalFileAction(dialogService, stateManager, preferences, entry, file, taskExecutor)));
StandardActions.OPEN_EXTERNAL_FILE, new OpenSingleExternalFileAction(dialogService, preferences, entry, file, taskExecutor, stateManager)));
return fileContextMenu;
}

Expand Down
6 changes: 2 additions & 4 deletions jabgui/src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@

@AllowedToUseClassGetResource("JavaFX internally handles the passed URLs properly.")
public class MainTable extends TableView<BibEntryTableViewModel> {

private static final Logger LOGGER = LoggerFactory.getLogger(MainTable.class);
private static final PseudoClass MATCHING_SEARCH_AND_GROUPS = PseudoClass.getPseudoClass("matching-search-and-groups");
private static final PseudoClass MATCHING_SEARCH_NOT_GROUPS = PseudoClass.getPseudoClass("matching-search-not-groups");
Expand Down Expand Up @@ -112,7 +111,6 @@ public MainTable(MainTableDataModel model,
TaskExecutor taskExecutor,
ImportHandler importHandler) {
super();

this.libraryTab = libraryTab;
this.stateManager = stateManager;
this.database = Objects.requireNonNull(database);
Expand Down Expand Up @@ -369,7 +367,7 @@ private void setupKeyBindings(KeyBindingRepository keyBindings) {
EditAction cutAction = new EditAction(StandardActions.CUT, () -> libraryTab, stateManager, undoManager);
EditAction deleteAction = new EditAction(StandardActions.DELETE_ENTRY, () -> libraryTab, stateManager, undoManager);
OpenUrlAction openUrlAction = new OpenUrlAction(dialogService, stateManager, preferences);
OpenExternalFileAction openExternalFileActionFileAction = new OpenExternalFileAction(dialogService, stateManager, preferences, taskExecutor);
OpenSelectedEntriesFilesAction openSelectedEntriesFilesActionFileAction = new OpenSelectedEntriesFilesAction(dialogService, stateManager, preferences, taskExecutor);
MergeWithFetchedEntryAction mergeWithFetchedEntryAction = new MergeWithFetchedEntryAction(dialogService, stateManager, taskExecutor, preferences, undoManager);
LookupIdentifierAction<DOI> lookupIdentifierAction = new LookupIdentifierAction<>(WebFetchers.getIdFetcherForIdentifier(DOI.class), stateManager, undoManager, dialogService, taskExecutor);

Expand Down Expand Up @@ -422,7 +420,7 @@ private void setupKeyBindings(KeyBindingRepository keyBindings) {
event.consume();
break;
case OPEN_FILE:
openExternalFileActionFileAction.execute();
openSelectedEntriesFilesActionFileAction.execute();
event.consume();
break;
case MERGE_WITH_FETCHED_ENTRY:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.jabref.gui.maintable;

import java.util.List;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.ActionHelper;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.TaskExecutor;

public class OpenSelectedEntriesFilesAction extends SimpleCommand {

private static final int FILES_LIMIT = 10;

private final DialogService dialogService;
private final StateManager stateManager;
private final GuiPreferences preferences;
private final TaskExecutor taskExecutor;

public OpenSelectedEntriesFilesAction(DialogService dialogService,
StateManager stateManager,
GuiPreferences preferences,
TaskExecutor taskExecutor) {
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.taskExecutor = taskExecutor;

this.executable.bind(ActionHelper.hasLinkedFileForSelectedEntries(stateManager)
.and(ActionHelper.needsEntriesSelected(stateManager)));
}

@Override
public void execute() {
stateManager.getActiveDatabase().ifPresent(databaseContext -> {
List<LinkedFileViewModel> linkedFileViewModelList = stateManager
.getSelectedEntries().stream()
.flatMap(entry -> entry.getFiles().stream()
.map(linkedFile -> new LinkedFileViewModel(
linkedFile,
entry,
databaseContext,
taskExecutor,
dialogService,
preferences)))
.toList();
if (linkedFileViewModelList.size() > FILES_LIMIT) {
boolean continueOpening = dialogService.showConfirmationDialogAndWait(
Localization.lang("Opening large number of files"),
Localization.lang("You are about to open %0 files. Continue?", linkedFileViewModelList.size()),
Localization.lang("Open all linked files"),
Localization.lang("Cancel file opening")
);
if (!continueOpening) {
return;
}
}

linkedFileViewModelList.forEach(LinkedFileViewModel::open);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.jabref.gui.maintable;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.fieldeditors.LinkedFileViewModel;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;

import org.jspecify.annotations.NonNull;

public class OpenSingleExternalFileAction extends SimpleCommand {

private final DialogService dialogService;
private final GuiPreferences preferences;
private final BibEntry entry;
private final LinkedFile linkedFile;
private final TaskExecutor taskExecutor;
private final StateManager stateManager;

public OpenSingleExternalFileAction(@NonNull DialogService dialogService,
@NonNull GuiPreferences preferences,
@NonNull BibEntry entry,
@NonNull LinkedFile linkedFile,
@NonNull TaskExecutor taskExecutor,
@NonNull StateManager stateManager) {
this.dialogService = dialogService;
this.preferences = preferences;
this.entry = entry;
this.linkedFile = linkedFile;
this.taskExecutor = taskExecutor;
this.stateManager = stateManager;

this.setExecutable(true);
}

@Override
public void execute() {
stateManager.getActiveDatabase()
.ifPresent(databaseContext -> new LinkedFileViewModel(
linkedFile, entry, databaseContext, taskExecutor, dialogService, preferences)
.open());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static ContextMenu create(BibEntryTableViewModel entry,
factory.createMenuItem(StandardActions.ATTACH_FILE, new AttachFileAction(libraryTab, dialogService, stateManager, preferences.getFilePreferences(), preferences.getExternalApplicationsPreferences())),
factory.createMenuItem(StandardActions.ATTACH_FILE_FROM_URL, new AttachFileFromURLAction(dialogService, stateManager, taskExecutor, preferences)),
factory.createMenuItem(StandardActions.OPEN_FOLDER, new OpenFolderAction(dialogService, stateManager, preferences, taskExecutor)),
factory.createMenuItem(StandardActions.OPEN_EXTERNAL_FILE, new OpenExternalFileAction(dialogService, stateManager, preferences, taskExecutor)),
factory.createMenuItem(StandardActions.OPEN_EXTERNAL_FILE, new OpenSelectedEntriesFilesAction(dialogService, stateManager, preferences, taskExecutor)),
extractFileReferencesOnline,
extractFileReferencesOffline,

Expand Down
3 changes: 3 additions & 0 deletions jablib/src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3001,3 +3001,6 @@ File\ '%0'\ already\ exists.\ Use\ -f\ or\ --force\ to\ overwrite.=File '%0' alr
Pseudonymizing\ library\ '%0'...=Pseudonymizing library '%0'...
Invalid\ output\ file\ type\ provided.=Invalid output file type provided.
Saved\ %0.=Saved %0.

Open\ all\ linked\ files=Open all linked files
Cancel\ file\ opening=Cancel file opening