use of org.adempiere.exceptions.ValueChangeEvent in project adempiere by adempiere.
the class WDateEditor method onEvent.
public void onEvent(Event event) {
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) {
Date date = getComponent().getValue();
Timestamp newValue = null;
if (date != null) {
newValue = new Timestamp(date.getTime());
}
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
if (oldValue == null && newValue == null) {
return;
}
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
}
use of org.adempiere.exceptions.ValueChangeEvent in project adempiere by adempiere.
the class WDatetimeEditor method onEvent.
public void onEvent(Event event) {
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) {
Date date = getComponent().getValue();
Timestamp newValue = null;
if (date != null) {
newValue = new Timestamp(date.getTime());
}
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
if (oldValue == null && newValue == null) {
return;
}
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
}
use of org.adempiere.exceptions.ValueChangeEvent in project adempiere by adempiere.
the class WNumberEditor method onEvent.
/**
* Event handler
* @param event
*/
public void onEvent(Event event) {
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()) || Events.ON_OK.equalsIgnoreCase(event.getName())) {
Object newValue = getComponent().getValue();
if (oldValue == null && newValue == null) {
return;
}
if (displayType == DisplayType.Integer) {
if (newValue != null && newValue instanceof BigDecimal) {
newValue = new Integer(((BigDecimal) newValue).intValue());
}
if (oldValue != null && oldValue instanceof BigDecimal) {
oldValue = new Integer(((BigDecimal) oldValue).intValue());
}
}
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
oldValue = newValue;
}
}
use of org.adempiere.exceptions.ValueChangeEvent in project adempiere by adempiere.
the class WLocationEditor method onEvent.
public void onEvent(Event event) throws Exception {
//
if ("onClick".equals(event.getName())) {
if (((Button) event.getTarget()).getName().equals("bUrl")) {
Env.startBrowser(DefaultContextProvider.GOOGLE_MAPS_URL_PREFIX + m_value.toString().replace(" ", "%"));
return;
} else {
log.config("actionPerformed - " + m_value);
WLocationDialog ld = new WLocationDialog(Msg.getMsg(Env.getCtx(), "Location"), m_value);
ld.setVisible(true);
AEnv.showWindow(ld);
m_value = ld.getValue();
//
if (!ld.isChanged())
return;
// Data Binding
int C_Location_ID = 0;
if (m_value != null)
C_Location_ID = m_value.getC_Location_ID();
Integer ii = new Integer(C_Location_ID);
// force Change - user does not realize that embedded object is already saved.
ValueChangeEvent valuechange = new ValueChangeEvent(this, getColumnName(), null, null);
// resets m_mLocation
fireValueChange(valuechange);
if (C_Location_ID != 0) {
ValueChangeEvent vc = new ValueChangeEvent(this, getColumnName(), null, ii);
fireValueChange(vc);
}
setValue(ii);
}
}
}
use of org.adempiere.exceptions.ValueChangeEvent in project adempiere by adempiere.
the class WLocatorEditor method setValue.
/**
* Set Value
* @param value value
* @param fire data binding
*/
private void setValue(Object value, boolean fire) {
if (value != null) {
m_mLocator.setOnly_Warehouse_ID(getOnly_Warehouse_ID());
m_mLocator.setOnly_Product_ID(getOnly_Product_ID());
if (!m_mLocator.isValid(value)) {
value = null;
gridField.setValue(null, false);
}
}
oldValue = m_value;
m_value = value;
// loads value
getComponent().setText(m_mLocator.getDisplay(value));
// Data Binding
if (fire) {
ValueChangeEvent val = new ValueChangeEvent(this, getColumnName(), oldValue, value);
fireValueChange(val);
}
}
Aggregations