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

Changes to FileColumn allowing mouse click access to multiple files(.md, .png, etc.) #12085

Merged
merged 7 commits into from
Nov 1, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ public MainTableColumnFactory(BibDatabaseContext database,
}
}
break;
default:
case NORMALFIELD:
if (!column.getQualifier().isBlank()) {
returnColumn = createFieldColumn(column, tooltip);
}
break;
default:
}
return returnColumn;
}
Expand Down
31 changes: 29 additions & 2 deletions src/main/java/org/jabref/gui/maintable/columns/FileColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,35 @@ public FileColumn(MainTableColumnModel model,
.getGraphicNode());

new ValueTableCellFactory<BibEntryTableViewModel, List<LinkedFile>>()
.withGraphic((entry, linkedFiles) -> createFileIcon(entry, linkedFiles.stream().filter(linkedFile ->
linkedFile.getFileType().equalsIgnoreCase(fileType)).collect(Collectors.toList())))
.withGraphic((entry, linkedFiles) -> createFileIcon(entry, linkedFiles.stream()
.filter(linkedFile -> linkedFile.getFileType().equalsIgnoreCase(fileType))
.collect(Collectors.toList())))
.withOnMouseClickedEvent((entry, linkedFiles) -> event -> {
List<LinkedFile> filteredFiles = linkedFiles.stream()
.filter(linkedFile -> linkedFile.getFileType().equalsIgnoreCase(fileType))
.collect(Collectors.toList());

if (event.getButton() == MouseButton.PRIMARY) {
if (filteredFiles.size() == 1) {
// Only one file - open directly
LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel(filteredFiles.getFirst(),
entry.getEntry(), database, taskExecutor, dialogService, preferences);
linkedFileViewModel.open();
} else if (filteredFiles.size() > 1) {
// Multiple files - show context menu to choose file
ContextMenu contextMenu = new ContextMenu();
for (LinkedFile linkedFile : filteredFiles) {
LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel(linkedFile,
entry.getEntry(), database, taskExecutor, dialogService, preferences);
MenuItem menuItem = new MenuItem(linkedFileViewModel.getTruncatedDescriptionAndLink(),
linkedFileViewModel.getTypeIcon().getGraphicNode());
menuItem.setOnAction(e -> linkedFileViewModel.open());
contextMenu.getItems().add(menuItem);
}
contextMenu.show(((Node) event.getSource()), event.getScreenX(), event.getScreenY());
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
}
}
})
.install(this);
}

Expand Down
Loading