use of org.jabref.model.Defaults in project jabref by JabRef.
the class Benchmarks method init.
@Setup
public void init() throws Exception {
Globals.prefs = JabRefPreferences.getInstance();
Random randomizer = new Random();
for (int i = 0; i < 1000; i++) {
BibEntry entry = new BibEntry();
entry.setCiteKey("id" + i);
entry.setField("title", "This is my title " + i);
entry.setField("author", "Firstname Lastname and FirstnameA LastnameA and FirstnameB LastnameB" + i);
entry.setField("journal", "Journal Title " + i);
entry.setField("keyword", "testkeyword");
entry.setField("year", "1" + i);
entry.setField("rnd", "2" + randomizer.nextInt());
database.insertEntry(entry);
}
BibtexDatabaseWriter<StringSaveSession> databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new);
StringSaveSession saveSession = databaseWriter.savePartOfDatabase(new BibDatabaseContext(database, new MetaData(), new Defaults()), database.getEntries(), new SavePreferences());
bibtexString = saveSession.getStringValue();
latexConversionString = "{A} \\textbf{bold} approach {\\it to} ${{\\Sigma}}{\\Delta}$ modulator \\textsuperscript{2} \\$";
htmlConversionString = "<b>Österreich</b> – & characters ⪢ <i>italic</i>";
}
use of org.jabref.model.Defaults in project jabref by JabRef.
the class NewDatabaseAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// Create a new, empty, database.
BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new Defaults(BibDatabaseMode.BIBTEX));
bibDatabaseContext.setMode(mode);
jabRefFrame.addTab(bibDatabaseContext, true);
jabRefFrame.output(Localization.lang("New %0 library created.", mode.getFormattedName()));
}
use of org.jabref.model.Defaults in project jabref by JabRef.
the class NewSubDatabaseAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// Create a new, empty, database.
FromAuxDialog dialog = new FromAuxDialog(jabRefFrame, "", true, jabRefFrame.getTabbedPane());
dialog.setLocationRelativeTo(jabRefFrame);
dialog.setVisible(true);
if (dialog.generatePressed()) {
Defaults defaults = new Defaults(Globals.prefs.getDefaultBibDatabaseMode());
BasePanel bp = new BasePanel(jabRefFrame, new BibDatabaseContext(dialog.getGenerateDB(), defaults));
jabRefFrame.addTab(bp, true);
jabRefFrame.output(Localization.lang("New library created."));
}
}
use of org.jabref.model.Defaults in project jabref by JabRef.
the class SharedDatabaseUIManager method openSharedDatabaseFromParserResult.
public void openSharedDatabaseFromParserResult(ParserResult parserResult) throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException, NotASharedDatabaseException {
Optional<String> sharedDatabaseIDOptional = parserResult.getDatabase().getSharedDatabaseID();
if (!sharedDatabaseIDOptional.isPresent()) {
throw new NotASharedDatabaseException();
}
String sharedDatabaseID = sharedDatabaseIDOptional.get();
DBMSConnectionProperties dbmsConnectionProperties = new DBMSConnectionProperties(new SharedDatabasePreferences(sharedDatabaseID));
JabRefFrame frame = JabRefGUI.getMainFrame();
BibDatabaseMode selectedMode = Globals.prefs.getDefaultBibDatabaseMode();
BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new Defaults(selectedMode), DatabaseLocation.SHARED, Globals.prefs.getKeywordDelimiter(), Globals.prefs.getKeyPattern());
bibDatabaseContext.getDatabase().setSharedDatabaseID(sharedDatabaseID);
bibDatabaseContext.setDatabaseFile(parserResult.getDatabaseContext().getDatabaseFile().orElse(null));
dbmsSynchronizer = bibDatabaseContext.getDBMSSynchronizer();
dbmsSynchronizer.openSharedDatabase(dbmsConnectionProperties);
dbmsSynchronizer.registerListener(this);
parserResult.setDatabaseContext(bibDatabaseContext);
frame.output(Localization.lang("Connection_to_%0_server_established.", dbmsConnectionProperties.getType().toString()));
}
Aggregations