From 11c11d0f7d9e65c74614ab0fb0bbc36205fff384 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 16 Jun 2022 14:52:44 +0200 Subject: [PATCH] SEBSERV-185 implemented --- .../examconfig/impl/TableFieldBuilder.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java index 642dc79a..9b529c7b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/TableFieldBuilder.java @@ -150,8 +150,19 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder { private void deleteRow(final int selectionIndex) { this.control.remove(selectionIndex); this.values.remove(selectionIndex); + try { + if (this.values.size() > selectionIndex) { + this.control.select(selectionIndex); + } else { + this.control.select(this.values.size() - 1); + } + this.control.showSelection(); + } catch (final Exception e) { + // ignore auto selection error + } // send new values to web-service - this.tableContext.getValueChangeListener() + this.tableContext + .getValueChangeListener() .tableChanged(extractTableValue(this.values)); } @@ -168,6 +179,12 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder { this.values.add(rowValues); addTableRow(this.values.size() - 1, rowValues); this.control.layout(); + try { + this.control.select(index); + this.control.showSelection(); + } catch (final Exception e) { + // ignore auto selection error + } // send new values to web-service this.tableContext.getValueChangeListener() .tableChanged(extractTableValue(this.values));