Skip to content

Commit

Permalink
Fix #3034: Make font size in entry editor and group panel customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Aug 7, 2017
1 parent 9d511d1 commit fd08825
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed

- We made the font size in the entry editor and group panel customizable by "Menu and label font size". [#3034](https://github.com/JabRef/jabref/issues/3034)
- If fetched article is already in database, then the entry merge dialog is shown.
- An error message is now displayed if you try to create a group containing the keyword separator or if there is already a group with the same name. [#3075](https://github.com/JabRef/jabref/issues/3075) and [#1495](https://github.com/JabRef/jabref/issues/1495)

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public void keyPressed(java.awt.event.KeyEvent e) {
});
DefaultTaskExecutor.runInJavaFXThread(() -> {
addTabs(lastTabName);

tabbed.setStyle("-fx-font-size: " + Globals.prefs.getFontSizeFX() + "pt;");

container.setScene(new Scene(tabbed));
});
add(container, BorderLayout.CENTER);
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/org/jabref/gui/entryeditor/SourceTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public SourceTab(BibDatabaseContext context, BibEntry entry) {
this.setGraphic(IconTheme.JabRefIcon.SOURCE.getGraphicNode());
}

private static String getSourceString(BibEntry entry, BibDatabaseMode type) throws IOException {
StringWriter stringWriter = new StringWriter(200);
LatexFieldFormatter formatter = LatexFieldFormatter
.buildIgnoreHashes(Globals.prefs.getLatexFieldFormatterPreferences());
new BibEntryWriter(formatter, false).writeWithoutPrependedNewlines(entry, stringWriter, type);

return stringWriter.getBuffer().toString();
}

@Subscribe
public void listen(EntryChangedEvent event) {
if (codeArea != null && this.entry.equals(event.getBibEntry())) {
Expand All @@ -67,19 +76,11 @@ public void listen(EntryChangedEvent event) {
}
}

private static String getSourceString(BibEntry entry, BibDatabaseMode type) throws IOException {
StringWriter stringWriter = new StringWriter(200);
LatexFieldFormatter formatter = LatexFieldFormatter
.buildIgnoreHashes(Globals.prefs.getLatexFieldFormatterPreferences());
new BibEntryWriter(formatter, false).writeWithoutPrependedNewlines(entry, stringWriter, type);

return stringWriter.getBuffer().toString();
}

private Node createSourceEditor(BibEntry entry, BibDatabaseMode mode) {
codeArea = new CodeArea();
codeArea.setWrapText(true);
//codeArea.(Font.font("Monospaced", Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)));
codeArea.lookup(".styled-text-area").setStyle(
"-fx-font-size: " + Globals.prefs.getFontSizeFX() + "pt;");
EasyBind.subscribe(codeArea.focusedProperty(), focused -> {
if (!focused) {
storeSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private void addFromURL(ActionEvent event) {

private ContextMenu createContextMenuForFile(LinkedFileViewModel linkedFile) {
ContextMenu menu = new ContextMenu();
menu.setStyle("-fx-font-size: " + Globals.prefs.getFontSizeFX() + "pt;");

MenuItem edit = new MenuItem(Localization.lang("Edit"));
edit.setOnAction(event -> linkedFile.edit());
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/jabref/gui/groups/GroupTreeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;

import org.jabref.Globals;
import org.jabref.gui.AbstractController;
import org.jabref.gui.DialogService;
import org.jabref.gui.DragAndDropDataFormats;
Expand Down Expand Up @@ -72,6 +73,7 @@ public void initialize() {
viewModel = new GroupTreeViewModel(stateManager, dialogService, taskExecutor);

// Set-up groups tree
groupTree.setStyle("-fx-font-size: " + Globals.prefs.getFontSizeFX() + "pt;");
groupTree.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

// Set-up bindings
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,11 @@ private static void insertDefaultCleanupPreset(Map<String, Object> storage) {
storage.put(CLEANUP_FORMATTERS, convertListToString(preset.getFormatterCleanups().getAsStringList(OS.NEWLINE)));
}

public int getFontSizeFX() {
// Decrease font size by 3 since JavaFX has default font size of 9, while Swing uses 12
return getInt(MENU_FONT_SIZE) - 3;
}

public String getUser() {
try {
return get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName();
Expand Down

0 comments on commit fd08825

Please sign in to comment.