# HG changeset patch # User dirk # Date 1317959730 -7200 # Node ID 8262e3a8ed6f2ef24e4dd6998676ef376e524b62 # Parent a3f88353554ae8df8a26fb824174d09c5240afb6 do not use the selection index in conflict list from the event, get it from the list instead. If the selection is cleared in the list, the event will report a wrong index. diff -r a3f88353554a -r 8262e3a8ed6f conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java --- a/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java Fri Oct 07 05:41:53 2011 +0200 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java Fri Oct 07 05:55:30 2011 +0200 @@ -97,7 +97,7 @@ @Override protected void execute(int index) throws Exception { - selectConflictDocument(index); + selectConflictDocument(); } }; ExceptionHandlingListSelectionListener listener = new ExceptionHandlingListSelectionListener( @@ -210,7 +210,20 @@ _frame.getConflictsList().setModel(model); } - protected void selectConflictDocument(int index) throws Exception + protected void selectConflictDocument() throws Exception + { + int selectedIndex = _frame.getConflictsList().getSelectedIndex(); + if (selectedIndex > -1) + { + selectConflictDocument(selectedIndex); + } + else + { + deselectConflictDocument(); + } + } + + private void selectConflictDocument(int index) throws Exception { JsonNode conflictNode = (JsonNode)_frame.getConflictsList().getModel().getElementAt(index); _controller.setCurrentConflict(conflictNode); @@ -222,6 +235,12 @@ _frame.disableButtons(); } + private void deselectConflictDocument() + { + TableModel model = new DifferenceTableModel(); + _frame.getDifferencesTable().setModel(model); + } + protected void selectDifference(int index) { // the index that's passed in from the list selection event is wrong! @@ -270,8 +289,6 @@ { _controller.save(); - resetDifferencesTableModel(); - JsonNode resolvedConflict = _controller.getCurrentConflict(); ConflictsListModel conflictsModel = (ConflictsListModel)_frame.getConflictsList().getModel(); conflictsModel.remove(resolvedConflict); @@ -283,13 +300,4 @@ { _frame.getConflictsList().getSelectionModel().clearSelection(); } - - private void resetDifferencesTableModel() - { - _controller.setCurrentDifference(null); - - DifferenceTableModel model = new DifferenceTableModel(); - _frame.getDifferencesTable().setModel(model); - _frame.repaint(); - } }