diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java index 38fddb62f7..8d336baca0 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WNumberEditor.java @@ -17,6 +17,8 @@ package org.adempiere.webui.editor; +import java.math.BigDecimal; + import org.adempiere.webui.ValuePreference; import org.adempiere.webui.component.NumberBox; import org.adempiere.webui.event.ContextMenuEvent; @@ -66,7 +68,13 @@ public class WNumberEditor extends WEditor public void onEvent(Event event) { String newValue = getComponent().getValue(); - ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue); + BigDecimal oldNumber = null; + if (oldValue != null && oldValue.trim().length() > 0) + oldNumber = new BigDecimal(oldValue); + BigDecimal newNumber = null; + if (newValue != null && newValue.trim().length() > 0) + newNumber = new BigDecimal(newValue); + ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldNumber, newNumber); super.fireValueChange(changeEvent); oldValue = newValue; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index 46dafaa034..0a243318ab 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -531,11 +531,44 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To return true; } - if (curTabpanel.isEditing()) + if (curTab != null) { - FDialog.warn(curWindowNo, "Please save your changes before " + - "switching tabs!!!", title); - return false; + if (curTab.isSortTab()) + { + if (curTabpanel instanceof ADSortTab) + { + ((ADSortTab)curTabpanel).saveData(); + ((ADSortTab)curTabpanel).unregisterPanel(); + } + } + else if (curTab.needSave(true, false)) + { + if (curTab.needSave(true, true)) + { + // Automatic Save + if (Env.isAutoCommit(ctx, curWindowNo)) + { + if (!curTab.dataSave(true)) + { + // there is a problem, stop here + return false; + } + } + // explicitly ask when changing tabs + else if (FDialog.ask(curWindowNo, this.getComponent(), "SaveChanges?", curTab.getCommitWarning())) + { // yes we want to save + if (!curTab.dataSave(true)) + { + // there is a problem, stop here + return false; + } + } + else // Don't save + curTab.dataIgnore(); + } + else // new record, but nothing changed + curTab.dataIgnore(); + } // there is a change } if (!adTab.updateSelectedIndex(oldTabIndex, newTabIndex)) @@ -565,6 +598,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To curTabIndex = newTabIndex; curTabpanel = newTabpanel; + + if (curTabpanel instanceof ADSortTab) + { + ((ADSortTab)curTabpanel).registerAPanel(this); + } updateToolbar();