-
-
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
Fix changing the font size not working when importing preferences #2069
Conversation
@@ -182,7 +182,7 @@ public AppearancePrefsTab(JabRefPreferences prefs) { | |||
overrideFonts.addActionListener(e -> fontSize.setEnabled(overrideFonts.isSelected())); | |||
|
|||
fontButton.addActionListener( | |||
e -> new FontSelectorDialog(null, GUIGlobals.currentFont).getSelectedFont().ifPresent(x -> usedFont = x)); | |||
e -> new FontSelectorDialog(null, usedFont).getSelectedFont().ifPresent(x -> usedFont = x)); |
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.
The problematic part may be the ifPresent
, as I am not sure if you can reassign a variable usedFont
within a lambda x -> usedFont = x
so that it x
will be accessible from the outside.
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.
It has to work, since when I open the font selector again, the new value is assigned for usedFont and gets selected in the list. This did not work before as @oscargus mentioned.
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.
It works, when the variable usedFont is a field: http://stackoverflow.com/questions/25055392/lambdas-local-variables-need-final-instance-variables-dont
I made the PreferenceDialog store the settings when preferences are exported so that the exported preferences are the same as the ones shown in the dialog. I thought about doing the same when the "show preferences" button is pressed. But I am not convinced that the user would expect that the changes made in the dialog are stored when he wants to show them. Maybe he just wants to compare stuff and then accidentally changes the settings. |
The preference dialog now gets disposed when preferences has been imported. This prevents that the user overrides the imported preferences. |
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.
Only minor comments then it's good to me.
// First check that all tabs are ready to close: | ||
int count = main.getComponentCount(); | ||
Component[] comps = main.getComponents(); | ||
for (int i = 0; i < count; i++) { |
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.
If you don't need the counter variable please use for each. for (Component currentComponent : comps)
.
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.
Done
} | ||
} | ||
// Then store settings and close: | ||
for (int i = 0; i < count; i++) { |
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.
Same as last comment.
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.
Done
} catch (JabRefException ex) { | ||
LOGGER.warn(ex.getMessage(), ex); | ||
JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), | ||
Localization.lang("Export preferences"), JOptionPane.ERROR_MESSAGE); |
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.
The Exception should be treated consistently. Either use LOGGER.error
or JOptionPane.WARNING_MESSAGE
.
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.
Done
private void storeAllSettings(){ | ||
// First check that all tabs are ready to close: | ||
int count = main.getComponentCount(); | ||
Component[] comps = main.getComponents(); |
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.
I thought this can only be tabs? If so please rename variable to preferenceTabs
.
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.
Done
@@ -222,15 +222,15 @@ private void updateAfterPreferenceChanges() { | |||
private void storeAllSettings(){ | |||
// First check that all tabs are ready to close: | |||
int count = main.getComponentCount(); |
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.
You don't need this anymore. Once removed it's fine by me.
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.
Done
@@ -42,6 +42,8 @@ | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
|
|||
import static net.sf.jabref.Globals.prefs; |
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.
I'm not sure if we want to import this statically. I see the point, but it will be quite confusing compared to all other files where it is accessed as Globals.prefs
...
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.
Done
Can this be merged? |
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.
For me it looks good, if it works.
* upstream/master: Fix isSharedDatabaseAlreadyPresent check. don't change entry after search if editing an entry (#2129) Change download URL to downloads.jabref.org (#2145) fix switching edited textfield in the entry editor with TAB (#2138) Update me.champeau.gradle.jmh' version from 0.3.0 to 0.3.1 Update install4j plugin from 6.1.2 to 6.1.3 Remove gradle plugin com.github.youribonnaffe.gradle.format as it is deprecated and the config uses a non-existing file Update gradle from 3.0 to 3.1 Fix changing the font size not working when importing preferences (#2069) select whole word when selecting search bar (#2149)
* upstream/master: (24 commits) hotfix NPE in the main table (#2158) Enhance side pane toggle (#1605) Added gray background text to authors field to assist newcomers (#2147) Rewrite google scholar fetcher to new infrastructure (#2101) Found entries will be shown when dropping a pdf with xmp meta data (#2150) Japanese translation (#2155) Add shortcuts to context menu (#2131) [WIP] Doi resolution ignore (#2154) Fix DuplicationChecker and key generator (#2151) just close popup on first ESC keep entry in sight Fix isSharedDatabaseAlreadyPresent check. don't change entry after search if editing an entry (#2129) Change download URL to downloads.jabref.org (#2145) fix switching edited textfield in the entry editor with TAB (#2138) Update me.champeau.gradle.jmh' version from 0.3.0 to 0.3.1 Update install4j plugin from 6.1.2 to 6.1.3 Remove gradle plugin com.github.youribonnaffe.gradle.format as it is deprecated and the config uses a non-existing file Update gradle from 3.0 to 3.1 Fix changing the font size not working when importing preferences (#2069) ... # Conflicts: # src/main/java/net/sf/jabref/gui/externalfiles/DroppedFileHandler.java # src/main/java/net/sf/jabref/gui/importer/fetcher/GoogleScholarFetcher.java
I initialized the FontSelectorDialog with the variable that keeps changes made in the dialog instead of the current Globals. This seems to fix both issues named here #1808