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;
}
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);
});
}
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();
}
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;
}
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);
}
}
Aggregations