Search in sources :

Example 1 with BibDatabaseMode

use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.

the class BibtexKeyPatternPanel method buildGUI.

private void buildGUI() {
    JPanel pan = new JPanel();
    JScrollPane sp = new JScrollPane(pan);
    sp.setPreferredSize(new Dimension(100, 100));
    sp.setBorder(BorderFactory.createEmptyBorder());
    pan.setLayout(gbl);
    setLayout(gbl);
    // The header - can be removed
    JLabel lblEntryType = new JLabel(Localization.lang("Entry type"));
    Font f = new Font("plain", Font.BOLD, 12);
    lblEntryType.setFont(f);
    con.gridx = 0;
    con.gridy = 0;
    con.gridwidth = 1;
    con.gridheight = 1;
    con.fill = GridBagConstraints.VERTICAL;
    con.anchor = GridBagConstraints.WEST;
    con.insets = new Insets(5, 5, 10, 0);
    gbl.setConstraints(lblEntryType, con);
    pan.add(lblEntryType);
    JLabel lblKeyPattern = new JLabel(Localization.lang("Key pattern"));
    lblKeyPattern.setFont(f);
    con.gridx = 1;
    con.gridy = 0;
    con.gridheight = 1;
    con.fill = GridBagConstraints.HORIZONTAL;
    con.anchor = GridBagConstraints.WEST;
    con.insets = new Insets(5, 5, 10, 5);
    gbl.setConstraints(lblKeyPattern, con);
    pan.add(lblKeyPattern);
    con.gridy = 1;
    con.gridx = 0;
    JLabel lab = new JLabel(Localization.lang("Default pattern"));
    gbl.setConstraints(lab, con);
    pan.add(lab);
    con.gridx = 1;
    gbl.setConstraints(defaultPat, con);
    pan.add(defaultPat);
    con.insets = new Insets(5, 5, 10, 5);
    JButton btnDefault = new JButton(Localization.lang("Default"));
    btnDefault.addActionListener(e -> defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN)));
    con.gridx = 2;
    int y = 2;
    gbl.setConstraints(btnDefault, con);
    pan.add(btnDefault);
    BibDatabaseMode mode;
    // check mode of currently used DB
    if (panel != null) {
        mode = panel.getBibDatabaseContext().getMode();
    } else {
        // use preferences value if no DB is open
        mode = Globals.prefs.getDefaultBibDatabaseMode();
    }
    for (EntryType type : EntryTypes.getAllValues(mode)) {
        textFields.put(type.getName().toLowerCase(Locale.ROOT), addEntryType(pan, type, y));
        y++;
    }
    con.fill = GridBagConstraints.BOTH;
    con.gridx = 0;
    con.gridy = 1;
    con.gridwidth = 3;
    con.weightx = 1;
    con.weighty = 1;
    gbl.setConstraints(sp, con);
    add(sp);
    // A help button
    con.gridwidth = 1;
    con.gridx = 1;
    con.gridy = 2;
    con.fill = GridBagConstraints.HORIZONTAL;
    //
    con.weightx = 0;
    con.weighty = 0;
    con.anchor = GridBagConstraints.SOUTHEAST;
    con.insets = new Insets(0, 5, 0, 5);
    JButton hlb = new JButton(IconTheme.JabRefIcon.HELP.getSmallIcon());
    hlb.setToolTipText(Localization.lang("Help on key patterns"));
    gbl.setConstraints(hlb, con);
    add(hlb);
    hlb.addActionListener(help);
    // And finally a button to reset everything
    JButton btnDefaultAll = new JButton(Localization.lang("Reset all"));
    con.gridx = 2;
    con.gridy = 2;
    con.weightx = 1;
    con.weighty = 0;
    con.anchor = GridBagConstraints.SOUTHEAST;
    con.insets = new Insets(20, 5, 0, 5);
    gbl.setConstraints(btnDefaultAll, con);
    btnDefaultAll.addActionListener(e -> {
        for (JTextField field : textFields.values()) {
            field.setText("");
        }
        defaultPat.setText((String) Globals.prefs.defaults.get(JabRefPreferences.DEFAULT_BIBTEX_KEY_PATTERN));
    });
    add(btnDefaultAll);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) EntryType(org.jabref.model.entry.EntryType) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) Font(java.awt.Font)

Example 2 with BibDatabaseMode

use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.

the class SharedDatabaseUIManager method openNewSharedDatabaseTab.

/**
     * Opens a new shared database tab with the given {@link DBMSConnectionProperties}.
     *
     * @param dbmsConnectionProperties Connection data
     * @param raiseTab If <code>true</code> the new tab gets selected.
     * @return BasePanel which also used by {@link SaveDatabaseAction}
     */
public BasePanel openNewSharedDatabaseTab(DBMSConnectionProperties dbmsConnectionProperties) throws SQLException, DatabaseNotSupportedException, InvalidDBMSConnectionPropertiesException {
    JabRefFrame frame = JabRefGUI.getMainFrame();
    BibDatabaseMode selectedMode = Globals.prefs.getDefaultBibDatabaseMode();
    BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(new Defaults(selectedMode), DatabaseLocation.SHARED, Globals.prefs.getKeywordDelimiter(), Globals.prefs.getKeyPattern());
    dbmsSynchronizer = bibDatabaseContext.getDBMSSynchronizer();
    dbmsSynchronizer.openSharedDatabase(dbmsConnectionProperties);
    dbmsSynchronizer.registerListener(this);
    frame.output(Localization.lang("Connection_to_%0_server_established.", dbmsConnectionProperties.getType().toString()));
    return frame.addTab(bibDatabaseContext, true);
}
Also used : JabRefFrame(org.jabref.gui.JabRefFrame) Defaults(org.jabref.model.Defaults) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) BibDatabaseContext(org.jabref.model.database.BibDatabaseContext)

Example 3 with BibDatabaseMode

use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.

the class BibtexParserTest method integrationTestBiblatexMode.

@Test
public void integrationTestBiblatexMode() throws IOException {
    ParserResult result = parser.parse(new StringReader("@comment{jabref-meta: databaseType:biblatex;}"));
    Optional<BibDatabaseMode> mode = result.getMetaData().getMode();
    assertEquals(BibDatabaseMode.BIBLATEX, mode.get());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 4 with BibDatabaseMode

use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.

the class EntryCustomizationDialog method updateEntriesForChangedTypes.

private void updateEntriesForChangedTypes(List<String> actuallyChangedTypes) {
    for (BasePanel bp : frame.getBasePanelList()) {
        // get all affected entries
        List<BibEntry> filtered = bp.getDatabase().getEntries().stream().filter(entry -> actuallyChangedTypes.contains(entry.getType().toLowerCase(Locale.ENGLISH))).collect(Collectors.toList());
        // update all affected entries with new type
        filtered.forEach(entry -> EntryTypes.getType(entry.getType(), bibDatabaseMode).ifPresent(entry::setType));
    }
}
Also used : ListSelectionModel(javax.swing.ListSelectionModel) Arrays(java.util.Arrays) ActionListener(java.awt.event.ActionListener) StringUtil(org.jabref.model.strings.StringUtil) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) HashMap(java.util.HashMap) BasePanel(org.jabref.gui.BasePanel) ArrayList(java.util.ArrayList) GridLayout(java.awt.GridLayout) HashSet(java.util.HashSet) JabRefFrame(org.jabref.gui.JabRefFrame) CustomEntryType(org.jabref.model.entry.CustomEntryType) Locale(java.util.Locale) Map(java.util.Map) InternalBibtexFields(org.jabref.model.entry.InternalBibtexFields) ListDataEvent(javax.swing.event.ListDataEvent) AbstractTableModel(javax.swing.table.AbstractTableModel) Localization(org.jabref.logic.l10n.Localization) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ActionMap(javax.swing.ActionMap) JComponent(javax.swing.JComponent) EntryTypes(org.jabref.model.EntryTypes) JButton(javax.swing.JButton) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) BibEntry(org.jabref.model.entry.BibEntry) JList(javax.swing.JList) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) GridBagConstraints(java.awt.GridBagConstraints) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) Collectors(java.util.stream.Collectors) Globals(org.jabref.Globals) List(java.util.List) ListDataListener(javax.swing.event.ListDataListener) JabRefDialog(org.jabref.gui.JabRefDialog) AbstractAction(javax.swing.AbstractAction) Optional(java.util.Optional) EntryType(org.jabref.model.entry.EntryType) GridBagLayout(java.awt.GridBagLayout) InputMap(javax.swing.InputMap) ListSelectionListener(javax.swing.event.ListSelectionListener) JPanel(javax.swing.JPanel) KeyBinding(org.jabref.gui.keyboard.KeyBinding) BibEntry(org.jabref.model.entry.BibEntry) BasePanel(org.jabref.gui.BasePanel)

Example 5 with BibDatabaseMode

use of org.jabref.model.database.BibDatabaseMode in project jabref by JabRef.

the class CheckForNewEntryTypesAction method performAction.

@Override
public void performAction(BasePanel panel, ParserResult parserResult) {
    BibDatabaseMode mode = getBibDatabaseModeFromParserResult(parserResult);
    List<EntryType> typesToStore = determineEntryTypesToSave(panel, getListOfUnknownAndUnequalCustomizations(parserResult), mode);
    if (!typesToStore.isEmpty()) {
        typesToStore.forEach(type -> EntryTypes.addOrModifyCustomEntryType((CustomEntryType) type, mode));
        CustomEntryTypesManager.saveCustomEntryTypes(Globals.prefs);
    }
}
Also used : CustomEntryType(org.jabref.model.entry.CustomEntryType) EntryType(org.jabref.model.entry.EntryType) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) CustomEntryType(org.jabref.model.entry.CustomEntryType)

Aggregations

BibDatabaseMode (org.jabref.model.database.BibDatabaseMode)6 JabRefFrame (org.jabref.gui.JabRefFrame)3 EntryType (org.jabref.model.entry.EntryType)3 JButton (javax.swing.JButton)2 JPanel (javax.swing.JPanel)2 CustomEntryType (org.jabref.model.entry.CustomEntryType)2 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)1 BorderLayout (java.awt.BorderLayout)1 Container (java.awt.Container)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 GridLayout (java.awt.GridLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1