Skip to content

Fix changing the font size not working when importing preferences#2069

Merged
koppor merged 9 commits into
JabRef:masterfrom
Braunch:ImportPreferencesFix
Oct 11, 2016
Merged

Fix changing the font size not working when importing preferences#2069
koppor merged 9 commits into
JabRef:masterfrom
Braunch:ImportPreferencesFix

Conversation

@Braunch

@Braunch Braunch commented Sep 26, 2016

Copy link
Copy Markdown
Contributor

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

  • Change in CHANGELOG.md described
  • Manually tested changed features in running JabRef

@Braunch Braunch added [outdated] type: bug Confirmed bugs or reports that are very likely to be bugs stupro labels Sep 26, 2016
@Braunch Braunch changed the title [WIP] Fix changing the font size does not work when importing preferences [WIP] Fix changing the font size not working when importing preferences Sep 26, 2016

fontButton.addActionListener(
e -> new FontSelectorDialog(null, GUIGlobals.currentFont).getSelectedFont().ifPresent(x -> usedFont = x));
e -> new FontSelectorDialog(null, usedFont).getSelectedFont().ifPresent(x -> usedFont = x));

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Braunch

Braunch commented Sep 26, 2016

Copy link
Copy Markdown
Contributor Author

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.

@Braunch

Braunch commented Sep 26, 2016

Copy link
Copy Markdown
Contributor Author

The preference dialog now gets disposed when preferences has been imported. This prevents that the user overrides the imported preferences.

@boceckts boceckts left a comment

Copy link
Copy Markdown
Contributor

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++) {

Copy link
Copy Markdown
Contributor

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).

Copy link
Copy Markdown
Contributor Author

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++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as last comment.

Copy link
Copy Markdown
Contributor Author

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);

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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();

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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();

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@boceckts boceckts added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 29, 2016
@boceckts boceckts changed the title [WIP] Fix changing the font size not working when importing preferences Fix changing the font size not working when importing preferences Sep 29, 2016
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import static net.sf.jabref.Globals.prefs;

Copy link
Copy Markdown
Contributor

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Braunch

Braunch commented Oct 5, 2016

Copy link
Copy Markdown
Contributor Author

Can this be merged?

@Siedlerchr Siedlerchr left a comment

Copy link
Copy Markdown
Member

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.

@koppor koppor merged commit 01f01ab into JabRef:master Oct 11, 2016
Siedlerchr added a commit that referenced this pull request Oct 11, 2016
* 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)
Siedlerchr added a commit that referenced this pull request Oct 13, 2016
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[outdated] type: bug Confirmed bugs or reports that are very likely to be bugs status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants