SynFunctionTreeModel extends AbstractTreeTableModel implements ISyntacticalFunctionProvider { public TreePath addTopLevelGroup() { final UUID childReference = UUID.randomUUID(); this.topLevelGrouping.put(childReference, new ArrayList<>(3)); final TreePath rootPath = new TreePath(this.getRoot()); this.modelSupport.fireChildAdded(rootPath, this.topLevelGrouping.size() - 1, childReference); return rootPath.pathByAddingChild(childReference); } SynFunctionTreeModel(); void reset(final ISyntacticalFunctionProvider provider); @Override List<List<AbstractSyntacticalFunctionElement>> provideFunctions(); @Override int getColumnCount(); @Override boolean isCellEditable(final Object reference, final int columnIndex); @Override Object getValueAt(final Object reference, final int columnIndex); @Override UUID getChild(final Object parentReference, final int childIndex); @Override int getChildCount(final Object parentReference); @Override int getIndexOfChild(final Object parentReference, final Object childReference); TreePath addSynFunctionRow(final TreePath parentPath); TreePath addGroupRow(final TreePath parentPath); TreePath addTopLevelGroup(); void moveEntry(final TreePath targetPath, final boolean moveDown); void removeEntry(final TreePath targetPath); void updatedRow(final TreePath updatedPath);  }
@Test public void testAddTopLevelGroup() { Assert.assertEquals(3, this.model.getChildCount(this.root)); final TreePath newEntry = this.model.addTopLevelGroup(); Assert.assertEquals(4, this.model.getChildCount(this.root)); final UUID newGroupNode = this.model.getChild(this.root, 3); Assert.assertEquals(new TreePath(new Object[] { this.root, newGroupNode }), newEntry); }