Skip to content

Commit

Permalink
Show Citation style also in entry preview in preferences (#4121)
Browse files Browse the repository at this point in the history
* Fixes issue 3849

* Fixes some checkstyle errors and changes a line to pass the tests

* Removes BasePanel hack

* Adds changelog entry and changes a variable name
  • Loading branch information
eso31 authored and tobiasdiez committed Jun 12, 2018
1 parent 66afd42 commit df98c31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We reworked the "Edit file" dialog to make it resizeable and improved the workflow for adding and editing files https://github.com/JabRef/jabref/issues/2970
- We fixed an issue where the month was not shown in the preview https://github.com/JabRef/jabref/issues/3239.
- Rewritten logic to detect a second jabref instance. [#4023](https://github.com/JabRef/jabref/issues/4023)
- We fixed an issue where the preview pane in entry preview in preferences wasn't showing the citation style selected [#3849](https://github.com/JabRef/jabref/issues/3849)

### Removed
- The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group.
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jabref.logic.citationstyle.CitationStyle;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.TestEntry;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.preferences.PreviewPreferences;

import com.google.common.primitives.Ints;
Expand Down Expand Up @@ -84,13 +85,15 @@ private void setupLogic() {
availableModel.removeElement(object);
chosenModel.addElement(object);
}
storeSettings();
});

btnLeft.addActionListener(event -> {
for (Object object : chosen.getSelectedValuesList()) {
availableModel.addElement(object);
chosenModel.removeElement(object);
}
storeSettings();
});

btnUp.addActionListener(event -> {
Expand All @@ -102,6 +105,7 @@ private void setupLogic() {
newSelectedIndices.add(newIndex);
}
chosen.setSelectedIndices(Ints.toArray(newSelectedIndices));
storeSettings();
});

btnDown.addActionListener(event -> {
Expand All @@ -115,6 +119,7 @@ private void setupLogic() {
newSelectedIndices.add(newIndex);
}
chosen.setSelectedIndices(Ints.toArray(newSelectedIndices));
storeSettings();
});

btnDefault.addActionListener(event -> layout.setText(Globals.prefs.getPreviewPreferences()
Expand All @@ -126,8 +131,19 @@ private void setupLogic() {
DefaultTaskExecutor.runInJavaFXThread(() -> {

PreviewPanel testPane = new PreviewPanel(null, null, Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), dialogService);
testPane.setFixedLayout(layout.getText());
testPane.setEntry(TestEntry.getTestEntry());
if (chosen.isSelectionEmpty()) {
testPane.setFixedLayout(layout.getText());
testPane.setEntry(TestEntry.getTestEntry());
}
else {
int indexStyle = chosen.getSelectedIndex();
PreviewPreferences preferences = Globals.prefs.getPreviewPreferences();
preferences = new PreviewPreferences(preferences.getPreviewCycle(),indexStyle,preferences.getPreviewPanelDividerPosition(),preferences.isPreviewPanelEnabled(), preferences.getPreviewStyle(),preferences.getPreviewStyleDefault());

testPane = new PreviewPanel(JabRefGUI.getMainFrame().getCurrentBasePanel(), new BibDatabaseContext(), Globals.getKeyPrefs(), preferences, dialogService);
testPane.setEntry(TestEntry.getTestEntry());
testPane.updateLayout(preferences);
}

DialogPane pane = new DialogPane();
pane.setContent(testPane);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class PreviewPreferences {

private final List<String> previewCycle;
private final int previewCyclePosition;
private int previewCyclePosition;
private final Number previewPanelDividerPosition;
private final boolean previewPanelEnabled;
private final String previewStyle;
Expand Down

0 comments on commit df98c31

Please sign in to comment.