-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Show Citation style also in entry preview in preferences #4121
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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 -> { | ||
|
@@ -102,6 +105,7 @@ private void setupLogic() { | |
newSelectedIndices.add(newIndex); | ||
} | ||
chosen.setSelectedIndices(Ints.toArray(newSelectedIndices)); | ||
storeSettings(); | ||
}); | ||
|
||
btnDown.addActionListener(event -> { | ||
|
@@ -115,6 +119,7 @@ private void setupLogic() { | |
newSelectedIndices.add(newIndex); | ||
} | ||
chosen.setSelectedIndices(Ints.toArray(newSelectedIndices)); | ||
storeSettings(); | ||
}); | ||
|
||
btnDefault.addActionListener(event -> layout.setText(Globals.prefs.getPreviewPreferences() | ||
|
@@ -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 p = Globals.prefs.getPreviewPreferences(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't use abbreviations as this makes the code harder to understand: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about that, I changed it to preferences, and added a changelog entry as well. Thank you. |
||
p = new PreviewPreferences(p.getPreviewCycle(),indexStyle,p.getPreviewPanelDividerPosition(),p.isPreviewPanelEnabled(), p.getPreviewStyle(),p.getPreviewStyleDefault()); | ||
|
||
testPane = new PreviewPanel(Globals.basePanel, new BibDatabaseContext(), Globals.getKeyPrefs(), p, dialogService); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you really need the base panel here? If you look at the line 133 where the PreviewPanel is initialized for the first time, there is null passed for the basePanel and the bibdatabasecontex. So I assume you don't need the Globals.basepanel hack here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I need the basepanel because in the PreviewPanel.java file checks if basePanel is present in order to get the citation otherwise it doesn't work. At first I initialized it with null because if no citation style is selected generates a default citation. So that's why I did it that way, the other thing I could try is to write the same logic there without calling the function updateLayout in PreviewPanel but it'll end up with duplicated code. What do you think is the best approach? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, I now did take a closer look at the code here. Having a dependency on the BasePanel is not nice. Well, but looking at the code and trying out some things I see no other way as the CitationStyleCache is configured on the basePanel. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, I removed it from Globals and used getCurrentBasePanel instead and it worked. |
||
testPane.setEntry(TestEntry.getTestEntry()); | ||
testPane.updateLayout(p); | ||
} | ||
|
||
DialogPane pane = new DialogPane(); | ||
pane.setContent(testPane); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here null is passed for BasePanel and bibdatabasecontext,