RelationTreeModel extends AbstractTreeTableModel implements ISemanticalRelationProvider { @Override public boolean isCellEditable(final Object node, final int columnIndex) { if (!(node instanceof UUID)) { return false; } final List<UUID> siblings; switch (columnIndex) { case 2: return this.relationGroups.containsKey(node); case 3: siblings = this.getSiblings(node); return siblings != null && siblings.indexOf(node) > 0; case 4: siblings = this.getSiblings(node); return siblings != null && siblings.indexOf(node) + 1 < siblings.size(); case 5: return true; default: return false; } } 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 testIsCellEditable() { final Object root = this.model.getRoot(); Assert.assertFalse(this.model.isCellEditable(root, 0)); Assert.assertFalse(this.model.isCellEditable(root, 1)); Assert.assertFalse(this.model.isCellEditable(root, 2)); Assert.assertFalse(this.model.isCellEditable(root, 3)); Assert.assertFalse(this.model.isCellEditable(root, 4)); Assert.assertFalse(this.model.isCellEditable(root, 5)); final Object groupNode1 = this.model.getChild(root, 0); Assert.assertFalse(this.model.isCellEditable(groupNode1, 0)); Assert.assertFalse(this.model.isCellEditable(groupNode1, 1)); Assert.assertTrue(this.model.isCellEditable(groupNode1, 2)); Assert.assertFalse(this.model.isCellEditable(groupNode1, 3)); Assert.assertTrue(this.model.isCellEditable(groupNode1, 4)); Assert.assertTrue(this.model.isCellEditable(groupNode1, 5)); final Object groupNode2 = this.model.getChild(root, 1); Assert.assertFalse(this.model.isCellEditable(groupNode2, 0)); Assert.assertFalse(this.model.isCellEditable(groupNode2, 1)); Assert.assertTrue(this.model.isCellEditable(groupNode2, 2)); Assert.assertTrue(this.model.isCellEditable(groupNode2, 3)); Assert.assertTrue(this.model.isCellEditable(groupNode2, 4)); Assert.assertTrue(this.model.isCellEditable(groupNode2, 5)); final Object groupNode3 = this.model.getChild(root, 2); Assert.assertFalse(this.model.isCellEditable(groupNode3, 0)); Assert.assertFalse(this.model.isCellEditable(groupNode3, 1)); Assert.assertTrue(this.model.isCellEditable(groupNode3, 2)); Assert.assertTrue(this.model.isCellEditable(groupNode3, 3)); Assert.assertFalse(this.model.isCellEditable(groupNode3, 4)); Assert.assertTrue(this.model.isCellEditable(groupNode3, 5)); final Object childNodeC1 = this.model.getChild(groupNode3, 0); Assert.assertFalse(this.model.isCellEditable(childNodeC1, 0)); Assert.assertFalse(this.model.isCellEditable(childNodeC1, 1)); Assert.assertFalse(this.model.isCellEditable(childNodeC1, 2)); Assert.assertFalse(this.model.isCellEditable(childNodeC1, 3)); Assert.assertTrue(this.model.isCellEditable(childNodeC1, 4)); Assert.assertTrue(this.model.isCellEditable(childNodeC1, 5)); final Object childNodeC2 = this.model.getChild(groupNode3, 1); Assert.assertFalse(this.model.isCellEditable(childNodeC2, 0)); Assert.assertFalse(this.model.isCellEditable(childNodeC2, 1)); Assert.assertFalse(this.model.isCellEditable(childNodeC2, 2)); Assert.assertTrue(this.model.isCellEditable(childNodeC2, 3)); Assert.assertTrue(this.model.isCellEditable(childNodeC2, 4)); Assert.assertTrue(this.model.isCellEditable(childNodeC2, 5)); final Object childNodeC4 = this.model.getChild(groupNode3, 3); Assert.assertFalse(this.model.isCellEditable(childNodeC4, 0)); Assert.assertFalse(this.model.isCellEditable(childNodeC4, 1)); Assert.assertFalse(this.model.isCellEditable(childNodeC4, 2)); Assert.assertTrue(this.model.isCellEditable(childNodeC4, 3)); Assert.assertFalse(this.model.isCellEditable(childNodeC4, 4)); Assert.assertTrue(this.model.isCellEditable(childNodeC4, 5)); }