use of org.jabref.logic.journals.JournalAbbreviationLoader in project jabref by JabRef.
the class ManageJournalAbbreviationsViewModelTest method setUpViewModel.
@Before
public void setUpViewModel() throws Exception {
abbreviationPreferences = mock(JournalAbbreviationPreferences.class);
PreferencesService preferences = mock(PreferencesService.class);
when(preferences.getJournalAbbreviationPreferences()).thenReturn(abbreviationPreferences);
dialogService = mock(DialogService.class);
TaskExecutor taskExecutor = new CurrentThreadTaskExecutor();
JournalAbbreviationLoader journalAbbreviationLoader = mock(JournalAbbreviationLoader.class);
viewModel = new ManageJournalAbbreviationsViewModel(preferences, dialogService, taskExecutor, journalAbbreviationLoader);
emptyTestFile = createTemporaryTestFile("emptyTestFile.txt", "");
testFile1Entries = createTemporaryTestFile("testFile1Entries.txt", "Test Entry = TE" + NEWLINE + "");
testFile3Entries = createTemporaryTestFile("testFile3Entries.txt", "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "");
testFile4Entries = createTemporaryTestFile("testFile4Entries.txt", "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "Entry = E" + NEWLINE + "");
testFile5EntriesWithDuplicate = createTemporaryTestFile("testFile5Entries.txt", "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "EntryEntry = EE" + NEWLINE + "");
}
use of org.jabref.logic.journals.JournalAbbreviationLoader in project jabref by JabRef.
the class JabRefMain method start.
private static void start(String[] args) {
FallbackExceptionHandler.installExceptionHandler();
JabRefPreferences preferences = JabRefPreferences.getInstance();
ProxyPreferences proxyPreferences = preferences.getProxyPreferences();
ProxyRegisterer.register(proxyPreferences);
if (proxyPreferences.isUseProxy() && proxyPreferences.isUseAuthentication()) {
Authenticator.setDefault(new ProxyAuthenticator());
}
Globals.prefs = preferences;
Globals.startBackgroundTasks();
Localization.setLanguage(preferences.get(JabRefPreferences.LANGUAGE));
Globals.prefs.setLanguageDependentDefaultValues();
// Perform Migrations
// Perform checks and changes for users with a preference set from an older JabRef version.
PreferencesMigrations.upgradePrefsToOrgJabRef();
PreferencesMigrations.upgradeSortOrder();
PreferencesMigrations.upgradeFaultyEncodingStrings();
PreferencesMigrations.upgradeLabelPatternToBibtexKeyPattern();
PreferencesMigrations.upgradeStoredCustomEntryTypes();
// Update handling of special fields based on preferences
InternalBibtexFields.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS));
// Update name of the time stamp field based on preferences
InternalBibtexFields.updateTimeStampField(Globals.prefs.get(JabRefPreferences.TIME_STAMP_FIELD));
// Update which fields should be treated as numeric, based on preferences:
InternalBibtexFields.setNumericFields(Globals.prefs.getStringList(JabRefPreferences.NUMERIC_FIELDS));
// Read list(s) of journal names and abbreviations
Globals.journalAbbreviationLoader = new JournalAbbreviationLoader();
/* Build list of Import and Export formats */
Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), Globals.prefs.getXMPPreferences());
EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX), preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX));
Map<String, ExportFormat> customFormats = Globals.prefs.customExports.getCustomExportFormats(Globals.prefs, Globals.journalAbbreviationLoader);
LayoutFormatterPreferences layoutPreferences = Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs);
ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences);
// Initialize protected terms loader
Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences());
ProtectTermsFormatter.setProtectedTermsLoader(Globals.protectedTermsLoader);
// Check for running JabRef
RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences();
if (remotePreferences.useRemoteServer()) {
Globals.REMOTE_LISTENER.open(new JabRefMessageHandler(), remotePreferences.getPort());
if (!Globals.REMOTE_LISTENER.isOpen()) {
// we are not alone, there is already a server out there, try to contact already running JabRef:
if (RemoteListenerClient.sendToActiveJabRefInstance(args, remotePreferences.getPort())) {
// We have successfully sent our command line options through the socket to another JabRef instance.
// So we assume it's all taken care of, and quit.
LOGGER.info(Localization.lang("Arguments passed on to running JabRef instance. Shutting down."));
Globals.shutdownThreadPools();
// needed to tell JavaFx to stop
Platform.exit();
return;
}
}
// we are alone, we start the server
Globals.REMOTE_LISTENER.start();
}
// override used newline character with the one stored in the preferences
// The preferences return the system newline character sequence as default
OS.NEWLINE = Globals.prefs.get(JabRefPreferences.NEWLINE);
// Process arguments
ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START);
// See if we should shut down now
if (argumentProcessor.shouldShutDown()) {
Globals.shutdownThreadPools();
return;
}
// If not, start GUI
SwingUtilities.invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), argumentProcessor.isBlank()));
}
Aggregations