Search in sources :

Example 1 with ExportFormat

use of org.jabref.logic.exporter.ExportFormat in project jabref by JabRef.

the class ArgumentProcessor method importPreferences.

private void importPreferences() {
    try {
        Globals.prefs.importPreferences(cli.getPreferencesImport());
        EntryTypes.loadCustomEntryTypes(Globals.prefs.loadCustomEntryTypes(BibDatabaseMode.BIBTEX), Globals.prefs.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);
    } catch (JabRefException ex) {
        LOGGER.error("Cannot import preferences", ex);
    }
}
Also used : LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) JabRefException(org.jabref.JabRefException) SavePreferences(org.jabref.logic.exporter.SavePreferences) IExportFormat(org.jabref.logic.exporter.IExportFormat) ExportFormat(org.jabref.logic.exporter.ExportFormat)

Example 2 with ExportFormat

use of org.jabref.logic.exporter.ExportFormat in project jabref by JabRef.

the class PreferencesDialog method updateAfterPreferenceChanges.

private void updateAfterPreferenceChanges() {
    setValues();
    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);
    Globals.prefs.updateEntryEditorTabList();
}
Also used : LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) SavePreferences(org.jabref.logic.exporter.SavePreferences) ExportFormat(org.jabref.logic.exporter.ExportFormat)

Example 3 with ExportFormat

use of org.jabref.logic.exporter.ExportFormat in project jabref by JabRef.

the class CustomExportList method createFormat.

private Optional<ExportFormat> createFormat(List<String> s, LayoutFormatterPreferences layoutPreferences, SavePreferences savePreferences) {
    if (s.size() < 3) {
        return Optional.empty();
    }
    String lfFileName;
    if (s.get(1).endsWith(".layout")) {
        lfFileName = s.get(1).substring(0, s.get(1).length() - 7);
    } else {
        lfFileName = s.get(1);
    }
    ExportFormat format = new ExportFormat(s.get(0), s.get(0), lfFileName, null, s.get(2), layoutPreferences, savePreferences);
    format.setCustomExport(true);
    return Optional.of(format);
}
Also used : ExportFormat(org.jabref.logic.exporter.ExportFormat)

Example 4 with ExportFormat

use of org.jabref.logic.exporter.ExportFormat in project jabref by JabRef.

the class CustomExportList method readPrefs.

private void readPrefs(JabRefPreferences prefs, JournalAbbreviationLoader loader) {
    Objects.requireNonNull(prefs);
    Objects.requireNonNull(loader);
    formats.clear();
    list.clear();
    int i = 0;
    List<String> s;
    LayoutFormatterPreferences layoutPreferences = prefs.getLayoutFormatterPreferences(loader);
    SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(prefs);
    while (!((s = prefs.getStringList(JabRefPreferences.CUSTOM_EXPORT_FORMAT + i)).isEmpty())) {
        Optional<ExportFormat> format = createFormat(s, layoutPreferences, savePreferences);
        if (format.isPresent()) {
            formats.put(format.get().getConsoleName(), format.get());
            list.add(s);
        } else {
            String customExportFormat = prefs.get(JabRefPreferences.CUSTOM_EXPORT_FORMAT + i);
            LOGGER.error("Error initializing custom export format from string " + customExportFormat);
        }
        i++;
    }
}
Also used : LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) SavePreferences(org.jabref.logic.exporter.SavePreferences) ExportFormat(org.jabref.logic.exporter.ExportFormat)

Example 5 with ExportFormat

use of org.jabref.logic.exporter.ExportFormat 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()));
}
Also used : ProtectedTermsLoader(org.jabref.logic.protectedterms.ProtectedTermsLoader) JournalAbbreviationLoader(org.jabref.logic.journals.JournalAbbreviationLoader) ExportFormat(org.jabref.logic.exporter.ExportFormat) ArgumentProcessor(org.jabref.cli.ArgumentProcessor) ProxyPreferences(org.jabref.logic.net.ProxyPreferences) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) JabRefMessageHandler(org.jabref.gui.remote.JabRefMessageHandler) ProxyAuthenticator(org.jabref.logic.net.ProxyAuthenticator) RemotePreferences(org.jabref.logic.remote.RemotePreferences) JabRefPreferences(org.jabref.preferences.JabRefPreferences) SavePreferences(org.jabref.logic.exporter.SavePreferences)

Aggregations

ExportFormat (org.jabref.logic.exporter.ExportFormat)6 SavePreferences (org.jabref.logic.exporter.SavePreferences)5 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)5 IExportFormat (org.jabref.logic.exporter.IExportFormat)2 ActionEvent (java.awt.event.ActionEvent)1 File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 FileFilter (javax.swing.filechooser.FileFilter)1 JabRefException (org.jabref.JabRefException)1 ArgumentProcessor (org.jabref.cli.ArgumentProcessor)1 JabRefFrame (org.jabref.gui.JabRefFrame)1 MnemonicAwareAction (org.jabref.gui.actions.MnemonicAwareAction)1 JabRefMessageHandler (org.jabref.gui.remote.JabRefMessageHandler)1 AbstractWorker (org.jabref.gui.worker.AbstractWorker)1 JournalAbbreviationLoader (org.jabref.logic.journals.JournalAbbreviationLoader)1 ProxyAuthenticator (org.jabref.logic.net.ProxyAuthenticator)1 ProxyPreferences (org.jabref.logic.net.ProxyPreferences)1 ProtectedTermsLoader (org.jabref.logic.protectedterms.ProtectedTermsLoader)1 RemotePreferences (org.jabref.logic.remote.RemotePreferences)1 BibEntry (org.jabref.model.entry.BibEntry)1