Search in sources :

Example 21 with EntryType

use of org.jabref.model.entry.EntryType in project jabref by JabRef.

the class MainTable method getCellStatus.

private CellRendererMode getCellStatus(int row, int col, boolean checkResolved) {
    try {
        BibEntry be = getEntryAt(row);
        if (checkResolved && tableFormat.getTableColumn(col).isResolved(be)) {
            return CellRendererMode.RESOLVED;
        }
        Optional<EntryType> type = EntryTypes.getType(be.getType(), panel.getBibDatabaseContext().getMode());
        if (type.isPresent()) {
            String columnName = getColumnName(col).toLowerCase(Locale.ROOT);
            if (columnName.equals(BibEntry.KEY_FIELD) || type.get().getRequiredFieldsFlat().contains(columnName)) {
                return CellRendererMode.REQUIRED;
            }
            if (type.get().getOptionalFields().contains(columnName)) {
                return CellRendererMode.OPTIONAL;
            }
        }
        return CellRendererMode.OTHER;
    } catch (NullPointerException ex) {
        return CellRendererMode.OTHER;
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) TypedBibEntry(org.jabref.logic.TypedBibEntry) EntryType(org.jabref.model.entry.EntryType)

Example 22 with EntryType

use of org.jabref.model.entry.EntryType in project jabref by JabRef.

the class ChangeEntryTypeMenu method populateChangeEntryTypeMenu.

/**
     * Remove all types from the menu. Then cycle through all available
     * types, and add them.
     */
private void populateChangeEntryTypeMenu(JMenu menu, BasePanel panel) {
    menu.removeAll();
    // biblatex?
    if (panel.getBibDatabaseContext().isBiblatexMode()) {
        for (EntryType type : EntryTypes.getAllValues(BibDatabaseMode.BIBLATEX)) {
            menu.add(new ChangeTypeAction(type, panel));
        }
        List<EntryType> customTypes = EntryTypes.getAllCustomTypes(BibDatabaseMode.BIBLATEX);
        if (!customTypes.isEmpty()) {
            menu.addSeparator();
            // custom types
            createEntryTypeSection(panel, menu, "Custom Entries", customTypes);
        }
    } else {
        // Bibtex
        createEntryTypeSection(panel, menu, "BibTeX Entries", BibtexEntryTypes.ALL);
        menu.addSeparator();
        // ieeetran
        createEntryTypeSection(panel, menu, "IEEETran Entries", IEEETranEntryTypes.ALL);
        List<EntryType> customTypes = EntryTypes.getAllCustomTypes(BibDatabaseMode.BIBTEX);
        if (!customTypes.isEmpty()) {
            menu.addSeparator();
            // custom types
            createEntryTypeSection(panel, menu, "Custom Entries", customTypes);
        }
    }
}
Also used : EntryType(org.jabref.model.entry.EntryType) ChangeTypeAction(org.jabref.gui.actions.ChangeTypeAction)

Aggregations

EntryType (org.jabref.model.entry.EntryType)22 ArrayList (java.util.ArrayList)8 BibEntry (org.jabref.model.entry.BibEntry)8 JPanel (javax.swing.JPanel)6 IOException (java.io.IOException)5 CustomEntryType (org.jabref.model.entry.CustomEntryType)5 Font (java.awt.Font)4 ParserResult (org.jabref.logic.importer.ParserResult)4 Insets (java.awt.Insets)3 JLabel (javax.swing.JLabel)3 StringReader (java.io.StringReader)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 ChangeEvent (javax.swing.event.ChangeEvent)2 ChangeListener (javax.swing.event.ChangeListener)2 EntryTypeDialog (org.jabref.gui.EntryTypeDialog)2 UndoableInsertEntry (org.jabref.gui.undo.UndoableInsertEntry)2 TypedBibEntry (org.jabref.logic.TypedBibEntry)2