use of org.jabref.model.groups.ExplicitGroup in project jabref by JabRef.
the class GroupTreeNodeViewModel method getDescription.
public String getDescription() {
AbstractGroup group = node.getGroup();
String shortDescription = "";
boolean showDynamic = true;
if (group instanceof ExplicitGroup) {
shortDescription = GroupDescriptions.getShortDescriptionExplicitGroup((ExplicitGroup) group);
} else if (group instanceof KeywordGroup) {
shortDescription = GroupDescriptions.getShortDescriptionKeywordGroup((KeywordGroup) group, showDynamic);
} else if (group instanceof SearchGroup) {
shortDescription = GroupDescriptions.getShortDescription((SearchGroup) group, showDynamic);
} else {
shortDescription = GroupDescriptions.getShortDescriptionAllEntriesGroup();
}
return "<html>" + shortDescription + "</html>";
}
use of org.jabref.model.groups.ExplicitGroup in project jabref by JabRef.
the class AppendDatabaseAction method mergeFromBibtex.
private static void mergeFromBibtex(BasePanel panel, ParserResult parserResult, boolean importEntries, boolean importStrings, boolean importGroups, boolean importSelectorWords) throws KeyCollisionException {
BibDatabase fromDatabase = parserResult.getDatabase();
List<BibEntry> appendedEntries = new ArrayList<>();
List<BibEntry> originalEntries = new ArrayList<>();
BibDatabase database = panel.getDatabase();
NamedCompound ce = new NamedCompound(Localization.lang("Append library"));
MetaData meta = parserResult.getMetaData();
if (importEntries) {
// Add entries
boolean overwriteOwner = Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_OWNER);
boolean overwriteTimeStamp = Globals.prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP);
for (BibEntry originalEntry : fromDatabase.getEntries()) {
BibEntry entry = (BibEntry) originalEntry.clone();
UpdateField.setAutomaticFields(entry, overwriteOwner, overwriteTimeStamp, Globals.prefs.getUpdateFieldPreferences());
database.insertEntry(entry);
appendedEntries.add(entry);
originalEntries.add(originalEntry);
ce.addEdit(new UndoableInsertEntry(database, entry, panel));
}
}
if (importStrings) {
for (BibtexString bs : fromDatabase.getStringValues()) {
if (!database.hasStringLabel(bs.getName())) {
database.addString(bs);
ce.addEdit(new UndoableInsertString(panel, database, bs));
}
}
}
if (importGroups) {
meta.getGroups().ifPresent(newGroups -> {
if (newGroups.getGroup() instanceof AllEntriesGroup) {
try {
ExplicitGroup group = new ExplicitGroup("Imported", GroupHierarchyType.INDEPENDENT, Globals.prefs.getKeywordDelimiter());
newGroups.setGroup(group);
group.add(appendedEntries);
} catch (IllegalArgumentException e) {
LOGGER.error(e);
}
}
addGroups(newGroups, ce);
});
}
if (importSelectorWords) {
for (ContentSelector selector : meta.getContentSelectorList()) {
panel.getBibDatabaseContext().getMetaData().addContentSelector(selector);
}
}
ce.end();
panel.getUndoManager().addEdit(ce);
panel.markBaseChanged();
}
use of org.jabref.model.groups.ExplicitGroup in project jabref by JabRef.
the class ConvertLegacyExplicitGroups method getExplicitGroupsWithLegacyKeys.
private List<ExplicitGroup> getExplicitGroupsWithLegacyKeys(GroupTreeNode node) {
Objects.requireNonNull(node);
List<ExplicitGroup> findings = new ArrayList<>();
if (node.getGroup() instanceof ExplicitGroup) {
ExplicitGroup group = (ExplicitGroup) node.getGroup();
if (!group.getLegacyEntryKeys().isEmpty()) {
findings.add(group);
}
}
node.getChildren().forEach(child -> findings.addAll(getExplicitGroupsWithLegacyKeys(child)));
return findings;
}
use of org.jabref.model.groups.ExplicitGroup in project jabref by JabRef.
the class BibtexDatabaseWriterTest method writeGroups.
@Test
public void writeGroups() throws Exception {
GroupTreeNode groupRoot = GroupTreeNode.fromGroup(new AllEntriesGroup(""));
groupRoot.addSubgroup(new ExplicitGroup("test", GroupHierarchyType.INCLUDING, ','));
metaData.setGroups(groupRoot);
StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), new SavePreferences());
// @formatter:off
assertEquals(OS.NEWLINE + "@Comment{jabref-meta: grouping:" + OS.NEWLINE + "0 AllEntriesGroup:;" + OS.NEWLINE + "1 StaticGroup:test\\;2\\;1\\;\\;\\;\\;;" + OS.NEWLINE + "}" + OS.NEWLINE, session.getStringValue());
// @formatter:on
}
use of org.jabref.model.groups.ExplicitGroup in project jabref by JabRef.
the class GroupSerializerTest method serializeSingleExplicitGroupWithEscapedSlash.
@Test
public // For https://github.com/JabRef/jabref/issues/1681
void serializeSingleExplicitGroupWithEscapedSlash() {
ExplicitGroup group = new ExplicitGroup("B{\\\"{o}}hmer", GroupHierarchyType.INDEPENDENT, ',');
List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
assertEquals(Collections.singletonList("0 StaticGroup:B{\\\\\"{o}}hmer;0;1;;;;"), serialization);
}
Aggregations