Search in sources :

Example 6 with LayoutFormatterPreferences

use of org.jabref.logic.layout.LayoutFormatterPreferences in project jabref by JabRef.

the class CsvExportFormatTest method setUp.

@Before
public void setUp() {
    Map<String, ExportFormat> customFormats = new HashMap<>();
    LayoutFormatterPreferences layoutPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS);
    SavePreferences savePreferences = mock(SavePreferences.class);
    ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences);
    exportFormat = ExportFormats.getExportFormat("oocsv");
    databaseContext = new BibDatabaseContext();
    charset = Charsets.UTF_8;
}
Also used : LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) HashMap(java.util.HashMap) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Before(org.junit.Before)

Example 7 with LayoutFormatterPreferences

use of org.jabref.logic.layout.LayoutFormatterPreferences in project jabref by JabRef.

the class CitationStyleToClipboardWorker method doInBackground.

@Override
protected List<String> doInBackground() throws Exception {
    if (CitationStyle.isCitationStyleFile(style)) {
        return CitationStyleGenerator.generateCitations(selectedEntries, style, outputFormat);
    } else {
        StringReader sr = new StringReader(previewStyle.replace("__NEWLINE__", "\n"));
        LayoutFormatterPreferences layoutFormatterPreferences = Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader);
        Layout layout = new LayoutHelper(sr, layoutFormatterPreferences).getLayoutFromText();
        List<String> citations = new ArrayList<>(selectedEntries.size());
        for (BibEntry entry : selectedEntries) {
            citations.add(layout.doLayout(entry, basePanel.getDatabase()));
        }
        return citations;
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Layout(org.jabref.logic.layout.Layout) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) LayoutHelper(org.jabref.logic.layout.LayoutHelper)

Example 8 with LayoutFormatterPreferences

use of org.jabref.logic.layout.LayoutFormatterPreferences in project jabref by JabRef.

the class ExportFormatTest method exportFormats.

@Parameterized.Parameters(name = "{index}: {1}")
public static Collection<Object[]> exportFormats() {
    Collection<Object[]> result = new ArrayList<>();
    Map<String, ExportFormat> customFormats = new HashMap<>();
    LayoutFormatterPreferences layoutPreferences = mock(LayoutFormatterPreferences.class);
    SavePreferences savePreferences = mock(SavePreferences.class);
    ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences);
    for (IExportFormat format : ExportFormats.getExportFormats().values()) {
        result.add(new Object[] { format, format.getDisplayName() });
    }
    return result;
}
Also used : LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 9 with LayoutFormatterPreferences

use of org.jabref.logic.layout.LayoutFormatterPreferences in project jabref by JabRef.

the class HtmlExportFormatTest method setUp.

@Before
public void setUp() {
    Map<String, ExportFormat> customFormats = new HashMap<>();
    LayoutFormatterPreferences layoutPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS);
    SavePreferences savePreferences = mock(SavePreferences.class);
    ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences);
    exportFormat = ExportFormats.getExportFormat("html");
    databaseContext = new BibDatabaseContext();
    charset = Charsets.UTF_8;
    BibEntry entry = new BibEntry();
    entry.setField("title", "my paper title");
    entry.setField("author", "Stefan Kolb");
    entry.setCiteKey("mykey");
    entries = Arrays.asList(entry);
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) HashMap(java.util.HashMap) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) Before(org.junit.Before)

Example 10 with LayoutFormatterPreferences

use of org.jabref.logic.layout.LayoutFormatterPreferences 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

LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)11 ExportFormat (org.jabref.logic.exporter.ExportFormat)5 SavePreferences (org.jabref.logic.exporter.SavePreferences)5 BibEntry (org.jabref.model.entry.BibEntry)5 HashMap (java.util.HashMap)3 BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)3 Before (org.junit.Before)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JabRefFrame (org.jabref.gui.JabRefFrame)2 BibDatabase (org.jabref.model.database.BibDatabase)2 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1