Skip to content

Commit

Permalink
Add a variable to track the change in preview style (#4587)
Browse files Browse the repository at this point in the history
  • Loading branch information
chel-seyy authored and Siedlerchr committed Jan 22, 2019
1 parent 701e73d commit 05f3350
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/main/java/org/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class PreviewPanel extends ScrollPane implements SearchQueryHighlightList
private final DialogService dialogService;
private final KeyBindingRepository keyBindingRepository;

private String previewStyle;
private final String defaultPreviewStyle = "Preview";
private Optional<BasePanel> basePanel = Optional.empty();

private boolean fixedLayout;
Expand Down Expand Up @@ -220,21 +222,26 @@ private void updateLayout(PreviewPreferences previewPreferences, boolean init) {
}

String style = previewPreferences.getCurrentPreviewStyle();
if (CitationStyle.isCitationStyleFile(style)) {
if (basePanel.isPresent()) {
if (previewStyle == null) {
previewStyle = style;
}
if (basePanel.isPresent() && !previewStyle.equals(style)) {
if (CitationStyle.isCitationStyleFile(style)) {
layout = Optional.empty();
CitationStyle.createCitationStyleFromFile(style)
.ifPresent(citationStyle -> {
basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle);
if (!init) {
basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle()));
}
});
}
} else {
updatePreviewLayout(previewPreferences.getPreviewStyle(), previewPreferences.getLayoutFormatterPreferences());
if (!init) {
basePanel.ifPresent(panel -> panel.output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview"))));
.ifPresent(citationStyle -> {
basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle);
if (!init) {
basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle()));
}
});
previewStyle = style;
} else {
previewStyle = defaultPreviewStyle;
updatePreviewLayout(previewPreferences.getPreviewStyle(), previewPreferences.getLayoutFormatterPreferences());
if (!init) {
basePanel.get().output(Localization.lang("Preview style changed to: %0", Localization.lang("Preview")));
}
}
}

Expand Down

0 comments on commit 05f3350

Please sign in to comment.