Mercurial > hg > ConflictEditor
changeset 36:8262e3a8ed6f
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.
author | dirk |
---|---|
date | Fri, 07 Oct 2011 05:55:30 +0200 |
parents | a3f88353554a |
children | 76b2dafcb1b4 |
files | conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditor.java |
diffstat | 1 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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(); - } }