From 0f7fed2c298e5e3c0747afa102e0037da2dad1d5 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 11 Mar 2020 21:33:16 +0100 Subject: [PATCH 1/3] Remove GUIGlobals --- src/main/java/org/jabref/JabRefGUI.java | 3 +- src/main/java/org/jabref/gui/BasePanel.java | 10 +- src/main/java/org/jabref/gui/GUIGlobals.java | 55 ------- src/main/java/org/jabref/gui/JabRefFrame.java | 44 +----- .../java/org/jabref/gui/StateManager.java | 6 + .../jabref/gui/entryeditor/EntryEditor.java | 9 -- .../org/jabref/gui/groups/GroupTreeView.java | 3 +- .../java/org/jabref/gui/icon/IconTheme.java | 12 +- .../org/jabref/gui/keyboard/KeyBinding.java | 3 - .../org/jabref/gui/maintable/MainTable.java | 13 +- .../PreferencesDialogViewModel.java | 2 - .../gui/preferences/PreviewTabView.java | 7 +- .../gui/preferences/PreviewTabViewModel.java | 7 +- .../jabref/gui/util/CustomLocalDragboard.java | 4 +- .../jabref/preferences/JabRefPreferences.java | 144 ++---------------- src/main/resources/l10n/JabRef_en.properties | 4 - 16 files changed, 49 insertions(+), 277 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/GUIGlobals.java diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index 3d9b20c3ba3..d1f4057818b 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -12,7 +12,6 @@ import javafx.stage.Stage; import org.jabref.gui.BasePanel; -import org.jabref.gui.GUIGlobals; import org.jabref.gui.JabRefFrame; import org.jabref.gui.dialogs.BackupUIManager; import org.jabref.gui.help.VersionWorker; @@ -57,7 +56,7 @@ public JabRefGUI(Stage mainStage, List databases, boolean isBlank) } private void openWindow(Stage mainStage) { - GUIGlobals.init(); + IconTheme.loadFonts(); LOGGER.debug("Initializing frame"); mainFrame.init(); diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index 835ee0fa07a..548fe11456e 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -157,7 +157,7 @@ public String getTabTitle() { String changeFlag = isModified() && !isAutosaveEnabled ? "*" : ""; title.append(this.bibDatabaseContext.getDatabaseFile().get().getName()).append(changeFlag); } else { - title.append(GUIGlobals.UNTITLED_TITLE); + title.append(Localization.lang("untitled")); if (getDatabase().hasEntries()) { // if the database is not empty and no file is assigned, @@ -290,17 +290,11 @@ public void editEntryAndFocusField(BibEntry entry, Field field) { }); } - public void updateTableFont() { - mainTable.updateFont(); - } - private void createMainTable() { bibDatabaseContext.getDatabase().registerListener(SpecialFieldDatabaseChangeListener.INSTANCE); mainTable = new MainTable(tableModel, frame, this, bibDatabaseContext, preferences.getTablePreferences(), externalFileTypes, preferences.getKeyBindings()); - mainTable.updateFont(); - // Add the listener that binds selection to state manager (TODO: should be replaced by proper JavaFX binding as soon as table is implemented in JavaFX) mainTable.addSelectionListener(listEvent -> Globals.stateManager.setSelectedEntries(mainTable.getSelectedEntries())); @@ -567,7 +561,7 @@ public synchronized void markChangedOrUnChanged() { if (getBibDatabaseContext().getDatabaseFile().isPresent()) { frame.setTabTitle(this, getTabTitle(), getBibDatabaseContext().getDatabaseFile().get().getAbsolutePath()); } else { - frame.setTabTitle(this, GUIGlobals.UNTITLED_TITLE, null); + frame.setTabTitle(this, Localization.lang("untitled"), null); } } frame.setWindowTitle(); diff --git a/src/main/java/org/jabref/gui/GUIGlobals.java b/src/main/java/org/jabref/gui/GUIGlobals.java deleted file mode 100644 index 21c19c98081..00000000000 --- a/src/main/java/org/jabref/gui/GUIGlobals.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.jabref.gui; - -import javafx.scene.paint.Color; -import javafx.scene.text.Font; - -import org.jabref.Globals; -import org.jabref.gui.icon.IconTheme; -import org.jabref.gui.util.CustomLocalDragboard; -import org.jabref.logic.l10n.Localization; -import org.jabref.preferences.JabRefPreferences; - -/** - * Static variables for graphics files and keyboard shortcuts. - */ -public class GUIGlobals { - - public static Color editorTextColor; - public static Color validFieldBackgroundColor; - public static Color activeBackgroundColor; - public static Color invalidFieldBackgroundColor; - public static Font currentFont; - - public static CustomLocalDragboard localDragboard = new CustomLocalDragboard(); - - public static final String UNTITLED_TITLE = Localization.lang("untitled"); - - private GUIGlobals() { - } - - public static void updateEntryEditorColors() { - GUIGlobals.activeBackgroundColor = JabRefPreferences.getInstance().getColor(JabRefPreferences.ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR); - GUIGlobals.validFieldBackgroundColor = JabRefPreferences.getInstance().getColor(JabRefPreferences.VALID_FIELD_BACKGROUND_COLOR); - GUIGlobals.invalidFieldBackgroundColor = JabRefPreferences.getInstance().getColor(JabRefPreferences.INVALID_FIELD_BACKGROUND_COLOR); - GUIGlobals.editorTextColor = JabRefPreferences.getInstance().getColor(JabRefPreferences.FIELD_EDITOR_TEXT_COLOR); - } - - /** - * Perform initializations that are only used in graphical mode. This is to prevent - * the "Xlib: connection to ":0.0" refused by server" error when access to the X server - * on Un*x is unavailable. - */ - public static void init() { - // Set up entry editor colors, first time: - GUIGlobals.updateEntryEditorColors(); - - IconTheme.loadFonts(); - GUIGlobals.currentFont = new Font(Globals.prefs.getFontFamily(), Globals.prefs.getDouble(JabRefPreferences.FONT_SIZE)); - } - - public static void setFont(double size) { - currentFont = new Font(currentFont.getFamily(), size); - // update preferences - Globals.prefs.putInt(JabRefPreferences.FONT_SIZE, size); - } -} diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index b097b875c92..fc21d0b2b43 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -243,18 +243,6 @@ private void initKeyBindings() { tabbedPane.getSelectionModel().selectPrevious(); event.consume(); break; - case INCREASE_TABLE_FONT_SIZE: - increaseTableFontSize(); - event.consume(); - break; - case DECREASE_TABLE_FONT_SIZE: - decreaseTableFontSize(); - event.consume(); - break; - case DEFAULT_TABLE_FONT_SIZE: - setDefaultTableFontSize(); - event.consume(); - break; case SEARCH: getGlobalSearchBar().focus(); break; @@ -320,7 +308,7 @@ public void setWindowTitle() { String databaseFile = panel.getBibDatabaseContext() .getDatabaseFile() .map(File::getPath) - .orElse(GUIGlobals.UNTITLED_TITLE); + .orElse(Localization.lang("untitled")); //setTitle(FRAME_TITLE + " - " + databaseFile + changeFlag + modeInfo); } else if (panel.getBibDatabaseContext().getLocation() == DatabaseLocation.SHARED) { //setTitle(FRAME_TITLE + " - " + panel.getBibDatabaseContext().getDBMSSynchronizer().getDBName() + " [" @@ -1134,7 +1122,7 @@ private boolean confirmClose(BasePanel panel) { .getDatabasePath() .map(Path::toAbsolutePath) .map(Path::toString) - .orElse(GUIGlobals.UNTITLED_TITLE); + .orElse(Localization.lang("untitled")); ButtonType saveChanges = new ButtonType(Localization.lang("Save changes"), ButtonBar.ButtonData.YES); ButtonType discardChanges = new ButtonType(Localization.lang("Discard changes"), ButtonBar.ButtonData.NO); @@ -1229,34 +1217,6 @@ public DialogService getDialogService() { return dialogService; } - private void setDefaultTableFontSize() { - GUIGlobals.setFont(Globals.prefs.getIntDefault(JabRefPreferences.FONT_SIZE)); - for (BasePanel basePanel : getBasePanelList()) { - basePanel.updateTableFont(); - } - dialogService.notify(Localization.lang("Table font size is %0", String.valueOf(GUIGlobals.currentFont.getSize()))); - } - - private void increaseTableFontSize() { - GUIGlobals.setFont(GUIGlobals.currentFont.getSize() + 1); - for (BasePanel basePanel : getBasePanelList()) { - basePanel.updateTableFont(); - } - dialogService.notify(Localization.lang("Table font size is %0", String.valueOf(GUIGlobals.currentFont.getSize()))); - } - - private void decreaseTableFontSize() { - double currentSize = GUIGlobals.currentFont.getSize(); - if (currentSize < 2) { - return; - } - GUIGlobals.setFont(currentSize - 1); - for (BasePanel basePanel : getBasePanelList()) { - basePanel.updateTableFont(); - } - dialogService.notify(Localization.lang("Table font size is %0", String.valueOf(GUIGlobals.currentFont.getSize()))); - } - /** * The action concerned with closing the window. */ diff --git a/src/main/java/org/jabref/gui/StateManager.java b/src/main/java/org/jabref/gui/StateManager.java index 19a45f94c71..05a9364f65d 100644 --- a/src/main/java/org/jabref/gui/StateManager.java +++ b/src/main/java/org/jabref/gui/StateManager.java @@ -15,6 +15,7 @@ import javafx.collections.ObservableMap; import javafx.scene.Node; +import org.jabref.gui.util.CustomLocalDragboard; import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.logic.search.SearchQuery; import org.jabref.model.database.BibDatabaseContext; @@ -32,6 +33,7 @@ */ public class StateManager { + private final CustomLocalDragboard localDragboard = new CustomLocalDragboard(); private final OptionalObjectProperty activeDatabase = OptionalObjectProperty.empty(); private final ReadOnlyListWrapper activeGroups = new ReadOnlyListWrapper<>(FXCollections.observableArrayList()); private final ObservableList selectedEntries = FXCollections.observableArrayList(); @@ -44,6 +46,10 @@ public StateManager() { activeGroups.bind(Bindings.valueAt(selectedGroups, activeDatabase.orElse(null))); } + public CustomLocalDragboard getLocalDragboard() { + return localDragboard; + } + public OptionalObjectProperty activeDatabaseProperty() { return activeDatabase; } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 18fe1f0fd00..f6cbfb7b996 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -28,7 +28,6 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.DialogService; -import org.jabref.gui.GUIGlobals; import org.jabref.gui.StateManager; import org.jabref.gui.bibtexkeypattern.GenerateBibtexKeySingleAction; import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab; @@ -39,7 +38,6 @@ import org.jabref.gui.menus.ChangeEntryTypeMenu; import org.jabref.gui.mergeentries.FetchAndMergeEntry; import org.jabref.gui.undo.CountingUndoManager; -import org.jabref.gui.util.ColorUtil; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.TypedBibEntry; @@ -103,13 +101,6 @@ public EntryEditor(BasePanel panel, ExternalFileTypes externalFileTypes) { this.fileLinker = new ExternalFilesEntryLinker(externalFileTypes, preferencesService.getFilePreferences(), databaseContext); - if (GUIGlobals.currentFont != null) { - setStyle(String.format("text-area-background: %s;text-area-foreground: %s;text-area-highlight: %s;", - ColorUtil.toHex(GUIGlobals.validFieldBackgroundColor), - ColorUtil.toHex(GUIGlobals.editorTextColor), - ColorUtil.toHex(GUIGlobals.activeBackgroundColor))); - } - EasyBind.subscribe(tabbed.getSelectionModel().selectedItemProperty(), tab -> { EntryEditorTab activeTab = (EntryEditorTab) tab; if (activeTab != null) { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 8932d44fc97..58bb942cf34 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -34,7 +34,6 @@ import org.jabref.gui.DialogService; import org.jabref.gui.DragAndDropDataFormats; -import org.jabref.gui.GUIGlobals; import org.jabref.gui.StateManager; import org.jabref.gui.util.BindingsHelper; import org.jabref.gui.util.ControlHelper; @@ -77,7 +76,7 @@ public class GroupTreeView { @FXML public void initialize() { - this.localDragboard = GUIGlobals.localDragboard; + this.localDragboard = stateManager.getLocalDragboard(); viewModel = new GroupTreeViewModel(stateManager, dialogService, preferencesService, taskExecutor, localDragboard); // Set-up groups tree diff --git a/src/main/java/org/jabref/gui/icon/IconTheme.java b/src/main/java/org/jabref/gui/icon/IconTheme.java index 0faa4d0eb7a..89a51634fcf 100644 --- a/src/main/java/org/jabref/gui/icon/IconTheme.java +++ b/src/main/java/org/jabref/gui/icon/IconTheme.java @@ -17,6 +17,7 @@ import javafx.scene.control.ToggleButton; import javafx.scene.image.Image; import javafx.scene.paint.Color; +import javafx.scene.text.Font; import org.jabref.preferences.JabRefPreferences; @@ -27,22 +28,21 @@ public class IconTheme { - public static final Color DEFAULT_DISABLED_COLOR = JabRefPreferences.getInstance().getColor(JabRefPreferences.ICON_DISABLED_COLOR); - public static final javafx.scene.paint.Color SELECTED_COLOR = javafx.scene.paint.Color.web("#50618F"); + public static final Color DEFAULT_DISABLED_COLOR = Color.web("#c8c8c8"); + public static final Color SELECTED_COLOR = Color.web("#50618F"); private static final String DEFAULT_ICON_PATH = "/images/external/red.png"; private static final Logger LOGGER = LoggerFactory.getLogger(IconTheme.class); - private static final Map KEY_TO_ICON = readIconThemeFile( - IconTheme.class.getResource("/images/Icons.properties"), "/images/external/"); + private static final Map KEY_TO_ICON = readIconThemeFile(IconTheme.class.getResource("/images/Icons.properties"), "/images/external/"); public static void loadFonts() { try (InputStream stream = getMaterialDesignIconsStream()) { - javafx.scene.text.Font.loadFont(stream, 7); + Font.loadFont(stream, 7); } catch (IOException e) { LOGGER.error("Error loading Material Design Icons TTF font", e); } try (InputStream stream = getJabRefMaterialDesignIconsStream()) { - javafx.scene.text.Font.loadFont(stream, 7); + Font.loadFont(stream, 7); } catch (IOException e) { LOGGER.error("Error loading custom font for custom JabRef icons", e); } diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java index 7c4f66a193d..d2f8db9e875 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java @@ -23,7 +23,6 @@ public enum KeyBinding { CUT("Cut", Localization.lang("Cut"), "ctrl+X", KeyBindingCategory.EDIT), //We have to put Entry Editor Previous before, because otherwise the decrease font size is found first ENTRY_EDITOR_PREVIOUS_PANEL_2("Entry editor, previous panel 2", Localization.lang("Entry editor, previous panel 2"), "ctrl+MINUS", KeyBindingCategory.VIEW), - DECREASE_TABLE_FONT_SIZE("Decrease table font size", Localization.lang("Decrease table font size"), "ctrl+MINUS", KeyBindingCategory.VIEW), DELETE_ENTRY("Delete entry", Localization.lang("Delete entry"), "DELETE", KeyBindingCategory.BIBTEX), DEFAULT_DIALOG_ACTION("Execute default action in dialog", Localization.lang("Execute default action in dialog"), "ctrl+ENTER", KeyBindingCategory.VIEW), DOWNLOAD_FULL_TEXT("Download full text documents", Localization.lang("Download full text documents"), "alt+F7", KeyBindingCategory.QUALITY), @@ -43,8 +42,6 @@ public enum KeyBinding { HELP("Help", Localization.lang("Help"), "F1", KeyBindingCategory.FILE), IMPORT_INTO_CURRENT_DATABASE("Import into current library", Localization.lang("Import into current library"), "ctrl+I", KeyBindingCategory.FILE), IMPORT_INTO_NEW_DATABASE("Import into new library", Localization.lang("Import into new library"), "ctrl+alt+I", KeyBindingCategory.FILE), - INCREASE_TABLE_FONT_SIZE("Increase table font size", Localization.lang("Increase table font size"), "ctrl+PLUS", KeyBindingCategory.VIEW), - DEFAULT_TABLE_FONT_SIZE("Default table font size", Localization.lang("Default table font size"), "ctrl+0", KeyBindingCategory.VIEW), NEW_ARTICLE("New article", Localization.lang("New article"), "ctrl+shift+A", KeyBindingCategory.BIBTEX), NEW_BOOK("New book", Localization.lang("New book"), "ctrl+shift+B", KeyBindingCategory.BIBTEX), NEW_ENTRY("New entry", Localization.lang("New entry"), "ctrl+N", KeyBindingCategory.BIBTEX), diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 2293be5e914..530ef02f895 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -26,8 +26,8 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.DragAndDropDataFormats; -import org.jabref.gui.GUIGlobals; import org.jabref.gui.JabRefFrame; +import org.jabref.gui.StateManager; import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.keyboard.KeyBinding; @@ -56,7 +56,7 @@ public class MainTable extends TableView { private final MainTableDataModel model; private final ImportHandler importHandler; - private final CustomLocalDragboard localDragboard = GUIGlobals.localDragboard; + private final CustomLocalDragboard localDragboard; public MainTable(MainTableDataModel model, JabRefFrame frame, BasePanel panel, BibDatabaseContext database, @@ -76,6 +76,7 @@ public MainTable(MainTableDataModel model, JabRefFrame frame, Globals.getFileUpdateMonitor(), undoManager, Globals.stateManager); + localDragboard = Globals.stateManager.getLocalDragboard(); this.getColumns().addAll(new MainTableColumnFactory(database, preferences.getColumnPreferences(), externalFileTypes, panel.getUndoManager(), frame.getDialogService()).createColumns()); @@ -325,12 +326,4 @@ private Optional findEntry(BibEntry entry) { .filter(viewModel -> viewModel.getEntry().equals(entry)) .findFirst(); } - - /** - * Repaints the table with the most recent font configuration - */ - public void updateFont() { - // TODO: Font & padding customization - // setFont(GUIGlobals.currentFont); - } } diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java index 1d2bfb61bc6..c489ff3cf8d 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogViewModel.java @@ -12,7 +12,6 @@ import org.jabref.JabRefException; import org.jabref.gui.AbstractViewModel; import org.jabref.gui.DialogService; -import org.jabref.gui.GUIGlobals; import org.jabref.gui.JabRefFrame; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.logic.exporter.ExporterFactory; @@ -181,7 +180,6 @@ public void storeAllSettings() { + Localization.lang("You must restart JabRef for this to come into effect.")); } - GUIGlobals.updateEntryEditorColors(); frame.setupAllTables(); frame.getGlobalSearchBar().updateHintVisibility(); dialogService.notify(Localization.lang("Preferences recorded.")); diff --git a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java index 5c4678db9d3..c44d13e5af5 100644 --- a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java +++ b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java @@ -3,6 +3,8 @@ import java.util.ArrayList; import java.util.List; +import javax.inject.Inject; + import javafx.application.Platform; import javafx.beans.property.ListProperty; import javafx.fxml.FXML; @@ -20,6 +22,8 @@ import javafx.scene.input.TransferMode; import org.jabref.Globals; +import org.jabref.gui.DialogService; +import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.actions.StandardActions; @@ -51,6 +55,7 @@ public class PreviewTabView extends AbstractPreferenceTabView dragSourceList = null; - public PreviewTabViewModel(DialogService dialogService, JabRefPreferences preferences, TaskExecutor taskExecutor) { + public PreviewTabViewModel(DialogService dialogService, JabRefPreferences preferences, TaskExecutor taskExecutor, StateManager stateManager) { this.dialogService = dialogService; this.preferences = preferences; this.taskExecutor = taskExecutor; + this.localDragboard = stateManager.getLocalDragboard(); previewPreferences = preferences.getPreviewPreferences(); sourceTextProperty.addListener((observable, oldValue, newValue) -> { diff --git a/src/main/java/org/jabref/gui/util/CustomLocalDragboard.java b/src/main/java/org/jabref/gui/util/CustomLocalDragboard.java index 6f25aedd8b5..a36ec2cb969 100644 --- a/src/main/java/org/jabref/gui/util/CustomLocalDragboard.java +++ b/src/main/java/org/jabref/gui/util/CustomLocalDragboard.java @@ -6,13 +6,13 @@ import java.util.Map; import org.jabref.gui.DragAndDropDataFormats; -import org.jabref.gui.GUIGlobals; +import org.jabref.gui.StateManager; import org.jabref.logic.citationstyle.PreviewLayout; import org.jabref.model.entry.BibEntry; /** * Placeholder class for a custom generic type safe dragboard to be used in drag and drop, does not depend on serialization - * Don't use this class directly. Use the instance provided in {@link GUIGlobals#localDragboard} + * Don't use this class directly. Use the instance provided in {@link StateManager#getLocalDragboard()} */ public class CustomLocalDragboard { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 08037697918..c426bbec82d 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -125,7 +125,6 @@ public class JabRefPreferences implements PreferencesService { public static final String VIM = "vim"; public static final String LYXPIPE = "lyxpipe"; public static final String EXTERNAL_FILE_TYPES = "externalFileTypes"; - public static final String FONT_FAMILY = "fontFamily"; public static final String FX_THEME = "fxTheme"; public static final String LANGUAGE = "language"; public static final String NAMES_LAST_ONLY = "namesLastOnly"; @@ -137,13 +136,6 @@ public class JabRefPreferences implements PreferencesService { public static final String ENTRY_EDITOR_HEIGHT = "entryEditorHeightFX"; public static final String AUTO_RESIZE_MODE = "autoResizeMode"; public static final String WINDOW_MAXIMISED = "windowMaximised"; - public static final String USE_DEFAULT_LOOK_AND_FEEL = "useDefaultLookAndFeel"; - public static final String PROXY_PORT = "proxyPort"; - public static final String PROXY_HOSTNAME = "proxyHostname"; - public static final String PROXY_USE = "useProxy"; - public static final String PROXY_USERNAME = "proxyUsername"; - public static final String PROXY_PASSWORD = "proxyPassword"; - public static final String PROXY_USE_AUTHENTICATION = "useProxyAuthentication"; public static final String REFORMAT_FILE_ON_SAVE_AND_EXPORT = "reformatFileOnSaveAndExport"; public static final String EXPORT_IN_ORIGINAL_ORDER = "exportInOriginalOrder"; @@ -159,7 +151,6 @@ public class JabRefPreferences implements PreferencesService { public static final String COLUMN_WIDTHS = "columnWidths"; public static final String COLUMN_SORT_TYPES = "columnSortTypes"; public static final String COLUMN_SORT_ORDER = "columnSortOrder"; - public static final String SIDE_PANE_COMPONENT_PREFERRED_POSITIONS = "sidePaneComponentPreferredPositions"; public static final String SIDE_PANE_COMPONENT_NAMES = "sidePaneComponentNames"; public static final String XMP_PRIVACY_FILTERS = "xmpPrivacyFilters"; @@ -171,24 +162,6 @@ public class JabRefPreferences implements PreferencesService { public static final String SIZE_X = "mainWindowSizeX"; public static final String POS_Y = "mainWindowPosY"; public static final String POS_X = "mainWindowPosX"; - public static final String STRINGS_SIZE_Y = "stringsSizeY"; - public static final String STRINGS_SIZE_X = "stringsSizeX"; - public static final String STRINGS_POS_Y = "stringsPosY"; - public static final String STRINGS_POS_X = "stringsPosX"; - public static final String DUPLICATES_SIZE_Y = "duplicatesSizeY"; - public static final String DUPLICATES_SIZE_X = "duplicatesSizeX"; - public static final String DUPLICATES_POS_Y = "duplicatesPosY"; - public static final String DUPLICATES_POS_X = "duplicatesPosX"; - public static final String MERGEENTRIES_SIZE_Y = "mergeEntriesSizeY"; - public static final String MERGEENTRIES_SIZE_X = "mergeEntriesSizeX"; - public static final String MERGEENTRIES_POS_Y = "mergeEntriesPosY"; - public static final String MERGEENTRIES_POS_X = "mergeEntriesPosX"; - public static final String PREAMBLE_SIZE_Y = "preambleSizeY"; - public static final String PREAMBLE_SIZE_X = "preambleSizeX"; - public static final String PREAMBLE_POS_Y = "preamblePosY"; - public static final String PREAMBLE_POS_X = "preamblePosX"; - public static final String SEARCH_DIALOG_HEIGHT = "searchDialogHeight"; - public static final String SEARCH_DIALOG_WIDTH = "searchDialogWidth"; public static final String LAST_EDITED = "lastEdited"; public static final String OPEN_LAST_EDITED = "openLastEdited"; public static final String LAST_FOCUSED = "lastFocused"; @@ -205,16 +178,8 @@ public class JabRefPreferences implements PreferencesService { public static final String KEYWORD_SEPARATOR = "groupKeywordSeparator"; public static final String AUTO_ASSIGN_GROUP = "autoAssignGroup"; public static final String EXTRA_FILE_COLUMNS = "extraFileColumns"; - // Colors - public static final String FIELD_EDITOR_TEXT_COLOR = "fieldEditorTextColor"; - public static final String ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR = "activeFieldEditorBackgroundColor"; - public static final String INVALID_FIELD_BACKGROUND_COLOR = "invalidFieldBackgroundColor"; - public static final String VALID_FIELD_BACKGROUND_COLOR = "validFieldBackgroundColor"; - public static final String ICON_DISABLED_COLOR = "iconDisabledColor"; - public static final String FONT_SIZE = "fontSize"; public static final String OVERRIDE_DEFAULT_FONT_SIZE = "overrideDefaultFontSize"; public static final String MAIN_FONT_SIZE = "mainFontSize"; - public static final String FONT_STYLE = "fontStyle"; public static final String RECENT_DATABASES = "recentDatabases"; public static final String RENAME_ON_MOVE_FILE_TO_FILE_DIR = "renameOnMoveFileToFileDir"; @@ -222,7 +187,6 @@ public class JabRefPreferences implements PreferencesService { public static final String SHOW_ADVANCED_HINTS = "showAdvancedHints"; public static final String DEFAULT_OWNER = "defaultOwner"; public static final String DEFAULT_ENCODING = "defaultEncoding"; - public static final String TOOLBAR_VISIBLE = "toolbarVisible"; // Timestamp preferences public static final String USE_TIME_STAMP = "useTimeStamp"; public static final String UPDATE_TIMESTAMP = "updateTimestamp"; @@ -296,14 +260,6 @@ public class JabRefPreferences implements PreferencesService { public static final String SEND_OS_DATA = "sendOSData"; public static final String SEND_TIMEZONE_DATA = "sendTimezoneData"; public static final String VALIDATE_IN_ENTRY_EDITOR = "validateInEntryEditor"; - // Dropped file handler - public static final String DROPPEDFILEHANDLER_RENAME = "DroppedFileHandler_RenameFile"; - public static final String DROPPEDFILEHANDLER_MOVE = "DroppedFileHandler_MoveFile"; - public static final String DROPPEDFILEHANDLER_COPY = "DroppedFileHandler_CopyFile"; - public static final String DROPPEDFILEHANDLER_LEAVE = "DroppedFileHandler_LeaveFileInDir"; - // Remote - public static final String USE_REMOTE_SERVER = "useRemoteServer"; - public static final String REMOTE_SERVER_PORT = "remoteServerPort"; /** * The OpenOffice/LibreOffice connection preferences are: @@ -326,10 +282,6 @@ public class JabRefPreferences implements PreferencesService { public static final String OO_BIBLIOGRAPHY_STYLE_FILE = "ooBibliographyStyleFile"; public static final String OO_EXTERNAL_STYLE_FILES = "ooExternalStyleFiles"; - public static final String STYLES_SIZE_Y = "stylesSizeY"; - public static final String STYLES_SIZE_X = "stylesSizeX"; - public static final String STYLES_POS_Y = "stylesPosY"; - public static final String STYLES_POS_X = "stylesPosX"; // Special field preferences public static final String SPECIALFIELDSENABLED = "specialFieldsEnabled"; // The choice between AUTOSYNCSPECIALFIELDSTOKEYWORDS and SERIALIZESPECIALFIELDS is mutually exclusive @@ -355,6 +307,9 @@ public class JabRefPreferences implements PreferencesService { // String delimiter public static final Character STRINGLIST_DELIMITER = ';'; + // UI + private static final String FONT_FAMILY = "fontFamily"; + // Preview private static final String PREVIEW_STYLE = "previewStyle"; private static final String CYCLE_PREVIEW_POS = "cyclePreviewPos"; @@ -362,6 +317,14 @@ public class JabRefPreferences implements PreferencesService { private static final String PREVIEW_PANEL_HEIGHT = "previewPanelHeightFX"; private static final String PREVIEW_AS_TAB = "previewAsTab"; + // Proxy + private static final String PROXY_PORT = "proxyPort"; + private static final String PROXY_HOSTNAME = "proxyHostname"; + private static final String PROXY_USE = "useProxy"; + private static final String PROXY_USERNAME = "proxyUsername"; + private static final String PROXY_PASSWORD = "proxyPassword"; + private static final String PROXY_USE_AUTHENTICATION = "useProxyAuthentication"; + // Auto completion private static final String AUTO_COMPLETE = "autoComplete"; private static final String AUTOCOMPLETER_FIRSTNAME_MODE = "autoCompFirstNameMode"; @@ -403,6 +366,10 @@ public class JabRefPreferences implements PreferencesService { private static final int EXPORTER_FILENAME_INDEX = 1; private static final int EXPORTER_EXTENSION_INDEX = 2; + // Remote + private static final String USE_REMOTE_SERVER = "useRemoteServer"; + private static final String REMOTE_SERVER_PORT = "remoteServerPort"; + // The only instance of this class: private static JabRefPreferences singleton; /** @@ -482,7 +449,6 @@ private JabRefPreferences() { defaults.put(PROXY_USERNAME, ""); defaults.put(PROXY_PASSWORD, ""); - defaults.put(USE_DEFAULT_LOOK_AND_FEEL, Boolean.TRUE); defaults.put(LYXPIPE, USER_HOME + File.separator + ".lyx/lyxpipe"); defaults.put(VIM, "vim"); defaults.put(VIM_SERVER, "vim"); @@ -535,22 +501,6 @@ private JabRefPreferences() { defaults.put(OPEN_LAST_EDITED, Boolean.TRUE); defaults.put(LAST_EDITED, ""); defaults.put(LAST_FOCUSED, ""); - defaults.put(STRINGS_POS_X, 0); - defaults.put(STRINGS_POS_Y, 0); - defaults.put(STRINGS_SIZE_X, 600); - defaults.put(STRINGS_SIZE_Y, 400); - defaults.put(DUPLICATES_POS_X, 0); - defaults.put(DUPLICATES_POS_Y, 0); - defaults.put(DUPLICATES_SIZE_X, 800); - defaults.put(DUPLICATES_SIZE_Y, 600); - defaults.put(MERGEENTRIES_POS_X, 0); - defaults.put(MERGEENTRIES_POS_Y, 0); - defaults.put(MERGEENTRIES_SIZE_X, 800); - defaults.put(MERGEENTRIES_SIZE_Y, 600); - defaults.put(PREAMBLE_POS_X, 0); - defaults.put(PREAMBLE_POS_Y, 0); - defaults.put(PREAMBLE_SIZE_X, 600); - defaults.put(PREAMBLE_SIZE_Y, 400); defaults.put(DEFAULT_SHOW_SOURCE, Boolean.FALSE); defaults.put(DEFAULT_AUTO_SORT, Boolean.FALSE); @@ -576,24 +526,12 @@ private JabRefPreferences() { defaults.put(AUTO_ASSIGN_GROUP, Boolean.TRUE); defaults.put(GROUP_INTERSECT_UNION_VIEW_MODE, GroupViewMode.INTERSECTION.name()); defaults.put(KEYWORD_SEPARATOR, ", "); - defaults.put(TOOLBAR_VISIBLE, Boolean.TRUE); defaults.put(DEFAULT_ENCODING, StandardCharsets.UTF_8.name()); defaults.put(DEFAULT_OWNER, System.getProperty("user.name")); defaults.put(MEMORY_STICK_MODE, Boolean.FALSE); defaults.put(SHOW_ADVANCED_HINTS, Boolean.TRUE); defaults.put(RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE); - defaults.put(FONT_STYLE, 0); //for backwards compatibility, is equal to java.awt.Font.PLAIN - defaults.put(FONT_SIZE, 12); - // Main table color settings: - defaults.put(VALID_FIELD_BACKGROUND_COLOR, "255:255:255"); - defaults.put(INVALID_FIELD_BACKGROUND_COLOR, "255:0:0"); - defaults.put(ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR, "220:220:255"); - defaults.put(FIELD_EDITOR_TEXT_COLOR, "0:0:0"); - - // default icon colors - defaults.put(ICON_DISABLED_COLOR, "200:200:200"); - defaults.put(EXTRA_FILE_COLUMNS, Boolean.FALSE); defaults.put(PROTECTED_TERMS_ENABLED_INTERNAL, convertListToString(ProtectedTermsLoader.getInternalLists())); @@ -621,10 +559,6 @@ private JabRefPreferences() { defaults.put(OO_USE_ALL_OPEN_BASES, Boolean.TRUE); defaults.put(OO_BIBLIOGRAPHY_STYLE_FILE, StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH); defaults.put(OO_EXTERNAL_STYLE_FILES, ""); - defaults.put(STYLES_POS_X, 0); - defaults.put(STYLES_POS_Y, 0); - defaults.put(STYLES_SIZE_X, 600); - defaults.put(STYLES_SIZE_Y, 400); defaults.put(SPECIALFIELDSENABLED, Boolean.TRUE); defaults.put(AUTOSYNCSPECIALFIELDSTOKEYWORDS, Boolean.TRUE); @@ -692,12 +626,6 @@ private JabRefPreferences() { defaults.put(ASK_AUTO_NAMING_PDFS_AGAIN, Boolean.TRUE); insertDefaultCleanupPreset(defaults); - // defaults for DroppedFileHandler UI - defaults.put(DROPPEDFILEHANDLER_LEAVE, Boolean.FALSE); - defaults.put(DROPPEDFILEHANDLER_COPY, Boolean.TRUE); - defaults.put(DROPPEDFILEHANDLER_MOVE, Boolean.FALSE); - defaults.put(DROPPEDFILEHANDLER_RENAME, Boolean.FALSE); - // use BibTeX key appended with filename as default pattern defaults.put(IMPORT_FILENAMEPATTERN, ImportTabViewModel.DEFAULT_FILENAME_PATTERNS[1]); //Default empty String to be backwards compatible @@ -774,28 +702,6 @@ private static String convertListToString(List value) { return value.stream().map(val -> StringUtil.quote(val, STRINGLIST_DELIMITER.toString(), '\\')).collect(Collectors.joining(STRINGLIST_DELIMITER.toString())); } - /** - * Looks up a color definition in preferences, and returns an array containing the RGB values. - * - * @param value The key for this setting. - * @return The RGB values corresponding to this color setting. - */ - private static int[] getRgb(String value) { - int[] values = new int[3]; - - if ((value != null) && !value.isEmpty()) { - String[] elements = value.split(":"); - values[0] = Integer.parseInt(elements[0]); - values[1] = Integer.parseInt(elements[1]); - values[2] = Integer.parseInt(elements[2]); - } else { - values[0] = 0; - values[1] = 0; - values[2] = 0; - } - return values; - } - private static Preferences getPrefsNodeForCustomizedEntryTypes(BibDatabaseMode mode) { if (mode == BibDatabaseMode.BIBLATEX) { return Preferences.userNodeForPackage(PREFS_BASE_CLASS).node(CUSTOMIZED_BIBLATEX_TYPES); @@ -1094,24 +1000,6 @@ public List getStringList(String key) { return res; } - /** - * Looks up a color definition in preferences, and returns the Color object. - * - * @param key The key for this setting. - * @return The color corresponding to the setting. - */ - public Color getColor(String key) { - String value = get(key); - int[] rgb = getRgb(value); - return Color.rgb(rgb[0], rgb[1], rgb[2]); - } - - public Color getDefaultColor(String key) { - String value = (String) defaults.get(key); - int[] rgb = getRgb(value); - return Color.rgb(rgb[0], rgb[1], rgb[2]); - } - /** * Returns the default BibDatabase mode, which can be either BIBTEX or BIBLATEX. * @@ -2097,7 +1985,7 @@ public void saveCustomEntryTypes() { } private void saveCustomEntryTypes(BibDatabaseMode bibDatabaseMode) { - List customBiblatexBibTexTypes = Globals.entryTypesManager.getAllTypes(bibDatabaseMode).stream() + List customBiblatexBibTexTypes = Globals.entryTypesManager.getAllTypes(bibDatabaseMode).stream() .map(entryType -> entryType).collect(Collectors.toList()); storeBibEntryTypes(customBiblatexBibTexTypes, bibDatabaseMode); diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index a36946affb4..d01aea778bc 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1340,7 +1340,6 @@ Hint\:\ To\ search\ specific\ fields\ only,\ enter\ for\ example\:=Hint: To sear Unable\ to\ autodetect\ OpenOffice/LibreOffice\ installation.\ Please\ choose\ the\ installation\ directory\ manually.=Unable to autodetect OpenOffice/LibreOffice installation. Please choose the installation directory manually. Close\ library=Close library -Decrease\ table\ font\ size=Decrease table font size Entry\ editor,\ next\ entry=Entry editor, next entry Entry\ editor,\ next\ panel=Entry editor, next panel Entry\ editor,\ next\ panel\ 2=Entry editor, next panel 2 @@ -1352,7 +1351,6 @@ File\ list\ editor,\ move\ entry\ up=File list editor, move entry up Focus\ entry\ table=Focus entry table Import\ into\ current\ library=Import into current library Import\ into\ new\ library=Import into new library -Increase\ table\ font\ size=Increase table font size New\ article=New article New\ book=New book New\ entry=New entry @@ -1421,7 +1419,6 @@ Move\ linked\ files\ to\ default\ file\ directory\ %0=Move linked files to defau Do\ you\ still\ want\ to\ continue?=Do you still want to continue? Run\ field\ formatter\:=Run field formatter: -Table\ font\ size\ is\ %0=Table font size is %0 Internal\ style=Internal style Add\ style\ file=Add style file Current\ style\ is\ '%0'=Current style is '%0' @@ -1763,7 +1760,6 @@ journal\ not\ found\ in\ abbreviation\ list=journal not found in abbreviation li Unhandled\ exception\ occurred.=Unhandled exception occurred. strings\ included=strings included -Default\ table\ font\ size=Default table font size Escape\ underscores=Escape underscores Color=Color Please\ also\ add\ all\ steps\ to\ reproduce\ this\ issue,\ if\ possible.=Please also add all steps to reproduce this issue, if possible. From 07ff8ce0b341b2cbf3cdbebe3bba0c985bef941f Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 11 Mar 2020 21:33:39 +0100 Subject: [PATCH 2/3] Deprecate Globals --- src/main/java/org/jabref/Globals.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/jabref/Globals.java b/src/main/java/org/jabref/Globals.java index d854729374b..2524305194e 100644 --- a/src/main/java/org/jabref/Globals.java +++ b/src/main/java/org/jabref/Globals.java @@ -30,6 +30,10 @@ import com.microsoft.applicationinsights.telemetry.SessionState; import kong.unirest.Unirest; +/** + * @deprecated try to use {@link StateManager} and {@link org.jabref.preferences.PreferencesService} + */ +@Deprecated public class Globals { /** From 7643f53caacd9bb8e68190fd2f1f79e359107f1a Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Wed, 11 Mar 2020 21:41:19 +0100 Subject: [PATCH 3/3] Fix checkstyle --- src/main/java/org/jabref/gui/icon/IconTheme.java | 8 ++------ src/main/java/org/jabref/gui/maintable/MainTable.java | 1 - .../java/org/jabref/gui/preferences/PreviewTabView.java | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/icon/IconTheme.java b/src/main/java/org/jabref/gui/icon/IconTheme.java index 89a51634fcf..76d9684c13f 100644 --- a/src/main/java/org/jabref/gui/icon/IconTheme.java +++ b/src/main/java/org/jabref/gui/icon/IconTheme.java @@ -19,8 +19,6 @@ import javafx.scene.paint.Color; import javafx.scene.text.Font; -import org.jabref.preferences.JabRefPreferences; - import de.jensd.fx.glyphs.GlyphIcons; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; import org.slf4j.Logger; @@ -86,7 +84,7 @@ public static URL getIconUrl(String name) { String key = Objects.requireNonNull(name, "icon name"); if (!KEY_TO_ICON.containsKey(key)) { LOGGER.warn("Could not find icon url by name " + name + ", so falling back on default icon " - + DEFAULT_ICON_PATH); + + DEFAULT_ICON_PATH); } String path = KEY_TO_ICON.getOrDefault(key, DEFAULT_ICON_PATH); return Objects.requireNonNull(IconTheme.class.getResource(path), "Path must not be null for key " + key); @@ -110,7 +108,7 @@ private static Map readIconThemeFile(URL url, String prefix) { Map result = new HashMap<>(); try (BufferedReader in = new BufferedReader( - new InputStreamReader(url.openStream(), StandardCharsets.ISO_8859_1))) { + new InputStreamReader(url.openStream(), StandardCharsets.ISO_8859_1))) { String line; while ((line = in.readLine()) != null) { if (!line.contains("=")) { @@ -345,7 +343,6 @@ public ToggleButton asToggleButton() { @Override public JabRefIcon withColor(Color color) { return icon.withColor(color); - } @Override @@ -353,5 +350,4 @@ public JabRefIcon disabled() { return icon.disabled(); } } - } diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index 530ef02f895..24fa8753183 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -27,7 +27,6 @@ import org.jabref.gui.BasePanel; import org.jabref.gui.DragAndDropDataFormats; import org.jabref.gui.JabRefFrame; -import org.jabref.gui.StateManager; import org.jabref.gui.externalfiles.ImportHandler; import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.keyboard.KeyBinding; diff --git a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java index c44d13e5af5..c366341c729 100644 --- a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java +++ b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java @@ -22,7 +22,6 @@ import javafx.scene.input.TransferMode; import org.jabref.Globals; -import org.jabref.gui.DialogService; import org.jabref.gui.StateManager; import org.jabref.gui.actions.ActionFactory; import org.jabref.gui.actions.SimpleCommand;