Search in sources :

Example 16 with EntryType

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

the class EntryTypeDialog method createEntryGroupPanel.

private JPanel createEntryGroupPanel(String groupTitle, Collection<? extends EntryType> entries) {
    JPanel panel = new JPanel();
    GridBagLayout bagLayout = new GridBagLayout();
    panel.setLayout(bagLayout);
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(4, 4, 4, 4);
    // column count
    int col = 0;
    for (EntryType entryType : entries) {
        TypeButton entryButton = new TypeButton(entryType.getName(), entryType);
        entryButton.addActionListener(this);
        // Check if we should finish the row.
        col++;
        if (col == EntryTypeDialog.COLUMN) {
            col = 0;
            constraints.gridwidth = GridBagConstraints.REMAINDER;
        } else {
            constraints.gridwidth = 1;
        }
        bagLayout.setConstraints(entryButton, constraints);
        panel.add(entryButton);
    }
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), groupTitle));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) EntryType(org.jabref.model.entry.EntryType) GridBagLayout(java.awt.GridBagLayout)

Example 17 with EntryType

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

the class FindUnlinkedFilesDialog method startImport.

/**
     * This will start the import of all file of all selected nodes in this
     * dialogs tree view. <br>
     * <br>
     * The import itself will run in a seperate thread, whilst this dialog will
     * be showing a progress bar, until the thread has finished its work. <br>
     * <br>
     * When the import has finished, the {@link #importFinishedHandler(java.util.List)} is
     * invoked.
     */
private void startImport() {
    if (treeModel == null) {
        return;
    }
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    CheckableTreeNode root = (CheckableTreeNode) treeModel.getRoot();
    final List<File> fileList = getFileListFromNode(root);
    if ((fileList == null) || fileList.isEmpty()) {
        return;
    }
    progressBarImporting.setVisible(true);
    labelImportingInfo.setVisible(true);
    buttonApply.setVisible(false);
    buttonClose.setVisible(false);
    disOrEnableDialog(false);
    labelImportingInfo.setEnabled(true);
    progressBarImporting.setMinimum(0);
    progressBarImporting.setMaximum(fileList.size());
    progressBarImporting.setValue(0);
    progressBarImporting.setString("");
    final EntryType entryType = ((BibtexEntryTypeWrapper) comboBoxEntryTypeSelection.getSelectedItem()).getEntryType();
    threadState.set(true);
    JabRefExecutorService.INSTANCE.execute(() -> {
        List<String> errors = new LinkedList<>();
        creatorManager.addEntriesFromFiles(fileList, databaseContext.getDatabase(), frame.getCurrentBasePanel(), entryType, checkBoxWhyIsThereNoGetSelectedStupidSwing, new ChangeListener() {

            int counter;

            @Override
            public void stateChanged(ChangeEvent e) {
                counter++;
                progressBarImporting.setValue(counter);
                progressBarImporting.setString(Localization.lang("%0 of %1", Integer.toString(counter), Integer.toString(progressBarImporting.getMaximum())));
            }
        }, errors);
        importFinishedHandler(errors);
    });
}
Also used : BibtexEntryType(org.jabref.model.entry.BibtexEntryType) EntryType(org.jabref.model.entry.EntryType) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) File(java.io.File) LinkedList(java.util.LinkedList)

Example 18 with EntryType

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

the class EntryEditor method setupFieldPanels.

private void setupFieldPanels() {
    tabbed.removeAll();
    tabs.clear();
    EntryType type = EntryTypes.getTypeOrDefault(entry.getType(), this.frame.getCurrentBasePanel().getBibDatabaseContext().getMode());
    // required fields
    addRequiredTab(type);
    // optional fields
    Set<String> deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet());
    Set<String> usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields);
    if ((type.getOptionalFields() != null) && !type.getOptionalFields().isEmpty()) {
        if (!frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) {
            addOptionalTab(type);
        } else {
            addOptionalTab(type);
            deprecatedFields.add(FieldName.YEAR);
            deprecatedFields.add(FieldName.MONTH);
            List<String> secondaryOptionalFields = type.getSecondaryOptionalFields();
            List<String> optionalFieldsNotPrimaryOrDeprecated = new ArrayList<>(secondaryOptionalFields);
            optionalFieldsNotPrimaryOrDeprecated.removeAll(deprecatedFields);
            // Get list of all optional fields of this entry and their aliases
            Set<String> optionalFieldsAndAliases = new HashSet<>();
            for (String field : type.getOptionalFields()) {
                optionalFieldsAndAliases.add(field);
                if (EntryConverter.FIELD_ALIASES_LTX_TO_TEX.containsKey(field)) {
                    optionalFieldsAndAliases.add(EntryConverter.FIELD_ALIASES_LTX_TO_TEX.get(field));
                }
            }
            // Get all optional fields which are deprecated
            usedOptionalFieldsDeprecated.retainAll(optionalFieldsAndAliases);
            // Get other deprecated fields
            usedOptionalFieldsDeprecated.add(FieldName.MONTH);
            // Add tabs
            EntryEditorTab optPan2 = new EntryEditorTab(frame, panel, optionalFieldsNotPrimaryOrDeprecated, this, false, true, Localization.lang("Optional fields 2"), entry);
            tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan2.getPane(), Localization.lang("Show optional fields"));
            tabs.add(optPan2);
            if (!usedOptionalFieldsDeprecated.isEmpty()) {
                EntryEditorTab optPan3;
                optPan3 = new EntryEditorTab(frame, panel, new ArrayList<>(usedOptionalFieldsDeprecated), this, false, true, Localization.lang("Deprecated fields"), entry);
                tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan3.getPane(), Localization.lang("Show deprecated BibTeX fields"));
                tabs.add(optPan3);
            }
        }
    }
    // other fields
    List<String> displayedFields = type.getAllFields().stream().map(String::toLowerCase).collect(Collectors.toList());
    List<String> otherFields = entry.getFieldNames().stream().map(String::toLowerCase).filter(f -> !displayedFields.contains(f)).collect(Collectors.toList());
    if (!usedOptionalFieldsDeprecated.isEmpty()) {
        otherFields.removeAll(usedOptionalFieldsDeprecated);
    }
    otherFields.remove(BibEntry.KEY_FIELD);
    otherFields.removeAll(Globals.prefs.getCustomTabFieldNames());
    if (!otherFields.isEmpty()) {
        addOtherTab(otherFields);
    }
    // general fields from preferences
    addGeneralTabs();
    // special tabs (like MathSciNet Reviews)
    addSpecialTabs();
    // pdf annotations tab
    addPDFAnnotationTab();
    //related articles
    if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_RECOMMENDATIONS)) {
        addRelatedArticlesTab();
    }
    // source tab
    addSourceTab();
}
Also used : FieldEditorFocusListener(org.jabref.gui.fieldeditors.FieldEditorFocusListener) MathSciNetId(org.jabref.model.entry.identifier.MathSciNetId) BibDatabase(org.jabref.model.database.BibDatabase) CheckBoxMessage(org.jabref.gui.util.component.CheckBoxMessage) IconTheme(org.jabref.gui.IconTheme) StackPane(javafx.scene.layout.StackPane) JFXPanel(javafx.embed.swing.JFXPanel) TextField(org.jabref.gui.fieldeditors.TextField) JabRefFrame(org.jabref.gui.JabRefFrame) ChangeListener(javax.swing.event.ChangeListener) KeyStroke(javax.swing.KeyStroke) ChangeEvent(javax.swing.event.ChangeEvent) JToolBar(javax.swing.JToolBar) HelpFile(org.jabref.logic.help.HelpFile) FieldEditor(org.jabref.gui.fieldeditors.FieldEditor) BibDatabaseMode(org.jabref.model.database.BibDatabaseMode) Set(java.util.Set) Component(java.awt.Component) Platform(javafx.application.Platform) AbstractAction(javax.swing.AbstractAction) BibtexKeyPatternUtil(org.jabref.logic.bibtexkeypattern.BibtexKeyPatternUtil) LogFactory(org.apache.commons.logging.LogFactory) UndoableKeyChange(org.jabref.gui.undo.UndoableKeyChange) JPanel(javax.swing.JPanel) Actions(org.jabref.gui.actions.Actions) NamedCompound(org.jabref.gui.undo.NamedCompound) AutoCompleter(org.jabref.logic.autocompleter.AutoCompleter) TypedBibEntry(org.jabref.logic.TypedBibEntry) LocalDateTime(java.time.LocalDateTime) LatexFieldFormatter(org.jabref.logic.bibtex.LatexFieldFormatter) Action(javax.swing.Action) ArrayList(java.util.ArrayList) InvalidFieldValueException(org.jabref.logic.bibtex.InvalidFieldValueException) AWTKeyStroke(java.awt.AWTKeyStroke) JTabbedPane(javax.swing.JTabbedPane) BibtexParser(org.jabref.logic.importer.fileformat.BibtexParser) ActionMap(javax.swing.ActionMap) JButton(javax.swing.JButton) ChangeEntryTypeMenu(org.jabref.gui.menus.ChangeEntryTypeMenu) StringWriter(java.io.StringWriter) IOException(java.io.IOException) BibEntryWriter(org.jabref.logic.bibtex.BibEntryWriter) MouseEvent(java.awt.event.MouseEvent) Globals(org.jabref.Globals) JScrollPane(javax.swing.JScrollPane) KeyboardFocusManager(java.awt.KeyboardFocusManager) GUIGlobals(org.jabref.gui.GUIGlobals) StringReader(java.io.StringReader) UndoableChangeType(org.jabref.gui.undo.UndoableChangeType) UndoableFieldChange(org.jabref.gui.undo.UndoableFieldChange) JTextArea(javax.swing.JTextArea) EntryContainer(org.jabref.gui.EntryContainer) SearchQueryHighlightListener(org.jabref.logic.search.SearchQueryHighlightListener) EntryFetchAndMergeWorker(org.jabref.gui.mergeentries.EntryFetchAndMergeWorker) RenderingHints(java.awt.RenderingHints) WriteXMPEntryEditorAction(org.jabref.gui.externalfiles.WriteXMPEntryEditorAction) JabRefPreferences(org.jabref.preferences.JabRefPreferences) BasePanel(org.jabref.gui.BasePanel) FieldChangedEvent(org.jabref.model.entry.event.FieldChangedEvent) EntryBasedFetcher(org.jabref.logic.importer.EntryBasedFetcher) VerticalLabelUI(org.jabref.gui.util.component.VerticalLabelUI) InternalBibtexFields(org.jabref.model.entry.InternalBibtexFields) MouseAdapter(java.awt.event.MouseAdapter) UpdateField(org.jabref.logic.util.UpdateField) UndoableRemoveEntry(org.jabref.gui.undo.UndoableRemoveEntry) BorderLayout(java.awt.BorderLayout) ScrollPaneConstants(javax.swing.ScrollPaneConstants) EntryTypes(org.jabref.model.EntryTypes) Font(java.awt.Font) BibEntry(org.jabref.model.entry.BibEntry) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) FieldChange(org.jabref.model.FieldChange) List(java.util.List) Graphics(java.awt.Graphics) Entry(java.util.Map.Entry) Optional(java.util.Optional) OSXCompatibleToolbar(org.jabref.gui.OSXCompatibleToolbar) JTextAreaWithHighlighting(org.jabref.gui.fieldeditors.JTextAreaWithHighlighting) KeyBinding(org.jabref.gui.keyboard.KeyBinding) HelpAction(org.jabref.gui.help.HelpAction) Scene(javafx.scene.Scene) FieldProperty(org.jabref.model.entry.FieldProperty) Insets(java.awt.Insets) EntryConverter(org.jabref.model.entry.EntryConverter) FieldName(org.jabref.model.entry.FieldName) SpecialFieldUpdateListener(org.jabref.gui.specialfields.SpecialFieldUpdateListener) SwingConstants(javax.swing.SwingConstants) HashSet(java.util.HashSet) FocusAdapter(java.awt.event.FocusAdapter) SwingUtilities(javax.swing.SwingUtilities) JMenuItem(javax.swing.JMenuItem) Graphics2D(java.awt.Graphics2D) Localization(org.jabref.logic.l10n.Localization) Subscribe(com.google.common.eventbus.Subscribe) JComponent(javax.swing.JComponent) ParserResult(org.jabref.logic.importer.ParserResult) JPopupMenu(javax.swing.JPopupMenu) FieldContentSelector(org.jabref.gui.contentselector.FieldContentSelector) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) JTextComponent(javax.swing.text.JTextComponent) FocusEvent(java.awt.event.FocusEvent) JLabel(javax.swing.JLabel) DateTimeFormatter(java.time.format.DateTimeFormatter) Log(org.apache.commons.logging.Log) EntryType(org.jabref.model.entry.EntryType) InputMap(javax.swing.InputMap) WebFetchers(org.jabref.logic.importer.WebFetchers) EntryType(org.jabref.model.entry.EntryType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 19 with EntryType

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

the class CheckForNewEntryTypesAction method createCheckBoxPanel.

private JPanel createCheckBoxPanel(List<EntryType> newTypes, List<EntryType> differentCustomizations, Map<EntryType, JCheckBox> typeCheckBoxMap) {
    JPanel checkboxPanel = new JPanel();
    checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.PAGE_AXIS));
    JLabel customFoundLabel = new JLabel(Localization.lang("Custom entry types found in file") + ".");
    Font boldStandardFont = new Font(customFoundLabel.getFont().getFontName(), Font.BOLD, customFoundLabel.getFont().getSize());
    customFoundLabel.setFont(boldStandardFont);
    checkboxPanel.add(customFoundLabel);
    JLabel selectLabel = new JLabel(Localization.lang("Select all customized types to be stored in local preferences") + ":");
    selectLabel.setFont(boldStandardFont);
    checkboxPanel.add(selectLabel);
    checkboxPanel.add(new JLabel(" "));
    // add all unknown types:
    if (!newTypes.isEmpty()) {
        checkboxPanel.add(new JLabel(Localization.lang("Currently unknown") + ":"));
        for (EntryType type : newTypes) {
            JCheckBox box = new JCheckBox(type.getName(), true);
            checkboxPanel.add(box);
            typeCheckBoxMap.put(type, box);
        }
    }
    // add all different customizations
    if (!differentCustomizations.isEmpty()) {
        checkboxPanel.add(new JLabel(Localization.lang("Different customization, current settings will be overwritten") + ":"));
        for (EntryType type : differentCustomizations) {
            JCheckBox box = new JCheckBox(type.getName(), true);
            checkboxPanel.add(box);
            typeCheckBoxMap.put(type, box);
        }
    }
    return checkboxPanel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) CustomEntryType(org.jabref.model.entry.CustomEntryType) EntryType(org.jabref.model.entry.EntryType) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Font(java.awt.Font)

Example 20 with EntryType

use of org.jabref.model.entry.EntryType 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

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