// returns new selection private static int updateModel( @NotNull MyModel tableModel, @NotNull List<UsageNode> listOld, @NotNull List<UsageNode> listNew, int oldSelection) { UsageNode[] oa = listOld.toArray(new UsageNode[listOld.size()]); UsageNode[] na = listNew.toArray(new UsageNode[listNew.size()]); List<ModelDiff.Cmd> cmds = ModelDiff.createDiffCmds(tableModel, oa, na); int selection = oldSelection; if (cmds != null) { for (ModelDiff.Cmd cmd : cmds) { selection = cmd.translateSelection(selection); cmd.apply(); } } return selection; }