Browse Source

Fix funky alias delete behaviour.

Change-Id: Ic4c38d8245f4a88d1b3d1ce4fdf9ecb1c620d1da
Reviewed-on: http://gerrit.dmdirc.com/3562
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
changes/62/3562/2
Greg Holmes 10 years ago
parent
commit
bfe40a2951

+ 12
- 0
src/com/dmdirc/addons/ui_swing/dialogs/aliases/AliasManagerLinker.java View File

@@ -94,6 +94,8 @@ public class AliasManagerLinker {
94 94
                 final int index = commandList.getSelectedRow();
95 95
                 if (index == -1) {
96 96
                     model.setSelectedAlias(Optional.<Alias>absent());
97
+                } else if (index >= commandModel.getRowCount()) {
98
+                    model.setSelectedAlias(Optional.fromNullable(commandModel.getValue(index - 1)));
97 99
                 } else {
98 100
                     model.setSelectedAlias(Optional.fromNullable(commandModel.getValue(index)));
99 101
                 }
@@ -141,6 +143,16 @@ public class AliasManagerLinker {
141 143
             public void propertyChange(final PropertyChangeEvent evt) {
142 144
                 if (evt.getOldValue() != null) {
143 145
                     commandModel.removeValue((Alias) evt.getOldValue());
146
+                    final int index = commandList.getSelectedRow();
147
+                    if (index == -1) {
148
+                        model.setSelectedAlias(Optional.<Alias>absent());
149
+                    } else if (index >= commandModel.getRowCount()) {
150
+                        model.setSelectedAlias(Optional.fromNullable(commandModel.
151
+                                getValue(index - 1)));
152
+                        commandList.getSelectionModel().setLeadSelectionIndex(index - 1);
153
+                    } else {
154
+                        model.setSelectedAlias(Optional.fromNullable(commandModel.getValue(index)));
155
+                    }
144 156
                 }
145 157
             }
146 158
         });

Loading…
Cancel
Save