From cbce3650a9be1fcf9f2f2389ede0e72dace2f1c2 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 Sep 2015 21:00:19 +0200 Subject: [PATCH 1/3] Cleanup and format some files Run cleanup and format in eclipse on some files to make comparison in #162 easier. --- .../java/net/sf/jabref/JabRefPreferences.java | 676 +++++++++--------- .../net/sf/jabref/SearchManagerNoGUI.java | 8 +- .../sf/jabref/gui/AutoCompleteListener.java | 96 ++- .../java/net/sf/jabref/gui/BasePanel.java | 518 +++++--------- .../java/net/sf/jabref/gui/JabRefFrame.java | 561 +++++---------- .../gui/MainTableSelectionListener.java | 74 +- .../java/net/sf/jabref/gui/PreviewPanel.java | 105 +-- .../autocompleter/AbstractAutoCompleter.java | 16 +- 8 files changed, 811 insertions(+), 1243 deletions(-) diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java index 9047c7d368a..afdfb2dcafa 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -59,6 +59,7 @@ import net.sf.jabref.logic.util.strings.StringUtil; public class JabRefPreferences { + private static final Log LOGGER = LogFactory.getLog(JabRefPreferences.class); /** @@ -344,11 +345,11 @@ public class JabRefPreferences { // modifications, in order to indicate a removed default file type: private static final String FILE_TYPE_REMOVED_FLAG = "REMOVED"; - private static final char[][] VALUE_DELIMITERS = new char[][] { {'"', '"'}, {'{', '}'}}; + private static final char[][] VALUE_DELIMITERS = new char[][] {{'"', '"'}, {'{', '}'}}; public String WRAPPED_USERNAME; public final String MARKING_WITH_NUMBER_PATTERN; - + private int SHORTCUT_MASK = -1; private final Preferences prefs; @@ -459,7 +460,7 @@ private JabRefPreferences() { importPreferences("jabref.xml"); } } catch (IOException e) { - LOGGER.info("Could not import preferences from jabref.xml:" + e.getLocalizedMessage(), e); + JabRefPreferences.LOGGER.info("Could not import preferences from jabref.xml:" + e.getLocalizedMessage(), e); } // load user preferences @@ -470,210 +471,208 @@ private JabRefPreferences() { //defaults.put("pdfviewer", "/Applications/Preview.app"); //defaults.put("psviewer", "/Applications/Preview.app"); //defaults.put("htmlviewer", "/Applications/Safari.app"); - defaults.put(EMACS_PATH, "emacsclient"); - defaults.put(EMACS_23, true); - defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e"); - defaults.put(FONT_FAMILY, "SansSerif"); + defaults.put(JabRefPreferences.EMACS_PATH, "emacsclient"); + defaults.put(JabRefPreferences.EMACS_23, true); + defaults.put(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS, "-n -e"); + defaults.put(JabRefPreferences.FONT_FAMILY, "SansSerif"); } else if (OS.WINDOWS) { //defaults.put("pdfviewer", "cmd.exe /c start /b"); //defaults.put("psviewer", "cmd.exe /c start /b"); //defaults.put("htmlviewer", "cmd.exe /c start /b"); - defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel"); - defaults.put(WIN_EDT_PATH, "C:\\Program Files\\WinEdt Team\\WinEdt\\WinEdt.exe"); - defaults.put(LATEX_EDITOR_PATH, "C:\\Program Files\\LEd\\LEd.exe"); - defaults.put(EMACS_PATH, "emacsclient.exe"); - defaults.put(EMACS_23, true); - defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e"); - defaults.put(FONT_FAMILY, "Arial"); + defaults.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel"); + defaults.put(JabRefPreferences.WIN_EDT_PATH, "C:\\Program Files\\WinEdt Team\\WinEdt\\WinEdt.exe"); + defaults.put(JabRefPreferences.LATEX_EDITOR_PATH, "C:\\Program Files\\LEd\\LEd.exe"); + defaults.put(JabRefPreferences.EMACS_PATH, "emacsclient.exe"); + defaults.put(JabRefPreferences.EMACS_23, true); + defaults.put(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS, "-n -e"); + defaults.put(JabRefPreferences.FONT_FAMILY, "Arial"); } else { //defaults.put("pdfviewer", "evince"); //defaults.put("psviewer", "gv"); //defaults.put("htmlviewer", "firefox"); - defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel"); - defaults.put(FONT_FAMILY, "SansSerif"); + defaults.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel"); + defaults.put(JabRefPreferences.FONT_FAMILY, "SansSerif"); // linux - defaults.put(EMACS_PATH, "gnuclient"); - defaults.put(EMACS_23, false); - defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-batch -eval"); + defaults.put(JabRefPreferences.EMACS_PATH, "gnuclient"); + defaults.put(JabRefPreferences.EMACS_23, false); + defaults.put(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS, "-batch -eval"); } - defaults.put(USE_PROXY, Boolean.FALSE); - defaults.put(PROXY_HOSTNAME, "my proxy host"); - defaults.put(PROXY_PORT, "my proxy port"); - defaults.put(PDF_PREVIEW, Boolean.FALSE); - defaults.put(USE_DEFAULT_LOOK_AND_FEEL, Boolean.TRUE); - defaults.put(LYXPIPE, System.getProperty("user.home") + File.separator + ".lyx/lyxpipe"); - defaults.put(VIM, "vim"); - defaults.put(VIM_SERVER, "vim"); - defaults.put(POS_X, 0); - defaults.put(POS_Y, 0); - defaults.put(SIZE_X, 840); - defaults.put(SIZE_Y, 680); - defaults.put(WINDOW_MAXIMISED, Boolean.FALSE); - defaults.put(AUTO_RESIZE_MODE, JTable.AUTO_RESIZE_ALL_COLUMNS); - defaults.put(PREVIEW_PANEL_HEIGHT, 200); - defaults.put(ENTRY_EDITOR_HEIGHT, 400); - defaults.put(TABLE_COLOR_CODES_ON, Boolean.TRUE); - defaults.put(NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged" - defaults.put(NAMES_FIRST_LAST, Boolean.FALSE); // "Show 'Firstname Lastname'" - defaults.put(NAMES_LAST_FIRST, Boolean.FALSE); // "Show 'Lastname, Firstname'" - defaults.put(NAMES_NATBIB, Boolean.TRUE); // "Natbib style" - defaults.put(ABBR_AUTHOR_NAMES, Boolean.TRUE); // "Abbreviate names" - defaults.put(NAMES_LAST_ONLY, Boolean.TRUE); // "Show last names only" - defaults.put(LANGUAGE, "en"); - defaults.put(SHOW_SHORT, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_PROXY, Boolean.FALSE); + defaults.put(JabRefPreferences.PROXY_HOSTNAME, "my proxy host"); + defaults.put(JabRefPreferences.PROXY_PORT, "my proxy port"); + defaults.put(JabRefPreferences.PDF_PREVIEW, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL, Boolean.TRUE); + defaults.put(JabRefPreferences.LYXPIPE, System.getProperty("user.home") + File.separator + ".lyx/lyxpipe"); + defaults.put(JabRefPreferences.VIM, "vim"); + defaults.put(JabRefPreferences.VIM_SERVER, "vim"); + defaults.put(JabRefPreferences.POS_X, 0); + defaults.put(JabRefPreferences.POS_Y, 0); + defaults.put(JabRefPreferences.SIZE_X, 840); + defaults.put(JabRefPreferences.SIZE_Y, 680); + defaults.put(JabRefPreferences.WINDOW_MAXIMISED, Boolean.FALSE); + defaults.put(JabRefPreferences.AUTO_RESIZE_MODE, JTable.AUTO_RESIZE_ALL_COLUMNS); + defaults.put(JabRefPreferences.PREVIEW_PANEL_HEIGHT, 200); + defaults.put(JabRefPreferences.ENTRY_EDITOR_HEIGHT, 400); + defaults.put(JabRefPreferences.TABLE_COLOR_CODES_ON, Boolean.TRUE); + defaults.put(JabRefPreferences.NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged" + defaults.put(JabRefPreferences.NAMES_FIRST_LAST, Boolean.FALSE); // "Show 'Firstname Lastname'" + defaults.put(JabRefPreferences.NAMES_LAST_FIRST, Boolean.FALSE); // "Show 'Lastname, Firstname'" + defaults.put(JabRefPreferences.NAMES_NATBIB, Boolean.TRUE); // "Natbib style" + defaults.put(JabRefPreferences.ABBR_AUTHOR_NAMES, Boolean.TRUE); // "Abbreviate names" + defaults.put(JabRefPreferences.NAMES_LAST_ONLY, Boolean.TRUE); // "Show last names only" + defaults.put(JabRefPreferences.LANGUAGE, "en"); + defaults.put(JabRefPreferences.SHOW_SHORT, Boolean.TRUE); // Sorting preferences - defaults.put(PRIMARY_SORT_FIELD, "author"); - defaults.put(PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(SECONDARY_SORT_FIELD, "year"); - defaults.put(SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(TERTIARY_SORT_FIELD, "author"); - defaults.put(TERTIARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(SAVE_IN_ORIGINAL_ORDER, Boolean.FALSE); - defaults.put(SAVE_IN_SPECIFIED_ORDER, Boolean.FALSE); - defaults.put(SAVE_PRIMARY_SORT_FIELD, "bibtexkey"); - defaults.put(SAVE_PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(SAVE_SECONDARY_SORT_FIELD, "author"); - defaults.put(SAVE_SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(SAVE_TERTIARY_SORT_FIELD, ""); - defaults.put(SAVE_TERTIARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(EXPORT_IN_ORIGINAL_ORDER, Boolean.FALSE); - defaults.put(EXPORT_IN_SPECIFIED_ORDER, Boolean.FALSE); - defaults.put(EXPORT_PRIMARY_SORT_FIELD, "bibtexkey"); - defaults.put(EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(EXPORT_SECONDARY_SORT_FIELD, "author"); - defaults.put(EXPORT_SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(EXPORT_TERTIARY_SORT_FIELD, ""); - defaults.put(EXPORT_TERTIARY_SORT_DESCENDING, Boolean.TRUE); - - defaults.put(NEWLINE, System.lineSeparator()); - - defaults.put(SIDE_PANE_COMPONENT_NAMES, ""); - defaults.put(SIDE_PANE_COMPONENT_PREFERRED_POSITIONS, ""); - - defaults.put(COLUMN_NAMES, "entrytype;author;title;year;journal;owner;timestamp;bibtexkey"); - defaults.put(COLUMN_WIDTHS, "75;280;400;60;100;100;100;100"); - defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY, - PersistenceTableColumnListener.DEFAULT_ENABLED); - defaults.put(XMP_PRIVACY_FILTERS, "pdf;timestamp;keywords;owner;note;review"); - defaults.put(USE_XMP_PRIVACY_FILTER, Boolean.FALSE); - defaults.put(NUMBER_COL_WIDTH, GUIGlobals.NUMBER_COL_LENGTH); - defaults.put(WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(EXPORT_WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(IMPORT_WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(FILE_WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(AUTO_OPEN_FORM, Boolean.TRUE); - defaults.put(ENTRY_TYPE_FORM_HEIGHT_FACTOR, 1); - defaults.put(ENTRY_TYPE_FORM_WIDTH, 1); - defaults.put(BACKUP, Boolean.TRUE); - defaults.put(OPEN_LAST_EDITED, Boolean.TRUE); - defaults.put(LAST_EDITED, null); - 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(DEFAULT_SHOW_SOURCE, Boolean.FALSE); - defaults.put(SHOW_SOURCE, Boolean.TRUE); - defaults.put(DEFAULT_AUTO_SORT, Boolean.FALSE); - defaults.put(CASE_SENSITIVE_SEARCH, Boolean.FALSE); - defaults.put(SEARCH_REQ, Boolean.TRUE); - defaults.put(SEARCH_OPT, Boolean.TRUE); - defaults.put(SEARCH_GEN, Boolean.TRUE); - defaults.put(SEARCH_ALL, Boolean.FALSE); - defaults.put(INCREMENT_S, Boolean.FALSE); - defaults.put(SEARCH_AUTO_COMPLETE, Boolean.TRUE); - - defaults.put(SELECT_S, Boolean.FALSE); - defaults.put(REG_EXP_SEARCH, Boolean.TRUE); - defaults.put(HIGH_LIGHT_WORDS, Boolean.TRUE); - defaults.put(SEARCH_PANE_POS_X, 0); - defaults.put(SEARCH_PANE_POS_Y, 0); - defaults.put(EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE); - defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE); - defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE); - defaults.put(AUTO_COMPLETE, Boolean.TRUE); - defaults.put(AUTO_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords;crossref"); - defaults.put(AUTO_COMP_FIRST_LAST, Boolean.FALSE); // "Autocomplete names in 'Firstname Lastname' format only" - defaults.put(AUTO_COMP_LAST_FIRST, Boolean.FALSE); // "Autocomplete names in 'Lastname, Firstname' format only" - defaults.put(SHORTEST_TO_COMPLETE, 2); - defaults.put(AUTOCOMPLETE_FIRSTNAME_MODE, JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE_BOTH); - defaults.put(GROUP_SELECTOR_VISIBLE, Boolean.TRUE); - defaults.put(GROUP_FLOAT_SELECTIONS, Boolean.TRUE); - defaults.put(GROUP_INTERSECT_SELECTIONS, Boolean.TRUE); - defaults.put(GROUP_INVERT_SELECTIONS, Boolean.FALSE); - defaults.put(GROUP_SHOW_OVERLAPPING, Boolean.FALSE); - defaults.put(GROUP_SELECT_MATCHES, Boolean.FALSE); - defaults.put(GROUPS_DEFAULT_FIELD, "keywords"); - defaults.put(GROUP_SHOW_ICONS, Boolean.TRUE); - defaults.put(GROUP_SHOW_DYNAMIC, Boolean.TRUE); - defaults.put(GROUP_EXPAND_TREE, Boolean.TRUE); - defaults.put(GROUP_AUTO_SHOW, Boolean.TRUE); - defaults.put(GROUP_AUTO_HIDE, Boolean.TRUE); - defaults.put(GROUP_SHOW_NUMBER_OF_ELEMENTS, Boolean.FALSE); - defaults.put(AUTO_ASSIGN_GROUP, Boolean.TRUE); - defaults.put(GROUP_KEYWORD_SEPARATOR, ", "); - defaults.put(EDIT_GROUP_MEMBERSHIP_MODE, Boolean.FALSE); - defaults.put(HIGHLIGHT_GROUPS_MATCHING_ANY, Boolean.FALSE); - defaults.put(HIGHLIGHT_GROUPS_MATCHING_ALL, Boolean.FALSE); - defaults.put(TOOLBAR_VISIBLE, Boolean.TRUE); - defaults.put(SEARCH_PANEL_VISIBLE, Boolean.FALSE); - defaults.put(DEFAULT_ENCODING, System.getProperty("file.encoding")); - defaults.put(GROUPS_VISIBLE_ROWS, 8); - defaults.put(DEFAULT_OWNER, System.getProperty("user.name")); - defaults.put(PRESERVE_FIELD_FORMATTING, Boolean.FALSE); - defaults.put(MEMORY_STICK_MODE, Boolean.FALSE); - defaults.put(RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE); + defaults.put(JabRefPreferences.PRIMARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.PRIMARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.SECONDARY_SORT_FIELD, "year"); + defaults.put(JabRefPreferences.SECONDARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.TERTIARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.TERTIARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_IN_ORIGINAL_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_IN_SPECIFIED_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_PRIMARY_SORT_FIELD, "bibtexkey"); + defaults.put(JabRefPreferences.SAVE_PRIMARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_SECONDARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.SAVE_SECONDARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.SAVE_TERTIARY_SORT_FIELD, ""); + defaults.put(JabRefPreferences.SAVE_TERTIARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.EXPORT_IN_ORIGINAL_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.EXPORT_PRIMARY_SORT_FIELD, "bibtexkey"); + defaults.put(JabRefPreferences.EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.EXPORT_SECONDARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.EXPORT_SECONDARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.EXPORT_TERTIARY_SORT_FIELD, ""); + defaults.put(JabRefPreferences.EXPORT_TERTIARY_SORT_DESCENDING, Boolean.TRUE); + + defaults.put(JabRefPreferences.NEWLINE, System.lineSeparator()); + + defaults.put(JabRefPreferences.SIDE_PANE_COMPONENT_NAMES, ""); + defaults.put(JabRefPreferences.SIDE_PANE_COMPONENT_PREFERRED_POSITIONS, ""); + + defaults.put(JabRefPreferences.COLUMN_NAMES, "entrytype;author;title;year;journal;owner;timestamp;bibtexkey"); + defaults.put(JabRefPreferences.COLUMN_WIDTHS, "75;280;400;60;100;100;100;100"); + defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY, PersistenceTableColumnListener.DEFAULT_ENABLED); + defaults.put(JabRefPreferences.XMP_PRIVACY_FILTERS, "pdf;timestamp;keywords;owner;note;review"); + defaults.put(JabRefPreferences.USE_XMP_PRIVACY_FILTER, Boolean.FALSE); + defaults.put(JabRefPreferences.NUMBER_COL_WIDTH, GUIGlobals.NUMBER_COL_LENGTH); + defaults.put(JabRefPreferences.WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.IMPORT_WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.FILE_WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.AUTO_OPEN_FORM, Boolean.TRUE); + defaults.put(JabRefPreferences.ENTRY_TYPE_FORM_HEIGHT_FACTOR, 1); + defaults.put(JabRefPreferences.ENTRY_TYPE_FORM_WIDTH, 1); + defaults.put(JabRefPreferences.BACKUP, Boolean.TRUE); + defaults.put(JabRefPreferences.OPEN_LAST_EDITED, Boolean.TRUE); + defaults.put(JabRefPreferences.LAST_EDITED, null); + defaults.put(JabRefPreferences.STRINGS_POS_X, 0); + defaults.put(JabRefPreferences.STRINGS_POS_Y, 0); + defaults.put(JabRefPreferences.STRINGS_SIZE_X, 600); + defaults.put(JabRefPreferences.STRINGS_SIZE_Y, 400); + defaults.put(JabRefPreferences.DEFAULT_SHOW_SOURCE, Boolean.FALSE); + defaults.put(JabRefPreferences.SHOW_SOURCE, Boolean.TRUE); + defaults.put(JabRefPreferences.DEFAULT_AUTO_SORT, Boolean.FALSE); + defaults.put(JabRefPreferences.CASE_SENSITIVE_SEARCH, Boolean.FALSE); + defaults.put(JabRefPreferences.SEARCH_REQ, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_OPT, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_GEN, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_ALL, Boolean.FALSE); + defaults.put(JabRefPreferences.INCREMENT_S, Boolean.FALSE); + defaults.put(JabRefPreferences.SEARCH_AUTO_COMPLETE, Boolean.TRUE); + + defaults.put(JabRefPreferences.SELECT_S, Boolean.FALSE); + defaults.put(JabRefPreferences.REG_EXP_SEARCH, Boolean.TRUE); + defaults.put(JabRefPreferences.HIGH_LIGHT_WORDS, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_PANE_POS_X, 0); + defaults.put(JabRefPreferences.SEARCH_PANE_POS_Y, 0); + defaults.put(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE); + defaults.put(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE); + defaults.put(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_COMPLETE, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords;crossref"); + defaults.put(JabRefPreferences.AUTO_COMP_FIRST_LAST, Boolean.FALSE); // "Autocomplete names in 'Firstname Lastname' format only" + defaults.put(JabRefPreferences.AUTO_COMP_LAST_FIRST, Boolean.FALSE); // "Autocomplete names in 'Lastname, Firstname' format only" + defaults.put(JabRefPreferences.SHORTEST_TO_COMPLETE, 2); + defaults.put(JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE, JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE_BOTH); + defaults.put(JabRefPreferences.GROUP_SELECTOR_VISIBLE, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_FLOAT_SELECTIONS, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_INVERT_SELECTIONS, Boolean.FALSE); + defaults.put(JabRefPreferences.GROUP_SHOW_OVERLAPPING, Boolean.FALSE); + defaults.put(JabRefPreferences.GROUP_SELECT_MATCHES, Boolean.FALSE); + defaults.put(JabRefPreferences.GROUPS_DEFAULT_FIELD, "keywords"); + defaults.put(JabRefPreferences.GROUP_SHOW_ICONS, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_SHOW_DYNAMIC, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_EXPAND_TREE, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_AUTO_SHOW, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_AUTO_HIDE, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS, Boolean.FALSE); + defaults.put(JabRefPreferences.AUTO_ASSIGN_GROUP, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_KEYWORD_SEPARATOR, ", "); + defaults.put(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, Boolean.FALSE); + defaults.put(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ANY, Boolean.FALSE); + defaults.put(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ALL, Boolean.FALSE); + defaults.put(JabRefPreferences.TOOLBAR_VISIBLE, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_PANEL_VISIBLE, Boolean.FALSE); + defaults.put(JabRefPreferences.DEFAULT_ENCODING, System.getProperty("file.encoding")); + defaults.put(JabRefPreferences.GROUPS_VISIBLE_ROWS, 8); + defaults.put(JabRefPreferences.DEFAULT_OWNER, System.getProperty("user.name")); + defaults.put(JabRefPreferences.PRESERVE_FIELD_FORMATTING, Boolean.FALSE); + defaults.put(JabRefPreferences.MEMORY_STICK_MODE, Boolean.FALSE); + defaults.put(JabRefPreferences.RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE); // The general fields stuff is made obsolete by the CUSTOM_TAB_... entries. - defaults.put(GENERAL_FIELDS, "crossref;keywords;file;doi;url;urldate;" - + "pdf;comment;owner"); - - defaults.put(HISTORY_SIZE, 8); - defaults.put(FONT_STYLE, java.awt.Font.PLAIN); - defaults.put(FONT_SIZE, 12); - defaults.put(OVERRIDE_DEFAULT_FONTS, Boolean.FALSE); - defaults.put(MENU_FONT_FAMILY, "Times"); - defaults.put(MENU_FONT_STYLE, java.awt.Font.PLAIN); - defaults.put(MENU_FONT_SIZE, 11); - defaults.put(TABLE_ROW_PADDING, GUIGlobals.TABLE_ROW_PADDING); - defaults.put(TABLE_SHOW_GRID, Boolean.FALSE); + defaults.put(JabRefPreferences.GENERAL_FIELDS, "crossref;keywords;file;doi;url;urldate;" + "pdf;comment;owner"); + + defaults.put(JabRefPreferences.HISTORY_SIZE, 8); + defaults.put(JabRefPreferences.FONT_STYLE, java.awt.Font.PLAIN); + defaults.put(JabRefPreferences.FONT_SIZE, 12); + defaults.put(JabRefPreferences.OVERRIDE_DEFAULT_FONTS, Boolean.FALSE); + defaults.put(JabRefPreferences.MENU_FONT_FAMILY, "Times"); + defaults.put(JabRefPreferences.MENU_FONT_STYLE, java.awt.Font.PLAIN); + defaults.put(JabRefPreferences.MENU_FONT_SIZE, 11); + defaults.put(JabRefPreferences.TABLE_ROW_PADDING, GUIGlobals.TABLE_ROW_PADDING); + defaults.put(JabRefPreferences.TABLE_SHOW_GRID, Boolean.FALSE); // Main table color settings: - defaults.put(TABLE_BACKGROUND, "255:255:255"); - defaults.put(TABLE_REQ_FIELD_BACKGROUND, "230:235:255"); - defaults.put(TABLE_OPT_FIELD_BACKGROUND, "230:255:230"); - defaults.put(TABLE_TEXT, "0:0:0"); - defaults.put(GRID_COLOR, "210:210:210"); - defaults.put(GRAYED_OUT_BACKGROUND, "210:210:210"); - defaults.put(GRAYED_OUT_TEXT, "40:40:40"); - defaults.put(VERY_GRAYED_OUT_BACKGROUND, "180:180:180"); - defaults.put(VERY_GRAYED_OUT_TEXT, "40:40:40"); - defaults.put(MARKED_ENTRY_BACKGROUND0, "255:255:180"); - defaults.put(MARKED_ENTRY_BACKGROUND1, "255:220:180"); - defaults.put(MARKED_ENTRY_BACKGROUND2, "255:180:160"); - defaults.put(MARKED_ENTRY_BACKGROUND3, "255:120:120"); - defaults.put(MARKED_ENTRY_BACKGROUND4, "255:75:75"); - defaults.put(MARKED_ENTRY_BACKGROUND5, "220:255:220"); - 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"); - - defaults.put(INCOMPLETE_ENTRY_BACKGROUND, "250:175:175"); - - defaults.put(ANTIALIAS, Boolean.FALSE); - defaults.put(CTRL_CLICK, Boolean.FALSE); - defaults.put(DISABLE_ON_MULTIPLE_SELECTION, Boolean.FALSE); - defaults.put(PDF_COLUMN, Boolean.FALSE); - defaults.put(URL_COLUMN, Boolean.TRUE); - defaults.put(PREFER_URL_DOI, Boolean.FALSE); - defaults.put(FILE_COLUMN, Boolean.TRUE); - defaults.put(ARXIV_COLUMN, Boolean.FALSE); - - defaults.put(EXTRA_FILE_COLUMNS, Boolean.FALSE); - defaults.put(LIST_OF_FILE_COLUMNS, ""); + defaults.put(JabRefPreferences.TABLE_BACKGROUND, "255:255:255"); + defaults.put(JabRefPreferences.TABLE_REQ_FIELD_BACKGROUND, "230:235:255"); + defaults.put(JabRefPreferences.TABLE_OPT_FIELD_BACKGROUND, "230:255:230"); + defaults.put(JabRefPreferences.TABLE_TEXT, "0:0:0"); + defaults.put(JabRefPreferences.GRID_COLOR, "210:210:210"); + defaults.put(JabRefPreferences.GRAYED_OUT_BACKGROUND, "210:210:210"); + defaults.put(JabRefPreferences.GRAYED_OUT_TEXT, "40:40:40"); + defaults.put(JabRefPreferences.VERY_GRAYED_OUT_BACKGROUND, "180:180:180"); + defaults.put(JabRefPreferences.VERY_GRAYED_OUT_TEXT, "40:40:40"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND0, "255:255:180"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND1, "255:220:180"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND2, "255:180:160"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND3, "255:120:120"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND4, "255:75:75"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND5, "220:255:220"); + defaults.put(JabRefPreferences.VALID_FIELD_BACKGROUND_COLOR, "255:255:255"); + defaults.put(JabRefPreferences.INVALID_FIELD_BACKGROUND_COLOR, "255:0:0"); + defaults.put(JabRefPreferences.ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR, "220:220:255"); + defaults.put(JabRefPreferences.FIELD_EDITOR_TEXT_COLOR, "0:0:0"); + + defaults.put(JabRefPreferences.INCOMPLETE_ENTRY_BACKGROUND, "250:175:175"); + + defaults.put(JabRefPreferences.ANTIALIAS, Boolean.FALSE); + defaults.put(JabRefPreferences.CTRL_CLICK, Boolean.FALSE); + defaults.put(JabRefPreferences.DISABLE_ON_MULTIPLE_SELECTION, Boolean.FALSE); + defaults.put(JabRefPreferences.PDF_COLUMN, Boolean.FALSE); + defaults.put(JabRefPreferences.URL_COLUMN, Boolean.TRUE); + defaults.put(JabRefPreferences.PREFER_URL_DOI, Boolean.FALSE); + defaults.put(JabRefPreferences.FILE_COLUMN, Boolean.TRUE); + defaults.put(JabRefPreferences.ARXIV_COLUMN, Boolean.FALSE); + + defaults.put(JabRefPreferences.EXTRA_FILE_COLUMNS, Boolean.FALSE); + defaults.put(JabRefPreferences.LIST_OF_FILE_COLUMNS, ""); defaults.put(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED, SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED_DEFAULT); defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY, SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY_DEFAULT); @@ -686,140 +685,110 @@ private JabRefPreferences() { defaults.put(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS, SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS_DEFAULT); defaults.put(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS, SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS_DEFAULT); - defaults.put(SHOW_ONE_LETTER_HEADING_FOR_ICON_COLUMNS, Boolean.FALSE); - - defaults.put(USE_OWNER, Boolean.FALSE); - defaults.put(OVERWRITE_OWNER, Boolean.FALSE); - defaults.put(ALLOW_TABLE_EDITING, Boolean.FALSE); - defaults.put(DIALOG_WARNING_FOR_DUPLICATE_KEY, Boolean.TRUE); - defaults.put(DIALOG_WARNING_FOR_EMPTY_KEY, Boolean.TRUE); - defaults.put(DISPLAY_KEY_WARNING_DIALOG_AT_STARTUP, Boolean.TRUE); - defaults.put(AVOID_OVERWRITING_KEY, Boolean.FALSE); - defaults.put(WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE); - defaults.put(CONFIRM_DELETE, Boolean.TRUE); - defaults.put(GRAY_OUT_NON_HITS, Boolean.TRUE); - defaults.put(FLOAT_SEARCH, Boolean.TRUE); - defaults.put(SHOW_SEARCH_IN_DIALOG, Boolean.FALSE); - defaults.put(SEARCH_ALL_BASES, Boolean.FALSE); - defaults.put(DEFAULT_LABEL_PATTERN, "[auth][year]"); - defaults.put(PREVIEW_ENABLED, Boolean.TRUE); - defaults.put(ACTIVE_PREVIEW, 0); - defaults.put(PREVIEW_0, "" - + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" - + "\\end{bibtexkey}
__NEWLINE__" - + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" - + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " - + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" - + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" - + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" - + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" - + "__NEWLINE__

"); - defaults.put(PREVIEW_1, "" - + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" - + "\\end{bibtexkey}
__NEWLINE__" - + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" - + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " - + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" - + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" - + "__NEWLINE__

"); + defaults.put(JabRefPreferences.SHOW_ONE_LETTER_HEADING_FOR_ICON_COLUMNS, Boolean.FALSE); + + defaults.put(JabRefPreferences.USE_OWNER, Boolean.FALSE); + defaults.put(JabRefPreferences.OVERWRITE_OWNER, Boolean.FALSE); + defaults.put(JabRefPreferences.ALLOW_TABLE_EDITING, Boolean.FALSE); + defaults.put(JabRefPreferences.DIALOG_WARNING_FOR_DUPLICATE_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.DIALOG_WARNING_FOR_EMPTY_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.DISPLAY_KEY_WARNING_DIALOG_AT_STARTUP, Boolean.TRUE); + defaults.put(JabRefPreferences.AVOID_OVERWRITING_KEY, Boolean.FALSE); + defaults.put(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.CONFIRM_DELETE, Boolean.TRUE); + defaults.put(JabRefPreferences.GRAY_OUT_NON_HITS, Boolean.TRUE); + defaults.put(JabRefPreferences.FLOAT_SEARCH, Boolean.TRUE); + defaults.put(JabRefPreferences.SHOW_SEARCH_IN_DIALOG, Boolean.FALSE); + defaults.put(JabRefPreferences.SEARCH_ALL_BASES, Boolean.FALSE); + defaults.put(JabRefPreferences.DEFAULT_LABEL_PATTERN, "[auth][year]"); + defaults.put(JabRefPreferences.PREVIEW_ENABLED, Boolean.TRUE); + defaults.put(JabRefPreferences.ACTIVE_PREVIEW, 0); + defaults.put(JabRefPreferences.PREVIEW_0, "" + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + "\\end{bibtexkey}
__NEWLINE__" + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" + "__NEWLINE__

"); + defaults.put(JabRefPreferences.PREVIEW_1, "" + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + "\\end{bibtexkey}
__NEWLINE__" + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" + "__NEWLINE__

"); // TODO: Currently not possible to edit this setting: - defaults.put(PREVIEW_PRINT_BUTTON, Boolean.FALSE); - defaults.put(AUTO_DOUBLE_BRACES, Boolean.FALSE); - defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, "url"); - defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); - defaults.put(PUT_BRACES_AROUND_CAPITALS, "");//"title;journal;booktitle;review;abstract"); - defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file"); - defaults.put(USE_IMPORT_INSPECTION_DIALOG, Boolean.TRUE); - defaults.put(USE_IMPORT_INSPECTION_DIALOG_FOR_SINGLE, Boolean.TRUE); - defaults.put(GENERATE_KEYS_AFTER_INSPECTION, Boolean.TRUE); - defaults.put(MARK_IMPORTED_ENTRIES, Boolean.TRUE); - defaults.put(UNMARK_ALL_ENTRIES_BEFORE_IMPORTING, Boolean.TRUE); - defaults.put(WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE); - defaults.put(USE_TIME_STAMP, Boolean.FALSE); - defaults.put(OVERWRITE_TIME_STAMP, Boolean.FALSE); - defaults.put(TIME_STAMP_FORMAT, "yyyy.MM.dd"); - defaults.put(TIME_STAMP_FIELD, BibtexFields.TIMESTAMP); - defaults.put(UPDATE_TIMESTAMP, Boolean.FALSE); - defaults.put(GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE); + defaults.put(JabRefPreferences.PREVIEW_PRINT_BUTTON, Boolean.FALSE); + defaults.put(JabRefPreferences.AUTO_DOUBLE_BRACES, Boolean.FALSE); + defaults.put(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR, "url"); + defaults.put(JabRefPreferences.RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); + defaults.put(JabRefPreferences.PUT_BRACES_AROUND_CAPITALS, "");//"title;journal;booktitle;review;abstract"); + defaults.put(JabRefPreferences.NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file"); + defaults.put(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG_FOR_SINGLE, Boolean.TRUE); + defaults.put(JabRefPreferences.GENERATE_KEYS_AFTER_INSPECTION, Boolean.TRUE); + defaults.put(JabRefPreferences.MARK_IMPORTED_ENTRIES, Boolean.TRUE); + defaults.put(JabRefPreferences.UNMARK_ALL_ENTRIES_BEFORE_IMPORTING, Boolean.TRUE); + defaults.put(JabRefPreferences.WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_TIME_STAMP, Boolean.FALSE); + defaults.put(JabRefPreferences.OVERWRITE_TIME_STAMP, Boolean.FALSE); + defaults.put(JabRefPreferences.TIME_STAMP_FORMAT, "yyyy.MM.dd"); + defaults.put(JabRefPreferences.TIME_STAMP_FIELD, BibtexFields.TIMESTAMP); + defaults.put(JabRefPreferences.UPDATE_TIMESTAMP, Boolean.FALSE); + defaults.put(JabRefPreferences.GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE); // behavior of JabRef before 2.10: both: false - defaults.put(WRITEFIELD_ADDSPACES, Boolean.TRUE); - defaults.put(WRITEFIELD_CAMELCASENAME, Boolean.TRUE); + defaults.put(JabRefPreferences.WRITEFIELD_ADDSPACES, Boolean.TRUE); + defaults.put(JabRefPreferences.WRITEFIELD_CAMELCASENAME, Boolean.TRUE); //behavior of JabRef before LWang_AdjustableFieldOrder 1 //0 sorted order (2.10 default), 1 unsorted order (2.9.2 default), 2 user defined - defaults.put(WRITEFIELD_SORTSTYLE, 0); - defaults.put(WRITEFIELD_USERDEFINEDORDER, "author;title;journal;year;volume;number;pages;month;note;volume;pages;part;eid"); - defaults.put(WRITEFIELD_WRAPFIELD, Boolean.FALSE); + defaults.put(JabRefPreferences.WRITEFIELD_SORTSTYLE, 0); + defaults.put(JabRefPreferences.WRITEFIELD_USERDEFINEDORDER, "author;title;journal;year;volume;number;pages;month;note;volume;pages;part;eid"); + defaults.put(JabRefPreferences.WRITEFIELD_WRAPFIELD, Boolean.FALSE); defaults.put(RemotePreferences.USE_REMOTE_SERVER, Boolean.FALSE); defaults.put(RemotePreferences.REMOTE_SERVER_PORT, 6050); - defaults.put(PERSONAL_JOURNAL_LIST, null); - defaults.put(EXTERNAL_JOURNAL_LISTS, null); - defaults.put(CITE_COMMAND, "cite"); // obsoleted by the app-specific ones - defaults.put(CITE_COMMAND_VIM, "\\cite"); - defaults.put(CITE_COMMAND_EMACS, "\\cite"); - defaults.put(CITE_COMMAND_WIN_EDT, "\\cite"); - defaults.put(CITE_COMMAND_LED, "\\cite"); - defaults.put(FLOAT_MARKED_ENTRIES, Boolean.TRUE); - - defaults.put(USE_NATIVE_FILE_DIALOG_ON_MAC, Boolean.FALSE); - defaults.put(FILECHOOSER_DISABLE_RENAME, Boolean.TRUE); - - defaults.put(LAST_USED_EXPORT, null); - defaults.put(SIDE_PANE_WIDTH, -1); - - defaults.put(IMPORT_INSPECTION_DIALOG_WIDTH, 650); - defaults.put(IMPORT_INSPECTION_DIALOG_HEIGHT, 650); - defaults.put(SEARCH_DIALOG_WIDTH, 650); - defaults.put(SEARCH_DIALOG_HEIGHT, 500); - defaults.put(SHOW_FILE_LINKS_UPGRADE_WARNING, Boolean.TRUE); - defaults.put(AUTOLINK_EXACT_KEY_ONLY, Boolean.TRUE); - defaults.put(NUMERIC_FIELDS, "mittnum;author"); - defaults.put(RUN_AUTOMATIC_FILE_SEARCH, Boolean.FALSE); - defaults.put(USE_LOCK_FILES, Boolean.TRUE); - defaults.put(AUTO_SAVE, Boolean.TRUE); - defaults.put(AUTO_SAVE_INTERVAL, 5); - defaults.put(PROMPT_BEFORE_USING_AUTOSAVE, Boolean.TRUE); - defaults.put(ENFORCE_LEGAL_BIBTEX_KEY, Boolean.TRUE); - defaults.put(BIBLATEX_MODE, Boolean.FALSE); + defaults.put(JabRefPreferences.PERSONAL_JOURNAL_LIST, null); + defaults.put(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, null); + defaults.put(JabRefPreferences.CITE_COMMAND, "cite"); // obsoleted by the app-specific ones + defaults.put(JabRefPreferences.CITE_COMMAND_VIM, "\\cite"); + defaults.put(JabRefPreferences.CITE_COMMAND_EMACS, "\\cite"); + defaults.put(JabRefPreferences.CITE_COMMAND_WIN_EDT, "\\cite"); + defaults.put(JabRefPreferences.CITE_COMMAND_LED, "\\cite"); + defaults.put(JabRefPreferences.FLOAT_MARKED_ENTRIES, Boolean.TRUE); + + defaults.put(JabRefPreferences.USE_NATIVE_FILE_DIALOG_ON_MAC, Boolean.FALSE); + defaults.put(JabRefPreferences.FILECHOOSER_DISABLE_RENAME, Boolean.TRUE); + + defaults.put(JabRefPreferences.LAST_USED_EXPORT, null); + defaults.put(JabRefPreferences.SIDE_PANE_WIDTH, -1); + + defaults.put(JabRefPreferences.IMPORT_INSPECTION_DIALOG_WIDTH, 650); + defaults.put(JabRefPreferences.IMPORT_INSPECTION_DIALOG_HEIGHT, 650); + defaults.put(JabRefPreferences.SEARCH_DIALOG_WIDTH, 650); + defaults.put(JabRefPreferences.SEARCH_DIALOG_HEIGHT, 500); + defaults.put(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY, Boolean.TRUE); + defaults.put(JabRefPreferences.NUMERIC_FIELDS, "mittnum;author"); + defaults.put(JabRefPreferences.RUN_AUTOMATIC_FILE_SEARCH, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_LOCK_FILES, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_SAVE, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_SAVE_INTERVAL, 5); + defaults.put(JabRefPreferences.PROMPT_BEFORE_USING_AUTOSAVE, Boolean.TRUE); + defaults.put(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.BIBLATEX_MODE, Boolean.FALSE); // Curly brackets ({}) are the default delimiters, not quotes (") as these cause trouble when they appear within the field value: // Currently, JabRef does not escape them - defaults.put(VALUE_DELIMITERS2, 1); - defaults.put(INCLUDE_EMPTY_FIELDS, Boolean.FALSE); - defaults.put(KEY_GEN_FIRST_LETTER_A, Boolean.TRUE); - defaults.put(KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE); - defaults.put(EMAIL_SUBJECT, Localization.lang("References")); - defaults.put(OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE); - defaults.put(ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE); - defaults.put(WEB_SEARCH_VISIBLE, Boolean.FALSE); - defaults.put(SELECTED_FETCHER_INDEX, 0); - defaults.put(BIB_LOCATION_AS_FILE_DIR, Boolean.TRUE); - defaults.put(BIB_LOC_AS_PRIMARY_DIR, Boolean.FALSE); - defaults.put(DB_CONNECT_SERVER_TYPE, "MySQL"); - defaults.put(DB_CONNECT_HOSTNAME, "localhost"); - defaults.put(DB_CONNECT_DATABASE, "jabref"); - defaults.put(DB_CONNECT_USERNAME, "root"); + defaults.put(JabRefPreferences.VALUE_DELIMITERS2, 1); + defaults.put(JabRefPreferences.INCLUDE_EMPTY_FIELDS, Boolean.FALSE); + defaults.put(JabRefPreferences.KEY_GEN_FIRST_LETTER_A, Boolean.TRUE); + defaults.put(JabRefPreferences.KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE); + defaults.put(JabRefPreferences.EMAIL_SUBJECT, Localization.lang("References")); + defaults.put(JabRefPreferences.OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE); + defaults.put(JabRefPreferences.ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE); + defaults.put(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.FALSE); + defaults.put(JabRefPreferences.SELECTED_FETCHER_INDEX, 0); + defaults.put(JabRefPreferences.BIB_LOCATION_AS_FILE_DIR, Boolean.TRUE); + defaults.put(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR, Boolean.FALSE); + defaults.put(JabRefPreferences.DB_CONNECT_SERVER_TYPE, "MySQL"); + defaults.put(JabRefPreferences.DB_CONNECT_HOSTNAME, "localhost"); + defaults.put(JabRefPreferences.DB_CONNECT_DATABASE, "jabref"); + defaults.put(JabRefPreferences.DB_CONNECT_USERNAME, "root"); CleanUpAction.putDefaults(defaults); // defaults for DroppedFileHandler UI @@ -847,42 +816,41 @@ private JabRefPreferences() { //defaults.put("oooWarning", Boolean.TRUE); updateSpecialFieldHandling(); - WRAPPED_USERNAME = '[' + get(DEFAULT_OWNER) + ']'; - MARKING_WITH_NUMBER_PATTERN = "\\[" + get(DEFAULT_OWNER).replaceAll("\\\\", "\\\\\\\\") + ":(\\d+)\\]"; + WRAPPED_USERNAME = '[' + get(JabRefPreferences.DEFAULT_OWNER) + ']'; + MARKING_WITH_NUMBER_PATTERN = "\\[" + get(JabRefPreferences.DEFAULT_OWNER).replaceAll("\\\\", "\\\\\\\\") + ":(\\d+)\\]"; String defaultExpression = "**/.*[bibtexkey].*\\\\.[extension]"; - defaults.put(DEFAULT_REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); - defaults.put(REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); - defaults.put(USE_REG_EXP_SEARCH_KEY, Boolean.FALSE); - defaults.put(USE_IEEE_ABRV, Boolean.FALSE); - defaults.put(USE_CONVERT_TO_EQUATION, Boolean.FALSE); - defaults.put(USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE); - defaults.put(USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE); - - defaults.put(USER_FILE_DIR, GUIGlobals.FILE_FIELD + "Directory"); + defaults.put(JabRefPreferences.DEFAULT_REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); + defaults.put(JabRefPreferences.REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); + defaults.put(JabRefPreferences.USE_REG_EXP_SEARCH_KEY, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_IEEE_ABRV, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_CONVERT_TO_EQUATION, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE); + + defaults.put(JabRefPreferences.USER_FILE_DIR, GUIGlobals.FILE_FIELD + "Directory"); try { - defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp. - defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name + defaults.put(JabRefPreferences.USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp. + defaults.put(JabRefPreferences.USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name } catch (UnknownHostException ex) { - LOGGER.info("Hostname not found.", ex); - defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); - defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); + JabRefPreferences.LOGGER.info("Hostname not found.", ex); + defaults.put(JabRefPreferences.USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER)); + defaults.put(JabRefPreferences.USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER)); } } public void setLanguageDependentDefaultValues() { // Entry editor tab 0: - defaults.put(CUSTOM_TAB_NAME + "_def0", Localization.lang("General")); - defaults.put(CUSTOM_TAB_FIELDS + "_def0", "crossref;keywords;file;doi;url;" - + "comment;owner;timestamp"); + defaults.put(JabRefPreferences.CUSTOM_TAB_NAME + "_def0", Localization.lang("General")); + defaults.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def0", "crossref;keywords;file;doi;url;" + "comment;owner;timestamp"); // Entry editor tab 1: - defaults.put(CUSTOM_TAB_FIELDS + "_def1", "abstract"); - defaults.put(CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract")); + defaults.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def1", "abstract"); + defaults.put(JabRefPreferences.CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract")); // Entry editor tab 2: Review Field - used for research comments, etc. - defaults.put(CUSTOM_TAB_FIELDS + "_def2", "review"); - defaults.put(CUSTOM_TAB_NAME + "_def2", Localization.lang("Review")); + defaults.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def2", "review"); + defaults.put(JabRefPreferences.CUSTOM_TAB_NAME + "_def2", Localization.lang("Review")); } @@ -892,7 +860,7 @@ public boolean putBracesAroundCapitals(String fieldName) { public void updateSpecialFieldHandling() { putBracesAroundCapitalsFields.clear(); - String fieldString = get(PUT_BRACES_AROUND_CAPITALS); + String fieldString = get(JabRefPreferences.PUT_BRACES_AROUND_CAPITALS); if (!fieldString.isEmpty()) { String[] fields = fieldString.split(";"); for (String field : fields) { @@ -900,7 +868,7 @@ public void updateSpecialFieldHandling() { } } nonWrappableFields.clear(); - fieldString = get(NON_WRAPPABLE_FIELDS); + fieldString = get(JabRefPreferences.NON_WRAPPABLE_FIELDS); if (!fieldString.isEmpty()) { String[] fields = fieldString.split(";"); for (String field : fields) { @@ -915,7 +883,7 @@ public char getValueDelimiters(int index) { } private char[] getValueDelimiters() { - return JabRefPreferences.VALUE_DELIMITERS[getInt(VALUE_DELIMITERS2)]; + return JabRefPreferences.VALUE_DELIMITERS[getInt(JabRefPreferences.VALUE_DELIMITERS2)]; } /** @@ -1004,7 +972,7 @@ public void putStringArray(String key, String[] value) { if (value.length > 0) { StringBuilder linked = new StringBuilder(); - for (int i = 0; i < value.length - 1; i++) { + for (int i = 0; i < (value.length - 1); i++) { linked.append(makeEscape(value[i])); linked.append(';'); } @@ -1111,7 +1079,7 @@ public KeyStroke getKey(String bindName) { if (s == null) { // there isn't even a default value // Output error - LOGGER.info("Could not get key binding for \"" + bindName + '"'); + JabRefPreferences.LOGGER.info("Could not get key binding for \"" + bindName + '"'); // fall back to a default value s = "Not associated"; } @@ -1130,8 +1098,8 @@ public KeyStroke getKey(String bindName) { /** * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences, but adapted for Mac - * users, with the Command key preferred instead of Control. - * TODO: Move to OS.java? Or replace with portable Java key codes, i.e. KeyEvent + * users, with the Command key preferred instead of Control. TODO: Move to OS.java? Or replace with portable Java + * key codes, i.e. KeyEvent */ private KeyStroke getKeyForMac(KeyStroke ks) { if (ks == null) { @@ -1192,11 +1160,11 @@ public void clear(String key) { * Calling this method will write all preferences into the preference store. */ public void flush() { - if (getBoolean(MEMORY_STICK_MODE)) { + if (getBoolean(JabRefPreferences.MEMORY_STICK_MODE)) { try { exportPreferences("jabref.xml"); } catch (IOException e) { - LOGGER.info("Could not save preferences for memory stick mode: " + e.getLocalizedMessage(), e); + JabRefPreferences.LOGGER.info("Could not save preferences for memory stick mode: " + e.getLocalizedMessage(), e); } } try { @@ -1243,7 +1211,7 @@ public LabelPattern getKeyPattern() { } } } catch (BackingStoreException ex) { - LOGGER.info("BackingStoreException in JabRefPreferences.getKeyPattern", ex); + JabRefPreferences.LOGGER.info("BackingStoreException in JabRefPreferences.getKeyPattern", ex); } return JabRefPreferences.keyPattern; } @@ -1261,7 +1229,7 @@ public void putKeyPattern(LabelPattern pattern) { try { pre.clear(); // We remove all old entries. } catch (BackingStoreException ex) { - LOGGER.info("BackingStoreException in JabRefPreferences.putKeyPattern", ex); + JabRefPreferences.LOGGER.info("BackingStoreException in JabRefPreferences.putKeyPattern", ex); } for (Map.Entry> stringArrayListEntry : pattern.entrySet()) { @@ -1284,8 +1252,7 @@ private void restoreKeyBindings() { String[] bindings = getStringArray("bindings"); // Then set up the key bindings HashMap. - if (bindNames == null || bindings == null - || bindNames.length != bindings.length) { + if ((bindNames == null) || (bindings == null) || (bindNames.length != bindings.length)) { // Nothing defined in Preferences, or something is wrong. keyBinds = new KeyBinds(); return; @@ -1309,7 +1276,7 @@ private String getNextUnit(Reader data) throws IOException { boolean done = false; StringBuilder res = new StringBuilder(); - while (!done && (c = data.read()) != -1) { + while (!done && ((c = data.read()) != -1)) { if (c == '\\') { if (!escape) { escape = true; @@ -1345,7 +1312,7 @@ private String makeEscape(String s) { int c; for (int i = 0; i < s.length(); i++) { c = s.charAt(i); - if (c == '\\' || c == ';') { + if ((c == '\\') || (c == ';')) { sb.append('\\'); } sb.append((char) c); @@ -1370,8 +1337,8 @@ public void storeCustomEntryType(CustomEntryType tp, int number) { public CustomEntryType getCustomEntryType(int number) { String nr = "" + number; String name = get(JabRefPreferences.CUSTOM_TYPE_NAME + nr); - String[] req = getStringArray(JabRefPreferences.CUSTOM_TYPE_REQ + nr); - String[] opt = getStringArray(JabRefPreferences.CUSTOM_TYPE_OPT + nr); + String[] req = getStringArray(JabRefPreferences.CUSTOM_TYPE_REQ + nr); + String[] opt = getStringArray(JabRefPreferences.CUSTOM_TYPE_OPT + nr); String[] priOpt = getStringArray(JabRefPreferences.CUSTOM_TYPE_PRIOPT + nr); if (name == null) { return null; @@ -1447,7 +1414,7 @@ public ExternalFileType getExternalFileTypeByName(String name) { */ public ExternalFileType getExternalFileTypeByExt(String extension) { for (ExternalFileType type : externalFileTypes) { - if (type.getExtension() != null && type.getExtension().equalsIgnoreCase(extension)) { + if ((type.getExtension() != null) && type.getExtension().equalsIgnoreCase(extension)) { return type; } } @@ -1464,8 +1431,7 @@ public ExternalFileType getExternalFileTypeForName(String filename) { int longestFound = -1; ExternalFileType foundType = null; for (ExternalFileType type : externalFileTypes) { - if (type.getExtension() != null && filename.toLowerCase(). - endsWith(type.getExtension().toLowerCase())) { + if ((type.getExtension() != null) && filename.toLowerCase().endsWith(type.getExtension().toLowerCase())) { if (type.getExtension().length() > longestFound) { longestFound = type.getExtension().length(); foundType = type; @@ -1484,7 +1450,7 @@ public ExternalFileType getExternalFileTypeForName(String filename) { */ public ExternalFileType getExternalFileTypeByMimeType(String mimeType) { for (ExternalFileType type : externalFileTypes) { - if (type.getMimeType() != null && type.getMimeType().equals(mimeType)) { + if ((type.getMimeType() != null) && type.getMimeType().equals(mimeType)) { return type; } } @@ -1569,7 +1535,7 @@ public void updateExternalFileTypes() { // Read the prefs information for file types: String[][] vals = StringUtil.decodeStringDoubleArray(prefs.get("externalFileTypes", "")); for (String[] val : vals) { - if (val.length == 2 && val[1].equals(JabRefPreferences.FILE_TYPE_REMOVED_FLAG)) { + if ((val.length == 2) && val[1].equals(JabRefPreferences.FILE_TYPE_REMOVED_FLAG)) { // This entry indicates that a default entry type should be removed: ExternalFileType toRemove = null; for (ExternalFileType type : types) { diff --git a/src/main/java/net/sf/jabref/SearchManagerNoGUI.java b/src/main/java/net/sf/jabref/SearchManagerNoGUI.java index f0eb7b5f350..7c7a1c7e02b 100644 --- a/src/main/java/net/sf/jabref/SearchManagerNoGUI.java +++ b/src/main/java/net/sf/jabref/SearchManagerNoGUI.java @@ -47,9 +47,7 @@ public BibtexDatabase getDBfromMatches() { searchTerm = fieldYear(); } - SearchRule searchRule = SearchRules.getSearchRuleByQuery(searchTerm, - Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH), - Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH)); + SearchRule searchRule = SearchRules.getSearchRuleByQuery(searchTerm, Globals.prefs.getBoolean(JabRefPreferences.CASE_SENSITIVE_SEARCH), Globals.prefs.getBoolean(JabRefPreferences.REG_EXP_SEARCH)); if (!searchRule.validateSearchStrings(searchTerm)) { System.out.println(Localization.lang("Search failed: illegal search expression")); @@ -88,7 +86,7 @@ private String fieldYear() { int year1 = Integer.parseInt(years[0]); int year2 = Integer.parseInt(years[1]); - if (year1 < 2000 && year2 >= 2000) { //for 199. + if ((year1 < 2000) && (year2 >= 2000)) { //for 199. regPt1 = "199+[" + years[0].substring(3, 4) + "-9]"; reg1Set = true; } else { @@ -100,7 +98,7 @@ private String fieldYear() { // @formatter:on } } - if (Integer.parseInt(years[1]) >= 2000 && year1 < 2000) { //for 200. + if ((Integer.parseInt(years[1]) >= 2000) && (year1 < 2000)) { //for 200. regPt2 = "200+[0-" + years[1].substring(3, 4) + "]"; reg2Set = true; } else { diff --git a/src/main/java/net/sf/jabref/gui/AutoCompleteListener.java b/src/main/java/net/sf/jabref/gui/AutoCompleteListener.java index e8a4e94930f..6921e8e1bd5 100644 --- a/src/main/java/net/sf/jabref/gui/AutoCompleteListener.java +++ b/src/main/java/net/sf/jabref/gui/AutoCompleteListener.java @@ -59,9 +59,8 @@ public AutoCompleteListener(AutoCompleter completer) { } /** - * This method is used if the focus listener should call another focus listener - * after finishing. This is needed because the autocomplete listener must - * run before the focus listener responsible for storing the current edit. + * This method is used if the focus listener should call another focus listener after finishing. This is needed + * because the autocomplete listener must run before the focus listener responsible for storing the current edit. * * @param listener The listener to call. */ @@ -70,9 +69,10 @@ public void setNextFocusListener(FocusListener listener) { } /** - * This setting determines whether the autocomplete listener should consume the Enter key - * stroke when it leads to accepting a completion. If set to false, the JTextComponent will receive - * the Enter key press after the completion is done. The default value if true. + * This setting determines whether the autocomplete listener should consume the Enter key stroke when it leads to + * accepting a completion. If set to false, the JTextComponent will receive the Enter key press after the completion + * is done. The default value if true. + * * @param t true to indicate that the Enter key should be consumed, false that it should be forwarded */ public void setConsumeEnterKey(boolean t) { @@ -98,8 +98,7 @@ public void keyPressed(KeyEvent e) { else if ((e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) && (toSetIn != null)) { cycle((JTextComponent) e.getSource(), 1); e.consume(); - } - else if ((e.getKeyCode() == KeyEvent.VK_PAGE_UP) && (toSetIn != null)) { + } else if ((e.getKeyCode() == KeyEvent.VK_PAGE_UP) && (toSetIn != null)) { cycle((JTextComponent) e.getSource(), -1); e.consume(); } @@ -114,16 +113,16 @@ else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) { // shift is OK, everyhting else leads to a reset resetAutoCompletion(); } else { - LOGGER.debug("Special case: shift pressed. No action."); + AutoCompleteListener.LOGGER.debug("Special case: shift pressed. No action."); } } else { - LOGGER.debug("Special case: defined character, but not caught above"); + AutoCompleteListener.LOGGER.debug("Special case: defined character, but not caught above"); } } private void cycle(JTextComponent comp, int increment) { - assert (lastCompletions != null); - assert (lastCompletions.length > 0); + assert(lastCompletions != null); + assert(lastCompletions.length > 0); lastShownCompletion += increment; if (lastShownCompletion >= lastCompletions.length) { lastShownCompletion = 0; @@ -157,37 +156,34 @@ private void cycle(JTextComponent comp, int increment) { } /** - * If user cancels autocompletion by - * a) entering another letter than the completed word (and there is no other auto completion) - * b) space - * the casing of the letters has to be kept + * If user cancels autocompletion by a) entering another letter than the completed word (and there is no other auto + * completion) b) space the casing of the letters has to be kept * - * Global variable "lastBeginning" keeps track of typed letters. - * We rely on this variable to reconstruct the text + * Global variable "lastBeginning" keeps track of typed letters. We rely on this variable to reconstruct the text * * @param wordSeperatorTyped indicates whether the user has typed a white space character or a */ private void setUnmodifiedTypedLetters(JTextComponent comp, boolean lastBeginningContainsTypedCharacter, boolean wordSeperatorTyped) { if (lastBeginning == null) { - LOGGER.debug("No last beginning found"); + AutoCompleteListener.LOGGER.debug("No last beginning found"); // There was no previous input (if the user typed a word, where no autocompletion is available) // Thus, there is nothing to replace return; } - LOGGER.debug("lastBeginning: >" + lastBeginning + '<'); + AutoCompleteListener.LOGGER.debug("lastBeginning: >" + lastBeginning + '<'); if (comp.getSelectedText() == null) { // if there is no selection // the user has typed the complete word, but possibly with a different casing // we need a replacement if (wordSeperatorTyped) { - LOGGER.debug("Replacing complete word"); + AutoCompleteListener.LOGGER.debug("Replacing complete word"); } else { // if user did not press a white space character (space, ...), // then we do not do anything return; } } else { - LOGGER.debug("Selected text " + comp.getSelectedText() + " will be removed"); + AutoCompleteListener.LOGGER.debug("Selected text " + comp.getSelectedText() + " will be removed"); // remove completion suggestion comp.replaceSelection(""); } @@ -201,9 +197,7 @@ private void setUnmodifiedTypedLetters(JTextComponent comp, boolean lastBeginnin endIndex++; } String text = comp.getText(); - comp.setText(text.substring(0, endIndex). - concat(lastBeginning). - concat(text.substring(lastCaretPosition))); + comp.setText(text.substring(0, endIndex).concat(lastBeginning).concat(text.substring(lastCaretPosition))); if (lastBeginningContainsTypedCharacter) { // the current letter is NOT contained in comp.getText() // Thus, cursor position also did not get updated @@ -214,18 +208,17 @@ private void setUnmodifiedTypedLetters(JTextComponent comp, boolean lastBeginnin } /** - * Start a new completion attempt - * (instead of treating a continuation of an existing word or an interrupt of the current word) + * Start a new completion attempt (instead of treating a continuation of an existing word or an interrupt of the + * current word) */ private void startCompletion(StringBuffer currentword, KeyEvent e) { JTextComponent comp = (JTextComponent) e.getSource(); String[] completed = findCompletions(currentword.toString(), comp); String prefix = completer.getPrefix(); - String cWord = (prefix != null) && (!prefix.isEmpty()) ? - currentword.toString().substring(prefix.length()) : currentword.toString(); + String cWord = (prefix != null) && (!prefix.isEmpty()) ? currentword.toString().substring(prefix.length()) : currentword.toString(); - LOGGER.debug("StartCompletion currentword: >" + currentword + "'<' prefix: >" + prefix + "'<' cword: >" + cWord + '<'); + AutoCompleteListener.LOGGER.debug("StartCompletion currentword: >" + currentword + "'<' prefix: >" + prefix + "'<' cword: >" + cWord + '<'); int no = 0; // We use the first word in the array of completions. if ((completed != null) && (completed.length > 0)) { @@ -239,7 +232,7 @@ private void startCompletion(StringBuffer currentword, KeyEvent e) { // BUT we obey the completion toSetIn = sno.substring(cWord.length() - 1); - LOGGER.debug("toSetIn: >" + toSetIn + '<'); + AutoCompleteListener.LOGGER.debug("toSetIn: >" + toSetIn + '<'); StringBuilder alltext = new StringBuilder(comp.getText()); int cp = comp.getCaretPosition(); @@ -251,7 +244,7 @@ private void startCompletion(StringBuffer currentword, KeyEvent e) { lastCaretPosition = comp.getCaretPosition(); char ch = e.getKeyChar(); - LOGGER.debug("Appending >" + ch + '<'); + AutoCompleteListener.LOGGER.debug("Appending >" + ch + '<'); if (cWord.length() <= 1) { lastBeginning = Character.toString(ch); @@ -264,7 +257,7 @@ private void startCompletion(StringBuffer currentword, KeyEvent e) { @Override public void keyTyped(KeyEvent e) { - LOGGER.debug("key typed event caught " + e.getKeyCode()); + AutoCompleteListener.LOGGER.debug("key typed event caught " + e.getKeyCode()); char ch = e.getKeyChar(); if (ch == '\n') { // this case is handled at keyPressed(e) @@ -277,19 +270,18 @@ public void keyTyped(KeyEvent e) { JTextComponent comp = (JTextComponent) e.getSource(); if (toSetIn == null) { - LOGGER.debug("toSetIn is null"); + AutoCompleteListener.LOGGER.debug("toSetIn is null"); } else { - LOGGER.debug("toSetIn: >" + toSetIn + '<'); + AutoCompleteListener.LOGGER.debug("toSetIn: >" + toSetIn + '<'); } // The case-insensitive system is a bit tricky here // If keyword is "TODO" and user types "tO", then this is treated as "continue" as the "O" matches the "O" // If keyword is "TODO" and user types "To", then this is treated as "discont" as the "o" does NOT match the "O". - if ((toSetIn != null) && (toSetIn.length() > 1) && - (ch == toSetIn.charAt(1))) { + if ((toSetIn != null) && (toSetIn.length() > 1) && (ch == toSetIn.charAt(1))) { // User continues on the word that was suggested. - LOGGER.debug("cont"); + AutoCompleteListener.LOGGER.debug("cont"); toSetIn = toSetIn.substring(1); if (!toSetIn.isEmpty()) { @@ -324,9 +316,7 @@ public void keyTyped(KeyEvent e) { // "space" indicates that the user does NOT want the autocompletion, // but the typed word String text = comp.getText(); - comp.setText(text.substring(0, lastCaretPosition - lastBeginning.length()) - + lastBeginning - + text.substring(lastCaretPosition)); + comp.setText(text.substring(0, lastCaretPosition - lastBeginning.length()) + lastBeginning + text.substring(lastCaretPosition)); // there is no selected text, therefore we are not updating the selection toSetIn = null; } @@ -334,12 +324,11 @@ public void keyTyped(KeyEvent e) { } } - if ((toSetIn != null) && ((toSetIn.length() <= 1) || - (ch != toSetIn.charAt(1)))) { + if ((toSetIn != null) && ((toSetIn.length() <= 1) || (ch != toSetIn.charAt(1)))) { // User discontinues the word that was suggested. lastBeginning = lastBeginning + ch; - LOGGER.debug("discont toSetIn: >" + toSetIn + "'<' lastBeginning: >" + lastBeginning + '<'); + AutoCompleteListener.LOGGER.debug("discont toSetIn: >" + toSetIn + "'<' lastBeginning: >" + lastBeginning + '<'); String[] completed = findCompletions(lastBeginning, comp); if ((completed != null) && (completed.length > 0)) { @@ -354,9 +343,7 @@ public void keyTyped(KeyEvent e) { String text = comp.getText(); //Util.pr(""+lastLen); //we do not use toSetIn as we want to obey the casing of "sno" - comp.setText(text.substring(0, (lastCaretPosition - lastLen - lastBeginning.length()) + 1) - + sno - + text.substring(lastCaretPosition)); + comp.setText(text.substring(0, (lastCaretPosition - lastLen - lastBeginning.length()) + 1) + sno + text.substring(lastCaretPosition)); int startSelect = (lastCaretPosition + 1) - lastLen; int endSelect = (lastCaretPosition + toSetIn.length()) - lastLen; comp.select(startSelect, endSelect); @@ -372,7 +359,7 @@ public void keyTyped(KeyEvent e) { } } - LOGGER.debug("case else"); + AutoCompleteListener.LOGGER.debug("case else"); comp.replaceSelection(""); @@ -382,14 +369,14 @@ public void keyTyped(KeyEvent e) { } // only "real characters" end up here - assert (!Character.isISOControl(ch)); + assert(!Character.isISOControl(ch)); currentword.append(ch); startCompletion(currentword, e); return; } else { if (Character.isWhitespace(ch)) { - assert (!completer.isSingleUnitField()); - LOGGER.debug("whitespace && !singleUnitField"); + assert(!completer.isSingleUnitField()); + AutoCompleteListener.LOGGER.debug("whitespace && !singleUnitField"); // start a new search if end-of-field is reached // replace displayed letters with typed letters @@ -398,7 +385,7 @@ public void keyTyped(KeyEvent e) { return; } - LOGGER.debug("No letter/digit/whitespace or CHAR_UNDEFINED"); + AutoCompleteListener.LOGGER.debug("No letter/digit/whitespace or CHAR_UNDEFINED"); // replace displayed letters with typed letters setUnmodifiedTypedLetters((JTextComponent) e.getSource(), false, !Character.isISOControl(ch)); resetAutoCompletion(); @@ -412,7 +399,7 @@ public void keyTyped(KeyEvent e) { * Resets the auto completion data in a way that no leftovers are there */ private void resetAutoCompletion() { - LOGGER.debug("Resetting autocompletion"); + AutoCompleteListener.LOGGER.debug("Resetting autocompletion"); toSetIn = null; lastBeginning = null; } @@ -431,8 +418,7 @@ private StringBuffer getCurrentWord(JTextComponent comp) { // In most fields, we are only interested in the currently edited word, so we // seek from the caret backward to the closest space: if (!completer.isSingleUnitField()) { - if ((comp.getCaretPosition() < comp.getText().length()) - && Character.isWhitespace(comp.getText().charAt(comp.getCaretPosition()))) { + if ((comp.getCaretPosition() < comp.getText().length()) && Character.isWhitespace(comp.getText().charAt(comp.getCaretPosition()))) { // caret is in the middle of the text AND current character is a whitespace // that means: a new word is started and there is no current word return null; diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index 3bf7694cedb..f118968f63f 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -90,6 +90,7 @@ import org.apache.commons.logging.LogFactory; public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListener { + private static final long serialVersionUID = 1L; private static final Log LOGGER = LogFactory.getLog(BasePanel.class); @@ -182,16 +183,18 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe public final MetaData metaData; private final HashMap actions = new HashMap<>(); - private SidePaneManager sidePaneManager; + private final SidePaneManager sidePaneManager; + public ContentAutoCompleters getAutoCompleters() { return autoCompleters; } + private ContentAutoCompleters autoCompleters; - public BasePanel(JabRefFrame frame, BibtexDatabase db, File file, - MetaData metaData, String encoding) { + + public BasePanel(JabRefFrame frame, BibtexDatabase db, File file, MetaData metaData, String encoding) { Objects.requireNonNull(frame); Objects.requireNonNull(db); //file may be null @@ -208,7 +211,6 @@ public BasePanel(JabRefFrame frame, BibtexDatabase db, File file, setupMainPanel(); setupActions(); - metaData.setFile(file); // ensure that at each addition of a new entry, the entry is added to the groups interface @@ -224,10 +226,9 @@ public BasePanel(JabRefFrame frame, BibtexDatabase db, File file, } else { // Register so we get notifications about outside changes to the file. try { - fileMonitorHandle = Globals.fileUpdateMonitor.addUpdateListener(this, - file); + fileMonitorHandle = Globals.fileUpdateMonitor.addUpdateListener(this, file); } catch (IOException ex) { - LOGGER.warn("Could not register FileUpdateMonitor", ex); + BasePanel.LOGGER.warn("Could not register FileUpdateMonitor", ex); } } @@ -273,7 +274,7 @@ public void setEncoding(String encoding) { } public void output(String s) { - frame.output(s); + frame.output(s); } private void setupActions() { @@ -303,26 +304,21 @@ private void setupActions() { actions.put(Actions.COPY, (BaseAction) () -> { BibtexEntry[] bes = mainTable.getSelectedEntries(); - if (bes != null && bes.length > 0) { - TransferableBibtexEntry trbe - = new TransferableBibtexEntry(bes); + if ((bes != null) && (bes.length > 0)) { + TransferableBibtexEntry trbe = new TransferableBibtexEntry(bes); // ! look at ClipBoardManager - Toolkit.getDefaultToolkit().getSystemClipboard() - .setContents(trbe, BasePanel.this); - output(Localization.lang("Copied") + ' ' + (bes.length > 1 ? bes.length + " " - + Localization.lang("entries") - : "1 " + Localization.lang("entry") + '.')); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trbe, BasePanel.this); + output(Localization.lang("Copied") + ' ' + (bes.length > 1 ? bes.length + " " + Localization.lang("entries") : "1 " + Localization.lang("entry") + '.')); } else { // The user maybe selected a single cell. int[] rows = mainTable.getSelectedRows(); int[] cols = mainTable.getSelectedColumns(); - if (cols.length == 1 && rows.length == 1) { + if ((cols.length == 1) && (rows.length == 1)) { // Copy single value. Object o = mainTable.getValueAt(rows[0], cols[0]); if (o != null) { StringSelection ss = new StringSelection(o.toString()); - Toolkit.getDefaultToolkit().getSystemClipboard() - .setContents(ss, BasePanel.this); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this); output(Localization.lang("Copied cell contents") + '.'); } @@ -334,22 +330,17 @@ private void setupActions() { runCommand("copy"); BibtexEntry[] bes = mainTable.getSelectedEntries(); //int row0 = mainTable.getSelectedRow(); - if (bes != null && bes.length > 0) { + if ((bes != null) && (bes.length > 0)) { // Create a CompoundEdit to make the action undoable. - NamedCompound ce = new NamedCompound - (Localization.lang(bes.length > 1 ? "cut entries" : "cut entry")); + NamedCompound ce = new NamedCompound(Localization.lang(bes.length > 1 ? "cut entries" : "cut entry")); // Loop through the array of entries, and delete them. for (BibtexEntry be : bes) { database.removeEntry(be.getId()); ensureNotShowing(be); - ce.addEdit(new UndoableRemoveEntry - (database, be, BasePanel.this)); + ce.addEdit(new UndoableRemoveEntry(database, be, BasePanel.this)); } //entryTable.clearSelection(); - frame.output(Localization.lang("Cut_pr") + ' ' + - (bes.length > 1 ? bes.length - + " " + Localization.lang("entries") - : Localization.lang("entry")) + '.'); + frame.output(Localization.lang("Cut_pr") + ' ' + (bes.length > 1 ? bes.length + " " + Localization.lang("entries") : Localization.lang("entry")) + '.'); ce.end(); undoManager.addEdit(ce); markBaseChanged(); @@ -358,13 +349,12 @@ private void setupActions() { actions.put(Actions.DELETE, (BaseAction) () -> { BibtexEntry[] bes = mainTable.getSelectedEntries(); - if (bes != null && bes.length > 0) { + if ((bes != null) && (bes.length > 0)) { boolean goOn = showDeleteConfirmationDialog(bes.length); if (goOn) { // Create a CompoundEdit to make the action undoable. - NamedCompound ce = new NamedCompound - (Localization.lang(bes.length > 1 ? "delete entries" : "delete entry")); + NamedCompound ce = new NamedCompound(Localization.lang(bes.length > 1 ? "delete entries" : "delete entry")); // Loop through the array of entries, and delete them. for (BibtexEntry be : bes) { database.removeEntry(be.getId()); @@ -372,10 +362,7 @@ private void setupActions() { ce.addEdit(new UndoableRemoveEntry(database, be, BasePanel.this)); } markBaseChanged(); - frame.output(Localization.lang("Deleted") + ' ' + - (bes.length > 1 ? bes.length - + " " + Localization.lang("entries") - : Localization.lang("entry")) + '.'); + frame.output(Localization.lang("Deleted") + ' ' + (bes.length > 1 ? bes.length + " " + Localization.lang("entries") : Localization.lang("entry")) + '.'); ce.end(); undoManager.addEdit(ce); } @@ -408,7 +395,7 @@ private void setupActions() { try { BibtexParser bp = new BibtexParser(new StringReader((String) content.getTransferData(DataFlavor.stringFlavor))); BibtexDatabase db = bp.parse().getDatabase(); - LOGGER.info("Parsed " + db.getEntryCount() + " entries from clipboard text"); + BasePanel.LOGGER.info("Parsed " + db.getEntryCount() + " entries from clipboard text"); if (db.getEntryCount() > 0) { bes = db.getEntries().toArray(new BibtexEntry[db.getEntryCount()]); } @@ -422,7 +409,7 @@ private void setupActions() { // finally we paste in the entries (if any), which either came from TransferableBibtexEntries // or were parsed from a string - if (bes != null && bes.length > 0) { + if ((bes != null) && (bes.length > 0)) { NamedCompound ce = new NamedCompound(Localization.lang(bes.length > 1 ? "paste entries" : "paste entry")); @@ -439,9 +426,7 @@ private void setupActions() { if (firstBE == null) { firstBE = be; } - Util.setAutomaticFields(be, - Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_OWNER), - Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP)); + Util.setAutomaticFields(be, Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_OWNER), Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP)); // We have to clone the // entries, since the pasted @@ -451,18 +436,14 @@ private void setupActions() { be.setId(IdGenerator.next()); database.insertEntry(be); - ce.addEdit(new UndoableInsertEntry - (database, be, BasePanel.this)); + ce.addEdit(new UndoableInsertEntry(database, be, BasePanel.this)); } ce.end(); undoManager.addEdit(ce); //entryTable.clearSelection(); //entryTable.revalidate(); - output(Localization.lang("Pasted") + ' ' + - (bes.length > 1 ? bes.length + " " + - Localization.lang("entries") : "1 " + Localization.lang("entry")) - + '.'); + output(Localization.lang("Pasted") + ' ' + (bes.length > 1 ? bes.length + " " + Localization.lang("entries") : "1 " + Localization.lang("entry")) + '.'); markBaseChanged(); if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_OPEN_FORM)) { @@ -479,8 +460,7 @@ private void setupActions() { // The action for opening the preamble editor actions.put(Actions.EDIT_PREAMBLE, (BaseAction) () -> { if (preambleEditor == null) { - PreambleEditor form = new PreambleEditor - (frame, BasePanel.this, database, Globals.prefs); + PreambleEditor form = new PreambleEditor(frame, BasePanel.this, database, Globals.prefs); Util.placeDialog(form, frame); form.setVisible(true); preambleEditor = form; @@ -493,8 +473,7 @@ private void setupActions() { // The action for opening the string editor actions.put(Actions.EDIT_STRINGS, (BaseAction) () -> { if (stringDialog == null) { - StringDialog form = new StringDialog - (frame, BasePanel.this, database, Globals.prefs); + StringDialog form = new StringDialog(frame, BasePanel.this, database, Globals.prefs); Util.placeDialog(form, frame); form.setVisible(true); stringDialog = form; @@ -519,6 +498,7 @@ private void setupActions() { String errorMessage; boolean connectToDB; + // run first, in EDT: @Override public void init() { @@ -572,9 +552,7 @@ public void run() { errorMessage = SQLUtil.getExceptionMessage(ex); ex.printStackTrace(); dbs.isConfigValid(false); - JOptionPane.showMessageDialog(frame, Localization.lang(preamble) - + '\n' + errorMessage, Localization.lang("Export to SQL database"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frame, Localization.lang(preamble) + '\n' + errorMessage, Localization.lang("Export to SQL database"), JOptionPane.ERROR_MESSAGE); } metaData.setDBStrings(dbs); @@ -590,14 +568,11 @@ public void update() { if (connectToDB) { frame.output(Localization.lang("%0 export successful")); } - } else { // show an error dialog if an error occurred + } else { // show an error dialog if an error occurred String preamble = "Could not export to SQL database for the following reason:"; - frame.output(Localization.lang(preamble) - + " " + errorMessage); + frame.output(Localization.lang(preamble) + " " + errorMessage); - JOptionPane.showMessageDialog(frame, Localization.lang(preamble) - + '\n' + errorMessage, Localization.lang("Export to SQL database"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frame, Localization.lang(preamble) + '\n' + errorMessage, Localization.lang("Export to SQL database"), JOptionPane.ERROR_MESSAGE); errorMessage = null; } @@ -627,14 +602,11 @@ public void init() { numSelected = entries.size(); if (entries.isEmpty()) { // None selected. Inform the user to select entries first. - JOptionPane.showMessageDialog(frame, Localization.lang("First select the entries you want keys to be generated for."), - Localization.lang("Autogenerate BibTeX key"), JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(frame, Localization.lang("First select the entries you want keys to be generated for."), Localization.lang("Autogenerate BibTeX key"), JOptionPane.INFORMATION_MESSAGE); return; } frame.block(); - output(Localization.lang("Generating BibTeX key for") + ' ' + - numSelected + ' ' + (numSelected > 1 ? Localization.lang("entries") - : Localization.lang("entry")) + "..."); + output(Localization.lang("Generating BibTeX key for") + ' ' + numSelected + ' ' + (numSelected > 1 ? Localization.lang("entries") : Localization.lang("entry")) + "..."); } // Run second, on a different thread: @@ -645,7 +617,7 @@ public void run() { // First check if any entries have keys set already. If so, possibly remove // them from consideration, or warn about overwriting keys. - for (Iterator i = entries.iterator(); i.hasNext(); ) { + for (Iterator i = entries.iterator(); i.hasNext();) { bes = i.next(); if (bes.getField(BibtexEntry.KEY_FIELD) != null) { if (Globals.prefs.getBoolean(JabRefPreferences.AVOID_OVERWRITING_KEY)) { @@ -653,10 +625,8 @@ public void run() { i.remove(); } else if (Globals.prefs.getBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY)) { // Ask if the user wants to cancel the operation: - CheckBoxMessage cbm = new CheckBoxMessage(Localization.lang("One or more keys will be overwritten. Continue?"), - Localization.lang("Disable this confirmation dialog"), false); - int answer = JOptionPane.showConfirmDialog(frame, cbm, Localization.lang("Overwrite keys"), - JOptionPane.YES_NO_OPTION); + CheckBoxMessage cbm = new CheckBoxMessage(Localization.lang("One or more keys will be overwritten. Continue?"), Localization.lang("Disable this confirmation dialog"), false); + int answer = JOptionPane.showConfirmDialog(frame, cbm, Localization.lang("Overwrite keys"), JOptionPane.YES_NO_OPTION); if (cbm.isSelected()) { Globals.prefs.putBoolean(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, false); } @@ -688,9 +658,7 @@ public void run() { for (BibtexEntry entry : entries) { bes = entry; bes = LabelPatternUtil.makeLabel(metaData, database, bes); - ce.addEdit(new UndoableKeyChange - (database, bes.getId(), (String) oldvals.get(bes), - bes.getField(BibtexEntry.KEY_FIELD))); + ce.addEdit(new UndoableKeyChange(database, bes.getId(), (String) oldvals.get(bes), bes.getField(BibtexEntry.KEY_FIELD))); } ce.end(); undoManager.addEdit(ce); @@ -716,16 +684,14 @@ public void update() { @Override public void run() { final int row = mainTable.findEntry(bibEntry); - if (row >= 0 && mainTable.getSelectedRowCount() < entries.size()) { + if ((row >= 0) && (mainTable.getSelectedRowCount() < entries.size())) { mainTable.addRowSelectionInterval(row, row); } } }); } //////////////////////////////////////////////////////////////////////////////// - output(Localization.lang("Generated BibTeX key for") + ' ' + - numSelected + ' ' + (numSelected != 1 ? Localization.lang("entries") - : Localization.lang("entry"))); + output(Localization.lang("Generated BibTeX key for") + ' ' + numSelected + ' ' + (numSelected != 1 ? Localization.lang("entries") : Localization.lang("entry"))); frame.unblock(); } }); @@ -759,7 +725,7 @@ public void run() { // The action for copying the selected entry's key. actions.put(Actions.COPY_KEY, (BaseAction) () -> { BibtexEntry[] bes = mainTable.getSelectedEntries(); - if (bes != null && bes.length > 0) { + if ((bes != null) && (bes.length > 0)) { storeCurrentEdit(); List keys = new ArrayList<>(bes.length); // Collect all non-null keys. @@ -779,17 +745,13 @@ public void run() { } StringSelection ss = new StringSelection(sb.toString()); - Toolkit.getDefaultToolkit().getSystemClipboard() - .setContents(ss, BasePanel.this); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this); if (keys.size() == bes.length) { // All entries had keys. - output(Localization.lang(bes.length > 1 ? "Copied keys" - : "Copied key") + '.'); + output(Localization.lang(bes.length > 1 ? "Copied keys" : "Copied key") + '.'); } else { - output(Localization.lang("Warning") + ": " + (bes.length - keys.size()) - + ' ' + Localization.lang("out of") + ' ' + bes.length + ' ' + - Localization.lang("entries have undefined BibTeX key") + '.'); + output(Localization.lang("Warning") + ": " + (bes.length - keys.size()) + ' ' + Localization.lang("out of") + ' ' + bes.length + ' ' + Localization.lang("entries have undefined BibTeX key") + '.'); } } }); @@ -800,7 +762,7 @@ public void run() { @Override public void action() { BibtexEntry[] bes = mainTable.getSelectedEntries(); - if (bes != null && bes.length > 0) { + if ((bes != null) && (bes.length > 0)) { storeCurrentEdit(); List keys = new ArrayList<>(bes.length); // Collect all non-null keys. @@ -819,19 +781,14 @@ public void action() { sb.append(keys.get(i)); } - StringSelection ss = new StringSelection - ("\\cite{" + sb + '}'); - Toolkit.getDefaultToolkit().getSystemClipboard() - .setContents(ss, BasePanel.this); + StringSelection ss = new StringSelection("\\cite{" + sb + '}'); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this); if (keys.size() == bes.length) { // All entries had keys. - output(bes.length > 1 ? Localization.lang("Copied keys") - : Localization.lang("Copied key") + '.'); + output(bes.length > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key") + '.'); } else { - output(Localization.lang("Warning") + ": " + (bes.length - keys.size()) - + ' ' + Localization.lang("out of") + ' ' + bes.length + ' ' + - Localization.lang("entries have undefined BibTeX key") + '.'); + output(Localization.lang("Warning") + ": " + (bes.length - keys.size()) + ' ' + Localization.lang("out of") + ' ' + bes.length + ' ' + Localization.lang("entries have undefined BibTeX key") + '.'); } } } @@ -843,7 +800,7 @@ public void action() { @Override public void action() { BibtexEntry[] bes = mainTable.getSelectedEntries(); - if (bes != null && bes.length > 0) { + if ((bes != null) && (bes.length > 0)) { storeCurrentEdit(); // OK: in a future version, this string should be configurable to allow arbitrary exports @@ -873,17 +830,13 @@ public void action() { } StringSelection ss = new StringSelection(sb.toString()); - Toolkit.getDefaultToolkit().getSystemClipboard() - .setContents(ss, BasePanel.this); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this); if (copied == bes.length) { // All entries had keys. - output(Localization.lang(bes.length > 1 ? "Copied keys" - : "Copied key") + '.'); + output(Localization.lang(bes.length > 1 ? "Copied keys" : "Copied key") + '.'); } else { - output(Localization.lang("Warning") + ": " + copied - + ' ' + Localization.lang("out of") + ' ' + bes.length + ' ' + - Localization.lang("entries have undefined BibTeX key") + '.'); + output(Localization.lang("Warning") + ": " + copied + ' ' + Localization.lang("out of") + ' ' + bes.length + ' ' + Localization.lang("entries have undefined BibTeX key") + '.'); } } } @@ -902,14 +855,13 @@ public void run() { BibtexEntry[] bes = mainTable.getSelectedEntries(); String field = "ps"; - if (bes != null && bes.length == 1) { + if ((bes != null) && (bes.length == 1)) { FileListEntry entry = null; FileListTableModel tm = new FileListTableModel(); tm.setContent(bes[0].getField("file")); for (int i = 0; i < tm.getRowCount(); i++) { FileListEntry flEntry = tm.getEntry(i); - if (flEntry.getType().getName().toLowerCase().equals("pdf") - || flEntry.getType().getName().toLowerCase().equals("ps")) { + if (flEntry.getType().getName().toLowerCase().equals("pdf") || flEntry.getType().getName().toLowerCase().equals("ps")) { entry = flEntry; break; } @@ -969,7 +921,7 @@ public void run() { if (!res.isEmpty()) { filepath = res.get(0).getPath(); int index = filepath.lastIndexOf('.'); - if (index >= 0 && index < filepath.length() - 1) { + if ((index >= 0) && (index < (filepath.length() - 1))) { String extension = filepath.substring(index + 1); ExternalFileType type = Globals.prefs.getExternalFileTypeByExt(extension); if (type != null) { @@ -1018,9 +970,7 @@ public void run() { output(Localization.lang("Error") + ": " + ex.getMessage()); } } else { - output(Localization.lang( - "No pdf or ps defined, and no file matching Bibtex key found") + - '.'); + output(Localization.lang("No pdf or ps defined, and no file matching Bibtex key found") + '.'); } } else { output(Localization.lang("No entries or multiple entries selected.")); @@ -1042,7 +992,7 @@ public void action() { public void run() { BibtexEntry[] bes = mainTable.getSelectedEntries(); String field = GUIGlobals.FILE_FIELD; - if (bes != null && bes.length == 1) { + if ((bes != null) && (bes.length == 1)) { Object link = bes[0].getField(field); if (link == null) { runCommand("openFile"); // Fall back on PDF/PS fields??? @@ -1055,10 +1005,7 @@ public void run() { return; } FileListEntry flEntry = tableModel.getEntry(0); - ExternalFileMenuItem item = new ExternalFileMenuItem - (frame(), bes[0], "", - flEntry.getLink(), flEntry.getType().getIcon(), - metaData(), flEntry.getType()); + ExternalFileMenuItem item = new ExternalFileMenuItem(frame(), bes[0], "", flEntry.getLink(), flEntry.getType().getIcon(), metaData(), flEntry.getType()); item.openLink(); } else { output(Localization.lang("No entries or multiple entries selected.")); @@ -1082,7 +1029,7 @@ public void run() { try { JabRefDesktop.openFolderAndSelectFile(f.getAbsolutePath()); } catch (IOException e) { - LOGGER.info("Could not open folder", e); + BasePanel.LOGGER.info("Could not open folder", e); } } } @@ -1096,7 +1043,7 @@ public void run() { public void action() { BibtexEntry[] bes = mainTable.getSelectedEntries(); String field = "doi"; - if (bes != null && bes.length == 1) { + if ((bes != null) && (bes.length == 1)) { Object link = bes[0].getField("doi"); if (bes[0].getField("url") != null) { link = bes[0].getField("url"); @@ -1117,8 +1064,7 @@ public void action() { tm.setContent(bes[0].getField("file")); for (int i = 0; i < tm.getRowCount(); i++) { FileListEntry flEntry = tm.getEntry(i); - if (flEntry.getType().getName().toLowerCase().equals("url") - || flEntry.getType().getName().toLowerCase().equals("ps")) { + if (flEntry.getType().getName().toLowerCase().equals("url") || flEntry.getType().getName().toLowerCase().equals("ps")) { entry = flEntry; break; } @@ -1146,7 +1092,7 @@ public void action() { @Override public void action() { BibtexEntry[] bes = mainTable.getSelectedEntries(); - if (bes != null && bes.length == 1) { + if ((bes != null) && (bes.length == 1)) { Object link = null; if (bes[0].getField("eprint") != null) { link = SPIRESFetcher.constructUrlFromEprint(bes[0].getField("eprint")); @@ -1191,8 +1137,7 @@ public void action() { } } - output(Localization.lang("Replaced") + ' ' + counter + ' ' + - Localization.lang(counter == 1 ? "occurence" : "occurences") + '.'); + output(Localization.lang("Replaced") + ' ' + counter + ' ' + Localization.lang(counter == 1 ? "occurence" : "occurences") + '.'); if (counter > 0) { ce.end(); undoManager.addEdit(ce); @@ -1223,8 +1168,7 @@ public void action() { tidialog.setVisible(true); if (tidialog.okPressed()) { - Util.setAutomaticFields(Collections.singletonList(bibEntry), - false, false, false); + Util.setAutomaticFields(Collections.singletonList(bibEntry), false, false, false); insertEntry(bibEntry); } } @@ -1275,19 +1219,9 @@ public void action() { }); // Note that we can't put the number of entries that have been reverted into the undoText as the concrete number cannot be injected - actions.put(Relevance.getInstance().getValues().get(0).getActionName(), - new SpecialFieldAction(frame, Relevance.getInstance(), - Relevance.getInstance().getValues().get(0).getFieldValue(), true, - Localization.lang("Toggle relevance"), Localization.lang("Toggled relevance for %0 entries"))); - actions.put(Quality.getInstance().getValues().get(0).getActionName(), - new SpecialFieldAction(frame, Quality.getInstance(), - Quality.getInstance().getValues().get(0).getFieldValue(), true, - Localization.lang("Toggle quality"), Localization.lang("Toggled quality for %0 entries"))); - actions.put(Printed.getInstance().getValues().get(0).getActionName(), - new SpecialFieldAction(frame, Printed.getInstance(), - Printed.getInstance().getValues().get(0).getFieldValue(), true, - Localization.lang("Toggle print status"), - Localization.lang("Toggled print status for %0 entries"))); + actions.put(Relevance.getInstance().getValues().get(0).getActionName(), new SpecialFieldAction(frame, Relevance.getInstance(), Relevance.getInstance().getValues().get(0).getFieldValue(), true, Localization.lang("Toggle relevance"), Localization.lang("Toggled relevance for %0 entries"))); + actions.put(Quality.getInstance().getValues().get(0).getActionName(), new SpecialFieldAction(frame, Quality.getInstance(), Quality.getInstance().getValues().get(0).getFieldValue(), true, Localization.lang("Toggle quality"), Localization.lang("Toggled quality for %0 entries"))); + actions.put(Printed.getInstance().getValues().get(0).getActionName(), new SpecialFieldAction(frame, Printed.getInstance(), Printed.getInstance().getValues().get(0).getFieldValue(), true, Localization.lang("Toggle print status"), Localization.lang("Toggled print status for %0 entries"))); for (SpecialFieldValue prio : Priority.getInstance().getValues()) { actions.put(prio.getActionName(), prio.getAction(this.frame)); @@ -1333,8 +1267,7 @@ public void action() { actions.put(Actions.SWITCH_PREVIEW, (BaseAction) selectionListener::switchPreview); actions.put(Actions.MANAGE_SELECTORS, (BaseAction) () -> { - ContentSelectorDialog2 csd = new ContentSelectorDialog2 - (frame, frame, BasePanel.this, false, metaData, null); + ContentSelectorDialog2 csd = new ContentSelectorDialog2(frame, frame, BasePanel.this, false, metaData, null); Util.placeDialog(csd, frame); csd.setVisible(true); }); @@ -1362,16 +1295,14 @@ public void action() { } /** - * This method is called from JabRefFrame is a database specific - * action is requested by the user. Runs the command if it is - * defined, or prints an error message to the standard error - * stream. + * This method is called from JabRefFrame is a database specific action is requested by the user. Runs the command + * if it is defined, or prints an error message to the standard error stream. * * @param _command The name of the command to run. */ public void runCommand(String _command) { if (actions.get(_command) == null) { - LOGGER.info("No action defined for '" + _command + '\''); + BasePanel.LOGGER.info("No action defined for '" + _command + '\''); } else { Object o = actions.get(_command); try { @@ -1411,17 +1342,13 @@ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, F frame.block(); try { if (!selectedOnly) { - session = FileActions.saveDatabase(database, metaData, file, - Globals.prefs, false, false, encoding, false); + session = FileActions.saveDatabase(database, metaData, file, Globals.prefs, false, false, encoding, false); } else { - session = FileActions.savePartOfDatabase(database, metaData, file, - Globals.prefs, mainTable.getSelectedEntries(), encoding, saveType); + session = FileActions.savePartOfDatabase(database, metaData, file, Globals.prefs, mainTable.getSelectedEntries(), encoding, saveType); } } catch (UnsupportedCharsetException ex2) { - JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file. " - + "Character encoding '%0' is not supported.", encoding), - Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file. " + "Character encoding '%0' is not supported.", encoding), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex.specificEntry()) { @@ -1436,11 +1363,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, F ex.printStackTrace(); } - JOptionPane.showMessageDialog - (frame, Localization.lang("Could not save file") - + ".\n" + ex.getMessage(), - Localization.lang("Save database"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { @@ -1452,19 +1375,15 @@ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, F DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("left:pref, 4dlu, fill:pref", "")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); - builder.append(Localization.lang("The chosen encoding '%0' could not encode the following characters: ", - session.getEncoding())); + builder.append(Localization.lang("The chosen encoding '%0' could not encode the following characters: ", session.getEncoding())); builder.append(ta); builder.append(Localization.lang("What do you want to do?")); String tryDiff = Localization.lang("Try different encoding"); - int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, - new String[]{Localization.lang("Save"), tryDiff, Localization.lang("Cancel")}, tryDiff); + int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] {Localization.lang("Save"), tryDiff, Localization.lang("Cancel")}, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. - Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), - JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS, encoding); + Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS, encoding); if (choice != null) { String newEncoding = (String) choice; return saveDatabase(file, selectedOnly, newEncoding, saveType); @@ -1488,9 +1407,8 @@ private boolean saveDatabase(File file, boolean selectedOnly, String encoding, F } /** - * This method is called from JabRefFrame when the user wants to - * create a new entry. If the argument is null, the user is - * prompted for an entry type. + * This method is called from JabRefFrame when the user wants to create a new entry. If the argument is null, the + * user is prompted for an entry type. * * @param type The type of the entry to create. * @return The newly created BibtexEntry or null the operation was canceled by the user. @@ -1516,8 +1434,7 @@ public BibtexEntry newEntry(BibtexEntryType type) { // Create an UndoableInsertEntry object. undoManager.addEdit(new UndoableInsertEntry(database, be, BasePanel.this)); - output(Localization.lang("Added new") + " '" + type.getName().toLowerCase() + "' " - + Localization.lang("entry") + '.'); + output(Localization.lang("Added new") + " '" + type.getName().toLowerCase() + "' " + Localization.lang("entry") + '.'); // We are going to select the new entry. Before that, make sure that we are in // show-entry mode. If we aren't already in that mode, enter the WILL_SHOW_EDITOR @@ -1541,7 +1458,7 @@ public BibtexEntry newEntry(BibtexEntryType type) { return be; } catch (KeyCollisionException ex) { - LOGGER.info(ex.getMessage(), ex); + BasePanel.LOGGER.info(ex.getMessage(), ex); } } return null; @@ -1549,16 +1466,14 @@ public BibtexEntry newEntry(BibtexEntryType type) { /** - * This listener is used to add a new entry to a group (or a set of groups) - * in case the Group View is selected and one or more groups are marked + * This listener is used to add a new entry to a group (or a set of groups) in case the Group View is selected and + * one or more groups are marked */ private class GroupTreeUpdater implements DatabaseChangeListener { @Override public void databaseChanged(DatabaseChangeEvent e) { - if (e.getType() == ChangeType.ADDED_ENTRY - && Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP) - && frame.groupToggle.isSelected()) { + if ((e.getType() == ChangeType.ADDED_ENTRY) && Globals.prefs.getBoolean(JabRefPreferences.AUTO_ASSIGN_GROUP) && frame.groupToggle.isSelected()) { BibtexEntry[] entries = {e.getEntry()}; TreePath[] selection = frame.groupSelector.getGroupsTree().getSelectionPaths(); if (selection != null) { @@ -1580,28 +1495,28 @@ public void run() { } /** - * Ensures that the search auto completer is up to date when entries are changed - * AKA Let the auto completer, if any, harvest words from the entry + * Ensures that the search auto completer is up to date when entries are changed AKA Let the auto completer, if any, + * harvest words from the entry */ private class SearchAutoCompleterUpdater implements DatabaseChangeListener { @Override public void databaseChanged(DatabaseChangeEvent e) { - if (e.getType() == ChangeType.CHANGED_ENTRY || e.getType() == ChangeType.ADDED_ENTRY) { + if ((e.getType() == ChangeType.CHANGED_ENTRY) || (e.getType() == ChangeType.ADDED_ENTRY)) { searchAutoCompleter.addBibtexEntry(e.getEntry()); } } } /** - * Ensures that auto completers are up to date when entries are changed - * AKA Let the auto completer, if any, harvest words from the entry + * Ensures that auto completers are up to date when entries are changed AKA Let the auto completer, if any, harvest + * words from the entry */ private class AutoCompletersUpdater implements DatabaseChangeListener { @Override public void databaseChanged(DatabaseChangeEvent e) { - if (e.getType() == ChangeType.CHANGED_ENTRY || e.getType() == ChangeType.ADDED_ENTRY) { + if ((e.getType() == ChangeType.CHANGED_ENTRY) || (e.getType() == ChangeType.ADDED_ENTRY)) { BasePanel.this.autoCompleters.addEntry(e.getEntry()); } } @@ -1609,8 +1524,7 @@ public void databaseChanged(DatabaseChangeEvent e) { /** - * This method is called from JabRefFrame when the user wants to - * create a new entry. + * This method is called from JabRefFrame when the user wants to create a new entry. * * @param bibEntry The new entry. */ @@ -1624,9 +1538,7 @@ public void insertEntry(BibtexEntry bibEntry) { } // Create an UndoableInsertEntry object. undoManager.addEdit(new UndoableInsertEntry(database, bibEntry, BasePanel.this)); - output(Localization.lang("Added new") + " '" - + bibEntry.getType().getName().toLowerCase() + "' " - + Localization.lang("entry") + '.'); + output(Localization.lang("Added new") + " '" + bibEntry.getType().getName().toLowerCase() + "' " + Localization.lang("entry") + '.'); markBaseChanged(); // The database just changed. if (Globals.prefs.getBoolean(JabRefPreferences.AUTO_OPEN_FORM)) { @@ -1634,7 +1546,7 @@ public void insertEntry(BibtexEntry bibEntry) { } highlightEntry(bibEntry); } catch (KeyCollisionException ex) { - LOGGER.info("Collision for bibtex key" + bibEntry.getId(), ex); + BasePanel.LOGGER.info("Collision for bibtex key" + bibEntry.getId(), ex); } } } @@ -1670,11 +1582,9 @@ private void createMainTable() { @Override public void listChanged(ListEvent listEvent) { if (Globals.prefs.getBoolean(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ANY)) { - getGroupSelector().showMatchingGroups( - mainTable.getSelectedEntries(), false); + getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), false); } else if (Globals.prefs.getBoolean(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ALL)) { - getGroupSelector().showMatchingGroups( - mainTable.getSelectedEntries(), true); + getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), true); } else { // no highlight getGroupSelector().showMatchingGroups(null, true); @@ -1687,6 +1597,7 @@ public void listChanged(ListEvent listEvent) { private static final long serialVersionUID = 1L; + @Override public void actionPerformed(ActionEvent e) { try { @@ -1700,6 +1611,7 @@ public void actionPerformed(ActionEvent e) { private static final long serialVersionUID = 1L; + @Override public void actionPerformed(ActionEvent e) { try { @@ -1713,6 +1625,7 @@ public void actionPerformed(ActionEvent e) { private static final long serialVersionUID = 1L; + @Override public void actionPerformed(ActionEvent e) { try { @@ -1733,41 +1646,41 @@ public void keyPressed(KeyEvent e) { if (e.isControlDown()) { switch (keyCode) { - // The up/down/left/rightkeystrokes are displayed in the - // GroupSelector's popup menu, so if they are to be changed, - // edit GroupSelector.java accordingly! - case KeyEvent.VK_UP: - e.consume(); - if (node != null) { - frame.groupSelector.moveNodeUp(node, true); - } - break; - case KeyEvent.VK_DOWN: - e.consume(); - if (node != null) { - frame.groupSelector.moveNodeDown(node, true); - } - break; - case KeyEvent.VK_LEFT: - e.consume(); - if (node != null) { - frame.groupSelector.moveNodeLeft(node, true); - } - break; - case KeyEvent.VK_RIGHT: - e.consume(); - if (node != null) { - frame.groupSelector.moveNodeRight(node, true); - } - break; - case KeyEvent.VK_PAGE_DOWN: - frame.nextTab.actionPerformed(null); - e.consume(); - break; - case KeyEvent.VK_PAGE_UP: - frame.prevTab.actionPerformed(null); - e.consume(); - break; + // The up/down/left/rightkeystrokes are displayed in the + // GroupSelector's popup menu, so if they are to be changed, + // edit GroupSelector.java accordingly! + case KeyEvent.VK_UP: + e.consume(); + if (node != null) { + frame.groupSelector.moveNodeUp(node, true); + } + break; + case KeyEvent.VK_DOWN: + e.consume(); + if (node != null) { + frame.groupSelector.moveNodeDown(node, true); + } + break; + case KeyEvent.VK_LEFT: + e.consume(); + if (node != null) { + frame.groupSelector.moveNodeLeft(node, true); + } + break; + case KeyEvent.VK_RIGHT: + e.consume(); + if (node != null) { + frame.groupSelector.moveNodeRight(node, true); + } + break; + case KeyEvent.VK_PAGE_DOWN: + frame.nextTab.actionPerformed(null); + e.consume(); + break; + case KeyEvent.VK_PAGE_UP: + frame.prevTab.actionPerformed(null); + e.consume(); + break; } } else if (keyCode == KeyEvent.VK_ENTER) { e.consume(); @@ -1882,7 +1795,7 @@ public void refreshTable() { //tableModel.remap(); if ((bes != null) && (bes.length > 0)) selectEntries(bes, 0); - + //long toc = System.currentTimeMillis(); // Util.pr("Refresh took: "+(toc-tic)+" ms"); } */ @@ -1916,8 +1829,8 @@ public void adjustSplitter() { } /** - * Stores the source view in the entry editor, if one is open, has the source view - * selected and the source has been edited. + * Stores the source view in the entry editor, if one is open, has the source view selected and the source has been + * edited. * * @return boolean false if there is a validation error in the source panel, true otherwise. */ @@ -1938,8 +1851,7 @@ public void moveFocusToEntryEditor() { } private boolean isShowingEditor() { - return splitPane.getBottomComponent() != null - && splitPane.getBottomComponent() instanceof EntryEditor; + return (splitPane.getBottomComponent() != null) && (splitPane.getBottomComponent() instanceof EntryEditor); } public void showEntry(final BibtexEntry be) { @@ -1977,8 +1889,7 @@ public void showEntry(final BibtexEntry be) { if (entryEditors.containsKey(be.getType().getName())) { // We already have an editor for this entry type. - form = entryEditors.get - (be.getType().getName()); + form = entryEditors.get(be.getType().getName()); form.switchTo(be); if (visName != null) { form.setVisiblePanel(visName); @@ -2000,8 +1911,7 @@ public void showEntry(final BibtexEntry be) { if (divLoc > 0) { splitPane.setDividerLocation(divLoc); } else { - splitPane.setDividerLocation - (splitPane.getHeight() - Globals.prefs.getInt(JabRefPreferences.ENTRY_EDITOR_HEIGHT)); + splitPane.setDividerLocation(splitPane.getHeight() - Globals.prefs.getInt(JabRefPreferences.ENTRY_EDITOR_HEIGHT)); //new FocusRequester(form); //form.requestFocus(); } @@ -2011,8 +1921,8 @@ public void showEntry(final BibtexEntry be) { } /** - * Get an entry editor ready to edit the given entry. If an appropriate editor is already - * cached, it will be updated and returned. + * Get an entry editor ready to edit the given entry. If an appropriate editor is already cached, it will be updated + * and returned. * * @param entry The entry to be edited. * @return A suitable entry editor. @@ -2023,12 +1933,11 @@ public EntryEditor getEntryEditor(BibtexEntry entry) { EntryEditor visibleNow = currentEditor; // We already have an editor for this entry type. - form = entryEditors.get - (entry.getType().getName()); + form = entryEditors.get(entry.getType().getName()); // If the cached editor is not the same as the currently shown one, // make sure the current one stores its current edit: - if (visibleNow != null && form != visibleNow) { + if ((visibleNow != null) && (form != visibleNow)) { visibleNow.storeCurrentEdit(); } @@ -2054,9 +1963,8 @@ public EntryEditor getCurrentEditor() { } /** - * Sets the given entry editor as the bottom component in the split pane. If an entry editor already - * was shown, makes sure that the divider doesn't move. - * Updates the mode to SHOWING_EDITOR. + * Sets the given entry editor as the bottom component in the split pane. If an entry editor already was shown, + * makes sure that the divider doesn't move. Updates the mode to SHOWING_EDITOR. * * @param editor The entry editor to add. */ @@ -2077,8 +1985,7 @@ public void showEntryEditor(EntryEditor editor) { } /** - * Sets the given preview panel as the bottom component in the split panel. - * Updates the mode to SHOWING_PREVIEW. + * Sets the given preview panel as the bottom component in the split panel. Updates the mode to SHOWING_PREVIEW. * * @param preview The preview to show. */ @@ -2097,8 +2004,8 @@ public void hideBottomComponent() { } /** - * This method selects the given entry, and scrolls it into view in the table. - * If an entryEditor is shown, it is given focus afterwards. + * This method selects the given entry, and scrolls it into view in the table. If an entryEditor is shown, it is + * given focus afterwards. */ public void highlightEntry(final BibtexEntry be) { //SwingUtilities.invokeLater(new Thread() { @@ -2114,8 +2021,8 @@ public void highlightEntry(final BibtexEntry be) { } /** - * This method is called from an EntryEditor when it should be closed. We relay - * to the selection listener, which takes care of the rest. + * This method is called from an EntryEditor when it should be closed. We relay to the selection listener, which + * takes care of the rest. * * @param editor The entry editor to close. */ @@ -2126,11 +2033,10 @@ public void entryEditorClosing(EntryEditor editor) { } /** - * This method selects the given enties. - * If an entryEditor is shown, it is given focus afterwards. + * This method selects the given enties. If an entryEditor is shown, it is given focus afterwards. */ /*public void selectEntries(final BibtexEntry[] bes, final int toScrollTo) { - + SwingUtilities.invokeLater(new Thread() { public void run() { int rowToScrollTo = 0; @@ -2159,7 +2065,7 @@ public void run() { * @param be a BibtexEntry value */ public void ensureNotShowing(BibtexEntry be) { - if (mode == BasePanel.SHOWING_EDITOR && currentEditor.getEntry() == be) { + if ((mode == BasePanel.SHOWING_EDITOR) && (currentEditor.getEntry() == be)) { selectionListener.entryEditorClosing(currentEditor); } } @@ -2179,8 +2085,7 @@ public void updateEntryEditorIfShowing() { } /** - * If an entry editor is showing, make sure its currently focused field - * stores its changes, if any. + * If an entry editor is showing, make sure its currently focused field stores its changes, if any. */ public void storeCurrentEdit() { if (isShowingEditor()) { @@ -2191,11 +2096,9 @@ public void storeCurrentEdit() { } /** - * This method iterates through all existing entry editors in this - * BasePanel, telling each to update all its instances of - * FieldContentSelector. This is done to ensure that the list of words - * in each selector is up-to-date after the user has made changes in - * the Manage dialog. + * This method iterates through all existing entry editors in this BasePanel, telling each to update all its + * instances of FieldContentSelector. This is done to ensure that the list of words in each selector is up-to-date + * after the user has made changes in the Manage dialog. */ public void updateAllContentSelectors() { for (Map.Entry stringEntryEditorEntry : entryEditors.entrySet()) { @@ -2244,8 +2147,7 @@ private synchronized void markChangedOrUnChanged() { } else if (baseChanged && !nonUndoableChange) { baseChanged = false; if (getFile() != null) { - frame.setTabTitle(BasePanel.this, getFile().getName(), - getFile().getAbsolutePath()); + frame.setTabTitle(BasePanel.this, getFile().getName(), getFile().getAbsolutePath()); } else { frame.setTabTitle(BasePanel.this, Localization.lang("untitled"), null); } @@ -2347,7 +2249,7 @@ public void stringsClosing() { } public void changeType(BibtexEntry entry, BibtexEntryType type) { - changeType(new BibtexEntry[]{entry}, type); + changeType(new BibtexEntry[] {entry}, type); } public void changeType(BibtexEntryType type) { @@ -2357,17 +2259,12 @@ public void changeType(BibtexEntryType type) { private void changeType(BibtexEntry[] bes, BibtexEntryType type) { - if (bes == null || bes.length == 0) { - output("First select the entries you wish to change type " + - "for."); + if ((bes == null) || (bes.length == 0)) { + output("First select the entries you wish to change type " + "for."); return; } if (bes.length > 1) { - int choice = JOptionPane.showConfirmDialog - (this, "Multiple entries selected. Do you want to change" - + "\nthe type of all these to '" + type.getName() + "'?", - "Change type", JOptionPane.YES_NO_OPTION, - JOptionPane.WARNING_MESSAGE); + int choice = JOptionPane.showConfirmDialog(this, "Multiple entries selected. Do you want to change" + "\nthe type of all these to '" + type.getName() + "'?", "Change type", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (choice == JOptionPane.NO_OPTION) { return; } @@ -2375,15 +2272,11 @@ private void changeType(BibtexEntry[] bes, BibtexEntryType type) { NamedCompound ce = new NamedCompound(Localization.lang("change type")); for (BibtexEntry be : bes) { - ce.addEdit(new UndoableChangeType(be, - be.getType(), - type)); + ce.addEdit(new UndoableChangeType(be, be.getType(), type)); be.setType(type); } - output(Localization.lang("Changed type to") + " '" + type.getName() + "' " - + Localization.lang("for") + ' ' + bes.length - + ' ' + Localization.lang("entries") + '.'); + output(Localization.lang("Changed type to") + " '" + type.getName() + "' " + Localization.lang("for") + ' ' + bes.length + ' ' + Localization.lang("entries") + '.'); ce.end(); undoManager.addEdit(ce); markBaseChanged(); @@ -2392,21 +2285,16 @@ private void changeType(BibtexEntry[] bes, BibtexEntryType type) { public boolean showDeleteConfirmationDialog(int numberOfEntries) { if (Globals.prefs.getBoolean(JabRefPreferences.CONFIRM_DELETE)) { - String msg = Localization.lang("Really delete the selected") - + ' ' + Localization.lang("entry") + '?'; + String msg = Localization.lang("Really delete the selected") + ' ' + Localization.lang("entry") + '?'; String title = Localization.lang("Delete entry"); if (numberOfEntries > 1) { - msg = Localization.lang("Really delete the selected") - + ' ' + numberOfEntries + ' ' + Localization.lang("entries") + '?'; + msg = Localization.lang("Really delete the selected") + ' ' + numberOfEntries + ' ' + Localization.lang("entries") + '?'; title = Localization.lang("Delete multiple entries"); } - CheckBoxMessage cb = new CheckBoxMessage - (msg, Localization.lang("Disable this confirmation dialog"), false); + CheckBoxMessage cb = new CheckBoxMessage(msg, Localization.lang("Disable this confirmation dialog"), false); - int answer = JOptionPane.showConfirmDialog(frame, cb, title, - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + int answer = JOptionPane.showConfirmDialog(frame, cb, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (cb.isSelected()) { Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, false); } @@ -2418,8 +2306,7 @@ public boolean showDeleteConfirmationDialog(int numberOfEntries) { } /** - * If the relevant option is set, autogenerate keys for all entries that are - * lacking keys. + * If the relevant option is set, autogenerate keys for all entries that are lacking keys. */ public void autoGenerateKeysBeforeSaving() { if (Globals.prefs.getBoolean(JabRefPreferences.GENERATE_KEYS_BEFORE_SAVING)) { @@ -2428,10 +2315,9 @@ public void autoGenerateKeysBeforeSaving() { for (BibtexEntry bes : database.getEntries()) { String oldKey = bes.getCiteKey(); - if (oldKey == null || oldKey.isEmpty()) { + if ((oldKey == null) || oldKey.isEmpty()) { LabelPatternUtil.makeLabel(metaData, database, bes); - ce.addEdit(new UndoableKeyChange(database, bes.getId(), null, - bes.getField(BibtexEntry.KEY_FIELD))); + ce.addEdit(new UndoableKeyChange(database, bes.getId(), null, bes.getField(BibtexEntry.KEY_FIELD))); any = true; } } @@ -2444,8 +2330,8 @@ public void autoGenerateKeysBeforeSaving() { } /** - * Activates or deactivates the entry preview, depending on the argument. - * When deactivating, makes sure that any visible preview is hidden. + * Activates or deactivates the entry preview, depending on the argument. When deactivating, makes sure that any + * visible preview is hidden. * * @param enabled */ @@ -2458,8 +2344,8 @@ public void setSelectionListenerEnabled(boolean enabled) { } /** - * Depending on whether a preview or an entry editor is showing, save the current - * divider location in the correct preference setting. + * Depending on whether a preview or an entry editor is showing, save the current divider location in the correct + * preference setting. */ public void saveDividerLocation() { if (mode == BasePanel.SHOWING_PREVIEW) { @@ -2476,10 +2362,10 @@ class UndoAction implements BaseAction { public void action() { try { JComponent focused = Globals.focusListener.getFocused(); - if (focused != null && focused instanceof FieldEditor && focused.hasFocus()) { + if ((focused != null) && (focused instanceof FieldEditor) && focused.hasFocus()) { // User is currently editing a field: // Check if it is the preamble: - if (preambleEditor != null && focused == preambleEditor.getFieldEditor()) { + if ((preambleEditor != null) && (focused == preambleEditor.getFieldEditor())) { preambleEditor.storeCurrentEdit(); } else { storeCurrentEdit(); @@ -2508,7 +2394,7 @@ public void action() { try { JComponent focused = Globals.focusListener.getFocused(); - if (focused != null && focused instanceof FieldEditor && focused.hasFocus()) { + if ((focused != null) && (focused instanceof FieldEditor) && focused.hasFocus()) { // User is currently editing a field: storeCurrentEdit(); } @@ -2535,7 +2421,7 @@ public void lostOwnership(Clipboard clipboard, Transferable contents) { } private void setEntryEditorEnabled(boolean enabled) { - if (getShowing() != null && splitPane.getBottomComponent() instanceof EntryEditor) { + if ((getShowing() != null) && (splitPane.getBottomComponent() instanceof EntryEditor)) { EntryEditor ed = (EntryEditor) splitPane.getBottomComponent(); if (ed.isEnabled() != enabled) { ed.setEnabled(enabled); @@ -2575,8 +2461,7 @@ public void run() { sidePaneManager.hideComponent(FileUpdatePanel.NAME); sidePaneManager.unregisterComponent(FileUpdatePanel.NAME); } - FileUpdatePanel pan = new FileUpdatePanel(frame, BasePanel.this, - sidePaneManager, getFile(), scanner); + FileUpdatePanel pan = new FileUpdatePanel(frame, BasePanel.this, sidePaneManager, getFile(), scanner); sidePaneManager.register(FileUpdatePanel.NAME, pan); sidePaneManager.show(FileUpdatePanel.NAME); //setUpdatedExternally(false); @@ -2585,8 +2470,7 @@ public void run() { }; // Test: running scan automatically in background - if (BasePanel.this.getFile() != null && - !FileBasedLock.waitForFileLock(BasePanel.this.getFile(), 10)) { + if ((BasePanel.this.getFile() != null) && !FileBasedLock.waitForFileLock(BasePanel.this.getFile(), 10)) { // The file is locked even after the maximum wait. Do nothing. System.err.println("File updated externally, but change scan failed because the file is locked."); // Perturb the stored timestamp so successive checks are made: @@ -2606,7 +2490,7 @@ public void run() { @Override public void fileRemoved() { - LOGGER.info("File '" + getFile().getPath() + "' has been deleted."); + BasePanel.LOGGER.info("File '" + getFile().getPath() + "' has been deleted."); } /** @@ -2631,8 +2515,8 @@ public void setUpdatedExternally(boolean b) { } /** - * Get an array containing the currently selected entries. - * The array is stable and not changed if the selection changes + * Get an array containing the currently selected entries. The array is stable and not changed if the selection + * changes * * @return An array containing the selected entries. Is never null. */ @@ -2650,8 +2534,7 @@ public File getFile() { } /** - * Get a String containing a comma-separated list of the bibtex keys - * of the selected entries. + * Get a String containing a comma-separated list of the bibtex keys of the selected entries. * * @return A comma-separated list of the keys of the selected entries. */ @@ -2662,7 +2545,7 @@ public String getKeysForSelection() { for (BibtexEntry bes : mainTable.getSelected()) { citeKey = bes.getField(BibtexEntry.KEY_FIELD); // if the key is empty we give a warning and ignore this entry - if (citeKey == null || citeKey.isEmpty()) { + if ((citeKey == null) || citeKey.isEmpty()) { continue; } if (first) { @@ -2716,9 +2599,8 @@ private BibtexEntry getShowing() { } /** - * Update the pointer to the currently shown entry in all cases where the user has - * moved to a new entry, except when using Back and Forward commands. Also updates - * history for Back command, and clears history for Forward command. + * Update the pointer to the currently shown entry in all cases where the user has moved to a new entry, except when + * using Back and Forward commands. Also updates history for Back command, and clears history for Forward command. * * @param entry The entry that is now to be shown. */ @@ -2748,8 +2630,7 @@ public void newEntryShowing(BibtexEntry entry) { } /** - * Go back (if there is any recorded history) and update the histories for - * the Back and Forward commands. + * Go back (if there is any recorded history) and update the histories for the Back and Forward commands. */ private void back() { if (!previousEntries.isEmpty()) { @@ -2795,21 +2676,14 @@ public SaveSelectedAction(DatabaseSaveType saveType) { @Override public void action() throws SaveException { - String chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), ".bib", - JFileChooser.SAVE_DIALOG, false); + String chosenFile = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), ".bib", JFileChooser.SAVE_DIALOG, false); if (chosenFile != null) { File expFile = new File(chosenFile); - if (!expFile.exists() || - JOptionPane.showConfirmDialog - (frame, '\'' + expFile.getName() + "' " + - Localization.lang("exists. Overwrite file?"), - Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) - == JOptionPane.OK_OPTION) { + if (!expFile.exists() || (JOptionPane.showConfirmDialog(frame, '\'' + expFile.getName() + "' " + Localization.lang("exists. Overwrite file?"), Localization.lang("Save database"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)) { saveDatabase(expFile, true, Globals.prefs.get(JabRefPreferences.DEFAULT_ENCODING), saveType); frame.getFileHistory().newFile(expFile.getPath()); - frame.output(Localization.lang("Saved selected to") + " '" - + expFile.getPath() + "'."); + frame.output(Localization.lang("Saved selected to") + " '" + expFile.getPath() + "'."); } } } diff --git a/src/main/java/net/sf/jabref/gui/JabRefFrame.java b/src/main/java/net/sf/jabref/gui/JabRefFrame.java index e570d3c9799..8a3fc27cb30 100644 --- a/src/main/java/net/sf/jabref/gui/JabRefFrame.java +++ b/src/main/java/net/sf/jabref/gui/JabRefFrame.java @@ -35,7 +35,6 @@ import java.awt.event.WindowEvent; import java.io.File; import java.io.IOException; -import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -132,6 +131,7 @@ * The main window of the application. */ public class JabRefFrame extends JFrame implements OutputPrinter { + private static final long serialVersionUID = 1L; private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class); @@ -150,10 +150,12 @@ public class JabRefFrame extends JFrame implements OutputPrinter { private final Insets marg = new Insets(1, 0, 2, 0); private final JabRef jabRef; + class ToolBar extends JToolBar { private static final long serialVersionUID = 1L; + void addAction(Action a) { JButton b = new JButton(a); b.setText(null); @@ -173,9 +175,7 @@ void addAction(Action a) { private final GridBagConstraints con = new GridBagConstraints(); final JLabel statusLine = new JLabel("", SwingConstants.LEFT); - private final JLabel statusLabel = new JLabel( - Localization.lang("Status") - + ':', SwingConstants.LEFT); + private final JLabel statusLabel = new JLabel(Localization.lang("Status") + ':', SwingConstants.LEFT); private final JProgressBar progressBar = new JProgressBar(); private final FileHistory fileHistory = new FileHistory(prefs, this); @@ -201,47 +201,23 @@ void addAction(Action a) { public JToggleButton highlightAll; final OpenDatabaseAction open = new OpenDatabaseAction(this, true); - private final AbstractAction - close = new CloseDatabaseAction(); + private final AbstractAction close = new CloseDatabaseAction(); private final AbstractAction quit = new CloseAction(); private final AbstractAction selectKeys = new SelectKeysAction(); private final AbstractAction newDatabaseAction = new NewDatabaseAction(this); private final AbstractAction newSubDatabaseAction = new NewSubDatabaseAction(this); private final AbstractAction integrityCheckAction = new IntegrityCheckAction(this); private final AbstractAction forkMeOnGitHubAction = new ForkMeOnGitHubAction(); - private final AbstractAction help = new HelpAction("JabRef help", helpDiag, - GUIGlobals.baseFrameHelp, Localization.lang("JabRef help"), - prefs.getKey("Help")); - private final AbstractAction contents = new HelpAction("Help contents", helpDiag, - GUIGlobals.helpContents, Localization.lang("Help contents"), - IconTheme.getImage("helpContents")); - private final AbstractAction about = new HelpAction("About JabRef", helpDiag, - GUIGlobals.aboutPage, Localization.lang("About JabRef"), - IconTheme.getImage("about")); - private final AbstractAction editEntry = new GeneralAction(Actions.EDIT, "Edit entry", - Localization.lang("Edit entry"), - prefs.getKey(KeyBinds.EDIT_ENTRY), - IconTheme.getImage("edit")); - private final AbstractAction focusTable = new GeneralAction(Actions.FOCUS_TABLE, "Focus entry table", - Localization.lang("Move the keyboard focus to the entry table"), - prefs.getKey(KeyBinds.FOCUS_ENTRY_TABLE)); - private final AbstractAction save = new GeneralAction(Actions.SAVE, "Save database", - Localization.lang("Save database"), - prefs.getKey(KeyBinds.SAVE_DATABASE), - IconTheme.getImage("save")); - private final AbstractAction saveAs = new GeneralAction(Actions.SAVE_AS, "Save database as ...", - Localization.lang("Save database as ..."), - prefs.getKey(KeyBinds.SAVE_DATABASE_AS), - IconTheme.getImage("saveAs")); + private final AbstractAction help = new HelpAction("JabRef help", helpDiag, GUIGlobals.baseFrameHelp, Localization.lang("JabRef help"), prefs.getKey("Help")); + private final AbstractAction contents = new HelpAction("Help contents", helpDiag, GUIGlobals.helpContents, Localization.lang("Help contents"), IconTheme.getImage("helpContents")); + private final AbstractAction about = new HelpAction("About JabRef", helpDiag, GUIGlobals.aboutPage, Localization.lang("About JabRef"), IconTheme.getImage("about")); + private final AbstractAction editEntry = new GeneralAction(Actions.EDIT, "Edit entry", Localization.lang("Edit entry"), prefs.getKey(KeyBinds.EDIT_ENTRY), IconTheme.getImage("edit")); + private final AbstractAction focusTable = new GeneralAction(Actions.FOCUS_TABLE, "Focus entry table", Localization.lang("Move the keyboard focus to the entry table"), prefs.getKey(KeyBinds.FOCUS_ENTRY_TABLE)); + private final AbstractAction save = new GeneralAction(Actions.SAVE, "Save database", Localization.lang("Save database"), prefs.getKey(KeyBinds.SAVE_DATABASE), IconTheme.getImage("save")); + private final AbstractAction saveAs = new GeneralAction(Actions.SAVE_AS, "Save database as ...", Localization.lang("Save database as ..."), prefs.getKey(KeyBinds.SAVE_DATABASE_AS), IconTheme.getImage("saveAs")); private final AbstractAction saveAll = new SaveAllAction(JabRefFrame.this); - private final AbstractAction saveSelectedAs = new GeneralAction(Actions.SAVE_SELECTED_AS, - "Save selected as ...", - Localization.lang("Save selected as ..."), - IconTheme.getImage("saveAs")); - private final AbstractAction saveSelectedAsPlain = new GeneralAction(Actions.SAVE_SELECTED_AS_PLAIN, - "Save selected as plain BibTeX ...", - Localization.lang("Save selected as plain BibTeX ..."), - IconTheme.getImage("saveAs")); + private final AbstractAction saveSelectedAs = new GeneralAction(Actions.SAVE_SELECTED_AS, "Save selected as ...", Localization.lang("Save selected as ..."), IconTheme.getImage("saveAs")); + private final AbstractAction saveSelectedAsPlain = new GeneralAction(Actions.SAVE_SELECTED_AS_PLAIN, "Save selected as plain BibTeX ...", Localization.lang("Save selected as plain BibTeX ..."), IconTheme.getImage("saveAs")); private final AbstractAction exportAll = ExportFormats.getExportAction(this, false); private final AbstractAction exportSelected = ExportFormats.getExportAction(this, true); private final AbstractAction importCurrent = ImportFormats.getImportAction(this, false); @@ -249,209 +225,102 @@ void addAction(Action a) { public final AbstractAction nextTab = new ChangeTabAction(true); public final AbstractAction prevTab = new ChangeTabAction(false); private final AbstractAction sortTabs = new SortTabsAction(this); - private final AbstractAction undo = new GeneralAction(Actions.UNDO, "Undo", Localization.lang("Undo"), - prefs.getKey(KeyBinds.UNDO), - IconTheme.getImage("undo")); - private final AbstractAction redo = new GeneralAction(Actions.REDO, "Redo", Localization.lang("Redo"), - prefs.getKey(KeyBinds.REDO), - IconTheme.getImage("redo")); - final AbstractAction forward = new GeneralAction(Actions.FORWARD, "Forward", Localization.lang("Forward"), - prefs.getKey(KeyBinds.FORWARD), IconTheme.getImage("right")); - final AbstractAction back = new GeneralAction(Actions.BACK, "Back", Localization.lang("Back"), - prefs.getKey(KeyBinds.BACK), IconTheme.getImage("left")); - private final AbstractAction delete = new GeneralAction(Actions.DELETE, "Delete", Localization.lang("Delete"), - prefs.getKey(KeyBinds.DELETE), - IconTheme.getImage("delete")); + private final AbstractAction undo = new GeneralAction(Actions.UNDO, "Undo", Localization.lang("Undo"), prefs.getKey(KeyBinds.UNDO), IconTheme.getImage("undo")); + private final AbstractAction redo = new GeneralAction(Actions.REDO, "Redo", Localization.lang("Redo"), prefs.getKey(KeyBinds.REDO), IconTheme.getImage("redo")); + final AbstractAction forward = new GeneralAction(Actions.FORWARD, "Forward", Localization.lang("Forward"), prefs.getKey(KeyBinds.FORWARD), IconTheme.getImage("right")); + final AbstractAction back = new GeneralAction(Actions.BACK, "Back", Localization.lang("Back"), prefs.getKey(KeyBinds.BACK), IconTheme.getImage("left")); + private final AbstractAction delete = new GeneralAction(Actions.DELETE, "Delete", Localization.lang("Delete"), prefs.getKey(KeyBinds.DELETE), IconTheme.getImage("delete")); private final AbstractAction copy = new EditAction(Actions.COPY, IconTheme.getImage("copy")); private final AbstractAction paste = new EditAction(Actions.PASTE, IconTheme.getImage("paste")); private final AbstractAction cut = new EditAction(Actions.CUT, IconTheme.getImage("cut")); - private final AbstractAction mark = new GeneralAction(Actions.MARK_ENTRIES, "Mark entries", - Localization.lang("Mark entries"), - prefs.getKey(KeyBinds.MARK_ENTRIES), - IconTheme.getImage("markEntries")); - private final AbstractAction unmark = new GeneralAction(Actions.UNMARK_ENTRIES, "Unmark entries", - Localization.lang("Unmark entries"), - prefs.getKey(KeyBinds.UNMARK_ENTRIES), - IconTheme.getImage("unmarkEntries")); + private final AbstractAction mark = new GeneralAction(Actions.MARK_ENTRIES, "Mark entries", Localization.lang("Mark entries"), prefs.getKey(KeyBinds.MARK_ENTRIES), IconTheme.getImage("markEntries")); + private final AbstractAction unmark = new GeneralAction(Actions.UNMARK_ENTRIES, "Unmark entries", Localization.lang("Unmark entries"), prefs.getKey(KeyBinds.UNMARK_ENTRIES), IconTheme.getImage("unmarkEntries")); private final AbstractAction unmarkAll = new GeneralAction(Actions.UNMARK_ALL, "Unmark all"); - private final AbstractAction toggleRelevance = new GeneralAction( - Relevance.getInstance().getValues().get(0).getActionName(), - Relevance.getInstance().getValues().get(0).getMenuString(), - Relevance.getInstance().getValues().get(0).getToolTipText(), - IconTheme.getImage(Relevance.getInstance().getValues().get(0).getActionName())); - private final AbstractAction toggleQualityAssured = new GeneralAction( - Quality.getInstance().getValues().get(0).getActionName(), - Quality.getInstance().getValues().get(0).getMenuString(), - Quality.getInstance().getValues().get(0).getToolTipText(), - IconTheme.getImage(Quality.getInstance().getValues().get(0).getActionName())); - private final AbstractAction togglePrinted = new GeneralAction( - Printed.getInstance().getValues().get(0).getActionName(), - Printed.getInstance().getValues().get(0).getMenuString(), - Printed.getInstance().getValues().get(0).getToolTipText(), - IconTheme.getImage(Printed.getInstance().getValues().get(0).getActionName())); + private final AbstractAction toggleRelevance = new GeneralAction(Relevance.getInstance().getValues().get(0).getActionName(), Relevance.getInstance().getValues().get(0).getMenuString(), Relevance.getInstance().getValues().get(0).getToolTipText(), IconTheme.getImage(Relevance.getInstance().getValues().get(0).getActionName())); + private final AbstractAction toggleQualityAssured = new GeneralAction(Quality.getInstance().getValues().get(0).getActionName(), Quality.getInstance().getValues().get(0).getMenuString(), Quality.getInstance().getValues().get(0).getToolTipText(), IconTheme.getImage(Quality.getInstance().getValues().get(0).getActionName())); + private final AbstractAction togglePrinted = new GeneralAction(Printed.getInstance().getValues().get(0).getActionName(), Printed.getInstance().getValues().get(0).getMenuString(), Printed.getInstance().getValues().get(0).getToolTipText(), IconTheme.getImage(Printed.getInstance().getValues().get(0).getActionName())); private final AbstractAction manageSelectors = new GeneralAction(Actions.MANAGE_SELECTORS, "Manage content selectors"); private final AbstractAction saveSessionAction = new SaveSessionAction(); public final AbstractAction loadSessionAction = new LoadSessionAction(); - private final AbstractAction incrementalSearch = new GeneralAction(Actions.INC_SEARCH, "Incremental search", - Localization.lang("Start incremental search"), - prefs.getKey(KeyBinds.INCREMENTAL_SEARCH), - IconTheme.getImage("incSearch")); - private final AbstractAction normalSearch = new GeneralAction(Actions.SEARCH, "Search", Localization.lang("Search"), - prefs.getKey(KeyBinds.SEARCH), - IconTheme.getImage("search")); - private final AbstractAction toggleSearch = new GeneralAction(Actions.TOGGLE_SEARCH, "Search", - Localization.lang("Toggle search panel"),IconTheme.getImage("toggleSearch")); - - private final AbstractAction copyKey = new GeneralAction(Actions.COPY_KEY, "Copy BibTeX key", - prefs.getKey(KeyBinds.COPY_BIB_TE_X_KEY)); + private final AbstractAction incrementalSearch = new GeneralAction(Actions.INC_SEARCH, "Incremental search", Localization.lang("Start incremental search"), prefs.getKey(KeyBinds.INCREMENTAL_SEARCH), IconTheme.getImage("incSearch")); + private final AbstractAction normalSearch = new GeneralAction(Actions.SEARCH, "Search", Localization.lang("Search"), prefs.getKey(KeyBinds.SEARCH), IconTheme.getImage("search")); + private final AbstractAction toggleSearch = new GeneralAction(Actions.TOGGLE_SEARCH, "Search", Localization.lang("Toggle search panel"), IconTheme.getImage("toggleSearch")); + + private final AbstractAction copyKey = new GeneralAction(Actions.COPY_KEY, "Copy BibTeX key", prefs.getKey(KeyBinds.COPY_BIB_TE_X_KEY)); private final AbstractAction//"Put a BibTeX reference to the selected entries on the clipboard", - copyCiteKey = new GeneralAction(Actions.COPY_CITE_KEY, "Copy \\cite{BibTeX key}", - //"Put a BibTeX reference to the selected entries on the clipboard", - prefs.getKey(KeyBinds.COPY_CITE_BIB_TE_X_KEY)); - private final AbstractAction copyKeyAndTitle = new GeneralAction(Actions.COPY_KEY_AND_TITLE, - "Copy BibTeX key and title", - prefs.getKey(KeyBinds.COPY_BIB_TE_X_KEY_AND_TITLE)); - private final AbstractAction mergeDatabaseAction = new GeneralAction(Actions.MERGE_DATABASE, - "Append database", - Localization.lang("Append contents from a BibTeX database into the currently viewed database"), - IconTheme.getImage("open")); - private final AbstractAction selectAll = new GeneralAction(Actions.SELECT_ALL, "Select all", - prefs.getKey(KeyBinds.SELECT_ALL)); - private final AbstractAction replaceAll = new GeneralAction(Actions.REPLACE_ALL, "Replace string", - prefs.getKey(KeyBinds.REPLACE_STRING)); - - private final AbstractAction editPreamble = new GeneralAction(Actions.EDIT_PREAMBLE, "Edit preamble", - Localization.lang("Edit preamble"), - prefs.getKey(KeyBinds.EDIT_PREAMBLE), - IconTheme.getImage("editPreamble")); - private final AbstractAction editStrings = new GeneralAction(Actions.EDIT_STRINGS, "Edit strings", - Localization.lang("Edit strings"), - prefs.getKey(KeyBinds.EDIT_STRINGS), - IconTheme.getImage("editStrings")); + copyCiteKey = new GeneralAction(Actions.COPY_CITE_KEY, "Copy \\cite{BibTeX key}", + //"Put a BibTeX reference to the selected entries on the clipboard", + prefs.getKey(KeyBinds.COPY_CITE_BIB_TE_X_KEY)); + private final AbstractAction copyKeyAndTitle = new GeneralAction(Actions.COPY_KEY_AND_TITLE, "Copy BibTeX key and title", prefs.getKey(KeyBinds.COPY_BIB_TE_X_KEY_AND_TITLE)); + private final AbstractAction mergeDatabaseAction = new GeneralAction(Actions.MERGE_DATABASE, "Append database", Localization.lang("Append contents from a BibTeX database into the currently viewed database"), IconTheme.getImage("open")); + private final AbstractAction selectAll = new GeneralAction(Actions.SELECT_ALL, "Select all", prefs.getKey(KeyBinds.SELECT_ALL)); + private final AbstractAction replaceAll = new GeneralAction(Actions.REPLACE_ALL, "Replace string", prefs.getKey(KeyBinds.REPLACE_STRING)); + + private final AbstractAction editPreamble = new GeneralAction(Actions.EDIT_PREAMBLE, "Edit preamble", Localization.lang("Edit preamble"), prefs.getKey(KeyBinds.EDIT_PREAMBLE), IconTheme.getImage("editPreamble")); + private final AbstractAction editStrings = new GeneralAction(Actions.EDIT_STRINGS, "Edit strings", Localization.lang("Edit strings"), prefs.getKey(KeyBinds.EDIT_STRINGS), IconTheme.getImage("editStrings")); private final AbstractAction toggleToolbar = new AbstractAction("Hide/show toolbar") { + { putValue(Action.ACCELERATOR_KEY, prefs.getKey(KeyBinds.HIDE_SHOW_TOOLBAR)); putValue(Action.SHORT_DESCRIPTION, Localization.lang("Hide/show toolbar")); } + @Override public void actionPerformed(ActionEvent e) { tlb.setVisible(!tlb.isVisible()); - }}; - private final AbstractAction toggleGroups = new GeneralAction(Actions.TOGGLE_GROUPS, - "Toggle groups interface", - Localization.lang("Toggle groups interface"), - prefs.getKey(KeyBinds.TOGGLE_GROUPS_INTERFACE), - IconTheme.getImage("toggleGroups")); - private final AbstractAction togglePreview = new GeneralAction(Actions.TOGGLE_PREVIEW, - "Toggle entry preview", - Localization.lang("Toggle entry preview"), - prefs.getKey(KeyBinds.TOGGLE_ENTRY_PREVIEW), - IconTheme.getImage("togglePreview")); - private final AbstractAction toggleHighlightAny = new GeneralAction(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ANY, - "Highlight groups matching any selected entry", - Localization.lang("Highlight groups matching any selected entry"), - IconTheme.getImage("groupsHighlightAny")); - private final AbstractAction toggleHighlightAll = new GeneralAction(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ALL, - "Highlight groups matching all selected entries", - Localization.lang("Highlight groups matching all selected entries"), - IconTheme.getImage("groupsHighlightAll")); - final AbstractAction switchPreview = new GeneralAction(Actions.SWITCH_PREVIEW, - "Switch preview layout", - prefs.getKey(KeyBinds.SWITCH_PREVIEW_LAYOUT)); - private final AbstractAction makeKeyAction = new GeneralAction(Actions.MAKE_KEY, "Autogenerate BibTeX keys", - Localization.lang("Autogenerate BibTeX keys"), - prefs.getKey(KeyBinds.AUTOGENERATE_BIB_TE_X_KEYS), - IconTheme.getImage("makeKey")); - - private final AbstractAction writeXmpAction = new GeneralAction(Actions.WRITE_XMP, "Write XMP-metadata to PDFs", - Localization.lang("Will write XMP-metadata to the PDFs linked from selected entries."), - prefs.getKey(KeyBinds.WRITE_XMP)); - - private final AbstractAction openFolder = new GeneralAction(Actions.OPEN_FOLDER, "Open folder", - Localization.lang("Open folder"), - prefs.getKey(KeyBinds.OPEN_FOLDER)); - private final AbstractAction openFile = new GeneralAction(Actions.OPEN_EXTERNAL_FILE, "Open file", - Localization.lang("Open file"), - prefs.getKey(KeyBinds.OPEN_FILE), - IconTheme.getImage("openExternalFile")); - private final AbstractAction openPdf = new GeneralAction(Actions.OPEN_FILE, "Open PDF or PS", - Localization.lang("Open PDF or PS"), - prefs.getKey(KeyBinds.OPEN_PDF_OR_PS), - IconTheme.getImage("openFile")); - private final AbstractAction openUrl = new GeneralAction(Actions.OPEN_URL, "Open URL or DOI", - Localization.lang("Open URL or DOI"), - prefs.getKey(KeyBinds.OPEN_URL_OR_DOI), - IconTheme.getImage("openUrl")); - private final AbstractAction openSpires = new GeneralAction(Actions.OPEN_SPIRES, "Open SPIRES entry", - Localization.lang("Open SPIRES entry"), - prefs.getKey(KeyBinds.OPEN_SPIRES_ENTRY)); + } + }; + private final AbstractAction toggleGroups = new GeneralAction(Actions.TOGGLE_GROUPS, "Toggle groups interface", Localization.lang("Toggle groups interface"), prefs.getKey(KeyBinds.TOGGLE_GROUPS_INTERFACE), IconTheme.getImage("toggleGroups")); + private final AbstractAction togglePreview = new GeneralAction(Actions.TOGGLE_PREVIEW, "Toggle entry preview", Localization.lang("Toggle entry preview"), prefs.getKey(KeyBinds.TOGGLE_ENTRY_PREVIEW), IconTheme.getImage("togglePreview")); + private final AbstractAction toggleHighlightAny = new GeneralAction(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ANY, "Highlight groups matching any selected entry", Localization.lang("Highlight groups matching any selected entry"), IconTheme.getImage("groupsHighlightAny")); + private final AbstractAction toggleHighlightAll = new GeneralAction(Actions.TOGGLE_HIGHLIGHTS_GROUPS_MATCHING_ALL, "Highlight groups matching all selected entries", Localization.lang("Highlight groups matching all selected entries"), IconTheme.getImage("groupsHighlightAll")); + final AbstractAction switchPreview = new GeneralAction(Actions.SWITCH_PREVIEW, "Switch preview layout", prefs.getKey(KeyBinds.SWITCH_PREVIEW_LAYOUT)); + private final AbstractAction makeKeyAction = new GeneralAction(Actions.MAKE_KEY, "Autogenerate BibTeX keys", Localization.lang("Autogenerate BibTeX keys"), prefs.getKey(KeyBinds.AUTOGENERATE_BIB_TE_X_KEYS), IconTheme.getImage("makeKey")); + + private final AbstractAction writeXmpAction = new GeneralAction(Actions.WRITE_XMP, "Write XMP-metadata to PDFs", Localization.lang("Will write XMP-metadata to the PDFs linked from selected entries."), prefs.getKey(KeyBinds.WRITE_XMP)); + + private final AbstractAction openFolder = new GeneralAction(Actions.OPEN_FOLDER, "Open folder", Localization.lang("Open folder"), prefs.getKey(KeyBinds.OPEN_FOLDER)); + private final AbstractAction openFile = new GeneralAction(Actions.OPEN_EXTERNAL_FILE, "Open file", Localization.lang("Open file"), prefs.getKey(KeyBinds.OPEN_FILE), IconTheme.getImage("openExternalFile")); + private final AbstractAction openPdf = new GeneralAction(Actions.OPEN_FILE, "Open PDF or PS", Localization.lang("Open PDF or PS"), prefs.getKey(KeyBinds.OPEN_PDF_OR_PS), IconTheme.getImage("openFile")); + private final AbstractAction openUrl = new GeneralAction(Actions.OPEN_URL, "Open URL or DOI", Localization.lang("Open URL or DOI"), prefs.getKey(KeyBinds.OPEN_URL_OR_DOI), IconTheme.getImage("openUrl")); + private final AbstractAction openSpires = new GeneralAction(Actions.OPEN_SPIRES, "Open SPIRES entry", Localization.lang("Open SPIRES entry"), prefs.getKey(KeyBinds.OPEN_SPIRES_ENTRY)); private final AbstractAction dupliCheck = new GeneralAction(Actions.DUPLI_CHECK, "Find duplicates"); - private final AbstractAction plainTextImport = new GeneralAction(Actions.PLAIN_TEXT_IMPORT, - "New entry from plain text", - prefs.getKey(KeyBinds.NEW_FROM_PLAIN_TEXT)); + private final AbstractAction plainTextImport = new GeneralAction(Actions.PLAIN_TEXT_IMPORT, "New entry from plain text", prefs.getKey(KeyBinds.NEW_FROM_PLAIN_TEXT)); private final AbstractAction customExpAction = new CustomizeExportsAction(); private final AbstractAction customImpAction = new CustomizeImportsAction(); private final AbstractAction customFileTypesAction = ExternalFileTypeEditor.getAction(this); AbstractAction exportToClipboard = new GeneralAction("exportToClipboard", "Export selected entries to clipboard"); - private final AbstractAction autoSetPdf = new GeneralAction(Actions.AUTO_SET_PDF, - Localization.lang("Synchronize %0 links", "PDF"), - prefs.getKey(KeyBinds.SYNCHRONIZE_PDF)); - private final AbstractAction autoSetPs = new GeneralAction(Actions.AUTO_SET_PS, - Localization.lang("Synchronize %0 links", "PS"), - prefs.getKey(KeyBinds.SYNCHRONIZE_PS)); - private final AbstractAction autoSetFile = new GeneralAction(Actions.AUTO_SET_FILE, - Localization.lang("Synchronize file links"), - Globals.prefs.getKey(KeyBinds.SYNCHRONIZE_FILES)); - - private final AbstractAction abbreviateMedline = new GeneralAction(Actions.ABBREVIATE_MEDLINE, "Abbreviate journal names (MEDLINE)", - Localization.lang("Abbreviate journal names of the selected entries (MEDLINE abbreviation)")); - private final AbstractAction abbreviateIso = new GeneralAction(Actions.ABBREVIATE_ISO, "Abbreviate journal names (ISO)", - Localization.lang("Abbreviate journal names of the selected entries (ISO abbreviation)"), - Globals.prefs.getKey(KeyBinds.ABBREVIATE)); - - private final AbstractAction unabbreviate = new GeneralAction(Actions.UNABBREVIATE, "Unabbreviate journal names", - Localization.lang("Unabbreviate journal names of the selected entries"), - Globals.prefs.getKey(KeyBinds.UNABBREVIATE)); + private final AbstractAction autoSetPdf = new GeneralAction(Actions.AUTO_SET_PDF, Localization.lang("Synchronize %0 links", "PDF"), prefs.getKey(KeyBinds.SYNCHRONIZE_PDF)); + private final AbstractAction autoSetPs = new GeneralAction(Actions.AUTO_SET_PS, Localization.lang("Synchronize %0 links", "PS"), prefs.getKey(KeyBinds.SYNCHRONIZE_PS)); + private final AbstractAction autoSetFile = new GeneralAction(Actions.AUTO_SET_FILE, Localization.lang("Synchronize file links"), Globals.prefs.getKey(KeyBinds.SYNCHRONIZE_FILES)); + + private final AbstractAction abbreviateMedline = new GeneralAction(Actions.ABBREVIATE_MEDLINE, "Abbreviate journal names (MEDLINE)", Localization.lang("Abbreviate journal names of the selected entries (MEDLINE abbreviation)")); + private final AbstractAction abbreviateIso = new GeneralAction(Actions.ABBREVIATE_ISO, "Abbreviate journal names (ISO)", Localization.lang("Abbreviate journal names of the selected entries (ISO abbreviation)"), Globals.prefs.getKey(KeyBinds.ABBREVIATE)); + + private final AbstractAction unabbreviate = new GeneralAction(Actions.UNABBREVIATE, "Unabbreviate journal names", Localization.lang("Unabbreviate journal names of the selected entries"), Globals.prefs.getKey(KeyBinds.UNABBREVIATE)); private final AbstractAction manageJournals = new ManageJournalsAction(this); private final AbstractAction databaseProperties = new DatabasePropertiesAction(); private final AbstractAction bibtexKeyPattern = new BibtexKeyPatternAction(); private final AbstractAction errorConsole = new ErrorConsoleAction(this, Globals.streamEavesdropper, Globals.handler); - private final AbstractAction dbConnect = new GeneralAction(Actions.DB_CONNECT, "Connect to external SQL database", - Localization.lang("Connect to external SQL database"), - IconTheme.getImage("dbConnect")); + private final AbstractAction dbConnect = new GeneralAction(Actions.DB_CONNECT, "Connect to external SQL database", Localization.lang("Connect to external SQL database"), IconTheme.getImage("dbConnect")); - private final AbstractAction dbExport = new GeneralAction(Actions.DB_EXPORT, "Export to external SQL database", - Localization.lang("Export to external SQL database"), - IconTheme.getImage("dbExport")); + private final AbstractAction dbExport = new GeneralAction(Actions.DB_EXPORT, "Export to external SQL database", Localization.lang("Export to external SQL database"), IconTheme.getImage("dbExport")); - private final AbstractAction Cleanup = new GeneralAction(Actions.CLEANUP, "Cleanup entries", - Localization.lang("Cleanup entries"), - prefs.getKey(KeyBinds.CLEANUP), - IconTheme.getImage("cleanupentries")); + private final AbstractAction Cleanup = new GeneralAction(Actions.CLEANUP, "Cleanup entries", Localization.lang("Cleanup entries"), prefs.getKey(KeyBinds.CLEANUP), IconTheme.getImage("cleanupentries")); - private final AbstractAction mergeEntries = new GeneralAction(Actions.MERGE_ENTRIES, "Merge entries", - Localization.lang("Merge entries"), - IconTheme.getImage("mergeentries")); + private final AbstractAction mergeEntries = new GeneralAction(Actions.MERGE_ENTRIES, "Merge entries", Localization.lang("Merge entries"), IconTheme.getImage("mergeentries")); private final AbstractAction dbImport = new DbImportAction(this).getAction(); private final AbstractAction increaseFontSize = new IncreaseTableFontSizeAction(); private final AbstractAction decreseFontSize = new DecreaseTableFontSizeAction(); - private final AbstractAction resolveDuplicateKeys = new GeneralAction(Actions.RESOLVE_DUPLICATE_KEYS, "Resolve duplicate BibTeX keys", - Localization.lang("Find and remove duplicate BibTeX keys"), - prefs.getKey(KeyBinds.RESOLVE_DUPLICATE_BIB_TE_X_KEYS)); + private final AbstractAction resolveDuplicateKeys = new GeneralAction(Actions.RESOLVE_DUPLICATE_KEYS, "Resolve duplicate BibTeX keys", Localization.lang("Find and remove duplicate BibTeX keys"), prefs.getKey(KeyBinds.RESOLVE_DUPLICATE_BIB_TE_X_KEYS)); final MassSetFieldAction massSetField = new MassSetFieldAction(this); final ManageKeywordsAction manageKeywords = new ManageKeywordsAction(this); - private final GeneralAction findUnlinkedFiles = new GeneralAction( - FindUnlinkedFilesDialog.ACTION_COMMAND, - FindUnlinkedFilesDialog.ACTION_TITLE, - FindUnlinkedFilesDialog.ACTION_SHORT_DESCRIPTION, - prefs.getKey(FindUnlinkedFilesDialog.ACTION_KEYBINDING_ACTION), - IconTheme.getImage("toggleSearch") - ); + private final GeneralAction findUnlinkedFiles = new GeneralAction(FindUnlinkedFilesDialog.ACTION_COMMAND, FindUnlinkedFilesDialog.ACTION_TITLE, FindUnlinkedFilesDialog.ACTION_SHORT_DESCRIPTION, prefs.getKey(FindUnlinkedFilesDialog.ACTION_KEYBINDING_ACTION), IconTheme.getImage("toggleSearch")); private final AutoLinkFilesAction autoLinkFile = new AutoLinkFilesAction(); @@ -475,25 +344,7 @@ public void actionPerformed(ActionEvent e) { // The action for adding a new entry of unspecified type. private final NewEntryAction newEntryAction = new NewEntryAction(this, prefs.getKey("New entry")); - private final NewEntryAction[] newSpecificEntryAction = new NewEntryAction[] - { - new NewEntryAction(this, "article", prefs.getKey("New article")), - new NewEntryAction(this, "book", prefs.getKey("New book")), - new NewEntryAction(this, "phdthesis", prefs.getKey("New phdthesis")), - new NewEntryAction(this, "inbook", prefs.getKey("New inbook")), - new NewEntryAction(this, "mastersthesis", prefs.getKey("New mastersthesis")), - new NewEntryAction(this, "proceedings", prefs.getKey("New proceedings")), - new NewEntryAction(this, "inproceedings"), - new NewEntryAction(this, "conference"), - new NewEntryAction(this, "incollection"), - new NewEntryAction(this, "booklet"), - new NewEntryAction(this, "manual"), - new NewEntryAction(this, "techreport"), - new NewEntryAction(this, "unpublished", - prefs.getKey("New unpublished")), - new NewEntryAction(this, "misc"), - new NewEntryAction(this, "other") - }; + private final NewEntryAction[] newSpecificEntryAction = new NewEntryAction[] {new NewEntryAction(this, "article", prefs.getKey("New article")), new NewEntryAction(this, "book", prefs.getKey("New book")), new NewEntryAction(this, "phdthesis", prefs.getKey("New phdthesis")), new NewEntryAction(this, "inbook", prefs.getKey("New inbook")), new NewEntryAction(this, "mastersthesis", prefs.getKey("New mastersthesis")), new NewEntryAction(this, "proceedings", prefs.getKey("New proceedings")), new NewEntryAction(this, "inproceedings"), new NewEntryAction(this, "conference"), new NewEntryAction(this, "incollection"), new NewEntryAction(this, "booklet"), new NewEntryAction(this, "manual"), new NewEntryAction(this, "techreport"), new NewEntryAction(this, "unpublished", prefs.getKey("New unpublished")), new NewEntryAction(this, "misc"), new NewEntryAction(this, "other")}; public JabRefFrame(JabRef jabRef) { @@ -547,8 +398,8 @@ public void windowClosing(WindowEvent e) { /* GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); - - + + // Get size of each screen for (int i=0; i width) { + if ((posX + sizeX) > width) { if (sizeX <= width) { posX = width - sizeX; } else { @@ -593,7 +443,7 @@ public void windowClosing(WindowEvent e) { } } - if (posY + sizeY > height) { + if ((posY + sizeY) > height) { if (sizeY <= height) { posY = height - sizeY; } else { @@ -624,10 +474,8 @@ public void stateChanged(ChangeEvent e) { groupToggle.setSelected(sidePaneManager.isComponentVisible("groups")); searchToggle.setSelected(sidePaneManager.isComponentVisible("search")); previewToggle.setSelected(Globals.prefs.getBoolean(JabRefPreferences.PREVIEW_ENABLED)); - highlightAny - .setSelected(Globals.prefs.getBoolean(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ANY)); - highlightAll - .setSelected(Globals.prefs.getBoolean(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ALL)); + highlightAny.setSelected(Globals.prefs.getBoolean(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ANY)); + highlightAll.setSelected(Globals.prefs.getBoolean(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ALL)); Globals.focusListener.setFocused(bp.mainTable); setWindowTitle(); // Update search autocompleter with information for the correct database: @@ -646,7 +494,7 @@ public void stateChanged(ChangeEvent e) { try { new MacAdapter().registerMacEvents(this); } catch (Exception e) { - LOGGER.fatal("could not interface with Mac OS X methods", e); + JabRefFrame.LOGGER.fatal("could not interface with Mac OS X methods", e); } } } @@ -691,7 +539,7 @@ public void openAction(String filePath) { // Check if the file is already open. for (int i = 0; i < this.getTabbedPane().getTabCount(); i++) { BasePanel bp = this.baseAt(i); - if (bp.getFile() != null && bp.getFile().equals(file)) { + if ((bp.getFile() != null) && bp.getFile().equals(file)) { //The file is already opened, so just raising its tab. this.getTabbedPane().setSelectedComponent(bp); return; @@ -715,12 +563,9 @@ public void run() { // General info dialog. The MacAdapter calls this method when "About" // is selected from the application menu. public void about() { - JDialog about = new JDialog(JabRefFrame.this, Localization.lang("About JabRef"), - true); + JDialog about = new JDialog(JabRefFrame.this, Localization.lang("About JabRef"), true); JEditorPane jp = new JEditorPane(); - JScrollPane sp = new JScrollPane - (jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + JScrollPane sp = new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); jp.setEditable(false); try { jp.setPage(GUIGlobals.class.getResource("/help/About.html"));//GUIGlobals.aboutPage); @@ -730,8 +575,7 @@ public void about() { @Override public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { - if (e.getEventType() - == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) { + if (e.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) { try { ((JEditorPane) e.getSource()).setPage(e.getURL()); } catch (IOException ignored) { @@ -745,8 +589,7 @@ public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { about.setVisible(true); } catch (IOException ex) { ex.printStackTrace(); - JOptionPane.showMessageDialog(JabRefFrame.this, "Could not load file 'About.html'", - "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(JabRefFrame.this, "Could not load file 'About.html'", "Error", JOptionPane.ERROR_MESSAGE); } } @@ -788,7 +631,8 @@ public JabRefPreferences prefs() { *

* FIXME: Currently some threads remain and therefore hinder JabRef to be closed properly * - * @param filenames the file names of all currently opened files - used for storing them if prefs openLastEdited is set to true + * @param filenames the file names of all currently opened files - used for storing them if prefs openLastEdited is + * set to true */ private void tearDownJabRef(Vector filenames) { JabRefExecutorService.INSTANCE.shutdownEverything(); @@ -863,9 +707,8 @@ private void tearDownJabRef(Vector filenames) { } /** - * General info dialog. The MacAdapter calls this method when "Quit" - * is selected from the application menu, Cmd-Q is pressed, or "Quit" is selected from the Dock. - * The function returns a boolean indicating if quitting is ok or not. + * General info dialog. The MacAdapter calls this method when "Quit" is selected from the application menu, Cmd-Q is + * pressed, or "Quit" is selected from the Dock. The function returns a boolean indicating if quitting is ok or not. *

* Non-OSX JabRef calls this when choosing "Quit" from the menu *

@@ -882,15 +725,9 @@ public boolean quit() { for (int i = 0; i < tabbedPane.getTabCount(); i++) { if (baseAt(i).isBaseChanged()) { tabbedPane.setSelectedIndex(i); - int answer = JOptionPane.showConfirmDialog - (JabRefFrame.this, Localization.lang - ("Database has changed. Do you " - + "want to save before closing?"), - Localization.lang("Save before closing"), - JOptionPane.YES_NO_CANCEL_OPTION); - - if (answer == JOptionPane.CANCEL_OPTION || - answer == JOptionPane.CLOSED_OPTION) { + int answer = JOptionPane.showConfirmDialog(JabRefFrame.this, Localization.lang("Database has changed. Do you " + "want to save before closing?"), Localization.lang("Save before closing"), JOptionPane.YES_NO_CANCEL_OPTION); + + if ((answer == JOptionPane.CANCEL_OPTION) || (answer == JOptionPane.CLOSED_OPTION)) { return false; } if (answer == JOptionPane.YES_OPTION) { @@ -945,8 +782,7 @@ private void initLayout() { setProgressBarVisible(false); - pushExternalButton = new PushToApplicationButton(this, - PushToApplicationButton.applications); + pushExternalButton = new PushToApplicationButton(this, PushToApplicationButton.applications); fillMenu(); createToolBar(); getContentPane().setLayout(gbl); @@ -975,7 +811,7 @@ private void initLayout() { empt.setBackground(GUIGlobals.lightGray); gbl.setConstraints(empt, con); getContentPane().add(empt); - + con.insets = new Insets(1,0,1,1); con.anchor = GridBagConstraints.EAST; con.weightx = 0; @@ -1069,10 +905,10 @@ public int baseCount() { private void markActiveBasePanel() { int now = tabbedPane.getSelectedIndex(); int len = tabbedPane.getTabCount(); - if (lastTabbedPanelSelectionIndex > -1 && lastTabbedPanelSelectionIndex < len) { + if ((lastTabbedPanelSelectionIndex > -1) && (lastTabbedPanelSelectionIndex < len)) { tabbedPane.setForegroundAt(lastTabbedPanelSelectionIndex, GUIGlobals.inActiveTabbed); } - if (now > -1 && now < len) { + if ((now > -1) && (now < len)) { tabbedPane.setForegroundAt(now, GUIGlobals.activeTabbed); } lastTabbedPanelSelectionIndex = now; @@ -1107,10 +943,12 @@ public void setTabTitle(JComponent comp, String title, String toolTip) { class GeneralAction extends MnemonicAwareAction { + private final Log LOGGER = LogFactory.getLog(JabRefFrame.class); private final String command; + public GeneralAction(String command, String text) { this.command = command; putValue(Action.NAME, text); @@ -1156,17 +994,17 @@ public GeneralAction(String command, String text, String description, KeyStroke public void actionPerformed(ActionEvent e) { if (tabbedPane.getTabCount() > 0) { try { - ((BasePanel) tabbedPane.getSelectedComponent()) - .runCommand(command); + ((BasePanel) tabbedPane.getSelectedComponent()).runCommand(command); } catch (Throwable ex) { ex.printStackTrace(); } } else { - LOGGER.info("Action '" + command + "' must be disabled when no database is open."); + LOGGER.info("Action '" + command + "' must be disabled when no database is open."); } } } + /** * Refresh import menus. */ @@ -1564,28 +1402,17 @@ public void stopShowingSearchResults() { private void initActions() { openDatabaseOnlyActions = new LinkedList<>(); - openDatabaseOnlyActions.addAll(Arrays.asList(manageSelectors, - mergeDatabaseAction, newSubDatabaseAction, close, save, saveAs, saveSelectedAs, saveSelectedAsPlain, undo, - redo, cut, delete, copy, paste, mark, unmark, unmarkAll, editEntry, - selectAll, copyKey, copyCiteKey, copyKeyAndTitle, editPreamble, editStrings, toggleGroups, toggleSearch, - makeKeyAction, normalSearch, - incrementalSearch, replaceAll, importMenu, exportMenu, - /* openSpires wasn't being supported so no point in supporting - * openInspire */ - openPdf, openUrl, openFolder, openFile, openSpires, /*openInspire,*/togglePreview, dupliCheck, /*strictDupliCheck,*/highlightAll, - highlightAny, newEntryAction, plainTextImport, massSetField, manageKeywords, - closeDatabaseAction, switchPreview, integrityCheckAction, autoSetPdf, autoSetPs, - toggleHighlightAny, toggleHighlightAll, databaseProperties, abbreviateIso, - abbreviateMedline, unabbreviate, exportAll, exportSelected, - importCurrent, saveAll, dbConnect, dbExport, focusTable)); + openDatabaseOnlyActions.addAll(Arrays.asList(manageSelectors, mergeDatabaseAction, newSubDatabaseAction, close, save, saveAs, saveSelectedAs, saveSelectedAsPlain, undo, redo, cut, delete, copy, paste, mark, unmark, unmarkAll, editEntry, selectAll, copyKey, copyCiteKey, copyKeyAndTitle, editPreamble, editStrings, toggleGroups, toggleSearch, makeKeyAction, normalSearch, incrementalSearch, replaceAll, importMenu, exportMenu, + /* openSpires wasn't being supported so no point in supporting + * openInspire */ + openPdf, openUrl, openFolder, openFile, openSpires, /*openInspire,*/togglePreview, dupliCheck, /*strictDupliCheck,*/highlightAll, highlightAny, newEntryAction, plainTextImport, massSetField, manageKeywords, closeDatabaseAction, switchPreview, integrityCheckAction, autoSetPdf, autoSetPs, toggleHighlightAny, toggleHighlightAll, databaseProperties, abbreviateIso, abbreviateMedline, unabbreviate, exportAll, exportSelected, importCurrent, saveAll, dbConnect, dbExport, focusTable)); openDatabaseOnlyActions.addAll(fetcherActions); openDatabaseOnlyActions.addAll(Arrays.asList(newSpecificEntryAction)); severalDatabasesOnlyActions = new LinkedList<>(); - severalDatabasesOnlyActions.addAll(Arrays - .asList(nextTab, prevTab, sortTabs)); + severalDatabasesOnlyActions.addAll(Arrays.asList(nextTab, prevTab, sortTabs)); tabbedPane.addChangeListener(new ChangeListener() { @@ -1598,9 +1425,10 @@ public void stateChanged(ChangeEvent event) { } /** - * Takes a list of Object and calls the method setEnabled on them, depending on whether it is an Action or a Component. + * Takes a list of Object and calls the method setEnabled on them, depending on whether it is an Action or a + * Component. * - * @param list List that should contain Actions and Components. + * @param list List that should contain Actions and Components. * @param enabled */ private static void setEnabled(List list, boolean enabled) { @@ -1637,9 +1465,8 @@ private void updateEnabledState() { } /** - * This method causes all open BasePanels to set up their tables - * anew. When called from PrefsDialog3, this updates to the new - * settings. + * This method causes all open BasePanels to set up their tables anew. When called from PrefsDialog3, this updates + * to the new settings. */ public void setupAllTables() { // This action can be invoked without an open database, so @@ -1692,16 +1519,14 @@ public void addTab(BasePanel bp, File file, boolean raisePanel) { // However, this causes https://sourceforge.net/p/jabref/bugs/1293/ // Therefore, plain "title" is used tabbedPane.add(title, bp); - tabbedPane.setToolTipTextAt(tabbedPane.getTabCount() - 1, - file != null ? file.getAbsolutePath() : null); + tabbedPane.setToolTipTextAt(tabbedPane.getTabCount() - 1, file != null ? file.getAbsolutePath() : null); if (raisePanel) { tabbedPane.setSelectedComponent(bp); } } /** - * Signal closing of the current tab. Standard warnings will be given if the - * database has been changed. + * Signal closing of the current tab. Standard warnings will be given if the database has been changed. */ public void closeCurrentTab() { closeDatabaseAction.actionPerformed(null); @@ -1716,6 +1541,7 @@ public void closeCurrentTabNoWarning() { class SelectKeysAction extends AbstractAction { + public SelectKeysAction() { super(Localization.lang("Customize key bindings")); } @@ -1729,13 +1555,7 @@ public void actionPerformed(ActionEvent e) { d.setVisible(true); if (d.getAction()) { prefs.setNewKeyBindings(d.getNewKeyBindings()); - JOptionPane.showMessageDialog - (JabRefFrame.this, - Localization.lang("Your new key bindings have been stored.") + '\n' - + Localization.lang("You must restart JabRef for the new key " - + "bindings to work properly."), - Localization.lang("Key bindings changed"), - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(JabRefFrame.this, Localization.lang("Your new key bindings have been stored.") + '\n' + Localization.lang("You must restart JabRef for the new key " + "bindings to work properly."), Localization.lang("Key bindings changed"), JOptionPane.INFORMATION_MESSAGE); } } } @@ -1744,6 +1564,7 @@ public void actionPerformed(ActionEvent e) { * The action concerned with closing the window. */ class CloseAction extends MnemonicAwareAction { + public CloseAction() { putValue(Action.NAME, "Quit"); putValue(Action.SHORT_DESCRIPTION, Localization.lang("Quit JabRef")); @@ -1756,10 +1577,13 @@ public void actionPerformed(ActionEvent e) { } } + // The action for closing the current database and leaving the window open. private final CloseDatabaseAction closeDatabaseAction = new CloseDatabaseAction(); + class CloseDatabaseAction extends MnemonicAwareAction { + public CloseDatabaseAction() { super(IconTheme.getImage("close")); putValue(Action.NAME, "Close database"); @@ -1777,10 +1601,8 @@ public void actionPerformed(ActionEvent e) { } if (basePanel().isBaseChanged()) { - int answer = JOptionPane.showConfirmDialog(JabRefFrame.this, - Localization.lang("Database has changed. Do you want to save before closing?"), - Localization.lang("Save before closing"), JOptionPane.YES_NO_CANCEL_OPTION); - if (answer == JOptionPane.CANCEL_OPTION || answer == JOptionPane.CLOSED_OPTION) { + int answer = JOptionPane.showConfirmDialog(JabRefFrame.this, Localization.lang("Database has changed. Do you want to save before closing?"), Localization.lang("Save before closing"), JOptionPane.YES_NO_CANCEL_OPTION); + if ((answer == JOptionPane.CANCEL_OPTION) || (answer == JOptionPane.CLOSED_OPTION)) { close = false; // The user has cancelled. } if (answer == JOptionPane.YES_OPTION) { @@ -1824,11 +1646,12 @@ public void close() { } } + // The action for opening the preferences dialog. private final AbstractAction showPrefs = new ShowPrefsAction(); - class ShowPrefsAction - extends MnemonicAwareAction { + + class ShowPrefsAction extends MnemonicAwareAction { public ShowPrefsAction() { super(IconTheme.getImage("preferences")); @@ -1844,31 +1667,26 @@ public void actionPerformed(ActionEvent e) { /** - * This method does the job of adding imported entries into the active - * database, or into a new one. It shows the ImportInspectionDialog if - * preferences indicate it should be used. Otherwise it imports directly. + * This method does the job of adding imported entries into the active database, or into a new one. It shows the + * ImportInspectionDialog if preferences indicate it should be used. Otherwise it imports directly. * - * @param panel The BasePanel to add to. - * @param entries The entries to add. - * @param filename Name of the file where the import came from. + * @param panel The BasePanel to add to. + * @param entries The entries to add. + * @param filename Name of the file where the import came from. * @param openInNew Should the entries be imported into a new database? */ - private void addImportedEntries(final BasePanel panel, final List entries, - String filename, final boolean openInNew) { + private void addImportedEntries(final BasePanel panel, final List entries, String filename, final boolean openInNew) { /* * Use the import inspection dialog if it is enabled in preferences, and * (there are more than one entry or the inspection dialog is also * enabled for single entries): */ - if (Globals.prefs.getBoolean(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG) && - (Globals.prefs.getBoolean(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG_FOR_SINGLE) || entries.size() > 1)) { + if (Globals.prefs.getBoolean(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG) && (Globals.prefs.getBoolean(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG_FOR_SINGLE) || (entries.size() > 1))) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - ImportInspectionDialog diag = new ImportInspectionDialog(JabRefFrame.this, - panel, BibtexFields.DEFAULT_INSPECTION_FIELDS, Localization.lang("Import"), - openInNew); + ImportInspectionDialog diag = new ImportInspectionDialog(JabRefFrame.this, panel, BibtexFields.DEFAULT_INSPECTION_FIELDS, Localization.lang("Import"), openInNew); diag.addEntries(entries); diag.entryListComplete(); // On the one hand, the following statement could help at issues when JabRef is minimized to the systray @@ -1883,7 +1701,7 @@ public void run() { } else { JabRefFrame.this.addBibEntries(entries, filename, openInNew); - if (panel != null && entries.size() == 1) { + if ((panel != null) && (entries.size() == 1)) { SwingUtilities.invokeLater(new Runnable() { @Override @@ -1898,30 +1716,24 @@ public void run() { /** * Adds the entries to the database, possibly checking for duplicates first. * - * @param filename If non-null, a message is printed to the status line describing - * how many entries were imported, and from which file. If null, the message will not - * be printed. - * @param intoNew Determines if the entries will be put in a new database or in the current - * one. + * @param filename If non-null, a message is printed to the status line describing how many entries were imported, + * and from which file. If null, the message will not be printed. + * @param intoNew Determines if the entries will be put in a new database or in the current one. */ - private int addBibEntries(List bibentries, String filename, - boolean intoNew) { - if (bibentries == null || bibentries.isEmpty()) { + private int addBibEntries(List bibentries, String filename, boolean intoNew) { + if ((bibentries == null) || bibentries.isEmpty()) { // No entries found. We need a message for this. - JOptionPane.showMessageDialog(JabRefFrame.this, Localization.lang("No entries found. Please make sure you are " - + "using the correct import filter."), Localization.lang("Import failed"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(JabRefFrame.this, Localization.lang("No entries found. Please make sure you are " + "using the correct import filter."), Localization.lang("Import failed"), JOptionPane.ERROR_MESSAGE); return 0; } int addedEntries = 0; // Set owner and timestamp fields: - Util.setAutomaticFields(bibentries, Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_OWNER), - Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP), Globals.prefs.getBoolean(JabRefPreferences.MARK_IMPORTED_ENTRIES)); + Util.setAutomaticFields(bibentries, Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_OWNER), Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP), Globals.prefs.getBoolean(JabRefPreferences.MARK_IMPORTED_ENTRIES)); - if (intoNew || tabbedPane.getTabCount() == 0) { + if (intoNew || (tabbedPane.getTabCount() == 0)) { // Import into new database. BibtexDatabase database = new BibtexDatabase(); for (BibtexEntry entry : bibentries) { @@ -1943,10 +1755,7 @@ private int addBibEntries(List bibentries, String filename, bp.markBaseChanged(); tabbedPane.setSelectedComponent(bp); if (filename != null) { - output(Localization.lang("Imported database") + " '" + filename + "' " + - Localization.lang("with") + ' ' + - database.getEntryCount() + ' ' + - Localization.lang("entries into new database") + '.'); + output(Localization.lang("Imported database") + " '" + filename + "' " + Localization.lang("with") + ' ' + database.getEntryCount() + ' ' + Localization.lang("entries into new database") + '.'); } } else { // Import into current database. @@ -1955,24 +1764,20 @@ private int addBibEntries(List bibentries, String filename, int oldCount = database.getEntryCount(); NamedCompound ce = new NamedCompound(Localization.lang("Import entries")); - mainLoop: - for (BibtexEntry entry : bibentries) { + mainLoop: for (BibtexEntry entry : bibentries) { boolean dupli = false; // Check for duplicates among the current entries: for (String s : database.getKeySet()) { BibtexEntry existingEntry = database.getEntryById(s); - if (DuplicateCheck.isDuplicate(entry, existingEntry - )) { - DuplicateResolverDialog drd = new DuplicateResolverDialog - (JabRefFrame.this, existingEntry, entry, DuplicateResolverDialog.IMPORT_CHECK); + if (DuplicateCheck.isDuplicate(entry, existingEntry)) { + DuplicateResolverDialog drd = new DuplicateResolverDialog(JabRefFrame.this, existingEntry, entry, DuplicateResolverDialog.IMPORT_CHECK); drd.setVisible(true); int res = drd.getSelected(); if (res == DuplicateResolverDialog.KEEP_LOWER) { dupli = true; } else if (res == DuplicateResolverDialog.KEEP_UPPER) { database.removeEntry(existingEntry.getId()); - ce.addEdit(new UndoableRemoveEntry - (database, existingEntry, basePanel)); + ce.addEdit(new UndoableRemoveEntry(database, existingEntry, basePanel)); } else if (res == DuplicateResolverDialog.BREAK) { break mainLoop; } @@ -1984,8 +1789,7 @@ private int addBibEntries(List bibentries, String filename, entry.setId(IdGenerator.next()); database.insertEntry(entry); - ce.addEdit(new UndoableInsertEntry - (database, entry, basePanel)); + ce.addEdit(new UndoableInsertEntry(database, entry, basePanel)); addedEntries++; } @@ -1995,10 +1799,7 @@ private int addBibEntries(List bibentries, String filename, basePanel.undoManager.addEdit(ce); basePanel.markBaseChanged(); if (filename != null) { - output(Localization.lang("Imported database") + " '" + filename + "' " + - Localization.lang("with") + ' ' + - (database.getEntryCount() - oldCount) + ' ' + - Localization.lang("entries into new database") + '.'); + output(Localization.lang("Imported database") + " '" + filename + "' " + Localization.lang("with") + ' ' + (database.getEntryCount() - oldCount) + ' ' + Localization.lang("entries into new database") + '.'); } } @@ -2070,19 +1871,18 @@ public void block() { } /** - * This method reverts the cursor to normal, and stops blocking input to the JFrame's contents. - * There are no adverse effects of calling this method redundantly. + * This method reverts the cursor to normal, and stops blocking input to the JFrame's contents. There are no adverse + * effects of calling this method redundantly. */ public void unblock() { getGlassPane().setVisible(false); } /** - * Set the visibility of the progress bar in the right end of the - * status line at the bottom of the frame. + * Set the visibility of the progress bar in the right end of the status line at the bottom of the frame. *

- * If not called on the event dispatch thread, this method uses - * SwingUtilities.invokeLater() to do the actual operation on the EDT. + * If not called on the event dispatch thread, this method uses SwingUtilities.invokeLater() to do the actual + * operation on the EDT. */ public void setProgressBarVisible(final boolean visible) { if (SwingUtilities.isEventDispatchThread()) { @@ -2101,8 +1901,8 @@ public void run() { /** * Sets the current value of the progress bar. *

- * If not called on the event dispatch thread, this method uses - * SwingUtilities.invokeLater() to do the actual operation on the EDT. + * If not called on the event dispatch thread, this method uses SwingUtilities.invokeLater() to do the actual + * operation on the EDT. */ public void setProgressBarValue(final int value) { if (SwingUtilities.isEventDispatchThread()) { @@ -2122,8 +1922,8 @@ public void run() { /** * Sets the indeterminate status of the progress bar. *

- * If not called on the event dispatch thread, this method uses - * SwingUtilities.invokeLater() to do the actual operation on the EDT. + * If not called on the event dispatch thread, this method uses SwingUtilities.invokeLater() to do the actual + * operation on the EDT. */ public void setProgressBarIndeterminate(final boolean value) { if (SwingUtilities.isEventDispatchThread()) { @@ -2141,12 +1941,11 @@ public void run() { } /** - * Sets the maximum value of the progress bar. Always call this method - * before using the progress bar, to set a maximum value appropriate to - * the task at hand. + * Sets the maximum value of the progress bar. Always call this method before using the progress bar, to set a + * maximum value appropriate to the task at hand. *

- * If not called on the event dispatch thread, this method uses - * SwingUtilities.invokeLater() to do the actual operation on the EDT. + * If not called on the event dispatch thread, this method uses SwingUtilities.invokeLater() to do the actual + * operation on the EDT. */ public void setProgressBarMaximum(final int value) { if (SwingUtilities.isEventDispatchThread()) { @@ -2164,8 +1963,7 @@ public void run() { } - class SaveSessionAction - extends MnemonicAwareAction { + class SaveSessionAction extends MnemonicAwareAction { public SaveSessionAction() { super(IconTheme.getImage("save")); @@ -2183,12 +1981,7 @@ public void actionPerformed(ActionEvent e) { for (int i = 0; i < tabbedPane.getTabCount(); i++) { if (tabbedPane.getTitleAt(i).equals(GUIGlobals.untitledTitle)) { tabbedPane.setSelectedIndex(i); - int answer = JOptionPane.showConfirmDialog - (JabRefFrame.this, Localization.lang - ("This untitled database must be saved first to be " - + "included in the saved session. Save now?"), - Localization.lang("Save database"), - JOptionPane.YES_NO_OPTION); + int answer = JOptionPane.showConfirmDialog(JabRefFrame.this, Localization.lang("This untitled database must be saved first to be " + "included in the saved session. Save now?"), Localization.lang("Save database"), JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) { // The user wants to save. try { @@ -2221,6 +2014,7 @@ public class LoadSessionAction extends MnemonicAwareAction { volatile boolean running; + public LoadSessionAction() { super(IconTheme.getImage("loadSession")); putValue(Action.NAME, "Load session"); @@ -2264,8 +2058,7 @@ public void run() { } } } - output(Localization.lang("Files opened") + ": " + - (tabbedPane.getTabCount() - i0)); + output(Localization.lang("Files opened") + ": " + (tabbedPane.getTabCount() - i0)); running = false; } }); @@ -2282,8 +2075,7 @@ public ChangeTabAction(boolean next) { putValue(Action.NAME, next ? "Next tab" : "Previous tab"); this.next = next; //Util.pr(""+prefs.getKey("Next tab")); - putValue(Action.ACCELERATOR_KEY, - next ? prefs.getKey("Next tab") : prefs.getKey("Previous tab")); + putValue(Action.ACCELERATOR_KEY, next ? prefs.getKey("Next tab") : prefs.getKey("Previous tab")); } @Override @@ -2301,13 +2093,14 @@ public void actionPerformed(ActionEvent e) { } /** - * Class for handling general actions; cut, copy and paste. The focused component is - * kept track of by Globals.focusListener, and we call the action stored under the - * relevant name in its action map. + * Class for handling general actions; cut, copy and paste. The focused component is kept track of by + * Globals.focusListener, and we call the action stored under the relevant name in its action map. */ class EditAction extends MnemonicAwareAction { + private final String command; + public EditAction(String command, ImageIcon icon) { super(icon); this.command = command; @@ -2443,8 +2236,7 @@ public IncreaseTableFontSizeAction() { @Override public void actionPerformed(ActionEvent event) { int currentSize = GUIGlobals.CURRENTFONT.getSize(); - GUIGlobals.CURRENTFONT = new Font(GUIGlobals.CURRENTFONT.getFamily(), GUIGlobals.CURRENTFONT.getStyle(), - currentSize + 1); + GUIGlobals.CURRENTFONT = new Font(GUIGlobals.CURRENTFONT.getFamily(), GUIGlobals.CURRENTFONT.getStyle(), currentSize + 1); Globals.prefs.putInt(JabRefPreferences.FONT_SIZE, currentSize + 1); for (int i = 0; i < baseCount(); i++) { baseAt(i).updateTableFont(); @@ -2465,8 +2257,7 @@ public void actionPerformed(ActionEvent event) { if (currentSize < 2) { return; } - GUIGlobals.CURRENTFONT = new Font(GUIGlobals.CURRENTFONT.getFamily(), GUIGlobals.CURRENTFONT.getStyle(), - currentSize - 1); + GUIGlobals.CURRENTFONT = new Font(GUIGlobals.CURRENTFONT.getFamily(), GUIGlobals.CURRENTFONT.getStyle(), currentSize - 1); Globals.prefs.putInt(JabRefPreferences.FONT_SIZE, currentSize - 1); for (int i = 0; i < baseCount(); i++) { baseAt(i).updateTableFont(); @@ -2512,6 +2303,7 @@ public void showIfMinimizedToSysTray() { } } + private static class MyGlassPane extends JPanel { //ForegroundLabel infoLabel = new ForegroundLabel("Showing search"); @@ -2521,11 +2313,10 @@ public MyGlassPane() { addMouseListener(new MouseAdapter() { }); /* infoLabel.setForeground(new Color(255, 100, 100, 124)); - + setLayout(new BorderLayout()); add(infoLabel, BorderLayout.CENTER);*/ - super.setCursor( - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + super.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } // Override isOpaque() to prevent the glasspane from hiding the window contents: diff --git a/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java b/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java index c2518c7cfd2..9dcadc859b9 100644 --- a/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java +++ b/src/main/java/net/sf/jabref/gui/MainTableSelectionListener.java @@ -52,11 +52,10 @@ import net.sf.jabref.specialfields.SpecialFieldsUtils; /** - * List event, mouse, key and focus listener for the main table that makes up the - * most part of the BasePanel for a single bib database. + * List event, mouse, key and focus listener for the main table that makes up the most part of the BasePanel for a + * single bib database. */ -public class MainTableSelectionListener implements ListEventListener, MouseListener, - KeyListener, FocusListener { +public class MainTableSelectionListener implements ListEventListener, MouseListener, KeyListener, FocusListener { private PreviewPanel[] previewPanel; private int activePreview = Globals.prefs.getInt(JabRefPreferences.ACTIVE_PREVIEW); @@ -77,7 +76,8 @@ public class MainTableSelectionListener implements ListEventListener 0) - { + if (repeats > 0) { return; // We've already waited once. Give up on this selection. } Timer t = new Timer(50, new ActionListener() { @@ -312,8 +307,7 @@ public void mouseClicked(MouseEvent e) { } Object value = table.getValueAt(row, col); - if (value == null) - { + if (value == null) { return; // No icon here, so we do nothing. } @@ -348,7 +342,7 @@ public void run() { Object link = entry.getField(fieldName); if (link == null) { - LOGGER.info("Error: no link to " + fieldName + '.'); + MainTableSelectionListener.LOGGER.info("Error: no link to " + fieldName + '.'); return; // There is an icon, but the field is not set. } @@ -386,10 +380,7 @@ else if (fileList.getRowCount() > 0) { // if (fileList.getRowCount() > 0) { // FileListEntry flEntry = fileList.getEntry(0); - ExternalFileMenuItem item = new ExternalFileMenuItem - (panel.frame(), entry, "", - flEntry.getLink(), flEntry.getType().getIcon(), - panel.metaData(), flEntry.getType()); + ExternalFileMenuItem item = new ExternalFileMenuItem(panel.frame(), entry, "", flEntry.getLink(), flEntry.getType().getIcon(), panel.metaData(), flEntry.getType()); boolean success = item.openLink(); if (!success) { panel.output(Localization.lang("Unable to open link.")); @@ -424,8 +415,9 @@ else if (fileList.getRowCount() > 0) { } /** - * Process general right-click events on the table. Show the table context menu at - * the position where the user right-clicked. + * Process general right-click events on the table. Show the table context menu at the position where the user + * right-clicked. + * * @param e The mouse event defining the popup trigger. * @param row The row where the event occured. */ @@ -441,14 +433,13 @@ private void processPopupTrigger(MouseEvent e, int row) { } /** - * Process popup trigger events occurring on an icon cell in the table. Show - * a menu where the user can choose which external resource to open for the - * entry. If no relevant external resources exist, let the normal popup trigger + * Process popup trigger events occurring on an icon cell in the table. Show a menu where the user can choose which + * external resource to open for the entry. If no relevant external resources exist, let the normal popup trigger * handler do its thing instead. + * * @param e The mouse event defining this popup trigger. * @param row The row where the event occurred. - * @param iconType A string array containing the resource fields associated with - * this table cell. + * @param iconType A string array containing the resource fields associated with this table cell. */ private void showIconRightClickMenu(MouseEvent e, int row, String[] iconType) { BibtexEntry entry = tableRows.get(row); @@ -483,9 +474,7 @@ private void showIconRightClickMenu(MouseEvent e, int row, String[] iconType) { if ((description == null) || (description.trim().isEmpty())) { description = flEntry.getLink(); } - menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, - flEntry.getLink(), flEntry.getType().getIcon(), panel.metaData(), - flEntry.getType())); + menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.getLink(), flEntry.getType().getIcon(), panel.metaData(), flEntry.getType())); showDefaultPopup = false; } } else { @@ -500,9 +489,7 @@ private void showIconRightClickMenu(MouseEvent e, int row, String[] iconType) { for (String anIconType : iconType) { Object o = entry.getField(anIconType); if (o != null) { - menu.add(new ExternalFileMenuItem(panel.frame(), entry, (String) o, (String) o, - GUIGlobals.getTableIcon(anIconType).getIcon(), - panel.metaData(), anIconType)); + menu.add(new ExternalFileMenuItem(panel.frame(), entry, (String) o, (String) o, GUIGlobals.getTableIcon(anIconType).getIcon(), panel.metaData(), anIconType)); showDefaultPopup = false; } } @@ -564,20 +551,19 @@ public void switchPreview() { } /** - * Receive key event on the main table. If the key is a letter or a digit, - * we should select the first entry in the table which starts with the given - * letter in the column by which the table is sorted. + * Receive key event on the main table. If the key is a letter or a digit, we should select the first entry in the + * table which starts with the given letter in the column by which the table is sorted. + * * @param e The KeyEvent */ @Override public void keyTyped(KeyEvent e) { if ((!e.isActionKey()) && Character.isLetterOrDigit(e.getKeyChar()) - //&& !e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) { - && (e.getModifiers() == 0)) { + //&& !e.isControlDown() && !e.isAltDown() && !e.isMetaDown()) { + && (e.getModifiers() == 0)) { long time = System.currentTimeMillis(); long QUICK_JUMP_TIMEOUT = 2000; - if ((time - lastPressedTime) > QUICK_JUMP_TIMEOUT) - { + if ((time - lastPressedTime) > QUICK_JUMP_TIMEOUT) { lastPressedCount = 0; // Reset last pressed character } // Update timestamp: @@ -590,8 +576,7 @@ public void keyTyped(KeyEvent e) { } int sortingColumn = table.getSortingColumn(0); - if (sortingColumn == -1) - { + if (sortingColumn == -1) { return; // No sorting? TODO: look up by author, etc.? } // TODO: the following lookup should be done by a faster algorithm, @@ -611,8 +596,7 @@ public void keyTyped(KeyEvent e) { continue; } String s = o.toString().toLowerCase(); - if (s.length() >= lastPressedCount) - { + if (s.length() >= lastPressedCount) { for (int j = 0; j < lastPressedCount; j++) { if (s.charAt(j) != lastPressed[j]) { break; // Escape the loop immediately when we find a mismatch @@ -623,8 +607,8 @@ public void keyTyped(KeyEvent e) { return; } } - //if ((s.length() >= 1) && (s.charAt(0) == c)) { - //} + //if ((s.length() >= 1) && (s.charAt(0) == c)) { + //} } } // Finished, no result. If we didn't start at the beginning of diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index c5c3051bd55..a427d37512d 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -57,8 +57,7 @@ public class PreviewPanel extends JPanel implements VetoableChangeListener, Sear private MetaData metaData; /** - * If a database is set, the preview will attempt to resolve strings in the - * previewed entry using that database. + * If a database is set, the preview will attempt to resolve strings in the previewed entry using that database. */ private BibtexDatabase database; @@ -75,41 +74,27 @@ public class PreviewPanel extends JPanel implements VetoableChangeListener, Sear /** - * @param database - * (may be null) Optionally used to resolve strings. - * @param entry - * (may be null) If given this entry is shown otherwise you have - * to call setEntry to make something visible. - * @param panel - * (may be null) If not given no toolbar is shown on the right - * hand side. - * @param metaData - * (must be given) Used for resolving pdf directories for links. - * @param layoutFile - * (must be given) Used for layout + * @param database (may be null) Optionally used to resolve strings. + * @param entry (may be null) If given this entry is shown otherwise you have to call setEntry to make something + * visible. + * @param panel (may be null) If not given no toolbar is shown on the right hand side. + * @param metaData (must be given) Used for resolving pdf directories for links. + * @param layoutFile (must be given) Used for layout */ - public PreviewPanel(BibtexDatabase database, BibtexEntry entry, - BasePanel panel, MetaData metaData, String layoutFile) { + public PreviewPanel(BibtexDatabase database, BibtexEntry entry, BasePanel panel, MetaData metaData, String layoutFile) { this(database, entry, panel, metaData, layoutFile, false); } /** - * @param database - * (may be null) Optionally used to resolve strings. - * @param entry - * (may be null) If given this entry is shown otherwise you have - * to call setEntry to make something visible. - * @param panel - * (may be null) If not given no toolbar is shown on the right - * hand side. - * @param metaData - * (must be given) Used for resolving pdf directories for links. - * @param layoutFile - * (must be given) Used for layout + * @param database (may be null) Optionally used to resolve strings. + * @param entry (may be null) If given this entry is shown otherwise you have to call setEntry to make something + * visible. + * @param panel (may be null) If not given no toolbar is shown on the right hand side. + * @param metaData (must be given) Used for resolving pdf directories for links. + * @param layoutFile (must be given) Used for layout * @param withPDFPreview if true, a PDF preview is included in the PreviewPanel */ - public PreviewPanel(BibtexDatabase database, BibtexEntry entry, - BasePanel panel, MetaData metaData, String layoutFile, boolean withPDFPreview) { + public PreviewPanel(BibtexDatabase database, BibtexEntry entry, BasePanel panel, MetaData metaData, String layoutFile, boolean withPDFPreview) { this(panel, metaData, layoutFile, withPDFPreview); this.database = database; setEntry(entry); @@ -117,13 +102,9 @@ public PreviewPanel(BibtexDatabase database, BibtexEntry entry, /** * - * @param panel - * (may be null) If not given no toolbar is shown on the right - * hand side. - * @param metaData - * (must be given) Used for resolving pdf directories for links. - * @param layoutFile - * (must be given) Used for layout + * @param panel (may be null) If not given no toolbar is shown on the right hand side. + * @param metaData (must be given) Used for resolving pdf directories for links. + * @param layoutFile (must be given) Used for layout */ public PreviewPanel(BasePanel panel, MetaData metaData, String layoutFile) { this(panel, metaData, layoutFile, false); @@ -131,15 +112,11 @@ public PreviewPanel(BasePanel panel, MetaData metaData, String layoutFile) { /** * - * @param panel - * (may be null) If not given no toolbar is shown on the right - * hand side. - * @param metaData - * (must be given) Used for resolving pdf directories for links. - * @param layoutFile - * (must be given) Used for layout - * @param withPDFPreview if true, a PDF preview is included in the PreviewPanel. - * The user can override this setting by setting the config setting JabRefPreferences.PDF_PREVIEW to false. + * @param panel (may be null) If not given no toolbar is shown on the right hand side. + * @param metaData (must be given) Used for resolving pdf directories for links. + * @param layoutFile (must be given) Used for layout + * @param withPDFPreview if true, a PDF preview is included in the PreviewPanel. The user can override this setting + * by setting the config setting JabRefPreferences.PDF_PREVIEW to false. */ private PreviewPanel(BasePanel panel, MetaData metaData, String layoutFile, boolean withPDFPreview) { super(new BorderLayout(), true); @@ -162,23 +139,19 @@ private PreviewPanel(BasePanel panel, MetaData metaData, String layoutFile, bool } // Set up scroll pane for preview pane - scrollPane = new JScrollPane(previewPane, - ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane = new JScrollPane(previewPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); /* * If we have been given a panel and the preference option * previewPrintButton is set, show the tool bar */ - if (panel != null - && JabRefPreferences.getInstance().getBoolean(JabRefPreferences.PREVIEW_PRINT_BUTTON)) { + if ((panel != null) && JabRefPreferences.getInstance().getBoolean(JabRefPreferences.PREVIEW_PRINT_BUTTON)) { add(createToolBar(), BorderLayout.LINE_START); } if (withPDFPreview) { - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, - scrollPane, pdfPreviewPanel); + JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, pdfPreviewPanel); splitPane.setOneTouchExpandable(true); // int oneThird = panel.getWidth()/3; @@ -203,6 +176,7 @@ class PrintAction extends AbstractAction { private static final long serialVersionUID = 1L; + public PrintAction() { super(Localization.lang("Print Preview"), IconTheme.getImage("psSmall")); putValue(Action.SHORT_DESCRIPTION, Localization.lang("Print Preview")); @@ -226,11 +200,7 @@ public void run() { } catch (PrinterException e) { // Inform the user... we don't know what to do. - JOptionPane.showMessageDialog(PreviewPanel.this, - Localization.lang("Could not print preview") + ".\n" - + e.getMessage(), - Localization.lang("Printing Entry Preview"), - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(PreviewPanel.this, Localization.lang("Could not print preview") + ".\n" + e.getMessage(), Localization.lang("Printing Entry Preview"), JOptionPane.ERROR_MESSAGE); } } }); @@ -253,6 +223,7 @@ class CloseAction extends AbstractAction { private static final long serialVersionUID = 1L; + public CloseAction() { super(Localization.lang("Close window"), IconTheme.getImage("close")); putValue(Action.SHORT_DESCRIPTION, Localization.lang("Close window")); @@ -329,6 +300,7 @@ private JEditorPane createPreviewPane() { private static final long serialVersionUID = 1L; + @Override public Dimension getPreferredScrollableViewportSize() { return getPreferredSize(); @@ -349,8 +321,7 @@ public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { if (hyperlinkEvent.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { String address = hyperlinkEvent.getURL().toString(); - JabRefDesktop.openExternalViewer(PreviewPanel.this.metaData, - address, "url"); + JabRefDesktop.openExternalViewer(PreviewPanel.this.metaData, address, "url"); } catch (IOException e) { e.printStackTrace(); } @@ -375,10 +346,8 @@ public void readLayout(String layoutFormat) throws Exception { } private void readLayout() throws Exception { - StringReader sr = new StringReader(layoutFile.replaceAll("__NEWLINE__", - "\n")); - layout = new LayoutHelper(sr) - .getLayoutFromText(Globals.FORMATTER_PACKAGE); + StringReader sr = new StringReader(layoutFile.replaceAll("__NEWLINE__", "\n")); + layout = new LayoutHelper(sr).getLayoutFromText(Globals.FORMATTER_PACKAGE); } public void setLayout(Layout layout) { @@ -439,13 +408,11 @@ public boolean hasEntry() { } /** - * The PreviewPanel has registered itself as an event listener with the - * currently displayed BibtexEntry. If the entry changes, an event is - * received here, and we can update the preview immediately. + * The PreviewPanel has registered itself as an event listener with the currently displayed BibtexEntry. If the + * entry changes, an event is received here, and we can update the preview immediately. */ @Override - public void vetoableChange(PropertyChangeEvent evt) - throws PropertyVetoException { + public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException { // TODO updating here is not really necessary isn't it? // Only if we are visible. update(); diff --git a/src/main/java/net/sf/jabref/logic/autocompleter/AbstractAutoCompleter.java b/src/main/java/net/sf/jabref/logic/autocompleter/AbstractAutoCompleter.java index 5b326416df6..7a197d85637 100644 --- a/src/main/java/net/sf/jabref/logic/autocompleter/AbstractAutoCompleter.java +++ b/src/main/java/net/sf/jabref/logic/autocompleter/AbstractAutoCompleter.java @@ -23,8 +23,8 @@ import net.sf.jabref.model.entry.BibtexEntry; /** - * An autocompleter delivers possible completions for a given String. There are - * different types of autocompleters for different use cases. + * An autocompleter delivers possible completions for a given String. There are different types of autocompleters for + * different use cases. * * Example: {@link NameFieldAutoCompleter}, {@link EntireFieldAutoCompleter} * @@ -45,17 +45,16 @@ abstract class AbstractAutoCompleter implements AutoCompleter { private final HashMap> possibleStringsForSearchString = new HashMap<>(); - + @Override public abstract void addBibtexEntry(BibtexEntry entry); /** - * Returns one or more possible completions for a given String. The returned - * completion depends on which informations were stored while adding - * BibtexEntries by the used implementation of {@link AbstractAutoCompleter} - * . + * Returns one or more possible completions for a given String. The returned completion depends on which + * informations were stored while adding BibtexEntries by the used implementation of {@link AbstractAutoCompleter} . * * @see AbstractAutoCompleter#addBibtexEntry(BibtexEntry) */ + @Override public String[] complete(String toComplete) { if (AbstractAutoCompleter.stringMinLength(toComplete)) { return null; @@ -97,6 +96,7 @@ private static boolean stringMinLength(String toCheck) { return toCheck.length() < AutoCompleterFactory.SHORTEST_TO_COMPLETE; } + @Override public void addWordToIndex(String word) { if (word.length() >= AbstractAutoCompleter.SHORTEST_WORD) { indexCaseSensitive.add(word); @@ -115,10 +115,12 @@ public void addWordToIndex(String word) { } } + @Override public boolean indexContainsWord(String word) { return indexCaseInsensitive.contains(word.toLowerCase()); } + @Override public String getPrefix() { return ""; } From 7d8a71532917f94605ecd620ab4de90a41e86098 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 Sep 2015 21:07:34 +0200 Subject: [PATCH 2/3] Format Preferences --- .../java/net/sf/jabref/JabRefPreferences.java | 676 +++++++++--------- 1 file changed, 321 insertions(+), 355 deletions(-) diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java index 3884f36f0dd..fb0ebe58544 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -59,6 +59,7 @@ import net.sf.jabref.logic.util.strings.StringUtil; public class JabRefPreferences { + private static final Log LOGGER = LogFactory.getLog(JabRefPreferences.class); /** @@ -344,11 +345,11 @@ public class JabRefPreferences { // modifications, in order to indicate a removed default file type: private static final String FILE_TYPE_REMOVED_FLAG = "REMOVED"; - private static final char[][] VALUE_DELIMITERS = new char[][] { {'"', '"'}, {'{', '}'}}; + private static final char[][] VALUE_DELIMITERS = new char[][] {{'"', '"'}, {'{', '}'}}; public String WRAPPED_USERNAME; public final String MARKING_WITH_NUMBER_PATTERN; - + private int SHORTCUT_MASK = -1; private final Preferences prefs; @@ -459,7 +460,7 @@ private JabRefPreferences() { importPreferences("jabref.xml"); } } catch (IOException e) { - LOGGER.info("Could not import preferences from jabref.xml:" + e.getLocalizedMessage(), e); + JabRefPreferences.LOGGER.info("Could not import preferences from jabref.xml:" + e.getLocalizedMessage(), e); } // load user preferences @@ -470,210 +471,208 @@ private JabRefPreferences() { //defaults.put("pdfviewer", "/Applications/Preview.app"); //defaults.put("psviewer", "/Applications/Preview.app"); //defaults.put("htmlviewer", "/Applications/Safari.app"); - defaults.put(EMACS_PATH, "emacsclient"); - defaults.put(EMACS_23, true); - defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e"); - defaults.put(FONT_FAMILY, "SansSerif"); + defaults.put(JabRefPreferences.EMACS_PATH, "emacsclient"); + defaults.put(JabRefPreferences.EMACS_23, true); + defaults.put(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS, "-n -e"); + defaults.put(JabRefPreferences.FONT_FAMILY, "SansSerif"); } else if (OS.WINDOWS) { //defaults.put("pdfviewer", "cmd.exe /c start /b"); //defaults.put("psviewer", "cmd.exe /c start /b"); //defaults.put("htmlviewer", "cmd.exe /c start /b"); - defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel"); - defaults.put(WIN_EDT_PATH, "C:\\Program Files\\WinEdt Team\\WinEdt\\WinEdt.exe"); - defaults.put(LATEX_EDITOR_PATH, "C:\\Program Files\\LEd\\LEd.exe"); - defaults.put(EMACS_PATH, "emacsclient.exe"); - defaults.put(EMACS_23, true); - defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e"); - defaults.put(FONT_FAMILY, "Arial"); + defaults.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel"); + defaults.put(JabRefPreferences.WIN_EDT_PATH, "C:\\Program Files\\WinEdt Team\\WinEdt\\WinEdt.exe"); + defaults.put(JabRefPreferences.LATEX_EDITOR_PATH, "C:\\Program Files\\LEd\\LEd.exe"); + defaults.put(JabRefPreferences.EMACS_PATH, "emacsclient.exe"); + defaults.put(JabRefPreferences.EMACS_23, true); + defaults.put(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS, "-n -e"); + defaults.put(JabRefPreferences.FONT_FAMILY, "Arial"); } else { //defaults.put("pdfviewer", "evince"); //defaults.put("psviewer", "gv"); //defaults.put("htmlviewer", "firefox"); - defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel"); - defaults.put(FONT_FAMILY, "SansSerif"); + defaults.put(JabRefPreferences.WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel"); + defaults.put(JabRefPreferences.FONT_FAMILY, "SansSerif"); // linux - defaults.put(EMACS_PATH, "gnuclient"); - defaults.put(EMACS_23, false); - defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-batch -eval"); + defaults.put(JabRefPreferences.EMACS_PATH, "gnuclient"); + defaults.put(JabRefPreferences.EMACS_23, false); + defaults.put(JabRefPreferences.EMACS_ADDITIONAL_PARAMETERS, "-batch -eval"); } - defaults.put(USE_PROXY, Boolean.FALSE); - defaults.put(PROXY_HOSTNAME, "my proxy host"); - defaults.put(PROXY_PORT, "my proxy port"); - defaults.put(PDF_PREVIEW, Boolean.FALSE); - defaults.put(USE_DEFAULT_LOOK_AND_FEEL, Boolean.TRUE); - defaults.put(LYXPIPE, System.getProperty("user.home") + File.separator + ".lyx/lyxpipe"); - defaults.put(VIM, "vim"); - defaults.put(VIM_SERVER, "vim"); - defaults.put(POS_X, 0); - defaults.put(POS_Y, 0); - defaults.put(SIZE_X, 840); - defaults.put(SIZE_Y, 680); - defaults.put(WINDOW_MAXIMISED, Boolean.FALSE); - defaults.put(AUTO_RESIZE_MODE, JTable.AUTO_RESIZE_ALL_COLUMNS); - defaults.put(PREVIEW_PANEL_HEIGHT, 200); - defaults.put(ENTRY_EDITOR_HEIGHT, 400); - defaults.put(TABLE_COLOR_CODES_ON, Boolean.FALSE); - defaults.put(NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged" - defaults.put(NAMES_FIRST_LAST, Boolean.FALSE); // "Show 'Firstname Lastname'" - defaults.put(NAMES_LAST_FIRST, Boolean.FALSE); // "Show 'Lastname, Firstname'" - defaults.put(NAMES_NATBIB, Boolean.TRUE); // "Natbib style" - defaults.put(ABBR_AUTHOR_NAMES, Boolean.TRUE); // "Abbreviate names" - defaults.put(NAMES_LAST_ONLY, Boolean.TRUE); // "Show last names only" - defaults.put(LANGUAGE, "en"); - defaults.put(SHOW_SHORT, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_PROXY, Boolean.FALSE); + defaults.put(JabRefPreferences.PROXY_HOSTNAME, "my proxy host"); + defaults.put(JabRefPreferences.PROXY_PORT, "my proxy port"); + defaults.put(JabRefPreferences.PDF_PREVIEW, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL, Boolean.TRUE); + defaults.put(JabRefPreferences.LYXPIPE, System.getProperty("user.home") + File.separator + ".lyx/lyxpipe"); + defaults.put(JabRefPreferences.VIM, "vim"); + defaults.put(JabRefPreferences.VIM_SERVER, "vim"); + defaults.put(JabRefPreferences.POS_X, 0); + defaults.put(JabRefPreferences.POS_Y, 0); + defaults.put(JabRefPreferences.SIZE_X, 840); + defaults.put(JabRefPreferences.SIZE_Y, 680); + defaults.put(JabRefPreferences.WINDOW_MAXIMISED, Boolean.FALSE); + defaults.put(JabRefPreferences.AUTO_RESIZE_MODE, JTable.AUTO_RESIZE_ALL_COLUMNS); + defaults.put(JabRefPreferences.PREVIEW_PANEL_HEIGHT, 200); + defaults.put(JabRefPreferences.ENTRY_EDITOR_HEIGHT, 400); + defaults.put(JabRefPreferences.TABLE_COLOR_CODES_ON, Boolean.FALSE); + defaults.put(JabRefPreferences.NAMES_AS_IS, Boolean.FALSE); // "Show names unchanged" + defaults.put(JabRefPreferences.NAMES_FIRST_LAST, Boolean.FALSE); // "Show 'Firstname Lastname'" + defaults.put(JabRefPreferences.NAMES_LAST_FIRST, Boolean.FALSE); // "Show 'Lastname, Firstname'" + defaults.put(JabRefPreferences.NAMES_NATBIB, Boolean.TRUE); // "Natbib style" + defaults.put(JabRefPreferences.ABBR_AUTHOR_NAMES, Boolean.TRUE); // "Abbreviate names" + defaults.put(JabRefPreferences.NAMES_LAST_ONLY, Boolean.TRUE); // "Show last names only" + defaults.put(JabRefPreferences.LANGUAGE, "en"); + defaults.put(JabRefPreferences.SHOW_SHORT, Boolean.TRUE); // Sorting preferences - defaults.put(PRIMARY_SORT_FIELD, "author"); - defaults.put(PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(SECONDARY_SORT_FIELD, "year"); - defaults.put(SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(TERTIARY_SORT_FIELD, "author"); - defaults.put(TERTIARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(SAVE_IN_ORIGINAL_ORDER, Boolean.FALSE); - defaults.put(SAVE_IN_SPECIFIED_ORDER, Boolean.FALSE); - defaults.put(SAVE_PRIMARY_SORT_FIELD, "bibtexkey"); - defaults.put(SAVE_PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(SAVE_SECONDARY_SORT_FIELD, "author"); - defaults.put(SAVE_SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(SAVE_TERTIARY_SORT_FIELD, ""); - defaults.put(SAVE_TERTIARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(EXPORT_IN_ORIGINAL_ORDER, Boolean.FALSE); - defaults.put(EXPORT_IN_SPECIFIED_ORDER, Boolean.FALSE); - defaults.put(EXPORT_PRIMARY_SORT_FIELD, "bibtexkey"); - defaults.put(EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE); - defaults.put(EXPORT_SECONDARY_SORT_FIELD, "author"); - defaults.put(EXPORT_SECONDARY_SORT_DESCENDING, Boolean.TRUE); - defaults.put(EXPORT_TERTIARY_SORT_FIELD, ""); - defaults.put(EXPORT_TERTIARY_SORT_DESCENDING, Boolean.TRUE); - - defaults.put(NEWLINE, System.lineSeparator()); - - defaults.put(SIDE_PANE_COMPONENT_NAMES, ""); - defaults.put(SIDE_PANE_COMPONENT_PREFERRED_POSITIONS, ""); - - defaults.put(COLUMN_NAMES, "entrytype;author;title;year;journal;timestamp;bibtexkey"); - defaults.put(COLUMN_WIDTHS, "75;280;450;60;100;100;100"); - defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY, - PersistenceTableColumnListener.DEFAULT_ENABLED); - defaults.put(XMP_PRIVACY_FILTERS, "pdf;timestamp;keywords;owner;note;review"); - defaults.put(USE_XMP_PRIVACY_FILTER, Boolean.FALSE); - defaults.put(NUMBER_COL_WIDTH, GUIGlobals.NUMBER_COL_LENGTH); - defaults.put(WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(EXPORT_WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(IMPORT_WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(FILE_WORKING_DIRECTORY, System.getProperty("user.home")); - defaults.put(AUTO_OPEN_FORM, Boolean.TRUE); - defaults.put(ENTRY_TYPE_FORM_HEIGHT_FACTOR, 1); - defaults.put(ENTRY_TYPE_FORM_WIDTH, 1); - defaults.put(BACKUP, Boolean.TRUE); - defaults.put(OPEN_LAST_EDITED, Boolean.TRUE); - defaults.put(LAST_EDITED, null); - 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(DEFAULT_SHOW_SOURCE, Boolean.FALSE); - defaults.put(SHOW_SOURCE, Boolean.TRUE); - defaults.put(DEFAULT_AUTO_SORT, Boolean.FALSE); - defaults.put(CASE_SENSITIVE_SEARCH, Boolean.FALSE); - defaults.put(SEARCH_REQ, Boolean.TRUE); - defaults.put(SEARCH_OPT, Boolean.TRUE); - defaults.put(SEARCH_GEN, Boolean.TRUE); - defaults.put(SEARCH_ALL, Boolean.FALSE); - defaults.put(INCREMENT_S, Boolean.FALSE); - defaults.put(SEARCH_AUTO_COMPLETE, Boolean.TRUE); - - defaults.put(SELECT_S, Boolean.FALSE); - defaults.put(REG_EXP_SEARCH, Boolean.TRUE); - defaults.put(HIGH_LIGHT_WORDS, Boolean.TRUE); - defaults.put(SEARCH_PANE_POS_X, 0); - defaults.put(SEARCH_PANE_POS_Y, 0); - defaults.put(EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE); - defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE); - defaults.put(EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE); - defaults.put(AUTO_COMPLETE, Boolean.TRUE); - defaults.put(AUTO_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords;crossref"); - defaults.put(AUTO_COMP_FIRST_LAST, Boolean.FALSE); // "Autocomplete names in 'Firstname Lastname' format only" - defaults.put(AUTO_COMP_LAST_FIRST, Boolean.FALSE); // "Autocomplete names in 'Lastname, Firstname' format only" - defaults.put(SHORTEST_TO_COMPLETE, 2); - defaults.put(AUTOCOMPLETE_FIRSTNAME_MODE, JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE_BOTH); - defaults.put(GROUP_SELECTOR_VISIBLE, Boolean.TRUE); - defaults.put(GROUP_FLOAT_SELECTIONS, Boolean.TRUE); - defaults.put(GROUP_INTERSECT_SELECTIONS, Boolean.TRUE); - defaults.put(GROUP_INVERT_SELECTIONS, Boolean.FALSE); - defaults.put(GROUP_SHOW_OVERLAPPING, Boolean.FALSE); - defaults.put(GROUP_SELECT_MATCHES, Boolean.FALSE); - defaults.put(GROUPS_DEFAULT_FIELD, "keywords"); - defaults.put(GROUP_SHOW_ICONS, Boolean.TRUE); - defaults.put(GROUP_SHOW_DYNAMIC, Boolean.TRUE); - defaults.put(GROUP_EXPAND_TREE, Boolean.TRUE); - defaults.put(GROUP_AUTO_SHOW, Boolean.TRUE); - defaults.put(GROUP_AUTO_HIDE, Boolean.TRUE); - defaults.put(GROUP_SHOW_NUMBER_OF_ELEMENTS, Boolean.FALSE); - defaults.put(AUTO_ASSIGN_GROUP, Boolean.TRUE); - defaults.put(GROUP_KEYWORD_SEPARATOR, ", "); - defaults.put(EDIT_GROUP_MEMBERSHIP_MODE, Boolean.FALSE); - defaults.put(HIGHLIGHT_GROUPS_MATCHING_ANY, Boolean.FALSE); - defaults.put(HIGHLIGHT_GROUPS_MATCHING_ALL, Boolean.FALSE); - defaults.put(TOOLBAR_VISIBLE, Boolean.TRUE); - defaults.put(SEARCH_PANEL_VISIBLE, Boolean.FALSE); - defaults.put(DEFAULT_ENCODING, System.getProperty("file.encoding")); - defaults.put(GROUPS_VISIBLE_ROWS, 8); - defaults.put(DEFAULT_OWNER, System.getProperty("user.name")); - defaults.put(PRESERVE_FIELD_FORMATTING, Boolean.FALSE); - defaults.put(MEMORY_STICK_MODE, Boolean.FALSE); - defaults.put(RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE); + defaults.put(JabRefPreferences.PRIMARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.PRIMARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.SECONDARY_SORT_FIELD, "year"); + defaults.put(JabRefPreferences.SECONDARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.TERTIARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.TERTIARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_IN_ORIGINAL_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_IN_SPECIFIED_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_PRIMARY_SORT_FIELD, "bibtexkey"); + defaults.put(JabRefPreferences.SAVE_PRIMARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.SAVE_SECONDARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.SAVE_SECONDARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.SAVE_TERTIARY_SORT_FIELD, ""); + defaults.put(JabRefPreferences.SAVE_TERTIARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.EXPORT_IN_ORIGINAL_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, Boolean.FALSE); + defaults.put(JabRefPreferences.EXPORT_PRIMARY_SORT_FIELD, "bibtexkey"); + defaults.put(JabRefPreferences.EXPORT_PRIMARY_SORT_DESCENDING, Boolean.FALSE); + defaults.put(JabRefPreferences.EXPORT_SECONDARY_SORT_FIELD, "author"); + defaults.put(JabRefPreferences.EXPORT_SECONDARY_SORT_DESCENDING, Boolean.TRUE); + defaults.put(JabRefPreferences.EXPORT_TERTIARY_SORT_FIELD, ""); + defaults.put(JabRefPreferences.EXPORT_TERTIARY_SORT_DESCENDING, Boolean.TRUE); + + defaults.put(JabRefPreferences.NEWLINE, System.lineSeparator()); + + defaults.put(JabRefPreferences.SIDE_PANE_COMPONENT_NAMES, ""); + defaults.put(JabRefPreferences.SIDE_PANE_COMPONENT_PREFERRED_POSITIONS, ""); + + defaults.put(JabRefPreferences.COLUMN_NAMES, "entrytype;author;title;year;journal;timestamp;bibtexkey"); + defaults.put(JabRefPreferences.COLUMN_WIDTHS, "75;280;450;60;100;100;100"); + defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY, PersistenceTableColumnListener.DEFAULT_ENABLED); + defaults.put(JabRefPreferences.XMP_PRIVACY_FILTERS, "pdf;timestamp;keywords;owner;note;review"); + defaults.put(JabRefPreferences.USE_XMP_PRIVACY_FILTER, Boolean.FALSE); + defaults.put(JabRefPreferences.NUMBER_COL_WIDTH, GUIGlobals.NUMBER_COL_LENGTH); + defaults.put(JabRefPreferences.WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.EXPORT_WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.IMPORT_WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.FILE_WORKING_DIRECTORY, System.getProperty("user.home")); + defaults.put(JabRefPreferences.AUTO_OPEN_FORM, Boolean.TRUE); + defaults.put(JabRefPreferences.ENTRY_TYPE_FORM_HEIGHT_FACTOR, 1); + defaults.put(JabRefPreferences.ENTRY_TYPE_FORM_WIDTH, 1); + defaults.put(JabRefPreferences.BACKUP, Boolean.TRUE); + defaults.put(JabRefPreferences.OPEN_LAST_EDITED, Boolean.TRUE); + defaults.put(JabRefPreferences.LAST_EDITED, null); + defaults.put(JabRefPreferences.STRINGS_POS_X, 0); + defaults.put(JabRefPreferences.STRINGS_POS_Y, 0); + defaults.put(JabRefPreferences.STRINGS_SIZE_X, 600); + defaults.put(JabRefPreferences.STRINGS_SIZE_Y, 400); + defaults.put(JabRefPreferences.DEFAULT_SHOW_SOURCE, Boolean.FALSE); + defaults.put(JabRefPreferences.SHOW_SOURCE, Boolean.TRUE); + defaults.put(JabRefPreferences.DEFAULT_AUTO_SORT, Boolean.FALSE); + defaults.put(JabRefPreferences.CASE_SENSITIVE_SEARCH, Boolean.FALSE); + defaults.put(JabRefPreferences.SEARCH_REQ, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_OPT, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_GEN, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_ALL, Boolean.FALSE); + defaults.put(JabRefPreferences.INCREMENT_S, Boolean.FALSE); + defaults.put(JabRefPreferences.SEARCH_AUTO_COMPLETE, Boolean.TRUE); + + defaults.put(JabRefPreferences.SELECT_S, Boolean.FALSE); + defaults.put(JabRefPreferences.REG_EXP_SEARCH, Boolean.TRUE); + defaults.put(JabRefPreferences.HIGH_LIGHT_WORDS, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_PANE_POS_X, 0); + defaults.put(JabRefPreferences.SEARCH_PANE_POS_Y, 0); + defaults.put(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS, Boolean.FALSE); + defaults.put(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS_REBIND_CA, Boolean.TRUE); + defaults.put(JabRefPreferences.EDITOR_EMACS_KEYBINDINGS_REBIND_CF, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_COMPLETE, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_COMPLETE_FIELDS, "author;editor;title;journal;publisher;keywords;crossref"); + defaults.put(JabRefPreferences.AUTO_COMP_FIRST_LAST, Boolean.FALSE); // "Autocomplete names in 'Firstname Lastname' format only" + defaults.put(JabRefPreferences.AUTO_COMP_LAST_FIRST, Boolean.FALSE); // "Autocomplete names in 'Lastname, Firstname' format only" + defaults.put(JabRefPreferences.SHORTEST_TO_COMPLETE, 2); + defaults.put(JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE, JabRefPreferences.AUTOCOMPLETE_FIRSTNAME_MODE_BOTH); + defaults.put(JabRefPreferences.GROUP_SELECTOR_VISIBLE, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_FLOAT_SELECTIONS, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_INTERSECT_SELECTIONS, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_INVERT_SELECTIONS, Boolean.FALSE); + defaults.put(JabRefPreferences.GROUP_SHOW_OVERLAPPING, Boolean.FALSE); + defaults.put(JabRefPreferences.GROUP_SELECT_MATCHES, Boolean.FALSE); + defaults.put(JabRefPreferences.GROUPS_DEFAULT_FIELD, "keywords"); + defaults.put(JabRefPreferences.GROUP_SHOW_ICONS, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_SHOW_DYNAMIC, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_EXPAND_TREE, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_AUTO_SHOW, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_AUTO_HIDE, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_SHOW_NUMBER_OF_ELEMENTS, Boolean.FALSE); + defaults.put(JabRefPreferences.AUTO_ASSIGN_GROUP, Boolean.TRUE); + defaults.put(JabRefPreferences.GROUP_KEYWORD_SEPARATOR, ", "); + defaults.put(JabRefPreferences.EDIT_GROUP_MEMBERSHIP_MODE, Boolean.FALSE); + defaults.put(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ANY, Boolean.FALSE); + defaults.put(JabRefPreferences.HIGHLIGHT_GROUPS_MATCHING_ALL, Boolean.FALSE); + defaults.put(JabRefPreferences.TOOLBAR_VISIBLE, Boolean.TRUE); + defaults.put(JabRefPreferences.SEARCH_PANEL_VISIBLE, Boolean.FALSE); + defaults.put(JabRefPreferences.DEFAULT_ENCODING, System.getProperty("file.encoding")); + defaults.put(JabRefPreferences.GROUPS_VISIBLE_ROWS, 8); + defaults.put(JabRefPreferences.DEFAULT_OWNER, System.getProperty("user.name")); + defaults.put(JabRefPreferences.PRESERVE_FIELD_FORMATTING, Boolean.FALSE); + defaults.put(JabRefPreferences.MEMORY_STICK_MODE, Boolean.FALSE); + defaults.put(JabRefPreferences.RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE); // The general fields stuff is made obsolete by the CUSTOM_TAB_... entries. - defaults.put(GENERAL_FIELDS, "crossref;keywords;file;doi;url;urldate;" - + "pdf;comment;owner"); - - defaults.put(HISTORY_SIZE, 8); - defaults.put(FONT_STYLE, java.awt.Font.PLAIN); - defaults.put(FONT_SIZE, 12); - defaults.put(OVERRIDE_DEFAULT_FONTS, Boolean.FALSE); - defaults.put(MENU_FONT_FAMILY, "Times"); - defaults.put(MENU_FONT_STYLE, java.awt.Font.PLAIN); - defaults.put(MENU_FONT_SIZE, 11); - defaults.put(TABLE_ROW_PADDING, GUIGlobals.TABLE_ROW_PADDING); - defaults.put(TABLE_SHOW_GRID, Boolean.FALSE); + defaults.put(JabRefPreferences.GENERAL_FIELDS, "crossref;keywords;file;doi;url;urldate;" + "pdf;comment;owner"); + + defaults.put(JabRefPreferences.HISTORY_SIZE, 8); + defaults.put(JabRefPreferences.FONT_STYLE, java.awt.Font.PLAIN); + defaults.put(JabRefPreferences.FONT_SIZE, 12); + defaults.put(JabRefPreferences.OVERRIDE_DEFAULT_FONTS, Boolean.FALSE); + defaults.put(JabRefPreferences.MENU_FONT_FAMILY, "Times"); + defaults.put(JabRefPreferences.MENU_FONT_STYLE, java.awt.Font.PLAIN); + defaults.put(JabRefPreferences.MENU_FONT_SIZE, 11); + defaults.put(JabRefPreferences.TABLE_ROW_PADDING, GUIGlobals.TABLE_ROW_PADDING); + defaults.put(JabRefPreferences.TABLE_SHOW_GRID, Boolean.FALSE); // Main table color settings: - defaults.put(TABLE_BACKGROUND, "255:255:255"); - defaults.put(TABLE_REQ_FIELD_BACKGROUND, "230:235:255"); - defaults.put(TABLE_OPT_FIELD_BACKGROUND, "230:255:230"); - defaults.put(TABLE_TEXT, "0:0:0"); - defaults.put(GRID_COLOR, "210:210:210"); - defaults.put(GRAYED_OUT_BACKGROUND, "210:210:210"); - defaults.put(GRAYED_OUT_TEXT, "40:40:40"); - defaults.put(VERY_GRAYED_OUT_BACKGROUND, "180:180:180"); - defaults.put(VERY_GRAYED_OUT_TEXT, "40:40:40"); - defaults.put(MARKED_ENTRY_BACKGROUND0, "255:255:180"); - defaults.put(MARKED_ENTRY_BACKGROUND1, "255:220:180"); - defaults.put(MARKED_ENTRY_BACKGROUND2, "255:180:160"); - defaults.put(MARKED_ENTRY_BACKGROUND3, "255:120:120"); - defaults.put(MARKED_ENTRY_BACKGROUND4, "255:75:75"); - defaults.put(MARKED_ENTRY_BACKGROUND5, "220:255:220"); - 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"); - - defaults.put(INCOMPLETE_ENTRY_BACKGROUND, "250:175:175"); - - defaults.put(ANTIALIAS, Boolean.FALSE); - defaults.put(CTRL_CLICK, Boolean.FALSE); - defaults.put(DISABLE_ON_MULTIPLE_SELECTION, Boolean.FALSE); - defaults.put(PDF_COLUMN, Boolean.FALSE); - defaults.put(URL_COLUMN, Boolean.TRUE); - defaults.put(PREFER_URL_DOI, Boolean.FALSE); - defaults.put(FILE_COLUMN, Boolean.TRUE); - defaults.put(ARXIV_COLUMN, Boolean.FALSE); - - defaults.put(EXTRA_FILE_COLUMNS, Boolean.FALSE); - defaults.put(LIST_OF_FILE_COLUMNS, ""); + defaults.put(JabRefPreferences.TABLE_BACKGROUND, "255:255:255"); + defaults.put(JabRefPreferences.TABLE_REQ_FIELD_BACKGROUND, "230:235:255"); + defaults.put(JabRefPreferences.TABLE_OPT_FIELD_BACKGROUND, "230:255:230"); + defaults.put(JabRefPreferences.TABLE_TEXT, "0:0:0"); + defaults.put(JabRefPreferences.GRID_COLOR, "210:210:210"); + defaults.put(JabRefPreferences.GRAYED_OUT_BACKGROUND, "210:210:210"); + defaults.put(JabRefPreferences.GRAYED_OUT_TEXT, "40:40:40"); + defaults.put(JabRefPreferences.VERY_GRAYED_OUT_BACKGROUND, "180:180:180"); + defaults.put(JabRefPreferences.VERY_GRAYED_OUT_TEXT, "40:40:40"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND0, "255:255:180"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND1, "255:220:180"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND2, "255:180:160"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND3, "255:120:120"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND4, "255:75:75"); + defaults.put(JabRefPreferences.MARKED_ENTRY_BACKGROUND5, "220:255:220"); + defaults.put(JabRefPreferences.VALID_FIELD_BACKGROUND_COLOR, "255:255:255"); + defaults.put(JabRefPreferences.INVALID_FIELD_BACKGROUND_COLOR, "255:0:0"); + defaults.put(JabRefPreferences.ACTIVE_FIELD_EDITOR_BACKGROUND_COLOR, "220:220:255"); + defaults.put(JabRefPreferences.FIELD_EDITOR_TEXT_COLOR, "0:0:0"); + + defaults.put(JabRefPreferences.INCOMPLETE_ENTRY_BACKGROUND, "250:175:175"); + + defaults.put(JabRefPreferences.ANTIALIAS, Boolean.FALSE); + defaults.put(JabRefPreferences.CTRL_CLICK, Boolean.FALSE); + defaults.put(JabRefPreferences.DISABLE_ON_MULTIPLE_SELECTION, Boolean.FALSE); + defaults.put(JabRefPreferences.PDF_COLUMN, Boolean.FALSE); + defaults.put(JabRefPreferences.URL_COLUMN, Boolean.TRUE); + defaults.put(JabRefPreferences.PREFER_URL_DOI, Boolean.FALSE); + defaults.put(JabRefPreferences.FILE_COLUMN, Boolean.TRUE); + defaults.put(JabRefPreferences.ARXIV_COLUMN, Boolean.FALSE); + + defaults.put(JabRefPreferences.EXTRA_FILE_COLUMNS, Boolean.FALSE); + defaults.put(JabRefPreferences.LIST_OF_FILE_COLUMNS, ""); defaults.put(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED, SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED_DEFAULT); defaults.put(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY, SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY_DEFAULT); @@ -686,140 +685,110 @@ private JabRefPreferences() { defaults.put(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS, SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS_DEFAULT); defaults.put(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS, SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS_DEFAULT); - defaults.put(SHOW_ONE_LETTER_HEADING_FOR_ICON_COLUMNS, Boolean.FALSE); - - defaults.put(USE_OWNER, Boolean.FALSE); - defaults.put(OVERWRITE_OWNER, Boolean.FALSE); - defaults.put(ALLOW_TABLE_EDITING, Boolean.FALSE); - defaults.put(DIALOG_WARNING_FOR_DUPLICATE_KEY, Boolean.TRUE); - defaults.put(DIALOG_WARNING_FOR_EMPTY_KEY, Boolean.TRUE); - defaults.put(DISPLAY_KEY_WARNING_DIALOG_AT_STARTUP, Boolean.TRUE); - defaults.put(AVOID_OVERWRITING_KEY, Boolean.FALSE); - defaults.put(WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE); - defaults.put(CONFIRM_DELETE, Boolean.TRUE); - defaults.put(GRAY_OUT_NON_HITS, Boolean.TRUE); - defaults.put(FLOAT_SEARCH, Boolean.TRUE); - defaults.put(SHOW_SEARCH_IN_DIALOG, Boolean.FALSE); - defaults.put(SEARCH_ALL_BASES, Boolean.FALSE); - defaults.put(DEFAULT_LABEL_PATTERN, "[auth][year]"); - defaults.put(PREVIEW_ENABLED, Boolean.TRUE); - defaults.put(ACTIVE_PREVIEW, 0); - defaults.put(PREVIEW_0, "" - + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" - + "\\end{bibtexkey}
__NEWLINE__" - + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" - + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " - + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" - + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" - + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" - + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" - + "__NEWLINE__

"); - defaults.put(PREVIEW_1, "" - + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" - + "\\end{bibtexkey}
__NEWLINE__" - + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" - + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " - + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" - + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" - + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" - + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" - + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" - + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" - + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" - + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" - + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" - + "__NEWLINE__

"); + defaults.put(JabRefPreferences.SHOW_ONE_LETTER_HEADING_FOR_ICON_COLUMNS, Boolean.FALSE); + + defaults.put(JabRefPreferences.USE_OWNER, Boolean.FALSE); + defaults.put(JabRefPreferences.OVERWRITE_OWNER, Boolean.FALSE); + defaults.put(JabRefPreferences.ALLOW_TABLE_EDITING, Boolean.FALSE); + defaults.put(JabRefPreferences.DIALOG_WARNING_FOR_DUPLICATE_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.DIALOG_WARNING_FOR_EMPTY_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.DISPLAY_KEY_WARNING_DIALOG_AT_STARTUP, Boolean.TRUE); + defaults.put(JabRefPreferences.AVOID_OVERWRITING_KEY, Boolean.FALSE); + defaults.put(JabRefPreferences.WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.CONFIRM_DELETE, Boolean.TRUE); + defaults.put(JabRefPreferences.GRAY_OUT_NON_HITS, Boolean.TRUE); + defaults.put(JabRefPreferences.FLOAT_SEARCH, Boolean.TRUE); + defaults.put(JabRefPreferences.SHOW_SEARCH_IN_DIALOG, Boolean.FALSE); + defaults.put(JabRefPreferences.SEARCH_ALL_BASES, Boolean.FALSE); + defaults.put(JabRefPreferences.DEFAULT_LABEL_PATTERN, "[auth][year]"); + defaults.put(JabRefPreferences.PREVIEW_ENABLED, Boolean.TRUE); + defaults.put(JabRefPreferences.ACTIVE_PREVIEW, 0); + defaults.put(JabRefPreferences.PREVIEW_0, "" + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + "\\end{bibtexkey}
__NEWLINE__" + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" + "__NEWLINE__

"); + defaults.put(JabRefPreferences.PREVIEW_1, "" + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + "\\end{bibtexkey}
__NEWLINE__" + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" + "__NEWLINE__

"); // TODO: Currently not possible to edit this setting: - defaults.put(PREVIEW_PRINT_BUTTON, Boolean.FALSE); - defaults.put(AUTO_DOUBLE_BRACES, Boolean.FALSE); - defaults.put(DO_NOT_RESOLVE_STRINGS_FOR, "url"); - defaults.put(RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); - defaults.put(PUT_BRACES_AROUND_CAPITALS, "");//"title;journal;booktitle;review;abstract"); - defaults.put(NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file"); - defaults.put(USE_IMPORT_INSPECTION_DIALOG, Boolean.TRUE); - defaults.put(USE_IMPORT_INSPECTION_DIALOG_FOR_SINGLE, Boolean.TRUE); - defaults.put(GENERATE_KEYS_AFTER_INSPECTION, Boolean.TRUE); - defaults.put(MARK_IMPORTED_ENTRIES, Boolean.TRUE); - defaults.put(UNMARK_ALL_ENTRIES_BEFORE_IMPORTING, Boolean.TRUE); - defaults.put(WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE); - defaults.put(USE_TIME_STAMP, Boolean.FALSE); - defaults.put(OVERWRITE_TIME_STAMP, Boolean.FALSE); - defaults.put(TIME_STAMP_FORMAT, "yyyy.MM.dd"); - defaults.put(TIME_STAMP_FIELD, BibtexFields.TIMESTAMP); - defaults.put(UPDATE_TIMESTAMP, Boolean.FALSE); - defaults.put(GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE); + defaults.put(JabRefPreferences.PREVIEW_PRINT_BUTTON, Boolean.FALSE); + defaults.put(JabRefPreferences.AUTO_DOUBLE_BRACES, Boolean.FALSE); + defaults.put(JabRefPreferences.DO_NOT_RESOLVE_STRINGS_FOR, "url"); + defaults.put(JabRefPreferences.RESOLVE_STRINGS_ALL_FIELDS, Boolean.FALSE); + defaults.put(JabRefPreferences.PUT_BRACES_AROUND_CAPITALS, "");//"title;journal;booktitle;review;abstract"); + defaults.put(JabRefPreferences.NON_WRAPPABLE_FIELDS, "pdf;ps;url;doi;file"); + defaults.put(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_IMPORT_INSPECTION_DIALOG_FOR_SINGLE, Boolean.TRUE); + defaults.put(JabRefPreferences.GENERATE_KEYS_AFTER_INSPECTION, Boolean.TRUE); + defaults.put(JabRefPreferences.MARK_IMPORTED_ENTRIES, Boolean.TRUE); + defaults.put(JabRefPreferences.UNMARK_ALL_ENTRIES_BEFORE_IMPORTING, Boolean.TRUE); + defaults.put(JabRefPreferences.WARN_ABOUT_DUPLICATES_IN_INSPECTION, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_TIME_STAMP, Boolean.FALSE); + defaults.put(JabRefPreferences.OVERWRITE_TIME_STAMP, Boolean.FALSE); + defaults.put(JabRefPreferences.TIME_STAMP_FORMAT, "yyyy.MM.dd"); + defaults.put(JabRefPreferences.TIME_STAMP_FIELD, BibtexFields.TIMESTAMP); + defaults.put(JabRefPreferences.UPDATE_TIMESTAMP, Boolean.FALSE); + defaults.put(JabRefPreferences.GENERATE_KEYS_BEFORE_SAVING, Boolean.FALSE); // behavior of JabRef before 2.10: both: false - defaults.put(WRITEFIELD_ADDSPACES, Boolean.TRUE); - defaults.put(WRITEFIELD_CAMELCASENAME, Boolean.TRUE); + defaults.put(JabRefPreferences.WRITEFIELD_ADDSPACES, Boolean.TRUE); + defaults.put(JabRefPreferences.WRITEFIELD_CAMELCASENAME, Boolean.TRUE); //behavior of JabRef before LWang_AdjustableFieldOrder 1 //0 sorted order (2.10 default), 1 unsorted order (2.9.2 default), 2 user defined - defaults.put(WRITEFIELD_SORTSTYLE, 0); - defaults.put(WRITEFIELD_USERDEFINEDORDER, "author;title;journal;year;volume;number;pages;month;note;volume;pages;part;eid"); - defaults.put(WRITEFIELD_WRAPFIELD, Boolean.FALSE); + defaults.put(JabRefPreferences.WRITEFIELD_SORTSTYLE, 0); + defaults.put(JabRefPreferences.WRITEFIELD_USERDEFINEDORDER, "author;title;journal;year;volume;number;pages;month;note;volume;pages;part;eid"); + defaults.put(JabRefPreferences.WRITEFIELD_WRAPFIELD, Boolean.FALSE); defaults.put(RemotePreferences.USE_REMOTE_SERVER, Boolean.FALSE); defaults.put(RemotePreferences.REMOTE_SERVER_PORT, 6050); - defaults.put(PERSONAL_JOURNAL_LIST, null); - defaults.put(EXTERNAL_JOURNAL_LISTS, null); - defaults.put(CITE_COMMAND, "cite"); // obsoleted by the app-specific ones - defaults.put(CITE_COMMAND_VIM, "\\cite"); - defaults.put(CITE_COMMAND_EMACS, "\\cite"); - defaults.put(CITE_COMMAND_WIN_EDT, "\\cite"); - defaults.put(CITE_COMMAND_LED, "\\cite"); - defaults.put(FLOAT_MARKED_ENTRIES, Boolean.TRUE); - - defaults.put(USE_NATIVE_FILE_DIALOG_ON_MAC, Boolean.FALSE); - defaults.put(FILECHOOSER_DISABLE_RENAME, Boolean.TRUE); - - defaults.put(LAST_USED_EXPORT, null); - defaults.put(SIDE_PANE_WIDTH, -1); - - defaults.put(IMPORT_INSPECTION_DIALOG_WIDTH, 650); - defaults.put(IMPORT_INSPECTION_DIALOG_HEIGHT, 650); - defaults.put(SEARCH_DIALOG_WIDTH, 650); - defaults.put(SEARCH_DIALOG_HEIGHT, 500); - defaults.put(SHOW_FILE_LINKS_UPGRADE_WARNING, Boolean.TRUE); - defaults.put(AUTOLINK_EXACT_KEY_ONLY, Boolean.TRUE); - defaults.put(NUMERIC_FIELDS, "mittnum;author"); - defaults.put(RUN_AUTOMATIC_FILE_SEARCH, Boolean.FALSE); - defaults.put(USE_LOCK_FILES, Boolean.TRUE); - defaults.put(AUTO_SAVE, Boolean.TRUE); - defaults.put(AUTO_SAVE_INTERVAL, 5); - defaults.put(PROMPT_BEFORE_USING_AUTOSAVE, Boolean.TRUE); - defaults.put(ENFORCE_LEGAL_BIBTEX_KEY, Boolean.TRUE); - defaults.put(BIBLATEX_MODE, Boolean.FALSE); + defaults.put(JabRefPreferences.PERSONAL_JOURNAL_LIST, null); + defaults.put(JabRefPreferences.EXTERNAL_JOURNAL_LISTS, null); + defaults.put(JabRefPreferences.CITE_COMMAND, "cite"); // obsoleted by the app-specific ones + defaults.put(JabRefPreferences.CITE_COMMAND_VIM, "\\cite"); + defaults.put(JabRefPreferences.CITE_COMMAND_EMACS, "\\cite"); + defaults.put(JabRefPreferences.CITE_COMMAND_WIN_EDT, "\\cite"); + defaults.put(JabRefPreferences.CITE_COMMAND_LED, "\\cite"); + defaults.put(JabRefPreferences.FLOAT_MARKED_ENTRIES, Boolean.TRUE); + + defaults.put(JabRefPreferences.USE_NATIVE_FILE_DIALOG_ON_MAC, Boolean.FALSE); + defaults.put(JabRefPreferences.FILECHOOSER_DISABLE_RENAME, Boolean.TRUE); + + defaults.put(JabRefPreferences.LAST_USED_EXPORT, null); + defaults.put(JabRefPreferences.SIDE_PANE_WIDTH, -1); + + defaults.put(JabRefPreferences.IMPORT_INSPECTION_DIALOG_WIDTH, 650); + defaults.put(JabRefPreferences.IMPORT_INSPECTION_DIALOG_HEIGHT, 650); + defaults.put(JabRefPreferences.SEARCH_DIALOG_WIDTH, 650); + defaults.put(JabRefPreferences.SEARCH_DIALOG_HEIGHT, 500); + defaults.put(JabRefPreferences.SHOW_FILE_LINKS_UPGRADE_WARNING, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTOLINK_EXACT_KEY_ONLY, Boolean.TRUE); + defaults.put(JabRefPreferences.NUMERIC_FIELDS, "mittnum;author"); + defaults.put(JabRefPreferences.RUN_AUTOMATIC_FILE_SEARCH, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_LOCK_FILES, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_SAVE, Boolean.TRUE); + defaults.put(JabRefPreferences.AUTO_SAVE_INTERVAL, 5); + defaults.put(JabRefPreferences.PROMPT_BEFORE_USING_AUTOSAVE, Boolean.TRUE); + defaults.put(JabRefPreferences.ENFORCE_LEGAL_BIBTEX_KEY, Boolean.TRUE); + defaults.put(JabRefPreferences.BIBLATEX_MODE, Boolean.FALSE); // Curly brackets ({}) are the default delimiters, not quotes (") as these cause trouble when they appear within the field value: // Currently, JabRef does not escape them - defaults.put(VALUE_DELIMITERS2, 1); - defaults.put(INCLUDE_EMPTY_FIELDS, Boolean.FALSE); - defaults.put(KEY_GEN_FIRST_LETTER_A, Boolean.TRUE); - defaults.put(KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE); - defaults.put(EMAIL_SUBJECT, Localization.lang("References")); - defaults.put(OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE); - defaults.put(ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE); - defaults.put(WEB_SEARCH_VISIBLE, Boolean.FALSE); - defaults.put(SELECTED_FETCHER_INDEX, 0); - defaults.put(BIB_LOCATION_AS_FILE_DIR, Boolean.TRUE); - defaults.put(BIB_LOC_AS_PRIMARY_DIR, Boolean.FALSE); - defaults.put(DB_CONNECT_SERVER_TYPE, "MySQL"); - defaults.put(DB_CONNECT_HOSTNAME, "localhost"); - defaults.put(DB_CONNECT_DATABASE, "jabref"); - defaults.put(DB_CONNECT_USERNAME, "root"); + defaults.put(JabRefPreferences.VALUE_DELIMITERS2, 1); + defaults.put(JabRefPreferences.INCLUDE_EMPTY_FIELDS, Boolean.FALSE); + defaults.put(JabRefPreferences.KEY_GEN_FIRST_LETTER_A, Boolean.TRUE); + defaults.put(JabRefPreferences.KEY_GEN_ALWAYS_ADD_LETTER, Boolean.FALSE); + defaults.put(JabRefPreferences.EMAIL_SUBJECT, Localization.lang("References")); + defaults.put(JabRefPreferences.OPEN_FOLDERS_OF_ATTACHED_FILES, Boolean.FALSE); + defaults.put(JabRefPreferences.ALLOW_FILE_AUTO_OPEN_BROWSE, Boolean.TRUE); + defaults.put(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.FALSE); + defaults.put(JabRefPreferences.SELECTED_FETCHER_INDEX, 0); + defaults.put(JabRefPreferences.BIB_LOCATION_AS_FILE_DIR, Boolean.TRUE); + defaults.put(JabRefPreferences.BIB_LOC_AS_PRIMARY_DIR, Boolean.FALSE); + defaults.put(JabRefPreferences.DB_CONNECT_SERVER_TYPE, "MySQL"); + defaults.put(JabRefPreferences.DB_CONNECT_HOSTNAME, "localhost"); + defaults.put(JabRefPreferences.DB_CONNECT_DATABASE, "jabref"); + defaults.put(JabRefPreferences.DB_CONNECT_USERNAME, "root"); CleanUpAction.putDefaults(defaults); // defaults for DroppedFileHandler UI @@ -847,42 +816,41 @@ private JabRefPreferences() { //defaults.put("oooWarning", Boolean.TRUE); updateSpecialFieldHandling(); - WRAPPED_USERNAME = '[' + get(DEFAULT_OWNER) + ']'; - MARKING_WITH_NUMBER_PATTERN = "\\[" + get(DEFAULT_OWNER).replaceAll("\\\\", "\\\\\\\\") + ":(\\d+)\\]"; + WRAPPED_USERNAME = '[' + get(JabRefPreferences.DEFAULT_OWNER) + ']'; + MARKING_WITH_NUMBER_PATTERN = "\\[" + get(JabRefPreferences.DEFAULT_OWNER).replaceAll("\\\\", "\\\\\\\\") + ":(\\d+)\\]"; String defaultExpression = "**/.*[bibtexkey].*\\\\.[extension]"; - defaults.put(DEFAULT_REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); - defaults.put(REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); - defaults.put(USE_REG_EXP_SEARCH_KEY, Boolean.FALSE); - defaults.put(USE_IEEE_ABRV, Boolean.FALSE); - defaults.put(USE_CONVERT_TO_EQUATION, Boolean.FALSE); - defaults.put(USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE); - defaults.put(USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE); - - defaults.put(USER_FILE_DIR, GUIGlobals.FILE_FIELD + "Directory"); + defaults.put(JabRefPreferences.DEFAULT_REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); + defaults.put(JabRefPreferences.REG_EXP_SEARCH_EXPRESSION_KEY, defaultExpression); + defaults.put(JabRefPreferences.USE_REG_EXP_SEARCH_KEY, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_IEEE_ABRV, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_CONVERT_TO_EQUATION, Boolean.FALSE); + defaults.put(JabRefPreferences.USE_CASE_KEEPER_ON_SEARCH, Boolean.TRUE); + defaults.put(JabRefPreferences.USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE); + + defaults.put(JabRefPreferences.USER_FILE_DIR, GUIGlobals.FILE_FIELD + "Directory"); try { - defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp. - defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name + defaults.put(JabRefPreferences.USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER) + '@' + InetAddress.getLocalHost().getHostName()); // Legacy setting name - was a bug: @ not allowed inside BibTeX comment text. Retained for backward comp. + defaults.put(JabRefPreferences.USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER) + '-' + InetAddress.getLocalHost().getHostName()); // Valid setting name } catch (UnknownHostException ex) { - LOGGER.info("Hostname not found.", ex); - defaults.put(USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); - defaults.put(USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(DEFAULT_OWNER)); + JabRefPreferences.LOGGER.info("Hostname not found.", ex); + defaults.put(JabRefPreferences.USER_FILE_DIR_IND_LEGACY, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER)); + defaults.put(JabRefPreferences.USER_FILE_DIR_INDIVIDUAL, GUIGlobals.FILE_FIELD + "Directory" + '-' + get(JabRefPreferences.DEFAULT_OWNER)); } } public void setLanguageDependentDefaultValues() { // Entry editor tab 0: - defaults.put(CUSTOM_TAB_NAME + "_def0", Localization.lang("General")); - defaults.put(CUSTOM_TAB_FIELDS + "_def0", "crossref;keywords;file;doi;url;" - + "comment;owner;timestamp"); + defaults.put(JabRefPreferences.CUSTOM_TAB_NAME + "_def0", Localization.lang("General")); + defaults.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def0", "crossref;keywords;file;doi;url;" + "comment;owner;timestamp"); // Entry editor tab 1: - defaults.put(CUSTOM_TAB_FIELDS + "_def1", "abstract"); - defaults.put(CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract")); + defaults.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def1", "abstract"); + defaults.put(JabRefPreferences.CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract")); // Entry editor tab 2: Review Field - used for research comments, etc. - defaults.put(CUSTOM_TAB_FIELDS + "_def2", "review"); - defaults.put(CUSTOM_TAB_NAME + "_def2", Localization.lang("Review")); + defaults.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "_def2", "review"); + defaults.put(JabRefPreferences.CUSTOM_TAB_NAME + "_def2", Localization.lang("Review")); } @@ -892,7 +860,7 @@ public boolean putBracesAroundCapitals(String fieldName) { public void updateSpecialFieldHandling() { putBracesAroundCapitalsFields.clear(); - String fieldString = get(PUT_BRACES_AROUND_CAPITALS); + String fieldString = get(JabRefPreferences.PUT_BRACES_AROUND_CAPITALS); if (!fieldString.isEmpty()) { String[] fields = fieldString.split(";"); for (String field : fields) { @@ -900,7 +868,7 @@ public void updateSpecialFieldHandling() { } } nonWrappableFields.clear(); - fieldString = get(NON_WRAPPABLE_FIELDS); + fieldString = get(JabRefPreferences.NON_WRAPPABLE_FIELDS); if (!fieldString.isEmpty()) { String[] fields = fieldString.split(";"); for (String field : fields) { @@ -915,7 +883,7 @@ public char getValueDelimiters(int index) { } private char[] getValueDelimiters() { - return JabRefPreferences.VALUE_DELIMITERS[getInt(VALUE_DELIMITERS2)]; + return JabRefPreferences.VALUE_DELIMITERS[getInt(JabRefPreferences.VALUE_DELIMITERS2)]; } /** @@ -1004,7 +972,7 @@ public void putStringArray(String key, String[] value) { if (value.length > 0) { StringBuilder linked = new StringBuilder(); - for (int i = 0; i < value.length - 1; i++) { + for (int i = 0; i < (value.length - 1); i++) { linked.append(makeEscape(value[i])); linked.append(';'); } @@ -1111,7 +1079,7 @@ public KeyStroke getKey(String bindName) { if (s == null) { // there isn't even a default value // Output error - LOGGER.info("Could not get key binding for \"" + bindName + '"'); + JabRefPreferences.LOGGER.info("Could not get key binding for \"" + bindName + '"'); // fall back to a default value s = "Not associated"; } @@ -1130,8 +1098,8 @@ public KeyStroke getKey(String bindName) { /** * Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences, but adapted for Mac - * users, with the Command key preferred instead of Control. - * TODO: Move to OS.java? Or replace with portable Java key codes, i.e. KeyEvent + * users, with the Command key preferred instead of Control. TODO: Move to OS.java? Or replace with portable Java + * key codes, i.e. KeyEvent */ private KeyStroke getKeyForMac(KeyStroke ks) { if (ks == null) { @@ -1192,11 +1160,11 @@ public void clear(String key) { * Calling this method will write all preferences into the preference store. */ public void flush() { - if (getBoolean(MEMORY_STICK_MODE)) { + if (getBoolean(JabRefPreferences.MEMORY_STICK_MODE)) { try { exportPreferences("jabref.xml"); } catch (IOException e) { - LOGGER.info("Could not save preferences for memory stick mode: " + e.getLocalizedMessage(), e); + JabRefPreferences.LOGGER.info("Could not save preferences for memory stick mode: " + e.getLocalizedMessage(), e); } } try { @@ -1243,7 +1211,7 @@ public LabelPattern getKeyPattern() { } } } catch (BackingStoreException ex) { - LOGGER.info("BackingStoreException in JabRefPreferences.getKeyPattern", ex); + JabRefPreferences.LOGGER.info("BackingStoreException in JabRefPreferences.getKeyPattern", ex); } return JabRefPreferences.keyPattern; } @@ -1261,7 +1229,7 @@ public void putKeyPattern(LabelPattern pattern) { try { pre.clear(); // We remove all old entries. } catch (BackingStoreException ex) { - LOGGER.info("BackingStoreException in JabRefPreferences.putKeyPattern", ex); + JabRefPreferences.LOGGER.info("BackingStoreException in JabRefPreferences.putKeyPattern", ex); } for (Map.Entry> stringArrayListEntry : pattern.entrySet()) { @@ -1284,8 +1252,7 @@ private void restoreKeyBindings() { String[] bindings = getStringArray("bindings"); // Then set up the key bindings HashMap. - if (bindNames == null || bindings == null - || bindNames.length != bindings.length) { + if ((bindNames == null) || (bindings == null) || (bindNames.length != bindings.length)) { // Nothing defined in Preferences, or something is wrong. keyBinds = new KeyBinds(); return; @@ -1309,7 +1276,7 @@ private String getNextUnit(Reader data) throws IOException { boolean done = false; StringBuilder res = new StringBuilder(); - while (!done && (c = data.read()) != -1) { + while (!done && ((c = data.read()) != -1)) { if (c == '\\') { if (!escape) { escape = true; @@ -1345,7 +1312,7 @@ private String makeEscape(String s) { int c; for (int i = 0; i < s.length(); i++) { c = s.charAt(i); - if (c == '\\' || c == ';') { + if ((c == '\\') || (c == ';')) { sb.append('\\'); } sb.append((char) c); @@ -1370,8 +1337,8 @@ public void storeCustomEntryType(CustomEntryType tp, int number) { public CustomEntryType getCustomEntryType(int number) { String nr = "" + number; String name = get(JabRefPreferences.CUSTOM_TYPE_NAME + nr); - String[] req = getStringArray(JabRefPreferences.CUSTOM_TYPE_REQ + nr); - String[] opt = getStringArray(JabRefPreferences.CUSTOM_TYPE_OPT + nr); + String[] req = getStringArray(JabRefPreferences.CUSTOM_TYPE_REQ + nr); + String[] opt = getStringArray(JabRefPreferences.CUSTOM_TYPE_OPT + nr); String[] priOpt = getStringArray(JabRefPreferences.CUSTOM_TYPE_PRIOPT + nr); if (name == null) { return null; @@ -1447,7 +1414,7 @@ public ExternalFileType getExternalFileTypeByName(String name) { */ public ExternalFileType getExternalFileTypeByExt(String extension) { for (ExternalFileType type : externalFileTypes) { - if (type.getExtension() != null && type.getExtension().equalsIgnoreCase(extension)) { + if ((type.getExtension() != null) && type.getExtension().equalsIgnoreCase(extension)) { return type; } } @@ -1464,8 +1431,7 @@ public ExternalFileType getExternalFileTypeForName(String filename) { int longestFound = -1; ExternalFileType foundType = null; for (ExternalFileType type : externalFileTypes) { - if (type.getExtension() != null && filename.toLowerCase(). - endsWith(type.getExtension().toLowerCase())) { + if ((type.getExtension() != null) && filename.toLowerCase().endsWith(type.getExtension().toLowerCase())) { if (type.getExtension().length() > longestFound) { longestFound = type.getExtension().length(); foundType = type; @@ -1484,7 +1450,7 @@ public ExternalFileType getExternalFileTypeForName(String filename) { */ public ExternalFileType getExternalFileTypeByMimeType(String mimeType) { for (ExternalFileType type : externalFileTypes) { - if (type.getMimeType() != null && type.getMimeType().equals(mimeType)) { + if ((type.getMimeType() != null) && type.getMimeType().equals(mimeType)) { return type; } } @@ -1569,7 +1535,7 @@ public void updateExternalFileTypes() { // Read the prefs information for file types: String[][] vals = StringUtil.decodeStringDoubleArray(prefs.get("externalFileTypes", "")); for (String[] val : vals) { - if (val.length == 2 && val[1].equals(JabRefPreferences.FILE_TYPE_REMOVED_FLAG)) { + if ((val.length == 2) && val[1].equals(JabRefPreferences.FILE_TYPE_REMOVED_FLAG)) { // This entry indicates that a default entry type should be removed: ExternalFileType toRemove = null; for (ExternalFileType type : types) { From 9347fabf00946ef24f173863475691d184bf8f88 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 14 Sep 2015 20:29:15 +0200 Subject: [PATCH 3/3] Respect format of html --- .../java/net/sf/jabref/JabRefPreferences.java | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java index fb0ebe58544..6f7f6d754c8 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -555,8 +555,8 @@ private JabRefPreferences() { defaults.put(JabRefPreferences.SIDE_PANE_COMPONENT_NAMES, ""); defaults.put(JabRefPreferences.SIDE_PANE_COMPONENT_PREFERRED_POSITIONS, ""); - defaults.put(JabRefPreferences.COLUMN_NAMES, "entrytype;author;title;year;journal;timestamp;bibtexkey"); - defaults.put(JabRefPreferences.COLUMN_WIDTHS, "75;280;450;60;100;100;100"); + defaults.put(JabRefPreferences.COLUMN_NAMES, "entrytype;author;title;year;journal;bibtexkey"); + defaults.put(JabRefPreferences.COLUMN_WIDTHS, "75;300;470;60;130;100"); defaults.put(PersistenceTableColumnListener.ACTIVATE_PREF_KEY, PersistenceTableColumnListener.DEFAULT_ENABLED); defaults.put(JabRefPreferences.XMP_PRIVACY_FILTERS, "pdf;timestamp;keywords;owner;note;review"); defaults.put(JabRefPreferences.USE_XMP_PRIVACY_FILTER, Boolean.FALSE); @@ -703,13 +703,44 @@ private JabRefPreferences() { defaults.put(JabRefPreferences.DEFAULT_LABEL_PATTERN, "[auth][year]"); defaults.put(JabRefPreferences.PREVIEW_ENABLED, Boolean.TRUE); defaults.put(JabRefPreferences.ACTIVE_PREVIEW, 0); - defaults.put(JabRefPreferences.PREVIEW_0, "" + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + "\\end{bibtexkey}
__NEWLINE__" + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" + "__NEWLINE__

"); - defaults.put(JabRefPreferences.PREVIEW_1, "" + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + "\\end{bibtexkey}
__NEWLINE__" + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" - // Include the booktitle field for @inproceedings, @proceedings, etc. - + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" + "__NEWLINE__

"); - + //@formatter:off + defaults.put(JabRefPreferences.PREVIEW_0, "" + + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + + "\\end{bibtexkey}
__NEWLINE__" + + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + + "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + + "\\begin{review}

Review: \\format[HTMLChars]{\\review} \\end{review}" + + "__NEWLINE__

"); + defaults.put(JabRefPreferences.PREVIEW_1, "" + + "\\bibtextype\\begin{bibtexkey} (\\bibtexkey)" + + "\\end{bibtexkey}
__NEWLINE__" + + "\\begin{author} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\author}
\\end{author}__NEWLINE__" + + "\\begin{editor} \\format[Authors(LastFirst,Initials,Semicolon,Amp),HTMLChars]{\\editor} " + + "(\\format[IfPlural(Eds.,Ed.)]{\\editor})
\\end{editor}__NEWLINE__" + + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}
__NEWLINE__" + + "\\begin{chapter} \\format[HTMLChars]{\\chapter}
\\end{chapter}__NEWLINE__" + + "\\begin{journal} \\format[HTMLChars]{\\journal}, \\end{journal}__NEWLINE__" + // Include the booktitle field for @inproceedings, @proceedings, etc. + + "\\begin{booktitle} \\format[HTMLChars]{\\booktitle}, \\end{booktitle}__NEWLINE__" + + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + + "\\begin{institution} \\format[HTMLChars]{\\institution}, \\end{institution}__NEWLINE__" + + "\\begin{publisher} \\format[HTMLChars]{\\publisher}, \\end{publisher}__NEWLINE__" + + "\\begin{year}\\year\\end{year}\\begin{volume}, \\volume\\end{volume}" + + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" + + "__NEWLINE__

"); + //@formatter:on // TODO: Currently not possible to edit this setting: defaults.put(JabRefPreferences.PREVIEW_PRINT_BUTTON, Boolean.FALSE); defaults.put(JabRefPreferences.AUTO_DOUBLE_BRACES, Boolean.FALSE);