Skip to content

Commit

Permalink
Merge branch 'main' into JabRef#3197-TeXworks
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored Mar 4, 2024
2 parents 473f458 + 84463e7 commit 705a270
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 19 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added the possibility to redownload files that had been present but are no longer in the specified location. [#10848](https://github.com/JabRef/jabref/issues/10848)
- We added the citation key pattern `[camelN]`. Equivalent to the first N words of the `[camel]` pattern.
- We added ability to export in CFF (Citation File Format) [#10661](https://github.com/JabRef/jabref/issues/10661).
- We added ability to push entries to TeXworks [#3197](https://github.com/JabRef/jabref/issues/3197)
- We added ability to push entries to TeXworks. [#3197](https://github.com/JabRef/jabref/issues/3197)
- We added the ability to zoom in and out in the document viewer using <kbd>Ctrl</kbd> + <kbd>Scroll</kbd>. [#10964](https://github.com/JabRef/jabref/pull/10964)

### Changed

Expand Down Expand Up @@ -53,6 +54,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where the CrossRef field did not work if autocompletion was disabled [#8145](https://github.com/JabRef/jabref/issues/8145)
- We fixed an issue where exporting`@electronic` and `@online` entry types to the Office XMl would duplicate the field `title` [#10807](https://github.com/JabRef/jabref/issues/10807)
- We fixed an issue where the `CommentsTab` was not properly formatted when the `defaultOwner` contained capital or special letters. [#10870](https://github.com/JabRef/jabref/issues/10870)
- We fixed an issue where the `File -> Close library` menu item was not disabled when no library was open. [#10948](https://github.com/JabRef/jabref/issues/10948)
- We fixed an issue where the Document Viewer would show the PDF in only half the window when maximized. [#10934](https://github.com/JabRef/jabref/issues/10934)

### Removed

Expand Down
3 changes: 1 addition & 2 deletions rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ recipeList:
# - org.openrewrite.staticanalysis.UseAsBuilder
# "Upgrades" too much, deletes fields
# - org.openrewrite.staticanalysis.UseCollectionInterfaces
# Does not work at TreeNode
# - org.openrewrite.staticanalysis.UseDiamondOperator
# States that it gains performance, but the code is more unreable
# - org.openrewrite.staticanalysis.UseForEachRemoveInsteadOfSetRemoveAll
# We voted against it
Expand Down Expand Up @@ -189,6 +187,7 @@ recipeList:
- org.openrewrite.staticanalysis.TypecastParenPad
- org.openrewrite.staticanalysis.UnwrapRepeatableAnnotations
- org.openrewrite.staticanalysis.UpperCaseLiteralSuffixes
- org.openrewrite.staticanalysis.UseDiamondOperator
# - org.openrewrite.staticanalysis.UseJavaStyleArrayDeclarations
- org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface
# - org.openrewrite.staticanalysis.UseListSort
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ private ContextMenu createTabContextMenuFor(LibraryTab tab, KeyBindingRepository
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(tab::getBibDatabaseContext)),
factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(tab::getBibDatabaseContext, stateManager, prefs, dialogService)),
new SeparatorMenuItem(),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction(this, tab)),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction(this, tab, stateManager)),
factory.createMenuItem(StandardActions.CLOSE_OTHER_LIBRARIES, new CloseOthersDatabaseAction(tab)),
factory.createMenuItem(StandardActions.CLOSE_ALL_LIBRARIES, new CloseAllDatabaseAction()));

Expand Down Expand Up @@ -1059,22 +1059,27 @@ static protected class CloseDatabaseAction extends SimpleCommand {
private final LibraryTabContainer tabContainer;
private final LibraryTab libraryTab;

public CloseDatabaseAction(LibraryTabContainer tabContainer, LibraryTab libraryTab) {
public CloseDatabaseAction(LibraryTabContainer tabContainer, LibraryTab libraryTab, StateManager stateManager) {
this.tabContainer = tabContainer;
this.libraryTab = libraryTab;
this.executable.bind(ActionHelper.needsDatabase(stateManager));
}

/**
* Using this constructor will result in executing the command on the currently open library tab
*/
public CloseDatabaseAction(LibraryTabContainer tabContainer) {
this(tabContainer, null);
public CloseDatabaseAction(LibraryTabContainer tabContainer, StateManager stateManager) {
this(tabContainer, null, stateManager);
}

@Override
public void execute() {
Platform.runLater(() -> {
if (libraryTab == null) {
if (tabContainer.getCurrentLibraryTab() == null) {
LOGGER.error("No library tab to close");
return;
}
tabContainer.closeCurrentTab();
} else {
tabContainer.closeTab(libraryTab);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void createMenu() {
factory.createMenuItem(StandardActions.SAVE_LIBRARY, new SaveAction(SaveAction.SaveMethod.SAVE, frame::getCurrentLibraryTab, dialogService, preferencesService, stateManager)),
factory.createMenuItem(StandardActions.SAVE_LIBRARY_AS, new SaveAction(SaveAction.SaveMethod.SAVE_AS, frame::getCurrentLibraryTab, dialogService, preferencesService, stateManager)),
factory.createMenuItem(StandardActions.SAVE_ALL, new SaveAllAction(frame::getLibraryTabs, preferencesService, dialogService)),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new JabRefFrame.CloseDatabaseAction(frame)),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new JabRefFrame.CloseDatabaseAction(frame, stateManager)),

new SeparatorMenuItem(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.scene.control.ProgressIndicator;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.ScrollEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
Expand Down Expand Up @@ -76,6 +77,16 @@ public void show(DocumentViewModel document) {
flow.estimatedScrollYProperty().addListener((observable, oldValue, newValue) -> scrollY.setValue(newValue));
scrollY.addListener((observable, oldValue, newValue) -> flow.estimatedScrollYProperty().setValue((double) newValue));
flow.totalLengthEstimateProperty().addListener((observable, oldValue, newValue) -> scrollYMax.setValue(newValue));
flow.addEventFilter(ScrollEvent.SCROLL, (ScrollEvent event) -> {
if (event.isControlDown()) {
event.consume();
if (event.getDeltaY() > 0) {
changePageWidth(100);
} else {
changePageWidth(-100);
}
}
});
}

private void updateCurrentPage(ObservableList<DocumentViewerPage> visiblePages) {
Expand Down Expand Up @@ -128,7 +139,16 @@ private void updateSizeOfDisplayedPages() {

public void changePageWidth(int delta) {
// Assuming the current page is A4 (or has same aspect ratio)
setPageWidth(desiredPageDimension.getWidth(Math.sqrt(2)) + delta);
int newWidth = desiredPageDimension.getWidth(Math.sqrt(2)) + delta;
// Limit zoom out to ~1 page due to occasional display errors when zooming out further
int minWidth = (int) (flow.getHeight() / 2 * Math.sqrt(2));
if (newWidth < minWidth) {
if (newWidth - delta == minWidth) { // Attempting to zoom out when already at minWidth
return;
}
newWidth = minWidth;
}
setPageWidth(newWidth);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public DocumentViewerView() {

ViewLoader.view(this)
.load()
.setAsContent(this.getDialogPane());
.setAsDialogPane(this);

// Remove button bar at bottom, but add close button to keep the dialog closable by clicking the "x" window symbol
getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MapBasedEditorViewModel(Field field, SuggestionProvider<?> suggestionProv

@Override
public StringConverter<T> getStringConverter() {
return new StringConverter<T>() {
return new StringConverter<>() {
@Override
public String toString(T object) {
if (object == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public DelayTaskThrottler createThrottler(int delay) {
}

private <V> Task<V> getJavaFXTask(BackgroundTask<V> task) {
Task<V> javaTask = new Task<V>() {
Task<V> javaTask = new Task<>() {
{
this.updateMessage(task.messageProperty().get());
this.updateTitle(task.titleProperty().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ViewModelTreeTableCellFactory<S> withOnMouseClickedEvent(

@Override
public TreeTableCell<S, S> call(TreeTableColumn<S, S> param) {
return new TreeTableCell<S, S>() {
return new TreeTableCell<>() {
@Override
protected void updateItem(S viewModel, boolean empty) {
super.updateItem(viewModel, empty);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public LatexParserResult parse(List<Path> latexFiles) {
List<Path> referencedFiles = new ArrayList<>();

for (Path file : latexFiles) {
if (!file.toFile().exists()) {
if (!Files.exists(file)) {
LOGGER.error("File does not exist: {}", file);
continue;
}
Expand Down Expand Up @@ -141,7 +141,7 @@ private void matchBibFile(Path file, String line) {
? bibString
: "%s%s".formatted(bibString, BIB_EXT));

if (bibFile.toFile().exists()) {
if (Files.exists(bibFile)) {
latexParserResult.addBibFile(file, bibFile);
}
}
Expand All @@ -160,7 +160,7 @@ private void matchNestedFile(Path texFile, List<Path> texFiles, List<Path> refer
? filenamePassedToInclude
: "%s%s".formatted(filenamePassedToInclude, TEX_EXT);
Path nestedFile = texFile.getParent().resolve(texFileName);
if (nestedFile.toFile().exists() && !texFiles.contains(nestedFile)) {
if (Files.exists(nestedFile) && !texFiles.contains(nestedFile)) {
referencedFiles.add(nestedFile);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/jabref/model/paging/PageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class PageTest {
public void setup() {
testContent.addAll(Arrays.asList(testStrings));
testContent = Collections.unmodifiableCollection(testContent);
page1 = new Page<String>(testQuery, testPageNumber, testContent);
page2 = new Page<String>(testQuery, testPageNumber);
page1 = new Page<>(testQuery, testPageNumber, testContent);
page2 = new Page<>(testQuery, testPageNumber);
}

@Test
Expand Down

0 comments on commit 705a270

Please sign in to comment.