Search in sources :

Example 11 with ValueChangeEvent

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;
    }
}
Also used : ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 12 with ValueChangeEvent

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;
    }
}
Also used : ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 13 with ValueChangeEvent

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;
    }
}
Also used : ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) BigDecimal(java.math.BigDecimal)

Example 14 with ValueChangeEvent

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);
        }
    }
}
Also used : ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) WLocationDialog(org.adempiere.webui.window.WLocationDialog)

Example 15 with ValueChangeEvent

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);
    }
}
Also used : ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent)

Aggregations

ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)25 Timestamp (java.sql.Timestamp)3 Date (java.util.Date)3 WTableModelEvent (org.adempiere.webui.event.WTableModelEvent)3 Event (org.zkoss.zk.ui.event.Event)3 WPAttributeEditor (org.adempiere.webui.editor.WPAttributeEditor)2 WSearchEditor (org.adempiere.webui.editor.WSearchEditor)2 MProduct (org.compiere.model.MProduct)2 Point (java.awt.Point)1 BigDecimal (java.math.BigDecimal)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 ValueChangeListener (org.adempiere.exceptions.ValueChangeListener)1 WDateEditor (org.adempiere.webui.editor.WDateEditor)1 WTableDirEditor (org.adempiere.webui.editor.WTableDirEditor)1 InfoPAttributePanel (org.adempiere.webui.panel.InfoPAttributePanel)1 InfoProductPanel (org.adempiere.webui.panel.InfoProductPanel)1 InfoSchedule (org.adempiere.webui.window.InfoSchedule)1 WAccountDialog (org.adempiere.webui.window.WAccountDialog)1