use of org.jabref.model.groups.AbstractGroup in project jabref by JabRef.
the class GroupsParserTest method fromStringParsesAutomaticKeywordGroup.
@Test
public void fromStringParsesAutomaticKeywordGroup() throws Exception {
AutomaticGroup expected = new AutomaticKeywordGroup("myAutomaticGroup", GroupHierarchyType.INDEPENDENT, "keywords", ',', '>');
AbstractGroup parsed = GroupsParser.fromString("AutomaticKeywordGroup:myAutomaticGroup;0;keywords;,;>;1;;;;", ',');
assertEquals(expected, parsed);
}
use of org.jabref.model.groups.AbstractGroup in project jabref by JabRef.
the class GroupsParserTest method fromStringParsesExplicitGroupWithIconAndDesrcitpion.
@Test
public void fromStringParsesExplicitGroupWithIconAndDesrcitpion() throws Exception {
ExplicitGroup expected = new ExplicitGroup("myExplicitGroup", GroupHierarchyType.INDEPENDENT, ',');
expected.setIconCode("test icon");
expected.setExpanded(true);
expected.setColor(Color.ALICEBLUE);
expected.setDescription("test description");
AbstractGroup parsed = GroupsParser.fromString("StaticGroup:myExplicitGroup;0;1;0xf0f8ffff;test icon;test description;", ',');
assertEquals(expected, parsed);
}
use of org.jabref.model.groups.AbstractGroup in project jabref by JabRef.
the class GroupsParserTest method fromStringParsesExplicitGroupWithEscapedCharacterInName.
@Test
public // For https://github.com/JabRef/jabref/issues/1681
void fromStringParsesExplicitGroupWithEscapedCharacterInName() throws Exception {
ExplicitGroup expected = new ExplicitGroup("B{\\\"{o}}hmer", GroupHierarchyType.INDEPENDENT, ',');
AbstractGroup parsed = GroupsParser.fromString("ExplicitGroup:B{\\\\\"{o}}hmer;0;", ',');
assertEquals(expected, parsed);
}
use of org.jabref.model.groups.AbstractGroup in project jabref by JabRef.
the class GroupsParser method importGroups.
public static GroupTreeNode importGroups(List<String> orderedData, Character keywordSeparator) throws ParseException {
try {
GroupTreeNode cursor = null;
GroupTreeNode root = null;
for (String string : orderedData) {
// This allows to read databases that have been modified by, e.g., BibDesk
string = string.trim();
if (string.isEmpty()) {
continue;
}
int spaceIndex = string.indexOf(' ');
if (spaceIndex <= 0) {
throw new ParseException("Expected \"" + string + "\" to contain whitespace");
}
int level = Integer.parseInt(string.substring(0, spaceIndex));
AbstractGroup group = GroupsParser.fromString(string.substring(spaceIndex + 1), keywordSeparator);
GroupTreeNode newNode = GroupTreeNode.fromGroup(group);
if (cursor == null) {
// create new root
cursor = newNode;
root = cursor;
} else {
// insert at desired location
while ((level <= cursor.getLevel()) && (cursor.getParent().isPresent())) {
cursor = cursor.getParent().get();
}
cursor.addChild(newNode);
cursor = newNode;
}
}
return root;
} catch (ParseException e) {
throw new ParseException(Localization.lang("Group tree could not be parsed. If you save the BibTeX library, all groups will be lost."), e);
}
}
use of org.jabref.model.groups.AbstractGroup in project jabref by JabRef.
the class GroupTreeViewModel method addNewSubgroup.
/**
* Opens "New Group Dialog" and add the resulting group to the specified group
*/
public void addNewSubgroup(GroupNodeViewModel parent) {
SwingUtilities.invokeLater(() -> {
Optional<AbstractGroup> newGroup = dialogService.showCustomDialogAndWait(new GroupDialog());
newGroup.ifPresent(group -> {
GroupTreeNode newGroupNode = parent.addSubgroup(group);
dialogService.notify(Localization.lang("Added group \"%0\".", group.getName()));
});
});
}
Aggregations