/** * Constructor. * @param field The basefield owner of this listener (usually null and set on setOwner()). * @param fldDest The destination field. * @param fldSource The source field. * @param bClearIfThisNull If this listener's owner is set to null, set the destination field to null. * @param bOnlyIfDestNull Move only if the destination field is null. */ public void init(BaseField field, Converter fldDest, Converter fldSource, boolean bClearIfThisNull, boolean bOnlyIfDestNull, boolean bDontMoveNull) { super.init(field); this.setRespondsToMode(DBConstants.INIT_MOVE, false); this.setRespondsToMode(DBConstants.READ_MOVE, false); // By default, only respond to screen moves m_fldDest = fldDest; m_fldSource = fldSource; m_bClearIfThisNull = bClearIfThisNull; m_bOnlyIfDestNull = bOnlyIfDestNull; m_bDontMoveNull = bDontMoveNull; } /**
/** * The Field has Changed. * Move the source field to the destination field. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { int iErrorCode = this.moveIt(bDisplayOption, iMoveMode); if (iErrorCode != DBConstants.NORMAL_RETURN) if (this.getOwner() != m_fldSource) if (this.getOwner() != m_fldDest) iErrorCode = DBConstants.NORMAL_RETURN; // If the source and dest are unrelated this this, don't return an error (and revert this field) if (iErrorCode == DBConstants.NORMAL_RETURN) iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode); return iErrorCode; } /**
/** * Constructor. * @param fldDest The destination field. * @param fldSource The source field. */ public MoveOnChangeHandler(Converter fldDest, Converter fldSource) { this(); this.init(null, fldDest, fldSource, true, false, false); } /**
/** * Override this to add record listeners and filters to every screen where this is the main record. * @param screen The screen these listeners will be in. */ public void addScreenListeners(RecordOwner screen) { super.addScreenListeners(screen); Record recCity = ((ReferenceField)this.getField(TourHeaderTransport.CITY_ID)).getReferenceRecord(); recCity.getField(City.CITY_CODE).addListener(new MainReadOnlyHandler(City.CITY_CODE_KEY)); this.getField(TourHeaderTransport.CITY_ID).addListener(new MoveOnChangeHandler(this.getField(TourHeaderTransport.CITY_CODE), recCity.getField(City.CITY_CODE))); this.getField(TourHeaderTransport.CITY_CODE).addListener(new MoveOnChangeHandler(recCity.getField(City.CITY_CODE), this.getField(TourHeaderTransport.CITY_CODE))); recCity = ((ReferenceField)this.getField(TourHeaderTransport.TO_CITY_ID)).getReferenceRecord(); recCity.getField(City.CITY_CODE).addListener(new MainReadOnlyHandler(City.CITY_CODE_KEY)); this.getField(TourHeaderTransport.TO_CITY_ID).addListener(new MoveOnChangeHandler(this.getField(TourHeaderTransport.TO_CITY_CODE), recCity.getField(City.CITY_CODE))); this.getField(TourHeaderTransport.TO_CITY_CODE).addListener(new MoveOnChangeHandler(recCity.getField(City.CITY_CODE), this.getField(TourHeaderTransport.TO_CITY_CODE))); }
|| (listener.getDestField() != recordKeyField)) this.addListener(new MoveOnChangeHandler(recordKeyField, null));
/** * Add behaviors to this session. */ public void addListeners() { super.addListeners(); Record recBooking = this.getRecord(Booking.BOOKING_FILE); this.getMainRecord().addListener(new SubFileFilter(recBooking)); BookingDetail recBookingDetail = (BookingDetail)this.getMainRecord(); Record recProduct = (Record)recBookingDetail.getProduct(); recBookingDetail.getField(BookingDetail.PRODUCT_ID).addListener(new ReadSecondaryHandler(recProduct)); Record recVendor = ((ReferenceField)recProduct.getField(Product.VENDOR_ID)).getReferenceRecord(this); recProduct.getField(Product.VENDOR_ID).addListener(new ReadSecondaryHandler(recVendor)); Record recCurrencys = ((ReferenceField)recVendor.getField(Vendor.CURRENCYS_ID)).getReferenceRecord(this); recVendor.getField(Vendor.CURRENCYS_ID).addListener(new ReadSecondaryHandler(recCurrencys)); // This code read the currency CODE into a virtual field for use in displays MoveOnChangeHandler moveListener = new MoveOnChangeHandler(recBookingDetail.getField(BookingDetail.CURRENCY_CODE), recCurrencys.getField(Currencys.CURRENCY_CODE)); moveListener.setRespondsToMode(DBConstants.INIT_MOVE, true); moveListener.setRespondsToMode(DBConstants.READ_MOVE, true); recBookingDetail.getField(BookingDetail.PRODUCT_ID).addListener(moveListener); }
/** * Do the physical move operation. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int moveIt(boolean bDisplayOption, int iMoveMode) { if (m_bDontMoveNull) if (m_fldSource.getLength() == 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; if (m_bClearIfThisNull) if (this.getOwner().getLength() == 0) // If this is null, clear the dest field return ((BaseField)m_fldDest.getField()).moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // Move dependent field to here if (m_bOnlyIfDestNull) if (m_fldDest.getLength() != 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; int iErrorCode = this.moveSourceToDest(bDisplayOption, iMoveMode); if (iErrorCode == DBConstants.NORMAL_RETURN) if (m_fldDest == m_fldSource) return ((BaseField)m_fldDest.getField()).handleFieldChanged(bDisplayOption, iMoveMode); // Special case, move to yourself (Just want to call .FieldChanged()) return iErrorCode; } /**
/** * Do the physical move operation. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int moveIt(boolean bDisplayOption, int iMoveMode) { if (m_convCheckMark != null) if (m_convCheckMark.getState() == false) return DBConstants.NORMAL_RETURN; // If check mark is false (or no check mark), don't move return super.moveIt(bDisplayOption, iMoveMode); } }
/** * Set the field that owns this listener. * @owner The field that this listener is being added to (if null, this listener is being removed). */ public void setOwner(ListenerOwner owner) { super.setOwner(owner); if (owner != null) { if (m_fldSource == null) m_fldSource = this.getOwner(); if ((m_fldDest != null) && (((BaseField)m_fldDest.getField()).getRecord() != null) && (((BaseField)m_fldDest.getField()).getRecord() != this.getOwner().getRecord())) ((BaseField)m_fldDest.getField()).getRecord().addListener(new FileRemoveBOnCloseHandler(this)); // Not same file, if target file closes, remove this listener! else if ((m_fldSource.getField() != null) && (((BaseField)m_fldSource.getField()).getRecord() != null) && (((BaseField)m_fldSource.getField()).getRecord() != this.getOwner().getRecord())) ((BaseField)m_fldSource.getField()).getRecord().addListener(new FileRemoveBOnCloseHandler(this)); // Not same file, if target file closes, remove this listener! } } /**
/** * Override this to add record listeners and filters to every screen where this is the main record. * @param screen The screen these listeners will be in. */ public void addScreenListeners(RecordOwner screen) { super.addScreenListeners(screen); Record recCity = ((ReferenceField)this.getField(TransportProduct.CITY_ID)).getReferenceRecord(); recCity.getField(City.CITY_CODE).addListener(new MainReadOnlyHandler(City.CITY_CODE_KEY)); this.getField(TransportProduct.CITY_ID).addListener(new MoveOnChangeHandler(this.getField(TransportProduct.CITY_CODE), recCity.getField(City.CITY_CODE))); this.getField(TransportProduct.CITY_CODE).addListener(new MoveOnChangeHandler(recCity.getField(City.CITY_CODE), this.getField(TransportProduct.CITY_CODE))); recCity = ((ReferenceField)this.getField(TransportProduct.TO_CITY_ID)).getReferenceRecord(); recCity.getField(City.CITY_CODE).addListener(new MainReadOnlyHandler(City.CITY_CODE_KEY)); this.getField(TransportProduct.TO_CITY_ID).addListener(new MoveOnChangeHandler(this.getField(TransportProduct.TO_CITY_CODE), recCity.getField(City.CITY_CODE))); this.getField(TransportProduct.TO_CITY_CODE).addListener(new MoveOnChangeHandler(recCity.getField(City.CITY_CODE), this.getField(TransportProduct.TO_CITY_CODE))); }
|| (listener.getDestField() != recordKeyField)) this.addListener(new MoveOnChangeHandler(recordKeyField, null));
MoveOnChangeHandler moveListener = new MoveOnChangeHandler(recBooking.getField(Booking.CURRENCY_CODE), recCurrencys.getField(Currencys.CURRENCY_CODE)); moveListener.setRespondsToMode(DBConstants.INIT_MOVE, true); moveListener.setRespondsToMode(DBConstants.READ_MOVE, true); recBooking.getField(Booking.CURRENCYS_ID).addListener(moveListener);
/** * Do the physical move operation. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int moveIt(boolean bDisplayOption, int iMoveMode) { if (m_bDontMoveNull) if (m_fldSource.getLength() == 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; if (m_bClearIfThisNull) if (this.getOwner().getLength() == 0) // If this is null, clear the dest field return ((BaseField)m_fldDest.getField()).moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // Move dependent field to here if (m_bOnlyIfDestNull) if (m_fldDest.getLength() != 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; int iErrorCode = this.moveSourceToDest(bDisplayOption, iMoveMode); if (iErrorCode == DBConstants.NORMAL_RETURN) if (m_fldDest == m_fldSource) return ((BaseField)m_fldDest.getField()).handleFieldChanged(bDisplayOption, iMoveMode); // Special case, move to yourself (Just want to call .FieldChanged()) return iErrorCode; } /**
/** * Do the physical move operation. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int moveIt(boolean bDisplayOption, int iMoveMode) { if (m_convCheckMark != null) if (m_convCheckMark.getState() == false) return DBConstants.NORMAL_RETURN; // If check mark is false (or no check mark), don't move return super.moveIt(bDisplayOption, iMoveMode); } }
/** * Set the field that owns this listener. * @owner The field that this listener is being added to (if null, this listener is being removed). */ public void setOwner(ListenerOwner owner) { super.setOwner(owner); if (owner != null) { if (m_fldSource == null) m_fldSource = this.getOwner(); if ((m_fldDest != null) && (((BaseField)m_fldDest.getField()).getRecord() != null) && (((BaseField)m_fldDest.getField()).getRecord() != this.getOwner().getRecord())) ((BaseField)m_fldDest.getField()).getRecord().addListener(new FileRemoveBOnCloseHandler(this)); // Not same file, if target file closes, remove this listener! else if ((m_fldSource.getField() != null) && (((BaseField)m_fldSource.getField()).getRecord() != null) && (((BaseField)m_fldSource.getField()).getRecord() != this.getOwner().getRecord())) ((BaseField)m_fldSource.getField()).getRecord().addListener(new FileRemoveBOnCloseHandler(this)); // Not same file, if target file closes, remove this listener! } } /**
/** * Override this to add record listeners and filters to every screen where this is the main record. * @param screen The screen these listeners will be in. */ public void addScreenListeners(RecordOwner screen) { super.addScreenListeners(screen); Record recCity = ((ReferenceField)this.getField(TourHeaderTransport.CITY_ID)).getReferenceRecord(); recCity.getField(City.CITY_CODE).addListener(new MainReadOnlyHandler(City.CITY_CODE_KEY)); this.getField(TourHeaderTransport.CITY_ID).addListener(new MoveOnChangeHandler(this.getField(TourHeaderTransport.CITY_CODE), recCity.getField(City.CITY_CODE))); this.getField(TourHeaderTransport.CITY_CODE).addListener(new MoveOnChangeHandler(recCity.getField(City.CITY_CODE), this.getField(TourHeaderTransport.CITY_CODE))); recCity = ((ReferenceField)this.getField(TourHeaderTransport.TO_CITY_ID)).getReferenceRecord(); recCity.getField(City.CITY_CODE).addListener(new MainReadOnlyHandler(City.CITY_CODE_KEY)); this.getField(TourHeaderTransport.TO_CITY_ID).addListener(new MoveOnChangeHandler(this.getField(TourHeaderTransport.TO_CITY_CODE), recCity.getField(City.CITY_CODE))); this.getField(TourHeaderTransport.TO_CITY_CODE).addListener(new MoveOnChangeHandler(recCity.getField(City.CITY_CODE), this.getField(TourHeaderTransport.TO_CITY_CODE))); }
|| (listener.getDestField() != recordKeyField)) this.addListener(new MoveOnChangeHandler(recordKeyField, null));
/** * Constructor. * @param field The basefield owner of this listener (usually null and set on setOwner()). * @param fldDest The destination field. * @param fldSource The source field. */ public void init(BaseField field, BaseField fldDest, BaseField fldSource) { super.init(field, fldDest, fldSource, false, false, false); } /**
/** * The Field has Changed. * Move the source field to the destination field. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { int iErrorCode = this.moveIt(bDisplayOption, iMoveMode); if (iErrorCode != DBConstants.NORMAL_RETURN) if (this.getOwner() != m_fldSource) if (this.getOwner() != m_fldDest) iErrorCode = DBConstants.NORMAL_RETURN; // If the source and dest are unrelated this this, don't return an error (and revert this field) if (iErrorCode == DBConstants.NORMAL_RETURN) iErrorCode = super.fieldChanged(bDisplayOption, iMoveMode); return iErrorCode; } /**
/** * Do the physical move operation. * @param bDisplayOption If true, display the change. * @param iMoveMode The type of move being done (init/read/screen). * @return The error code (or NORMAL_RETURN if okay). */ public int moveIt(boolean bDisplayOption, int iMoveMode) { if (m_bDontMoveNull) if (m_fldSource.getLength() == 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; if (m_bClearIfThisNull) if (this.getOwner().getLength() == 0) // If this is null, clear the dest field return ((BaseField)m_fldDest.getField()).moveFieldToThis(this.getOwner(), bDisplayOption, iMoveMode); // Move dependent field to here if (m_bOnlyIfDestNull) if (m_fldDest.getLength() != 0) // Only move if dest is null return DBConstants.NORMAL_RETURN; int iErrorCode = this.moveSourceToDest(bDisplayOption, iMoveMode); if (iErrorCode == DBConstants.NORMAL_RETURN) if (m_fldDest == m_fldSource) return ((BaseField)m_fldDest.getField()).handleFieldChanged(bDisplayOption, iMoveMode); // Special case, move to yourself (Just want to call .FieldChanged()) return iErrorCode; } /**