From 3558d1bd5063a630f4d354b01f6aecf0f47ffa47 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Mon, 20 Oct 2014 11:00:30 +0200 Subject: [PATCH] =?UTF-8?q?Kdy=C5=BE=20je=20na=20po=C5=BEadavku=20v=C3=ADc?= =?UTF-8?q?=20polo=C5=BEek,=20tak=20=C5=BEe=20u=C5=BE=20se=20grid=20nevejd?= =?UTF-8?q?e=20do=20okna=20a=20p=C5=99id=C3=A1=20se=20polo=C5=BEka,=20tak?= =?UTF-8?q?=20grid=20odroluje=20na=20posledn=C3=AD=20p=C5=99id=C3=A1vanou?= =?UTF-8?q?=20polo=C5=BEku.=20Upravena=20aktualizace=20dat=20podle=20zm?= =?UTF-8?q?=C4=9Bn=20UI.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #158 --- .../bukova/isspst/data/RequirementItem.java | 17 ++++++++++++++++- .../orders/requirements/RequirementForm.java | 13 +++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/info/bukova/isspst/data/RequirementItem.java b/src/main/java/info/bukova/isspst/data/RequirementItem.java index b3d22d45..1b708cc8 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementItem.java +++ b/src/main/java/info/bukova/isspst/data/RequirementItem.java @@ -165,8 +165,23 @@ public class RequirementItem if (obj instanceof RequirementItem) { RequirementItem item = (RequirementItem)obj; + + int thisId = this.getId(); + int itemId = item.getId(); + boolean equalsId = (thisId == itemId); + + if (equalsId && (thisId == 0)) + { + // Při zadávání položek do gridu zatím nové položky nemají + // přiřazeno ID, takže se rozlišují podle reference + // Při hledání položky v seznamu nebo zjišťování indexu pak + // byly veškeré položky s ID = 0 a grid nevybíral aktivní + // položku správně, stejně tak nepřekresloval ani scrollbar + // a pod. + return super.equals(obj); + } - return (this.getId() == item.getId()); + return equalsId; } } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/RequirementForm.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/RequirementForm.java index 86288c26..cfb6409e 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/RequirementForm.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/RequirementForm.java @@ -162,7 +162,7 @@ public class RequirementForm extends FormViewModel } @GlobalCommand("insertSelectedItem") - @NotifyChange({ "syncItems", "selItemIndex" }) + @NotifyChange({ "syncItems", "selItemIndex", "selectedItem" }) public void insertSelectedItem(@BindingParam("selected") RequirementSubject selected, @BindingParam("window") Window window) { if (selected != null) @@ -198,7 +198,7 @@ public class RequirementForm extends FormViewModel } @Command - @NotifyChange({ "selectedItem", "syncItems" }) + @NotifyChange({ "selectedItem" }) public void recalculate(@BindingParam("form") SimpleForm form, @BindingParam("changed") String source) { if (this.selectedItem == null) @@ -222,7 +222,7 @@ public class RequirementForm extends FormViewModel } @Command - @NotifyChange({ "selectedItem", "syncItems" }) + @NotifyChange({ "selectedItem" }) public void onChangeGroup() { // Někdo změnil skupinu materiálu nebo služby @@ -253,7 +253,7 @@ public class RequirementForm extends FormViewModel } @Command - @NotifyChange({ "selectedItem", "syncItems" }) + @NotifyChange({ "syncItems", "selectedItem", "selItemIndex" }) public void addNewItem() { RequirementItem item = new RequirementItem(); @@ -268,8 +268,9 @@ public class RequirementForm extends FormViewModel item.setDescription(""); item.setMunit(new MUnitEmb()); - this.setSelectedItem(item); this.getDataBean().addItem(item); - this.setSelItemIndex(this.getDataBean().getItems().indexOf(item)); + + this.selItemIndex = this.getDataBean().getItems().indexOf(item); + this.selectedItem = item; } }