RelationTreeModel extends AbstractTreeTableModel implements ISemanticalRelationProvider { public TreePath addTemplateEntryToGroup(final TreePath groupPath) { final AssociateRole defaultHighWeight = new AssociateRole(HmxMessage.PREFERENCES_RELATION_DEFAULTROLE_HIGHWEIGHT.get(), true); final AssociateRole defaultLowWeight = new AssociateRole(HmxMessage.PREFERENCES_RELATION_DEFAULTROLE_LOWWEIGHT.get(), false); final RelationTemplate newTemplate = new RelationTemplate(defaultHighWeight, null, defaultLowWeight, ""); final List<UUID> parentGroup = this.relationGroups.get(groupPath.getLastPathComponent()); final UUID templateId = UUID.randomUUID(); parentGroup.add(templateId); this.relationTemplates.put(templateId, newTemplate); this.modelSupport.fireChildAdded(groupPath, parentGroup.size() - 1, templateId); return groupPath.pathByAddingChild(templateId); } RelationTreeModel(final ISemanticalRelationProvider relationProvider); @Override List<List<RelationTemplate>> provideRelationTemplates(); @Override Object getChild(final Object parent, final int index); @Override int getChildCount(final Object parent); @Override boolean isLeaf(final Object node); @Override int getIndexOfChild(final Object parent, final Object child); @Override int getColumnCount(); @Override String getColumnName(final int columnIndex); @Override Class<?> getColumnClass(final int columnIndex); @Override boolean isCellEditable(final Object node, final int columnIndex); @Override String getValueAt(final Object node, final int columnIndex); @Override void setValueAt(final Object value, final Object node, final int column); TreePath addGroupEntry(); RelationTemplate getTemplateAtPath(final TreePath path); TreePath addTemplateEntryToGroup(final TreePath groupPath); void updateTemplateEntry(final TreePath targetPath, final RelationTemplate newState); void moveEntry(final TreePath targetPath, final boolean moveDown); void removeEntry(final TreePath targetPath);  }
@Test public void testAddTemplateEntryToGroup() { final Object root = this.model.getRoot(); final Object groupNode1 = this.model.getChild(root, 0); final TreePath groupPath = new TreePath(new Object[] { root, groupNode1 }); final AssociateRole defaultHighWeight = new AssociateRole(HmxMessage.PREFERENCES_RELATION_DEFAULTROLE_HIGHWEIGHT.get(), true); final AssociateRole defaultLowWeight = new AssociateRole(HmxMessage.PREFERENCES_RELATION_DEFAULTROLE_LOWWEIGHT.get(), false); final RelationTemplate defaultTemplate = new RelationTemplate(defaultHighWeight, null, defaultLowWeight, ""); final TreePath newEntryPath = this.model.addTemplateEntryToGroup(groupPath); Assert.assertEquals(groupPath, newEntryPath.getParentPath()); Assert.assertEquals(defaultTemplate, this.model.getTemplateAtPath(newEntryPath)); }