/** Calling this method will write all preferences into the preference store. */ public void flush() { if (getBoolean("memoryStickMode")) { try { exportPreferences("jabref.xml"); } catch (IOException e) { Globals.logger( "Could not save preferences for memory stick mode: " + e.getLocalizedMessage()); } } try { prefs.flush(); } catch (BackingStoreException ex) { ex.printStackTrace(); } }
public void putKeyPattern(LabelPattern pattern) { keyPattern = pattern; LabelPattern parent = pattern.getParent(); if (parent == null) return; // Store overridden definitions to Preferences. Preferences pre = Preferences.userNodeForPackage(net.sf.jabref.labelPattern.LabelPattern.class); try { pre.clear(); // We remove all old entries. } catch (BackingStoreException ex) { Globals.logger("BackingStoreException in JabRefPreferences.putKeyPattern"); } for (String s : pattern.keySet()) { if (!(pattern.get(s)).equals(parent.get(s))) pre.put(s, pattern.getValue(s).get(0).toString()); } }
public LabelPattern getKeyPattern() { keyPattern = new LabelPattern(KEY_PATTERN); Preferences pre = Preferences.userNodeForPackage(net.sf.jabref.labelPattern.LabelPattern.class); try { String[] keys = pre.keys(); if (keys.length > 0) for (int i = 0; i < keys.length; i++) keyPattern.addLabelPattern(keys[i], pre.get(keys[i], null)); } catch (BackingStoreException ex) { Globals.logger("BackingStoreException in JabRefPreferences.getKeyPattern"); } /// // keyPattern.addLabelPattern("article", "[author][year]"); // putKeyPattern(keyPattern); /// return keyPattern; }
/** Returns the KeyStroke for this binding, as defined by the defaults, or in the Preferences. */ public KeyStroke getKey(String bindName) { String s = keyBinds.get(bindName); // If the current key bindings don't contain the one asked for, // we fall back on the default. This should only happen when a // user has his own set in Preferences, and has upgraded to a // new version where new bindings have been introduced. if (s == null) { s = defKeyBinds.get(bindName); // So, if this happens, we add the default value to the current // hashmap, so this doesn't happen again, and so this binding // will appear in the KeyBindingsDialog. keyBinds.put(bindName, s); } if (s == null) { Globals.logger("Could not get key binding for \"" + bindName + "\""); } if (Globals.ON_MAC) return getKeyForMac(KeyStroke.getKeyStroke(s)); else return KeyStroke.getKeyStroke(s); }
// The constructor is made private to enforce this as a singleton class: private JabRefPreferences() { try { if (new File("jabref.xml").exists()) { importPreferences("jabref.xml"); } } catch (IOException e) { Globals.logger("Could not import preferences from jabref.xml:" + e.getLocalizedMessage()); } prefs = Preferences.userNodeForPackage(JabRef.class); if (Globals.osName.equals(Globals.MAC)) { defaults.put("pdfviewer", "/Applications/Preview.app"); defaults.put("psviewer", "/Applications/Preview.app"); defaults.put("htmlviewer", "/Applications/Safari.app"); defaults.put("fontFamily", "SansSerif"); } else if (Globals.osName.toLowerCase().startsWith("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("lookAndFeel", "com.jgoodies.looks.windows.WindowsLookAndFeel"); defaults.put("winEdtPath", "C:\\Program Files\\WinEdt Team\\WinEdt\\WinEdt.exe"); defaults.put("latexEditorPath", "C:\\Program Files\\LEd\\LEd.exe"); defaults.put("fontFamily", "Arial"); } else { defaults.put("pdfviewer", "evince"); defaults.put("psviewer", "gv"); defaults.put("htmlviewer", "firefox"); defaults.put("lookAndFeel", "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel"); defaults.put("fontFamily", "SansSerif"); } defaults.put("useDefaultLookAndFeel", Boolean.TRUE); defaults.put("lyxpipe", System.getProperty("user.home") + File.separator + ".lyx/lyxpipe"); defaults.put("vim", "vim"); defaults.put("vimServer", "vim"); defaults.put("posX", new Integer(0)); defaults.put("posY", new Integer(0)); defaults.put("sizeX", new Integer(840)); defaults.put("sizeY", new Integer(680)); defaults.put("windowMaximised", Boolean.FALSE); defaults.put("rememberWindowLocation", Boolean.TRUE); defaults.put("autoResizeMode", new Integer(JTable.AUTO_RESIZE_ALL_COLUMNS)); defaults.put("tableColorCodesOn", Boolean.TRUE); defaults.put("namesAsIs", Boolean.FALSE); defaults.put("namesFf", Boolean.FALSE); defaults.put("namesLf", Boolean.FALSE); defaults.put("namesNatbib", Boolean.TRUE); defaults.put("abbrAuthorNames", Boolean.TRUE); defaults.put("namesLastOnly", Boolean.TRUE); defaults.put("language", "en"); defaults.put("showShort", Boolean.TRUE); defaults.put("priSort", "author"); defaults.put("priDescending", Boolean.FALSE); defaults.put("priBinary", Boolean.FALSE); defaults.put("secSort", "year"); defaults.put("secDescending", Boolean.TRUE); defaults.put("terSort", "author"); defaults.put("terDescending", Boolean.FALSE); defaults.put("columnNames", "entrytype;author;title;year;journal;owner;timestamp;bibtexkey"); defaults.put("columnWidths", "75;280;400;60;100;100;100;100"); defaults.put( PersistenceTableColumnListener.ACTIVATE_PREF_KEY, new Boolean(PersistenceTableColumnListener.DEFAULT_ENABLED)); defaults.put("xmpPrivacyFilters", "pdf;timestamp;keywords;owner;note;review"); defaults.put("useXmpPrivacyFilter", Boolean.FALSE); defaults.put("numberColWidth", new Integer(GUIGlobals.NUMBER_COL_LENGTH)); defaults.put("workingDirectory", System.getProperty("user.home")); defaults.put("exportWorkingDirectory", System.getProperty("user.home")); defaults.put("importWorkingDirectory", System.getProperty("user.home")); defaults.put("fileWorkingDirectory", System.getProperty("user.home")); defaults.put("autoOpenForm", Boolean.TRUE); defaults.put("entryTypeFormHeightFactor", new Integer(1)); defaults.put("entryTypeFormWidth", new Integer(1)); defaults.put("backup", Boolean.TRUE); defaults.put("openLastEdited", Boolean.TRUE); defaults.put("lastEdited", null); defaults.put("stringsPosX", new Integer(0)); defaults.put("stringsPosY", new Integer(0)); defaults.put("stringsSizeX", new Integer(600)); defaults.put("stringsSizeY", new Integer(400)); defaults.put("defaultShowSource", Boolean.FALSE); defaults.put("showSource", Boolean.TRUE); defaults.put("defaultAutoSort", Boolean.FALSE); defaults.put("enableSourceEditing", Boolean.TRUE); defaults.put("caseSensitiveSearch", Boolean.FALSE); defaults.put("searchReq", Boolean.TRUE); defaults.put("searchOpt", Boolean.TRUE); defaults.put("searchGen", Boolean.TRUE); defaults.put("searchAll", Boolean.FALSE); defaults.put("incrementS", Boolean.FALSE); defaults.put("saveInStandardOrder", Boolean.TRUE); defaults.put("saveInOriginalOrder", Boolean.FALSE); defaults.put("exportInStandardOrder", Boolean.TRUE); defaults.put("exportInOriginalOrder", Boolean.FALSE); defaults.put("selectS", Boolean.FALSE); defaults.put("regExpSearch", Boolean.TRUE); defaults.put("searchPanePosX", new Integer(0)); defaults.put("searchPanePosY", new Integer(0)); defaults.put("autoComplete", Boolean.TRUE); defaults.put("autoCompleteFields", "author;editor;title;journal;publisher;keywords;crossref"); defaults.put("groupSelectorVisible", Boolean.TRUE); defaults.put("groupFloatSelections", Boolean.TRUE); defaults.put("groupIntersectSelections", Boolean.TRUE); defaults.put("groupInvertSelections", Boolean.FALSE); defaults.put("groupShowOverlapping", Boolean.FALSE); defaults.put("groupSelectMatches", Boolean.FALSE); defaults.put("groupsDefaultField", "keywords"); defaults.put("groupShowIcons", Boolean.TRUE); defaults.put("groupShowDynamic", Boolean.TRUE); defaults.put("groupExpandTree", Boolean.TRUE); defaults.put("groupAutoShow", Boolean.TRUE); defaults.put("groupAutoHide", Boolean.TRUE); defaults.put("groupKeywordSeparator", ", "); defaults.put("highlightGroupsMatchingAny", Boolean.FALSE); defaults.put("highlightGroupsMatchingAll", Boolean.FALSE); defaults.put("searchPanelVisible", Boolean.FALSE); defaults.put("defaultEncoding", System.getProperty("file.encoding")); defaults.put("groupsVisibleRows", new Integer(8)); defaults.put("defaultOwner", System.getProperty("user.name")); defaults.put("preserveFieldFormatting", Boolean.FALSE); defaults.put("memoryStickMode", Boolean.FALSE); defaults.put("renameOnMoveFileToFileDir", Boolean.TRUE); // The general fields stuff is made obsolete by the CUSTOM_TAB_... entries. defaults.put( "generalFields", "crossref;keywords;file;doi;url;urldate;citeseerurl;" + "pdf;comment;owner"); defaults.put("useCustomIconTheme", Boolean.FALSE); defaults.put("customIconThemeFile", "/home/alver/div/crystaltheme_16/Icons.properties"); // Entry editor tab 0: defaults.put(CUSTOM_TAB_NAME + "_def0", Globals.lang("General")); defaults.put( CUSTOM_TAB_FIELDS + "_def0", "crossref;keywords;file;doi;url;citeseerurl;" + "comment;owner;timestamp"); // Entry editor tab 1: defaults.put(CUSTOM_TAB_FIELDS + "_def1", "abstract"); defaults.put(CUSTOM_TAB_NAME + "_def1", Globals.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", Globals.lang("Review")); // defaults.put("recentFiles", "/home/alver/Documents/bibk_dok/hovedbase.bib"); defaults.put("historySize", new Integer(8)); defaults.put("fontStyle", new Integer(java.awt.Font.PLAIN)); defaults.put("fontSize", new Integer(12)); defaults.put("overrideDefaultFonts", Boolean.FALSE); defaults.put("menuFontFamily", "Times"); defaults.put("menuFontStyle", new Integer(java.awt.Font.PLAIN)); defaults.put("menuFontSize", new Integer(11)); // Main table color settings: defaults.put("tableBackground", "255:255:255"); defaults.put("tableReqFieldBackground", "230:235:255"); defaults.put("tableOptFieldBackground", "230:255:230"); defaults.put("tableText", "0:0:0"); defaults.put("gridColor", "210:210:210"); defaults.put("grayedOutBackground", "210:210:210"); defaults.put("grayedOutText", "40:40:40"); defaults.put("veryGrayedOutBackground", "180:180:180"); defaults.put("veryGrayedOutText", "40:40:40"); defaults.put("markedEntryBackground", "255:255:180"); defaults.put("incompleteEntryBackground", "250:175:175"); defaults.put("antialias", Boolean.FALSE); defaults.put("ctrlClick", Boolean.FALSE); defaults.put("disableOnMultipleSelection", Boolean.FALSE); defaults.put("pdfColumn", Boolean.FALSE); defaults.put("urlColumn", Boolean.TRUE); defaults.put("fileColumn", Boolean.TRUE); defaults.put("citeseerColumn", Boolean.FALSE); defaults.put("useOwner", Boolean.TRUE); defaults.put("overwriteOwner", Boolean.FALSE); defaults.put("allowTableEditing", Boolean.FALSE); defaults.put("dialogWarningForDuplicateKey", Boolean.TRUE); defaults.put("dialogWarningForEmptyKey", Boolean.TRUE); defaults.put("displayKeyWarningDialogAtStartup", Boolean.TRUE); defaults.put("avoidOverwritingKey", Boolean.FALSE); defaults.put("warnBeforeOverwritingKey", Boolean.TRUE); defaults.put("confirmDelete", Boolean.TRUE); defaults.put("grayOutNonHits", Boolean.TRUE); defaults.put("floatSearch", Boolean.TRUE); defaults.put("showSearchInDialog", Boolean.FALSE); defaults.put("searchAllBases", Boolean.FALSE); defaults.put("defaultLabelPattern", "[auth][year]"); defaults.put("previewEnabled", Boolean.TRUE); defaults.put( "preview0", "<font face=\"arial\">" + "<b><i>\\bibtextype</i><a name=\"\\bibtexkey\">\\begin{bibtexkey} (\\bibtexkey)</a>" + "\\end{bibtexkey}</b><br>__NEWLINE__" + "\\begin{author} \\format[HTMLChars,AuthorAbbreviator,AuthorAndsReplacer]{\\author}<BR>\\end{author}__NEWLINE__" + "\\begin{editor} \\format[HTMLChars,AuthorAbbreviator,AuthorAndsReplacer]{\\editor} " + "<i>(\\format[IfPlural(Eds.,Ed.)]{\\editor})</i><BR>\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}<BR>__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}<BR>\\end{chapter}__NEWLINE__" + "\\begin{journal} <em>\\format[HTMLChars]{\\journal}, </em>\\end{journal}__NEWLINE__" // Include the booktitle field for @inproceedings, @proceedings, etc. + "\\begin{booktitle} <em>\\format[HTMLChars]{\\booktitle}, </em>\\end{booktitle}__NEWLINE__" + "\\begin{school} <em>\\format[HTMLChars]{\\school}, </em>\\end{school}__NEWLINE__" + "\\begin{institution} <em>\\format[HTMLChars]{\\institution}, </em>\\end{institution}__NEWLINE__" + "\\begin{publisher} <em>\\format[HTMLChars]{\\publisher}, </em>\\end{publisher}__NEWLINE__" + "\\begin{year}<b>\\year</b>\\end{year}\\begin{volume}<i>, \\volume</i>\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}__NEWLINE__" + "\\begin{abstract}<BR><BR><b>Abstract: </b> \\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + "\\begin{review}<BR><BR><b>Review: </b> \\format[HTMLChars]{\\review} \\end{review}" + "</dd>__NEWLINE__<p></p></font>"); defaults.put( "preview1", "<font face=\"arial\">" + "<b><i>\\bibtextype</i><a name=\"\\bibtexkey\">\\begin{bibtexkey} (\\bibtexkey)</a>" + "\\end{bibtexkey}</b><br>__NEWLINE__" + "\\begin{author} \\format[HTMLChars,AuthorAbbreviator,AuthorAndsReplacer]{\\author}<BR>\\end{author}__NEWLINE__" + "\\begin{editor} \\format[HTMLChars,AuthorAbbreviator,AuthorAndsReplacer]{\\editor} " + "<i>(\\format[IfPlural(Eds.,Ed.)]{\\editor})</i><BR>\\end{editor}__NEWLINE__" + "\\begin{title} \\format[HTMLChars]{\\title} \\end{title}<BR>__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}<BR>\\end{chapter}__NEWLINE__" + "\\begin{journal} <em>\\format[HTMLChars]{\\journal}, </em>\\end{journal}__NEWLINE__" // Include the booktitle field for @inproceedings, @proceedings, etc. + "\\begin{booktitle} <em>\\format[HTMLChars]{\\booktitle}, </em>\\end{booktitle}__NEWLINE__" + "\\begin{school} <em>\\format[HTMLChars]{\\school}, </em>\\end{school}__NEWLINE__" + "\\begin{institution} <em>\\format[HTMLChars]{\\institution}, </em>\\end{institution}__NEWLINE__" + "\\begin{publisher} <em>\\format[HTMLChars]{\\publisher}, </em>\\end{publisher}__NEWLINE__" + "\\begin{year}<b>\\year</b>\\end{year}\\begin{volume}<i>, \\volume</i>\\end{volume}" + "\\begin{pages}, \\format[FormatPagesForHTML]{\\pages} \\end{pages}" + "</dd>__NEWLINE__<p></p></font>"); // TODO: Currently not possible to edit this setting: defaults.put("previewPrintButton", Boolean.FALSE); defaults.put("autoDoubleBraces", Boolean.FALSE); defaults.put("doNotResolveStringsFor", "url"); defaults.put("resolveStringsAllFields", Boolean.FALSE); defaults.put("putBracesAroundCapitals", ""); // "title;journal;booktitle;review;abstract"); defaults.put("nonWrappableFields", "pdf;ps;url;doi;file"); defaults.put("useImportInspectionDialog", Boolean.TRUE); defaults.put("useImportInspectionDialogForSingle", Boolean.TRUE); defaults.put("generateKeysAfterInspection", Boolean.TRUE); defaults.put("markImportedEntries", Boolean.TRUE); defaults.put("unmarkAllEntriesBeforeImporting", Boolean.TRUE); defaults.put("warnAboutDuplicatesInInspection", Boolean.TRUE); defaults.put("useTimeStamp", Boolean.TRUE); defaults.put("overwriteTimeStamp", Boolean.FALSE); defaults.put("timeStampFormat", "yyyy.MM.dd"); // defaults.put("timeStampField", "timestamp"); defaults.put("timeStampField", BibtexFields.TIMESTAMP); defaults.put("generateKeysBeforeSaving", Boolean.FALSE); defaults.put("useRemoteServer", Boolean.FALSE); defaults.put("remoteServerPort", new Integer(6050)); defaults.put("personalJournalList", null); defaults.put("externalJournalLists", null); defaults.put("citeCommand", "cite"); // obsoleted by the app-specific ones defaults.put("citeCommandVim", "\\cite"); defaults.put("citeCommandEmacs", "\\cite"); defaults.put("citeCommandWinEdt", "\\cite"); defaults.put("citeCommandLed", "\\cite"); defaults.put("floatMarkedEntries", Boolean.TRUE); defaults.put("useNativeFileDialogOnMac", Boolean.FALSE); defaults.put("filechooserDisableRename", Boolean.TRUE); defaults.put("lastUsedExport", null); defaults.put("sidePaneWidth", new Integer(-1)); defaults.put("importInspectionDialogWidth", new Integer(650)); defaults.put("importInspectionDialogHeight", new Integer(650)); defaults.put("searchDialogWidth", new Integer(650)); defaults.put("searchDialogHeight", new Integer(500)); defaults.put("showFileLinksUpgradeWarning", Boolean.TRUE); defaults.put("autolinkExactKeyOnly", Boolean.TRUE); defaults.put("numericFields", "mittnum;author"); defaults.put("runAutomaticFileSearch", Boolean.FALSE); defaults.put("useLockFiles", Boolean.TRUE); defaults.put("autoSave", Boolean.TRUE); defaults.put("autoSaveInterval", 5); defaults.put("promptBeforeUsingAutosave", Boolean.TRUE); defaults.put("deletePlugins", ""); defaults.put("enforceLegalBibtexKey", Boolean.TRUE); defaults.put("biblatexMode", Boolean.FALSE); // defaults.put("lastAutodetectedImport", ""); // defaults.put("autoRemoveExactDuplicates", Boolean.FALSE); // defaults.put("confirmAutoRemoveExactDuplicates", Boolean.TRUE); // defaults.put("tempDir", System.getProperty("java.io.tmpdir")); // Util.pr(System.getProperty("java.io.tempdir")); // defaults.put("keyPattern", new LabelPattern(KEY_PATTERN)); restoreKeyBindings(); customExports = new CustomExportList(new ExportComparator()); customImports = new CustomImportList(this); // defaults.put("oooWarning", Boolean.TRUE); updateSpecialFieldHandling(); WRAPPED_USERNAME = "******" + get("defaultOwner") + "]"; 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("useIEEEAbrv", Boolean.TRUE); }