IDEMPIERE-3179:record should move to editing mode when user is editing first field
just change move status to edit, don't change anything (ever don't update new value for this field)
This commit is contained in:
parent
5352aeee35
commit
c624d4ec7d
|
@ -32,10 +32,11 @@ import org.idempiere.fa.util.Util;
|
|||
*/
|
||||
public final class DataStatusEvent extends EventObject implements Serializable
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8126804905593738238L;
|
||||
private static final long serialVersionUID = -1988674163839245029L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -73,6 +74,10 @@ public final class DataStatusEvent extends EventObject implements Serializable
|
|||
private int m_changedColumn = -1;
|
||||
private String m_columnName = null;
|
||||
|
||||
// IDEMPIERE-1287:indicate case user just start edit field, want update status of toolbar button (like save button)
|
||||
// but don't want change anything (ever value of edit field)
|
||||
private boolean isInitEdit = false;
|
||||
|
||||
/** Created */
|
||||
public Timestamp Created = null;
|
||||
/** Created By */
|
||||
|
@ -352,4 +357,19 @@ public final class DataStatusEvent extends EventObject implements Serializable
|
|||
e.m_currentRow == m_currentRow;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return indicate this event is by user start edit this field but not yet complete edit
|
||||
*/
|
||||
public boolean isInitEdit() {
|
||||
return isInitEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param indicate this event is by user start edit this field but not yet complete edit
|
||||
*/
|
||||
public void setIsInitEdit(boolean isInitEdit) {
|
||||
this.isInitEdit = isInitEdit;
|
||||
}
|
||||
|
||||
} // DataStatusEvent
|
||||
|
|
|
@ -99,11 +99,12 @@ import org.compiere.util.ValueNamePair;
|
|||
public class GridTable extends AbstractTableModel
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3993077765244392901L;
|
||||
|
||||
private static final long serialVersionUID = -4982992333796276205L;
|
||||
|
||||
public static final String DATA_REFRESH_MESSAGE = "Refreshed";
|
||||
public static final String DATA_UPDATE_COPIED_MESSAGE = "UpdateCopied";
|
||||
public static final String DATA_INSERTED_MESSAGE = "Inserted";
|
||||
|
@ -1247,11 +1248,11 @@ public class GridTable extends AbstractTableModel
|
|||
*/
|
||||
public final void setValueAt (Object value, int row, int col)
|
||||
{
|
||||
setValueAt (value, row, col, false);
|
||||
setValueAt (value, row, col, false, false);
|
||||
} // setValueAt
|
||||
|
||||
/**
|
||||
* Set Value in data and update GridField.
|
||||
* call {@link #setValueAt(Object, int, int, boolean, boolean)} with isInitEdit = false
|
||||
* (called directly or from JTable.editingStopped())
|
||||
*
|
||||
* @param value value to assign to cell
|
||||
|
@ -1260,6 +1261,21 @@ public class GridTable extends AbstractTableModel
|
|||
* @param force force setting new value
|
||||
*/
|
||||
public final void setValueAt (Object value, int row, int col, boolean force)
|
||||
{
|
||||
setValueAt (value, row, col, force, false);
|
||||
} // setValueAt
|
||||
|
||||
/**
|
||||
* Set Value in data and update GridField.
|
||||
* (called directly or from JTable.editingStopped())
|
||||
*
|
||||
* @param value value to assign to cell
|
||||
* @param row row index of cell
|
||||
* @param col column index of cell
|
||||
* @param force force setting new value
|
||||
* @param isInitEdit indicate event rise by start edit a field. just want change status to edit, don't change anything else
|
||||
*/
|
||||
public final void setValueAt (Object value, int row, int col, boolean force, boolean isInitEdit)
|
||||
{
|
||||
// Can we edit?
|
||||
if (!m_open || m_readOnly // not accessible
|
||||
|
@ -1275,7 +1291,7 @@ public class GridTable extends AbstractTableModel
|
|||
|
||||
// Has anything changed?
|
||||
Object oldValue = getValueAt(row, col);
|
||||
if (!force && !isValueChanged(oldValue, value) )
|
||||
if (!force && !isInitEdit && !isValueChanged(oldValue, value) )
|
||||
{
|
||||
if (log.isLoggable(Level.FINEST)) log.finest("r=" + row + " c=" + col + " - New=" + value + "==Old=" + oldValue + " - Ignored");
|
||||
return;
|
||||
|
@ -1321,6 +1337,7 @@ public class GridTable extends AbstractTableModel
|
|||
field.setValue(value, m_inserting);
|
||||
// inform
|
||||
DataStatusEvent evt = createDSE();
|
||||
evt.setIsInitEdit(isInitEdit);
|
||||
evt.setChangedColumn(col, field.getColumnName());
|
||||
fireDataStatusChanged(evt);
|
||||
} // setValueAt
|
||||
|
|
|
@ -1228,7 +1228,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
public void dataStatusChanged(DataStatusEvent e)
|
||||
{
|
||||
//ignore background event
|
||||
if (Executions.getCurrent() == null) return;
|
||||
if (Executions.getCurrent() == null || e.isInitEdit()) return;
|
||||
|
||||
int col = e.getChangedColumn();
|
||||
if (logger.isLoggable(Level.CONFIG)) logger.config("(" + gridTab + ") Col=" + col + ": " + e.toString());
|
||||
|
|
|
@ -72,6 +72,8 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
|||
|
||||
public static final int MAX_DISPLAY_LENGTH = 35;
|
||||
|
||||
public static final String INIT_EDIT_EVENT = "onInitEdit";
|
||||
|
||||
protected GridField gridField;
|
||||
|
||||
protected GridTab gridTab;
|
||||
|
@ -182,7 +184,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
|||
|
||||
/**
|
||||
* Normal zk component just fire onChange event when user loss focus
|
||||
* call this method with true value let component fire event when user type first character
|
||||
* call this method with true value let component fire event when user type first character
|
||||
*
|
||||
* remark: editor set true for this method also need handle INIT_EDIT_EVENT to take effect,
|
||||
* can refer implement at {@link WStringEditor#onEvent(Event)}
|
||||
* @param isChangeEventWhenEditing
|
||||
*/
|
||||
public void setChangeEventWhenEditing (boolean isChangeEventWhenEditing){
|
||||
|
@ -290,6 +295,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
|
|||
component.addEventListener(event, this);
|
||||
}
|
||||
|
||||
component.addEventListener(INIT_EDIT_EVENT, this);
|
||||
component.setAttribute("idempiere.editor", this);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,16 +173,20 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
|||
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName()))
|
||||
boolean isStartEdit = INIT_EDIT_EVENT.equalsIgnoreCase (event.getName());
|
||||
if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName()) || isStartEdit)
|
||||
{
|
||||
String newValue = getComponent().getValue();
|
||||
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||
if (!isStartEdit && oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||
return;
|
||||
}
|
||||
if (oldValue == null && newValue == null) {
|
||||
if (!isStartEdit && oldValue == null && newValue == null) {
|
||||
return;
|
||||
}
|
||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||
|
||||
changeEvent.setIsInitEdit(isStartEdit);
|
||||
|
||||
super.fireValueChange(changeEvent);
|
||||
oldValue = getComponent().getValue(); // IDEMPIERE-963 - check again the value could be changed by callout
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@ public class ValueChangeEvent
|
|||
* Previous value for property. May be null if not known.
|
||||
*/
|
||||
private Object oldValue;
|
||||
|
||||
// IDEMPIERE-1287:indicate case user just start edit field, want update status of toolbar button (like save button)
|
||||
// but don't want change anything (ever value of edit field)
|
||||
private boolean isInitEdit = false;
|
||||
|
||||
public ValueChangeEvent(Object source, String propertyName,
|
||||
Object oldValue, Object newValue)
|
||||
|
@ -74,4 +78,18 @@ public class ValueChangeEvent
|
|||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return indicate this event is by user start edit this field but not yet complete edit
|
||||
*/
|
||||
public boolean isInitEdit() {
|
||||
return isInitEdit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param indicate this event is by user start edit this field but not yet complete edit
|
||||
*/
|
||||
public void setIsInitEdit(boolean isInitEdit) {
|
||||
this.isInitEdit = isInitEdit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,10 @@ public class GridTabDataBinder implements ValueChangeListener {
|
|||
throw new IllegalArgumentException("Multiple Selection values not available for this field. " + e.getPropertyName());
|
||||
}
|
||||
|
||||
mTable.setValueAt (newValue, row, col);
|
||||
if (e.isInitEdit())
|
||||
mTable.setValueAt (newValue, row, col, false, true);
|
||||
else
|
||||
mTable.setValueAt (newValue, row, col);
|
||||
// Force Callout
|
||||
if ( e.getPropertyName().equals("S_ResourceAssignment_ID") )
|
||||
{
|
||||
|
|
|
@ -24,6 +24,12 @@ Copyright (C) 2007 Ashley G Ramdass.
|
|||
// just sent fake event when control is textfield and value is not yet sync to server
|
||||
if (wgt.$instanceof(zul.inp.Textbox) && wgt.$n().value != wgt.getText())
|
||||
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onChange',{"value":wgt.$n().value}));
|
||||
},
|
||||
|
||||
fireOnInitEdit: function (wgt) {
|
||||
// sent even to indicate field is start edit, this event sent new value to server but now don't use this data.
|
||||
if (wgt.$instanceof(zul.inp.Textbox))
|
||||
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onInitEdit',{"value":wgt.$n().value}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -74,7 +80,8 @@ Copyright (C) 2007 Ashley G Ramdass.
|
|||
var isEditting = winLayoutWg.get ("isEditting");
|
||||
// winLayoutWg should cache to improve perfomance
|
||||
if (isEditting == "false"){
|
||||
id.zk.Extend.fakeOnchange (this);//fire change event to move to edit
|
||||
winLayoutWg.set ("isEditting", "true");
|
||||
id.zk.Extend.fireOnInitEdit (this);//fire change event to move to edit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue