Search in sources :

Example 46 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext 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()));
}
Also used : Defaults(org.jabref.model.Defaults) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext)

Example 47 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext 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."));
    }
}
Also used : FromAuxDialog(org.jabref.gui.auximport.FromAuxDialog) BasePanel(org.jabref.gui.BasePanel) Defaults(org.jabref.model.Defaults) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext)

Example 48 with BibDatabaseContext

use of org.jabref.model.database.BibDatabaseContext 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()));
}
Also used : SharedDatabasePreferences(org.jabref.shared.prefs.SharedDatabasePreferences) JabRefFrame(org.jabref.gui.JabRefFrame) NotASharedDatabaseException(org.jabref.shared.exception.NotASharedDatabaseException) Defaults(org.jabref.model.Defaults) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext) DBMSConnectionProperties(org.jabref.shared.DBMSConnectionProperties)

Aggregations

BibDatabaseContext (org.jabref.model.database.BibDatabaseContext)48 Defaults (org.jabref.model.Defaults)24 Before (org.junit.Before)16 BibDatabase (org.jabref.model.database.BibDatabase)15 Test (org.junit.Test)13 BibEntry (org.jabref.model.entry.BibEntry)11 ParserResult (org.jabref.logic.importer.ParserResult)9 MetaData (org.jabref.model.metadata.MetaData)8 Charset (java.nio.charset.Charset)6 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)6 Path (java.nio.file.Path)5 Scanner (java.util.Scanner)5 BibtexDatabaseWriter (org.jabref.logic.exporter.BibtexDatabaseWriter)5 SavePreferences (org.jabref.logic.exporter.SavePreferences)5 IOException (java.io.IOException)4 SaveException (org.jabref.logic.exporter.SaveException)4 BibtexImporter (org.jabref.logic.importer.fileformat.BibtexImporter)4 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)4 FileSaveSession (org.jabref.logic.exporter.FileSaveSession)3 SaveSession (org.jabref.logic.exporter.SaveSession)3