LanguageTreeModel extends AbstractTreeTableModel { TreePath addModelRowClone(final TreePath path) { final LanguageModel originalModel = this.languageModels.get(path.getLastPathComponent()); final UUID cloneReference = UUID.randomUUID(); this.languageModels.put(cloneReference, originalModel.clone()); final TreePath rootPath = new TreePath(this.getRoot()); this.modelSupport.fireChildAdded(rootPath, this.languageModels.size() - 1, cloneReference); return rootPath.pathByAddingChild(cloneReference); } LanguageTreeModel(final ILanguageOptionHandler options); @Override int getColumnCount(); @Override UUID getChild(final Object parentNode, final int index); @Override int getChildCount(final Object parentNode); @Override int getIndexOfChild(final Object parentNode, final Object childNode); @Override boolean isCellEditable(final Object node, final int columnIndex); @Override Object getValueAt(final Object node, final int columnIndex);  }
@Test public void testAddModelRowClone() { final UUID referenceSystemModelB = this.model.getChild(this.root, 1); final TreePath originalRowPath = new TreePath(new Object[] { this.root, referenceSystemModelB }); final TreePath newRowPath = this.model.addModelRowClone(originalRowPath); final LanguageModel languageOriginal = this.model.getModelForPath(originalRowPath); final LanguageModel languageClone = this.model.getModelForPath(newRowPath); Assert.assertNotSame(languageOriginal, languageClone); Assert.assertEquals(languageOriginal, languageClone); Assert.assertEquals(6, this.model.getChildCount(this.root)); }