Search in sources :

Example 6 with AllEntriesGroup

use of org.jabref.model.groups.AllEntriesGroup in project jabref by JabRef.

the class ImportInspectionDialog method insertNodes.

private void insertNodes(JMenu menu, GroupTreeNode node) {
    final AbstractAction action = getAction(node);
    if (node.getNumberOfChildren() == 0) {
        menu.add(action);
        if (action.isEnabled()) {
            menu.setEnabled(true);
        }
        return;
    }
    JMenu submenu;
    if (node.getGroup() instanceof AllEntriesGroup) {
        for (GroupTreeNode child : node.getChildren()) {
            insertNodes(menu, child);
        }
    } else {
        submenu = new JMenu('[' + node.getName() + ']');
        // setEnabled(true) is done above/below if at least one menu
        // entry (item or submenu) is enabled
        submenu.setEnabled(action.isEnabled());
        submenu.add(action);
        submenu.add(new JPopupMenu.Separator());
        for (GroupTreeNode child : node.getChildren()) {
            insertNodes(submenu, child);
        }
        menu.add(submenu);
        if (submenu.isEnabled()) {
            menu.setEnabled(true);
        }
    }
}
Also used : AllEntriesGroup(org.jabref.model.groups.AllEntriesGroup) GroupTreeNode(org.jabref.model.groups.GroupTreeNode) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JPopupMenu(javax.swing.JPopupMenu)

Example 7 with AllEntriesGroup

use of org.jabref.model.groups.AllEntriesGroup in project jabref by JabRef.

the class DefaultGroupsFactory method getAllEntriesGroup.

public static AllEntriesGroup getAllEntriesGroup() {
    AllEntriesGroup group = new AllEntriesGroup(Localization.lang("All entries"));
    group.setIconCode(ALL_ENTRIES_GROUP_DEFAULT_ICON);
    return group;
}
Also used : AllEntriesGroup(org.jabref.model.groups.AllEntriesGroup)

Example 8 with AllEntriesGroup

use of org.jabref.model.groups.AllEntriesGroup in project jabref by JabRef.

the class BibtexDatabaseWriterTest method writeGroupsAndEncoding.

@Test
public void writeGroupsAndEncoding() throws Exception {
    SavePreferences preferences = new SavePreferences().withEncoding(Charsets.US_ASCII);
    GroupTreeNode groupRoot = GroupTreeNode.fromGroup(new AllEntriesGroup(""));
    groupRoot.addChild(GroupTreeNode.fromGroup(new ExplicitGroup("test", GroupHierarchyType.INCLUDING, ',')));
    metaData.setGroups(groupRoot);
    StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), preferences);
    // @formatter:off
    assertEquals("% Encoding: US-ASCII" + OS.NEWLINE + 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
}
Also used : AllEntriesGroup(org.jabref.model.groups.AllEntriesGroup) GroupTreeNode(org.jabref.model.groups.GroupTreeNode) ExplicitGroup(org.jabref.model.groups.ExplicitGroup) Test(org.junit.Test)

Example 9 with AllEntriesGroup

use of org.jabref.model.groups.AllEntriesGroup in project jabref by JabRef.

the class GroupSerializerTest method serializeSingleAllEntriesGroup.

@Test
public void serializeSingleAllEntriesGroup() {
    AllEntriesGroup group = new AllEntriesGroup("");
    List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
    assertEquals(Collections.singletonList("0 AllEntriesGroup:"), serialization);
}
Also used : AllEntriesGroup(org.jabref.model.groups.AllEntriesGroup) GroupTreeNodeTest(org.jabref.model.groups.GroupTreeNodeTest) Test(org.junit.Test)

Aggregations

AllEntriesGroup (org.jabref.model.groups.AllEntriesGroup)9 Test (org.junit.Test)6 GroupTreeNode (org.jabref.model.groups.GroupTreeNode)5 ExplicitGroup (org.jabref.model.groups.ExplicitGroup)4 ParserResult (org.jabref.logic.importer.ParserResult)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 AbstractAction (javax.swing.AbstractAction)1 JMenu (javax.swing.JMenu)1 JPopupMenu (javax.swing.JPopupMenu)1 NamedCompound (org.jabref.gui.undo.NamedCompound)1 UndoableInsertEntry (org.jabref.gui.undo.UndoableInsertEntry)1 UndoableInsertString (org.jabref.gui.undo.UndoableInsertString)1 BibDatabase (org.jabref.model.database.BibDatabase)1 BibEntry (org.jabref.model.entry.BibEntry)1 BibtexString (org.jabref.model.entry.BibtexString)1 GroupTreeNodeTest (org.jabref.model.groups.GroupTreeNodeTest)1 RegexKeywordGroup (org.jabref.model.groups.RegexKeywordGroup)1 WordKeywordGroup (org.jabref.model.groups.WordKeywordGroup)1 ContentSelector (org.jabref.model.metadata.ContentSelector)1