/** * 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_fldToDisable != null) if (this.getOwner().getRecord() != m_fldToDisable.getRecord()) m_fldToDisable.addListener(new FieldRemoveBOnCloseHandler(this)); // Make sure you remove this listener if m_fldToDisable is gone. if (owner != null) if (m_fldToDisable == null) m_fldToDisable = this.getOwner(); if (owner != null) this.fieldChanged(DBConstants.DONT_DISPLAY, DBConstants.INIT_MOVE); if (owner == null) m_fldToDisable.setEnabled(true); // Remove the behavior = reenable the field } /**
/** * Constructor. * @param fieldToDisable The field to disable when this listener's owner matches the target string. * @param strCompareString The string to compare to this listener's owner. * @param bDisableIfMatch If true, disables if the string matches, if false, enables on match. */ public DisableOnFieldHandler(BaseField fieldToDisable, String strCompareString, boolean bDisableIfMatch) { this(); this.init(null, fieldToDisable, strCompareString, bDisableIfMatch); } /**
/** * The Field has Changed. * If the target string matches this field, disable the target 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). * Disable field if criteria met. */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { boolean bFlag = this.compareFieldToString(); if (m_bDisableIfMatch) bFlag = !bFlag; m_fldToDisable.setEnabled(bFlag); return DBConstants.NORMAL_RETURN; } /**
/** * Add all the screen listeners. */ public void addListeners() { super.addListeners(); FieldListener fieldBehavior = null; Record record = this.getMainRecord(); record.getField(BookingTour.PRICING_TYPE_ID).setEnabled(true); record.getField(BookingTour.ASK_FOR_ANSWER).addListener(fieldBehavior = new DisableOnFieldHandler(record.getField(BookingTour.ASK_FOR_ANSWER), BooleanField.YES, false)); this.getRecord(Booking.BOOKING_FILE).getField(Booking.ALWAYS_RESOLVE).addListener(fieldBehavior = new DisableOnFieldHandler(this.getRecord(Booking.BOOKING_FILE).getField(Booking.ALWAYS_RESOLVE), BooleanField.YES, false)); record.addListener(new FileRemoveBOnCloseHandler(fieldBehavior)); } /**
DisableOnFieldHandler listener = (DisableOnFieldHandler)field.getListener(DisableOnFieldHandler.class.getName()); if (listener != null) listener.fieldChanged(DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); // I can do this because I know that this listener will not modify anything.
/** * 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); this.getField(Tour.SERV_CONF).setEnabled(false); if (this.getField(Tour.MANUAL_TOUR_STATUS).getListener(DisableOnFieldHandler.class) == null) this.getField(Tour.MANUAL_TOUR_STATUS).addListener(new DisableOnFieldHandler(this.getField(Tour.TOUR_STATUS_ID), BooleanField.YES, false)); } /**
DisableOnFieldHandler listener = (DisableOnFieldHandler)field.getListener(DisableOnFieldHandler.class.getName()); if (listener != null) listener.fieldChanged(DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); // I can do this because I know that this listener will not modify anything.
/** * 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); this.getField(Tour.SERV_CONF).setEnabled(false); if (this.getField(Tour.MANUAL_TOUR_STATUS).getListener(DisableOnFieldHandler.class) == null) this.getField(Tour.MANUAL_TOUR_STATUS).addListener(new DisableOnFieldHandler(this.getField(Tour.TOUR_STATUS_ID), BooleanField.YES, false)); } /**
/** * 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_fldToDisable != null) if (this.getOwner().getRecord() != m_fldToDisable.getRecord()) m_fldToDisable.addListener(new FieldRemoveBOnCloseHandler(this)); // Make sure you remove this listener if m_fldToDisable is gone. if (owner != null) if (m_fldToDisable == null) m_fldToDisable = this.getOwner(); if (owner != null) this.fieldChanged(DBConstants.DONT_DISPLAY, DBConstants.INIT_MOVE); if (owner == null) m_fldToDisable.setEnabled(true); // Remove the behavior = reenable the field } /**
/** * Initialize class fields. */ public void init(BaseField fieldToDisable, String strCompareString, boolean bDisableIfMatch) { m_sField = null; super.init(null, fieldToDisable, strCompareString, bDisableIfMatch); } /**
DisableOnFieldHandler listener = (DisableOnFieldHandler)field.getListener(DisableOnFieldHandler.class.getName()); if (listener != null) listener.fieldChanged(DBConstants.DISPLAY, DBConstants.SCREEN_MOVE); // I can do this because I know that this listener will not modify anything.
/** * The Field has Changed. * If the target string matches this field, disable the target 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). * Disable field if criteria met. */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { boolean bFlag = this.compareFieldToString(); if (m_bDisableIfMatch) bFlag = !bFlag; m_fldToDisable.setEnabled(bFlag); return DBConstants.NORMAL_RETURN; } /**
/** * Add all the screen listeners. */ public void addListeners() { super.addListeners(); if (this.getMainRecord() instanceof TourHeaderDetail) { String strManualTransportID = Integer.toString(((ReferenceField)this.getMainRecord().getField(TourHeaderDetail.INFO_MESSAGE_TRANSPORT_ID)).getIDFromCode(MessageTransport.MANUAL)); this.getMainRecord().getField(TourHeaderDetail.INFO_MESSAGE_TRANSPORT_ID).addListener(new DisableOnFieldHandler(this.getMainRecord().getField(TourHeaderDetail.INFO_STATUS_ID), strManualTransportID, false)); this.getMainRecord().getField(TourHeaderDetail.INVENTORY_MESSAGE_TRANSPORT_ID).addListener(new DisableOnFieldHandler(this.getMainRecord().getField(TourHeaderDetail.INVENTORY_STATUS_ID), strManualTransportID, false)); this.getMainRecord().getField(TourHeaderDetail.COST_MESSAGE_TRANSPORT_ID).addListener(new DisableOnFieldHandler(this.getMainRecord().getField(TourHeaderDetail.COST_STATUS_ID), strManualTransportID, false)); this.getMainRecord().getField(TourHeaderDetail.PRODUCT_MESSAGE_TRANSPORT_ID).addListener(new DisableOnFieldHandler(this.getMainRecord().getField(TourHeaderDetail.PRODUCT_STATUS_ID), strManualTransportID, false)); Converter convCheckMark = new RadioConverter(this.getMainRecord().getField(TourHeaderDetail.INFO_MESSAGE_TRANSPORT_ID), strManualTransportID, false); this.getMainRecord().getField(TourHeaderDetail.INFO_MESSAGE_TRANSPORT_ID).addListener(new RemoveConverterOnFreeHandler(convCheckMark)); this.getMainRecord().getField(TourHeaderDetail.INFO_MESSAGE_TRANSPORT_ID).addListener(new CopyDataHandler(this.getMainRecord().getField(TourHeaderDetail.INFO_STATUS_ID), null, convCheckMark)); this.getMainRecord().getField(TourHeaderDetail.INVENTORY_MESSAGE_TRANSPORT_ID).addListener(new CopyDataHandler(this.getMainRecord().getField(TourHeaderDetail.INVENTORY_STATUS_ID), null, convCheckMark)); this.getMainRecord().getField(TourHeaderDetail.COST_MESSAGE_TRANSPORT_ID).addListener(new CopyDataHandler(this.getMainRecord().getField(TourHeaderDetail.COST_STATUS_ID), null, convCheckMark)); this.getMainRecord().getField(TourHeaderDetail.PRODUCT_MESSAGE_TRANSPORT_ID).addListener(new CopyDataHandler(this.getMainRecord().getField(TourHeaderDetail.PRODUCT_STATUS_ID), null, convCheckMark)); } } /**
/** * 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_fldToDisable != null) if (this.getOwner().getRecord() != m_fldToDisable.getRecord()) m_fldToDisable.addListener(new FieldRemoveBOnCloseHandler(this)); // Make sure you remove this listener if m_fldToDisable is gone. if (owner != null) if (m_fldToDisable == null) m_fldToDisable = this.getOwner(); if (owner != null) this.fieldChanged(DBConstants.DONT_DISPLAY, DBConstants.INIT_MOVE); if (owner == null) m_fldToDisable.setEnabled(true); // Remove the behavior = reenable the field } /**
/** * Constructor. * @param fieldToDisable The field to disable when this listener's owner matches the target string. * @param strCompareString The string to compare to this listener's owner. * @param bDisableIfMatch If true, disables if the string matches, if false, enables on match. */ public DisableOnFieldHandler(BaseField fieldToDisable, String strCompareString, boolean bDisableIfMatch) { this(); this.init(null, fieldToDisable, strCompareString, bDisableIfMatch); } /**
return super.fieldChanged(bDisplayOption, iMoveMode);
/** * The Field has Changed. * If the target string matches this field, disable the target 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). * Disable field if criteria met. */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { boolean bFlag = this.compareFieldToString(); if (m_bDisableIfMatch) bFlag = !bFlag; m_fldToDisable.setEnabled(bFlag); return DBConstants.NORMAL_RETURN; } /**